简体   繁体   English

Java 2d图形性能

[英]Java 2d graphics performance

If I was making a 2D game in Java, would using the default Graphics2D be fast enough? 如果我用Java制作2D游戏,那么使用默认的Graphics2D会足够快吗? Would I get good FPS if it's just 2D? 如果它只是2D,我会获得好的FPS吗? (even if there is a good amount of sprites and other things going on) (即使有大量的精灵和其他事情发生)
Or when your doing any kind of game programming, 2d or 3d, should you opt for opengl/directx? 或者当你进行任何类型的游戏编程,2d或3d时,你应该选择opengl / directx吗?

Also when you render stuff with Graphics2D, is it all rendered on the CPU? 当你用Graphics2D渲染东西时,它是否都在CPU上渲染? Or is it hardware accelerated? 还是硬件加速?

You should use opengl/directx, or some java binding if you must use java (such as JMonkey). 如果必须使用java(例如JMonkey),则应使用opengl / directx或某些java绑定。 If you are new to game programming, I'd suggest using the XNA framework, as it simplifies a lot of things. 如果您不熟悉游戏编程,我建议使用XNA框架,因为它简化了很多事情。 I have used XNA, and it is fairly easy to use, and plug in different libraries. 我使用过XNA,它使用起来非常简单,并插入了不同的库。 If you want a browser based game, javascript + HTML5 Canvas2d, or webgl may be the best route. 如果你想要一个基于浏览器的游戏,javascript + HTML5 Canvas2d或webgl可能是最好的路线。

You will always get better performance out of using direct binding libraries over a 2D Graphics API type library. 通过2D Graphics API类型库使用直接绑定库,您将始终获得更好的性能。 The main thing to do is make sure you know how images and textures are being stored / rendered, so you aren't making the framework do extra work. 要做的主要是确保你知道图像和纹理是如何存储/渲染的,所以你不要让框架做额外的工作。 Extra work will result in low FPS. 额外的工作将导致低FPS。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM