如何处理不同计算机之间的 Java 2D 性能差异? [英] How to approach Java 2D performance variations between different computers?

查看:23
本文介绍了如何处理不同计算机之间的 Java 2D 性能差异?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在 Windows 上用 Java 设计纸牌游戏.它在我的笔记本电脑和其他一些系统上运行得非常好,但在许多其他系统(甚至是 Mac 和 Windows 的一些较新系统)上,动画速度非常慢.

I've been designing a card game in Java on Windows. It runs really well on my laptop and a few others, but on a lot of other systems (even a few newer ones both Mac and Windows) the animation is incredibly slow.

我找到了 用户Interface Toolkits for Java 是迄今为止最好的资源,但还没有做出重大改进.我正在使用 AWT/Swing 库.

I've found User Interface Toolkits for Java to be the best resource so far, but haven't been able to make a significant improvement. I'm using the AWT/Swing libraries.

问题:
看着 我的游戏,(<1.5Mb),在某些计算机(类似规格)上怎么会这样性能似乎明显低于我的笔记本电脑上的性能?整个应用程序是事件驱动的,我已经完成了我认为可以完成的大部分优化工作.

Question:
Looking at my game, (<1.5Mb), how could it be that on some computers (of similar spec) the performance seems to be significantly less that what it is on my laptop? The entire app is event-driven and I've done most of the optimization that I reckon could be done given the implementation.

我觉得它与内存有关.我创建(兼容)然后在开始时将所有图像存储到一个数组中,然后在那里引用它们.

I have a feeling it is memory-related. I create (compatible) and then store all my images into an array at the start, and then reference them there.

注意:我决定制作这个游戏,以便我可以学习和实践一些新想法,所以我不只是想分享它 - 我真的很想知道这里发生了什么.

推荐答案

在并非所有操作系统上,Java 2D 渲染管道都支持 GPU 的硬件加速.这取决于您使用的 Java 实现.

On not all operating systems, the Java 2D rendering pipeline supports hardware acceleration by the GPU. It depends on the Java implementation that you're using.

Oracle 的 Java SE 7 实施(将于本月底推出)的新特性之一是:Java 2D 的 XRender 管道,这意味着它将在 Linux 上具有更好的 2D 图形性能.

One of the new features for Oracle's Java SE 7 implementation (which is coming out at the end of the month) is this: XRender pipeline for Java 2D which means that it will have much better performing 2D graphics on Linux.

对于 Windows,在 Java SE 6 更新 10 中,通过使用 Direct3D 硬件加速(来源).

For Windows, in Java SE 6 update 10 there were some improvements to make Java 2D perform better by using Direct3D hardware acceleration (source).

这篇关于如何处理不同计算机之间的 Java 2D 性能差异?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆