標題: CWT - 跨平台Java遊戲開發之AWT/Swing架構
CWT - An AWT/Swing Architecture for Cross-Platform Java Game Development
作者: 汪益賢
Wang, Yi-Hsien
吳毅成
蔡文能
Wu, I-Chen
Tsai, Wen-Neng
資訊科學與工程研究所
關鍵字: CYC Window Toolkit;CWT;Java遊戲;DirectX;OpenGL;CYC Window Toolkit;CWT;Java Game;DirectX;OpenGL
公開日期: 2008
摘要: 近年來,Java平台在效能上的長足進步,使其達到開發遊戲之所需。然而,實際應用Java開發遊戲之後,我們發現Java標準內建的視窗工具組AWT及Swing在各種不同的執行環境組態中存在繪圖效能不一致的問題,這些執行環境的組合包含下列四項:一、Java執行環境版本(JRE);二、繪圖應用程式界面(API);三、Java執行期系統參數;四、常用的作業系統,如Windows XP、Windows Vista、Fedora及Mac OS X。這種效能不一致的現象使得遊戲開發人員難以預測Java遊戲在使用者電腦的繪圖效能,也降低了Java倡言的「撰寫一次即可隨處運行(Write-Once-Run-Anywhere)」的跨平台優勢。 為了解決繪圖效能不一致的問題,使遊戲在不同平台上執行皆能達到高速且一致的繪圖效能,我們提出了一套AWT/Swing架構,稱為CYC視窗工具組(CYC Window Toolkit),簡稱CWT,具有下述數項特性。首先,CWT架構支援多種常用的高速繪圖函式庫,如DirectX及OpenGL,為了相容於沒有硬體加速的環境,CWT也使用Java AWT來繪圖。CWT架構也維持Java的跨平台特性,支援各Java虛擬機器(Java VM)、.NET公共語言執行環境(.NET CLR)以及各種不同的作業系統。再者,CWT提供與Java AWT/Swing 1.1版相同API的元件,降低將既有Java遊戲移植到CWT的難度。對於需要進一步調整遊戲效能的程式設計師來說,CWT提供一對一對應的API,以便直接操作CWT內部的DirectX與OpenGL物件,以及遊戲相關的各種參數。此外,CWT也可以應用於3D應用程式,這對於現在流行的3D遊戲設計十分重要。 我們依照CWT架構實作了三種CWT工具組,並開放於專屬網站 (http://java.csie.nctu.edu.tw/cwt/) [15]。這三種實作各自使用AWT、DirectX及OpenGL來繪製使用者介面,尤其是後二項實作,可以在支援的作業系統中,得到繪圖加速卡的硬體加速支援。為了測試並比較原本Java AWT/Swing與CWT的繪圖效能,我們設計了兩支測試程式,用來測試基本繪圖能力(Micro-benchmark)與綜合繪圖能力(Macro-benchmark)。測試程式執行於常用的JRE,如MSVM及JRE 1.4至1.6版,以及前面提到的四個作業系統中,其結果顯示:CWT比Java AWT/Swing更能在這些不同的組態中達到更好且更一致的繪圖效能。由於CWT提供Java AWT/Swing 1.1版的介面,也可以在Java 1.1版的環境下運行,因此,CWT的API數量及Java執行期系統參數都較Java AWT/Swing少,較少的測試組合有助於提升程式設計師的生產力。 我們將實作CWT以及測試效能的經驗,歸納出三點方向,使Java在未來成為更好的跨平台遊戲的開發平台。一、由於繪圖加速卡的快速演進,Java應開放內部的DirectX與OpenGL物件,讓遊戲程式設計師能夠直接存取新功能或調整繪圖行為。二、Java AWT/Swing的繪圖管線應該與JRE分開發行,有助於更快速地升級、除錯該繪圖管線,並支援舊版本的JRE。三、複用現有的DirectX與OpenGL綁定(Bindings)以降低開發成本、提高可維護性、簡化運用Java AWT/Swing於Java 3D及JOGL應用程式中的難度,並提高效能。
In recent years, the performance of Java platforms has been greatly improved, which makes Java satisfy the requirements for developing games. However, after practicing in real game development, we observe that a phenomenon of performance inconsistency exists in the graphics of Java AWT/Swing with different combinations of JREs, graphics APIs, system properties, and operating systems (OSs), including Windows XP, Windows Vista, Fedora and Mac OS X. This phenomenon makes it hard to predict the rendering performance of Java games and weakens the merits of the Write-Once-Run-Anywhere feature of Java. In order to solve the above problems, we propose a portable AWT/Swing architecture, called CYC Window Toolkit (CWT), for developing cross-platform Java games with high and consistent rendering performance. CWT has the following features. First, the CWT architecture supports multiple graphics libraries such as AWT, DirectX and OpenGL, multiple virtual machines such as Java VM and .NET CLR, and multiple OSs. Next, CWT supports AWT/Swing 1.1 compatible widgets, so it can be easily applied to existing Java games. For programmers who want to fine tune their games, CWT supports one-to-one mapping APIs to directly manipulate DirectX and OpenGL objects and other game-related properties. In addition, CWT supports interoperability with 3D applications, which is an important feature for 3D game design. We implemented three versions of CWT – AWT, DirectX, and OpenGL, to take advantage of graphics hardware acceleration on all supported OSs. The implementations of CWT are available on our website (http://java.csie.nctu.edu.tw/cwt/) [15]. Two testing programs, including micro-benchmark and macro-benchmark, are also designed to evaluate the rendering performance of the original Java AWT/Swing and CWT. The benchmarking results show that CWT achieves more consistent and higher rendering performance than Java AWT/Swing does in commonly used JRES, including MSVM and JREs 1.4 to 1.6, on the four OSs. Moreover, CWT needs fewer efforts to test the combinations of graphics APIs and system properties, which greatly improves programmers’ productivity. Based on the benchmarking results and our experience, we propose three approaches to make Java be a better platform for developing cross-platform games in the future. First, since the video hardware evolves quickly, Java should open direct access to the internal DirectX and OpenGL objects for game programmers who need to access up-to-date hardware features or change the rendering behaviors. Second, Java should decouple the rendering pipelines of Java AWT/Swing from the JREs for faster upgrading and supporting old JREs. Third, Java should reuse existing DirectX and OpenGL bindings for lower developing cost, better maintainability, easier interoperability among Java AWT/Swing, Java 3D, and JOGL applications.
URI: http://140.113.39.130/cdrfb3/record/nctu/#GT009117801
http://hdl.handle.net/11536/50602
顯示於類別:畢業論文


文件中的檔案:

  1. 780101.pdf

若為 zip 檔案,請下載檔案解壓縮後,用瀏覽器開啟資料夾中的 index.html 瀏覽全文。