问题描述
我正在用 Java 制作游戏,并使用 BufferedImages 将内容呈现到屏幕上.我在应该运行游戏的低端机器上遇到了性能问题,所以我切换到通常速度更快的 VolatileImage.除非他们实际上减慢了整个过程.
I'm making a game in java and in used BufferedImages to render content to the screen. I had performance issues on low end machines where the game is supposed to run, so I switched to VolatileImage which are normally faster. Except they actually slow the whole thing down.
图像是用 GraphicsConfiguration.createCompatibleVolatileImage(...) 创建的,并用 Graphics.drawImage(...)(点击链接查看具体是哪一个).它们使用双缓冲绘制在 Canvas 上.
The images are created with GraphicsConfiguration.createCompatibleVolatileImage(...) and are drawn to the screen with Graphics.drawImage(...) (follow link to see which one specifically). They are drawn upon a Canvas using double buffering.
有人知道这里出了什么问题吗?
Does someone has an idea of what is going wrong here ?
推荐答案
很可能您的代码混合了加速和非加速操作.
Most likely your code is mixing accelerated and unaccelerated operations.
此文档是必读的.尤其是第 3.2 节对于使用加速 Java 图形的任何人来说都是必不可少的.
This document is a must read. Section 3.2 in particular is essential for anyone working with accelerated Java graphics.
这篇关于Java:VolatileImage 比 BufferedImage 慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!