Chapter 20: GAPI, the Game API - Programming Microsoft Windows Ce Net 3Rd [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Programming Microsoft Windows Ce Net 3Rd [Electronic resources] - نسخه متنی

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید






Chapter 20: GAPI, the Game API

Overview

Microsoft Windows CE devices sport microprocessors of surprising power. These small CPUs provide the oomph to support a full 32-bit operating system with virtual memory, an extensive window manager, and a RAM-based, transaction-based file system. For game developers, this would be nirvana—if only the operating system weren't there. Game developers love powerful CPUs but they dislike the layers of operating systems that, though helpful to the typical developer, hinder the developer who likes to write code directly to the hardware. To provide a path to the hardware, the Pocket PC and the Smartphone support the Game API (GAPI), a lightweight set of functions to provide the game developer access to the screen and keyboard of a Windows CE device.

GAPI isn't DirectX, which provides a much more extensive set of functions to the game developer. Although Windows CE supports Direct X, Microsoft decided not to provide the DirectX support on the current Pocket PC. In an attempt to make up for this slight, GAPI is supported instead.

GAPI contains a handful of functions that provide access to the display's frame buffer, the area of memory that holds the pixel information displayed on screen. In addition, GAPI enables an application to assume control of all buttons, even those that are normally captured by the shell. Finally, and perhaps most important, GAPI provides information about the display and the button layout in a consistent way across the divergent hardware provided by different Pocket PC manufacturers.

GAPI is provided as a single DLL, GX.DLL. This DLL comes with the Pocket PC 2003 but was not distributed with earlier Pocket PC devices. Instead, it is distributed by the application that uses it. When an application is installed, it should check for GX.DLL in the \windows directory. If GX.DLL isn't found, place it in its install directory, not in the \windows directory. The current versions of GAPI don't support any type of versioning. Instead, an application is required to keep its own version of the GAPI DLL in its own application directory to avoid the problem lovingly called DLL Hell. In DLL Hell, one application installs an older copy of a shared DLL in the place of a newer version of the DLL, thereby causing problems for the previously installed applications. Although there are a number of ways to avoid DLL Hell—including some that require entire operating system revisions—the simplest solution is to distribute version-sensitive DLLs with the application and keep them in the application's directory. As it stands today, GX.DLL is smaller than 20 KB, so the overhead of maintaining a few of these DLLs in a system is not huge.

To build a GAPI application, the program must include gx.h, which specifies the function prototypes and necessary structures. To provide the proper DLL import information, the program must also link to gx.lib. These files are available in the Pocket PC and Smartphone SDKs.

Table 20-1 lists the GAPI functions.
















































Table 20-1: GAPI Functions

Function Name


Description


GXOpenDisplay


Initializes GAPI. Can be called only once in an application.


GXCloseDisplay


Closes GAPI. Cleans up GAPI resources.


GXBeginDraw


Called to access the frame buffer for drawing.


GXEndDraw


Called when drawing is complete.


GXGetDisplayProperties


Provides information on the display device.


GXOpenInput


Captures the buttons for the game.


GXCloseInput


Frees the buttons for normal use.


GXGetDefaultKeys


Provides information on the suggested buttons.


GXSuspend


Suspends GAPI subsystem to allow other applications to gain focus.


GXResume


Resumes GAPI operation when the game regains focus.


GXIsDisplayDRAMBuffer


Suspends GAPI operations.


GXSetViewport


Allows GDI drawing and GAPI access to the same frame buffer.


/ 169