Index



 Special Characters and supported, detecting presence of, 154–156 supporting devices with no accelerometer, Numerics 156 + (plus) button, 66 access denied error, 22 .0bj file format, importing geometry using, 357– Activate button, 17 359 Activated event, 34, 104, 105 2D games. See OpenGL, creating 2D games with ActiveSync application, 21 3D, 311–351. See also lighting ActiveSync operation, 124 creating 3D objects in SketchUp Add button, 91 application, 354–356 Add Cube menu item, 323 depth buffer Add New Project window, 392 enabling, 316–318 Add New Smart Device Project window, 12 rendering transparent objects with, 318 Add Project Output Group window, 394 exporting 3D geometry (SketchUp application), 356–357 Add Score button, 235 perspective projection, 311–315 Add Special Folder, 395 rendering in, 247–248 AddEntry method, 236 defining 3D object, 318–323 AddItem method, 239 overview, 318 additive blend, 284 removing hidden surfaces, 324–325 additive colors, 54 using indexed triangles, 326–329 Add/Remove Programs feature, , 11 .3ds file, 360 AddScoreObject function, 218 3ds Max application, Autodesk, 360 Advance function, 84, 85, 90, 91, 96, 104, 124, 125, 366, 367  A Advanced Visualizer application, 356 A component, 55 algorithms, recursive, 272 AboutBox project, 241 Allow connections to use one of the following: abstract coordinate system, 247 DMA option, 21 accelerometer Allow unsafe code check box, 250, 251 initializing, 151–152 Allow unsafe code option, 251, 392 overview, 151 alpha blending, 245–247, 283–288 reading data from, 152–154 knowing available blending factors, 285

411  INDEX

with textures, 284–285 sound file types, 157–158 alpha channel, 246, 303 AutoScaleMode property, 31, 32, 53 alpha component, 293 autosize function, 35 alpha parameter, 255 AutoSize property, 35 alpha value, 282 axis, 338 AlphaBlending project, 284, 285 AygShell sound functions, 159, 160, 167–169 alphanumeric characters, 398 Alt-Tab keyboard combination, 19  B ambient light, 330, 344–345 back buffer, 75, 76, 90, 101, 102, 126, 260, 261 Ambient Light option, 347 BackColor property, 230, 232, 239 ambient material, 332 background, clearing, 63 animation, smooth, 72–76 BackgroundColor property, 90 antipiracy measures, 402 Ball bitmap, 94 API (application programming interface), 7 Balloon.png file, 298 Application Folder , 396 Balloons class, 299 application programming interface (API), 7 Balloons game, 300 Application Submission Requirements Balloons project, 298, 305 document, 401 Ball.png resource, 92 Application tab, 14, 385 base.Advance method, 194 Application.DoEvents class, 96 BASS API, 160 applications, executable, 14 Bass.BASS_MusicLoad function, 172 ArgumentOutOfRange exception, 54 BASS.dll aspect ratio, 313 overview, 169 Assembly Information button, 385 using BASS and BASS.NET in projects, 176 Assembly Information window, 385, 386, 387 wrapping BASS.NET, 170–175 assembly properties, setting, 385–387 bass.dll file, 395 Assembly Properties window, 392 BASS.NET wrapper, 169 Assembly Version field, Assembly Information BassNet.Registration function, 170 window, 387 billboards Assembly.GetManifestResourceStream function, 67, 277 adding billboard support to game engine, 379–381 AssemblyInfo file, 387 overview, 377 {AssemblyName} string, 239 rendering, 377–381 {AssemblyVersion} string, 239 BindTexture function, 278 asynchronous playback, AygShell sound functions, 167 bit rate, 157 audio, 157–177 Bitmap class, 60 adding support for sounds to game engine, Bitmap objects, 56, 64, 65, 67, 68, 291 176 bitmap pixels, 72 sound . See also BASS.dll bitmaps AygShell sound functions, 167–169 creating from predrawn graphics choosing, 177 embedding graphic resources, 66–68 overview, 158–159 graphic file formats, 68–69 PlaySound, 160–163 overview, 65 System.Media.SoundPlayer, 164–167 reading graphics from files, 68

412  INDEX

creating using graphics primitives, 64–65 Build tab, 250 overview, 64 busy indicator, 46 painting to screen button and keyboard input color keys, 71–72 button and keyboard events, 147–149 overview, 69 choosing keyboard input method, 150–151 partial bitmap copying, 69–70 input from SIP, 150 scaling, 71 overview, 147 blending. See alpha blending reading keyboard state, 149–150 blue parameter, 54, 255 button click handler, 23 BMP. See bitmaps Button controls, 14, 15, 20, 29 BOARD_GEMS_ACROSS constant, 187, 224 button1_Click procedure, 16 BOARD_GEMS_DOWN constant, 187, 224 buttons, 35–36 _boardLeft coordinate, 187 BoardLeft value, 190  C _boardTop coordinate, 187 CAB (cabinet) files, 391, 397 BoardTop value, 190 CAB setup projects, adding obfuscated files to, BoardXPos property, 201 407 BoardXPos value, 209 cabinet (CAB) files, 391, 397 _boardXPos variable, 195, 221 CAboutBox class, 239, 241 BoardYPos property, 201, 203, 206 CAboutBox.AddItem functions, 241 _boardYPos value, 196 CAboutBox.CalculatePositions function, 241 _boardYPos variable, 195, 196, 221 CAboutBox.CreateAboutItems function, 241 Bold font style, 62 CAboutBox.LayoutControls function, 241 bool parameter, 380 CAboutBox.ShowDialog method, 241 bool property, 212 CAboutItem class, 239 bool value, 30 CAboutItem objects, 239, 241 Boolean parameter, 370 CAccelerometerGame.Update function, 153 bounce example game CachedCameraMatrix, 371 CBounceGame class, 92–93 calculations CObjBall class, 93–95 2D, 339 getting game running, 95–97 cross product, 338 overview, 91 frames-per-second, 124 Bounce project, 101, 103, 113 normal, 338 Bounds property, 43 call stack command, 23 breakpoints, Visual Studio, 6 camera Browse and add assembly to list option, 403 capturing images from, 45–46 Browse item, 390 moving Browse tab, 91 adding camera objects to game engine, Brush class, 63 365–369 Brush object, 55 optimizing camera calculation, 371–374 brushes, 56, 58 overview, 364 buffers, 74, 75 positioning camera, 364–365 Build Action property, 67 projection matrix, 374 Build from the main application menu, 403 in scene using lighting, 370–371

413  INDEX

CameraCaptureDialog control, 45, 46 CGameEngineGDIBase.Render, 101 CameraControl project, 369, 370 CGameEngineOpenGL class, 367 capabilities enumeration, 107, 294 CGameEngineOpenGLBase class, 289, 290, 291, Capabilities parameter, 108 306, 317, 342, 344, 366, 375, 380 Cascading Style Sheets (CSS), 53 CGameEngineOpenGLBase.InitGLViewport case sensitivity, 400 function, 315, 374 casual piracy, 402 CGameEngineOpenGLBase.InitializeOpenGL function, 317 CBalloonsGame class, 298, 300 CGameEngineOpenGLBase.LoadCameraMatrix CBalloonsGame.Update function, 305 function, 372 CBounceGame class, 92–93, 97 CGameEngineOpenGLBase.RenderIndexedTria CBounceGame type, 93 ngles function, 327 CEncryption class, 237 CGameFunctions class, 90–91 CEncryption.Encrypt method, 400 CGameObjectBase class, 78, 82, 126–127, 289, CenterObject function, 361, 362 303 Central Processing Units (CPUs), 111 object mechanics, 87 CFogGame.InitFog function, 377 overview, 85 CGameEngineBase class, 124–126 positioning objects, 86 adding other functions, 85 storing object states, 87 advancing game, 84–85 CGameObjectGDIBase class, 78, 79, 91, 93, 102, game mechanics, 82 127, 128, 289 initializing start-up, 83 object movement, 88 managing game objects, 82 overview, 87 overview, 79 setting object state for GDI, 88 rendering, 83 CGameObjectGDIBase.GetRenderRectangle resetting game, 83 function, 126 updating game state, 84 CGameObjectOpenGL class, 305 CGameEngineBase constructor, 228, 231, 235, CGameObjectOpenGLBase class, 289, 290, 301, 241 304, 320, 348, 366 CGameEngineBase function, 294 rendering quadrilaterals, 293–294 CGameEngineBase.AboutBox property, 239 setting object state for OpenGL, 292–293 CGameEngineBase.Advance function, 124 CGameObjectOpenGLCameraBase class, 366, 367, 368, 371 CGameEngineBase.MessageBox property, 230 CGemDropsGame class, 184, 185, 197 CGameEngineGDIBase class, 78, 79, 91, 92, 98, 126, 289, 291 CGemDropsGame object, 188, 190 advancing game, 90 CGemDropsGame.Prepare function, 186, 190 overview, 88 CGemDropsGame.Update function, 201 rendering, 89–90 CGeomLoaderBase class, 359 CGameEngineGDIBase constructor, 104, 105 CGeomLoaderObj class, 362 CGameEngineGDIBase type, 93 CGeomLoaderObj object, 363 CGameEngineGDIBase.Advance function, 103, Change Target Platform window, 19 104 channels CGameEngineGDIBase.ForceRepaint method, BASS, 170 102 checking if sound is playing on, 175 CGameEngineGDIBase.Present method, 90 character keys, KeyDown event and, 148 characters, alphanumeric, 398

414  INDEX

CheckCapabilities function, 107, 295 CMessageBox class, 230–231 CheckCapabilities_CheckForAccelerometer CMessageBoxControl, 231 function, 155 CMessageBox.ShowDialog method, 230, 231 CheckCapabilities_CheckForOpenGL function, CMYK (Cyan, Magenta, Yellow, and Key-black) 295 model, 54 Checked property, 38 CObjBall class, 93–95, 136 CheckForUpdate function, 407, 408 CObjBalloon class, 301, 304 CheckGameOver function, 200 CObjBalloon.TestHit function, 309 CheckIfMoved function, 88, 102 CObjBox class, 136 CHighScoreControl, 236 CObjCamera class, 370, 371 CHighScoreEntry objects, 235, 236 CObjCube class, 347, 351 CHighScores class CObjCube.Render function, 320 accessing HighScores objects, 235 CObjCylinder class, 347, 351 overview, 232 CObjGem class, 184, 188, 190, 194–196, 205, presenting high scores, 236 206, 212, 221 storing data, 236–238 CObjGem.IsDroppingQuickly property, 212 understanding data structure, 235–236 CObjScore class, 221 CHighScores._highscoreTables collection, 235 CObjSelectableBase abstract object class, 136 CHighScores.Clear method, 235 CodeGenerator project, 398 CHighScores.EncryptionKey property, 233 CodeGenerator.exe file, 402 CHighScores.InitializeTable method, 233, 235 Collada (.dae) files, 356 CHighScores.LastEnteredName property, 234 Collada files, 356 CHighScoreTable class, 236 color array, 257, 260 CHighScoreTable objects, 235, 238 color buffer, 317 CHighScoreTable._scoreEntries collection, 236 color components, 333 CHouseObj class, 362 color conversion functions, 291 clamp colors, 247 color key, 71, 72 clamped, 333 Color object, 292 Class Library template, 14 color palette, 54 class-level variables, 81, 96 Color property, 55, 56 Clear method, 63, 235, 238, 257 color specification, 247 ClearBoard function, 192, 193 _color value, 303 ClearColor method, 255, 256 Color variable, 301 ClearColorKey function, 72 color vertices, 329 ClearDepth function, 317 ColoredCubes project, 320, 325 clearing background, 63 ColoredQuad project, 250, 262, 266 Click event, 16, 38, 40, 130, 231 ColorFromArgb program, 55 ClientRectangle dimensions, 256 colorHigh parameter, 72 ClientSize.Height value, 184 colorLow parameter, 72 CLightingGame.InitLight function, 341 ColorPointer function, 259, 284 ClipRegion property, 100, 101 colors Closed event, 96 additive, 54 Closing event, 261, 297 intensity of, 54 Closing handler, 186 overview, 53

415  INDEX

standard, 53 Text property, 32–33 subtractive, 54 WindowState property, 33 X11, 53 input panels, 43–44 colors array, 322 labels, 35 ColorToFloat3 function, 292, 303 menu bars ColorToFloat4 function, 292 MainMenu events, 38 CombineRectangles function, 90, 91, 99 menu design considerations, 36–37 Company field, Assembly Information window, menu item naming, 39 386 smart phone menus, 38 CompareTo method, 108, 303, 304 submenus, 37 components working with MainMenu controls, 38 creating About box, 238–241 overview, 31 creating high score table, 232–238 timers managing game , 225–229 concurrent Tick events, 40–41 overview, 225 other timers, 41 replacing MessageBox, 230–231 timer initialization, 40 using common game components, 241 timers on inactive forms, 41 config variable, 253 coordinate system, abstract, 247 configured icon, 390 coordinate system, OpenGL, 247 Connected Devices item, 21 coordinate systems, orthographic, 286–288 Connected Devices list, 21 coordinates Console Application template, 14 OpenGL, 247 context menus, 39–40, 144–146 pixel-based, 287 ContextMenu control, 40 Copyright field, Assembly Information window, Continue menu item, 234, 236, 241 386 control box, 31 CPUs (Central Processing Units), 111 control flow obfuscation, 406 Create New Shortcut item, 396 Control Library template, 14 CreateBackgroundImage function, 90 ControlBox button, 29 CreateGL function, 252, 254, 260, 262, 290 ControlBox property, 31, 32 cross product, 338 controls, user interface CSettings class, 233, 234, 235, 237 buttons, 35–36 accessing Settings object, 228 capturing camera images, 45–46 loading and saving settings, 229 context menus, 39–40 overview, 226 file dialog controls, 42–43 setting and retrieving values, 228–229 forms .csproj file, 390 AutoScaleMode property, 31 CSS (Cascading Style Sheets), 53 ControlBox property, 31 culled, 324 creating non-full-screen forms, 33–34 Cursor object, 46 FormFactor property, 32 cutoff angle property, 335 losing and gaining focus, 34–35 Cyan, Magenta, Yellow, and Key-black (CMYK) MinimizeBox property, 32 model, 54 Resize event, 33

416  INDEX

 D direction value, 209 .dae (Collada) files, 356 directional lights, 334, 343 .dae files, 360 DirectX component, 26 DashStyle property, 55 Disable function, 255, 341 DateTime parameter, 228 display attributes, 252 DateTime type, 226 Dispose method, 55, 56, 175, 282, 290, 297 DateTime.Now property, 120 DisposeSoundPlayer function, 166 Deactivate event, 34, 230, 231 distribution Debug build, 391 building distribution packages Debug mode, 391 adding setup project's files, 393–395 Debug Output window, 23 building CAB file, 397 debug text, 23 creating programs menu shortcut, 395– 396 debugging, Visual Studio, 22–23, 112 creating setup project, 392–393 Default Form Factor, 32 overview, 391 DefaultValue parameter, 226 switching into release mode, 391–392 DeleteValue function, 226, 229 implementing reverse engineering Deploy to Device option, 21 adding obfuscated files to CAB setup depth buffer, 247, 316–318 projects, 407 depth function, 317 obfuscating with Dotfuscator DepthBuffer project, 318 Community Edition, 403–405 _depthBufferEnabled variable, 317 overview, 402 Description field, Assembly Information using advanced obfuscation, 405–407 window, 386 overview, 385 design brief document, 179 preparing game for desktop CPUs, 9 creating icons, 388–391 Dest calculation, 285 overview, 385 DestroyGL function, 262 project versioning, 387–388 development mode, vs. released code, 112 setting assembly properties, 385–387 Device Application template, 12, 14 promoting game, 409 device capabilities, checking, 106–109 releasing new versions of game, 407–408 Device item, 18 selling games Device Options button, 18 creating evaluation applications, 397– Device Security Manager, Visual Studio 2008, 398 21 minimizing piracy, 401–402 Device toolbar, 18 overview, 397 Device Tools item, 14 upgrading to full versions, 398–400 DialogResult property, 35 using Windows Marketplace for Mobile, Dictionary of CHighScoreTable objects, 235 400–401 Dictionary, sound, 170 divisions, of game screen, 182, 183 difficulty level, GemDrops game, 182 .dll file, 14 diffuse light, 330 Dock property, 35 diffuse material, 332 Document Outline window, Visual Studio, 39 Direct3D, 26 DoEvents( ) method, 41 DirectDraw, 26 DOS-style path, 67

417  INDEX

Dotfuscated file, 403 egl.CreateWindowSurface function, 253 Dotfuscator Community Edition, 403–405, 406, EGLDisplay object, 252, 253, 254 407 _eglDisplay variable, 252 dots per inch (DPI) value, 31, 32 egl.GetDisplay method, 252, 253 double buffering technique, 74, 75 egl.Initialize method, 252 double values, 265 egl.MakeCurrent method, 254 DoubleBuffer method, 75 EGLNativeDisplayType object, 252 DoubleClick event, 130 EGLSurface object, 253 d-pads, 156, 182, 183, 213 EGLSurface parameter, 254 DPI (dots per inch) value, 31, 32 egl.SwapBuffers function, 261 DragBegin function, 139 elapsed values, 124 dragging objects, 138–140 elementsPerColor value, 322 DrawArrays function, 260, 274, 280, 322, 327 ellipses, 59–60 DrawBranch function, 273 embedded CPUs, 9 DrawElements function, 327 embedded resources DrawEllipse function, 59 loading sound from, 171 DrawImage method, 69, 70, 71, 72, 94, 190, 248 playing sounds from, 162, 165 drawing eMbedded Visual Basic language, 3 lines, 274–275 eMbedded Visual C++ language, 3 points, 274 Embedded-System Graphics Library (EGL), 252 primitives, 248 emissive color, 332 triangles, 275–277 emissive material, 332–333 drawing operations, 100 Empty Project template, 14 drawing requests, single-pixel, 60 emulators DrawLines method, 56, 57, 58 for Visual Studio, 5–6 DrawPolygon method, 57, 58 device selection, 18 DrawRectangle method, 59, 101 emulator state, 19 DrawString method, 60, 61, 63 obtaining more, 19 DropGems function, 203, 204, 207, 216 re-enabling Alt-Tab, 19 DropQuickly function, 212 sharing files with emulated device, 18– Dutta, Koushik, 151, 249 19 DWORD type value, 22 for Windows Mobile, 245 dynamic update intervals, 113–115 Enable function, 280, 303, 317, 340, 341 EnableClientState method, 259, 285  E Enabled property, 40, 43 Easy table, 236 enableDepthBuffer parameter, 317 edit and continue feature, 23 encrypted string, 404 EGL (Embedded-System Graphics Library), 252 encryptedBytes array, 404 EGL functions, 295 encryption, string, 406 EGL_NONE type, 253 EncryptionKey length, 237 egl.ChooseConfig function, 253 engine. See game engine EGLConfig object, 253, 254 Engine component, 79 EGLContext object, 254 Entries collection, 238 egl.CreateContext function, 254 Entries element, 236

418  INDEX

Entry elements, 238 FindCurrentRenderRectangle function, 99 Environment.OSVersion.Version object, 107 finger-friendly input, 146 Environment.TickCount property, 120 Fireworks project, 381 evaluation applications, creating, 397–398 fixed block, 260 Events section, 104 fixed interval updates, 113 events, touch screen input fixed statement, 259, 306, 322, 341 Click, 130 Flags attribute, 107 DoubleClick, 130 flags, passed to PlaySound, 161 MouseDown, 131 float arrays, 259, 359, 362 MouseUp, 131 float type, 86, 226 MoveMove, 131–132 float values, 247, 259, 260, 265, 301, 342, 371, overview, 129 376 exclusive or operator, 398 _floatDistance value, 223 .exe file, 14 _floatDistance variable, 221, 223 executables, copying, 402 float.MinValue value, 127 exit condition, 272 FloatToColor function, 292 Exit menu item, 261 fog, rendering, 374–377 Exit option, 250 Font object, 61 Explorer window, 66 font style, 61 exponent property, 335 FontFamily parameter, 62 exporter plug-in, SketchUp, 357 FontSize, 239 ExportOBJ plugin, SketchUp, 356, 357 FontStyle, 239 ExportObj.rb file, 356 ForceRefresh method, 146 ExportTexturedOBJ plugin, SketchUp, 356, 357 ForceRepaint method, 103, 105 external timer, 120–121 _forceRepaint variable, 103 eye position, 364 _forceRerender variable, 102 foreach loop, GameObjects list, 138  F Form class, 130 face (f) element, 357 form close button, 17 FallDistance property, 199, 201, 202, 203, 205, Form component, 79 206, 207 form design, GemDrops game, 185 _fallDistance variable, 195, 196, 206, 213 form designer, Visual Studio, 6, 32, 35, 36 FallSpeed property, 199, 200 Form Load event, 34 _fallSpeed variable, 195, 206, 207, 213 FormBorderStyle property, 34 far clip plane, 312, 313, 374 _formClosed variable, 96 file dialog controls, 42–43 FormFactor property, 32 on Target Machine node, 395 Form.MousePosition approach, DoubleClick File/Configure menu, 18, 19 event, 130 FileName property, 226, 229, 237 forms files, sharing with emulated device, 18–19 AutoScaleMode property, 31 FillEllipse function, 59 ControlBox property, 31 FillPolygon method, 58 creating non-full-screen forms, 33–34 FillRectangle method, 59, 60, 63 FormFactor property, 32 FindCameraObject function, 367 losing and gaining focus, 34–35

419  INDEX

MinimizeBox property, 32 CGameObjectGDIBase class, 87–88 overview, 31 overview, 79 Resize event, 33 importing geometry into Text property, 32–33 manipulating geometry data, 360–362 WindowState property, 33 overview, 359 Forums link, 24 reading geometry data from .obj files, four-directional navigation pad, 8 362 fractal tree, 271, 272 retrieving geometry data, 359–360 FractalTrees project, 271–273 using geometry loader class, 362–364 frames interacting with device additional, 114 handling SIP, 105–106 buffer configuration, 253 minimizing and restoring, 103–104 Frames Per Second timer initialization, 96 overview, 103 frames-per-second calculation, 124 resizing form, 105 FramesPerSecond property, 85, 124 optimizing rendering frames-per-second rate, 85 adding, updating, and deleting objects, frames-per-second value, 85 102 freefall, acceleration, 152 forcing repaint, 102 freeware, 397 overview, 98 frustum, viewing performance impact, 103 defining in OpenGL, 315 overview, 77 overview, 311–314 timing in full versions, upgrading to, 398–400 changes to interpolation-based functions, 124–127 Full VGA resolution, 9 changes to noninterpolation functions, functions, role of, 83 128 initializing and interrogating timer, 121–  G 124 game board, GemDrops game, 180 overview, 121 game class, 91 game objects, 78 game engine _game variable, 185, 188 adding support for sounds to, 176 _gameBoard array, 193, 203 bounce example game _game.DropQuickly method, 214 CBounceGame class, 92–93 GameEngine directory, 77 CObjBall class, 93–95 gameEngine parameter, 93 getting game running, 95–97 GameEngine property, 86 overview, 91 _gameEngine variable, 86 checking device capabilities, 106–109 GameEngine.CGameEngine.GDIBase class, 184 designing, 77–79 GameEngine.CGameObjectGDIBase class, 184, future enhancements, 109 188 implementing GameEngine.dll file, 395, 404 CGameEngineBase class, 79–85 gameForm object, 81 CGameEngineGDIBase class, 88–90 _gameForm variable, 81 CGameFunctions class, 90–91 GameFormActivated method, 104 CGameObjectBase class, 85–87 GameFormResize function, 105

420  INDEX

GameGraphics collection, 94 resetting game, 191–193 GameGraphics dictionary, 186 updating player's gems, 200–207 GameGraphics property, 291 gemGroup object, 219 GameGraphics.Count property, 92 _gemHeight field, 186, 187 _game.InitialiseOpenGL method, 318 gemPosition enumeration, 210 _gameObjects collection, 82 gemPosition.Above value, 211 GameObjects collection, 93, 200, 299 gemPosition.Left value, 211 GameObjects item, 367 Gems16.png file, 186 GameObjects list, 304, 305, 370 Gems32.png file, 186 GameObjects.Clear class, 93 GemsAreDropping function, 203, 207 GameObjects.Sort method, 305 gemsRemoved variable, 216 _gameOver property, 192 GemType property, 199 GameOver property, 200 _gemType variable, 195 _gameOver variable, 194, 202 GemTypes enumeration, 195 Games folder, 396 _gemWidth field, 186, 187 GAPI ('s Game API), 26 GenerateCode function, 398 GDI graphics. See Graphics Device Interface GenerateCode procedure, 404 (GDI) graphics GenerateIndexedTriangleNormals function, gem graphics, GemDrops game, 186 348, 349, 350 gem pairs, GemDrops game, 182 GenerateRandomGemColor function, 197 gem speed, GemDrops game, 182 GenerateTriangleNormals function, 348, 364 GEMCOLOR_NONE value, 208, 209 geometry, importing GEMCOLOR_OUTOFBOUNDS value, 208 into game engine, 359–364 GEMCOLOR_RAINBOW constant, 189, 221 overview, 353 GemDrops class, 224 SketchUp application, 353–357 GemDrops game using .0bj file format, 357–359 designing geometry loader class, 359 choosing sound effects, 183 GetAllObjectsAtPoint function, 136 conceptualizing game controls, 182–183 GetAsyncKeyState function, 149, 150, 214 outlining minimum requirements, 183– GetDisplayXCenter function, 366 184 GetDisplayXPos function, 126, 127, 302 overview, 179 GetDisplayXScale function, 292, 303 overview, 179 GetDisplayXUp function, 366 writing GetDisplayYPos function, 126, 127, 302 adding player control, 208–214 GetDisplayYScale function, 292, 303 creating game form, 185–186 GetDisplayZPos function, 126, 127 creating Gem game object, 188–190 GetDisplayZScale function, 292 creating project, 184 GetElapsedTime function, 123 creating score objects, 221, 223 GetGemColor function, 208, 209, 211 displaying player Gems, 194–200 GetManifestResourceStream function, 67, 68 overview, 184 GetModelviewMatrix function, 372, 373, 379 pausing game, 194 GetPixel method, 60 preparing game, 186–187 GetRenderRectangle function, 88, 94, 99, 127, removing gems from board, 215–221 128, 132

421  INDEX

GetTable method, 235 GL_POSITION property, 343 GetValue function, 226, 229 GL_SHININESS parameter, 346 gfx parameter, 291 GL_SMOOTH setting, 255 GIF (Graphics Interchange Format) files, 68 GL_SPECULAR parameter, 343, 346 gl prefix, 249 GL_SPOT_CUTOFF angle, 344 GL utility, 256 GL_SPOT_CUTOFF parameter, 343 GL_AMBIENT parameter, 343, 346 GL_SPOT_DIRECTION parameter, 343, 344 GL_BACK parameter, 346 GL_SPOT_EXPONENT parameter, 343 GL_COLOR_BUFFER_BIT parameter, 257 GL_SRC_ALPHA factor, 283, 284, 286 GL_CULL_FACE state, 325 GL_SRC_ALPHA_SATURATE factor, 286 GL_DEPTH_TEST flag, 255 GL_SRC_COLOR factor, 286 GL_DEPTH_TEST function, 317 GL_TEXTURE_2D flag, 280 GL_DIFFUSE parameter, 343, 346 GL_TEXTURE_COORD_ARRAY state, 280 GL_DST_ALPHA factor, 286 GL_TRIANGLE_FAN mode, 275, 277 GL_DST_COLOR factor, 286 GL_TRIANGLE_STRIP constant, 274 GL_EMISSION parameter, 346 GL_TRIANGLE_STRIP mode, 275, 276 GL_EXP algorithm, 375, 376 GL_TRIANGLE_STRIP parameter, 260 GL_EXP2 algorithm, 375, 376 GL_TRIANGLE_STRIP type, 322 GL_FLAT setting, 255 GL_TRIANGLES mode, 275, 276 GL_FLOAT constant, 259 GL_TRIANGLES type, 322 GL_FOG_DENSITY parameter, 376 GL_ZERO factor, 283, 286 GL_FOG_END parameter, 376 gl.Clear function, 249 GL_FOG_START parameter, 376 gl.CullFace method, 326 GL_FRONT constant, 346 gl.Disable function, 351 GL_LEQUAL value, 317 gl.Enable function, 351 GL_LIGHT0 constant, 341 gl.Get function, 373 GL_LIGHT7 constant, 341 _glInitialized flag, 260, 261 GL_LIGHTn constant, 341 gl.LoadIdentity function, 249 GL_LINE_LOOP mode, 275 glLoadIdentity function, 249, 367 GL_LINE_STRIP mode, 274, 275 gl.LoadIdentity function, 367, 369 GL_LINEAR algorithm, 375 glLoadIdentity function, 369 GL_LINES, GL_LINE_LOOP mode, 274 gl.LoadMatrixf function, 373 GL_LINES mode, 274, 275 glRotatef function, 249 GL_MODELVIEW mode, 315 gl.Rotatef function, 249 GL_ONE constant, 283 gl.Scale function, 351, 361, 362 GL_ONE factor, 283, 284, 285, 286 gl.Translate method, 374 GL_ONE_MINUS_DST_ALPHA factor, 286 GLU (OpenGL Utility) library, 306 GL_ONE_MINUS_DST_COLOR factor, 286 glu class, 256 GL_ONE_MINUS_SRC_ALPHA factor, 283, 284, glu library, 364 286 glu.cs file, 306 GL_ONE_MINUS_SRC_COLOR factor, 286 glu.LookAt function, 364, 365, 367, 371, 372 GL_POINTS constant, 274 glu.Perspective method, 256, 315 GL_POSITION array, 343 glu.Perspective parameter, 315 GL_POSITION parameter, 343 glu.UnProject function, 306

422  INDEX

Google Earth (.kmz) files, 356 graphics, rendering in OpenGL, 256–260 Google Groups, 24 Graphics.Clear method, 101 graphical routines, 35 Graphics.ClipRegion property, 100 graphical updates, 112 Graphics.DrawImage function, 69 graphics APIs Graphics.DrawString function, 223 Direct3D, 26 Graphics.MeasureString function, 222 DirectDraw, 26 GraphicsUnit.Pixel, 70 Graphics Device Interface (GDI), 25–26 green parameter, 54, 255 Microsoft's Game API (GAPI), 26 GSensor vector, reading data from OpenGL ES, 26 accelerometers, 153 graphics buffer, 75 GUID field, Assembly Information window, 387 Graphics class, 52 Graphics Device Interface (GDI) graphics, 246  H bitmaps hard barrier, 374 creating from predrawn graphics, 65–69 Hard table, 236 creating using graphics primitives, 64– hardware 65 acceleration, 245 overview, 64 buttons, 8 painting to screen, 69–72 cooperation with devices, 9–10 overview, 51 graphics hardware, 9 Paint event overview, 8 brushes, 56 processors, 9 clearing background, 63 screen size, 9 colors, 53–55 touch screens, 8 displaying text, 60–63 HasMoved property, 88, 99, 102, 200 drawing coordinate system, 53 Height property, 65, 93, 94, 189, 190, 292 ellipses, 59–60 height value, 59, 94 invalidating form, 53 hexadecimal numbers, 398 lines, 56–57 hidden surfaces, removing, 324–325 overview, 51 HiddenSurfaceRemoval project, 325 pens, 55 High Score dialog box, 233 pixels, 60 high score table polygons, 57–58 CHighScores class rectangles, 59 accessing HighScores objects, 235 smooth animation, 72–76 overview, 232 graphics hardware, 9 presenting high scores, 236 Graphics instance, 90 storing data, 236–238 Graphics Interchange Format (GIF) files, 68 understanding data structure, 235–236 Graphics method, 74 overview, 232 Graphics object, 56, 60, 62, 64, 87, 94 high-performance timer, 120–121 graphics performance, 112 HighScores element, 236, 238 graphics primitives, creating bitmaps using, 64– HighScores objects, accessing, 235 65 HighScores project, 235 Graphics property, 52 HighScores property, 235

423  INDEX

Hopper application, 401 InitGLViewPort function, 255, 261, 287, 290, house object, 364 300, 306 House.obj resource, 363 InitializeKineticDragging function, 141 HTC accelerometer, 151 InitializeOpenGL function, 290, 317 HTC devices, accelerometer readings, 154 InitializeTable function, 237 HTC manufacturer, 8 initializing timer, 121–124 HTC Touch Pro2 device, 46, 103 InitLight function, 341, 370 InitNextGems function, 198  I InitPlayerGems function, 198, 203, 207, 216 .ico files, 388, 389, 390 InitTimer function, 122 IcoFX editor, 389, 390 input capabilities category, 106 IComparable interface, 303 input panels, 43–44 IComparer interface, 235, 236 Input tab, Dotfuscator, 403, 405 Icon drop-down list, 390 InputPanel class, 45, 105, 106 Icon field, 390 InputPanel control, 43, 44 icon tray, 39 _inputPanel variable, 106 icons, creating, 388–391 installation window, Visual Studio, 10 IDE features, .NET for Windows Mobile installing, Visual Studio, 11–24 breakpoints, 6 int parameter, 186 debug output, 6 int type, 226 emulators, 5–6 int value, 247 form designer, 6 int.CompareTo method, 304 identity matrix, setting, 264 Interface for the Gravity Sensor (IGSensor), 151 IGSensor (Interface for the Gravity Sensor), 151 internal class, 90 IGSensor.GetGVector function, 152 internal element, 404 Image property, 56 internal properties, 241 ImageAttributes object, 72, 190 internal scope, 228, 231, 235, 241 i-mate PDA2, 103 interpolated positions, 118, 119 immediate window command, 23 interpolated updates importing geometry applying to game, 116–118 into game engine, 359–364 distinguishing between updates and frames, 119 overview, 353 overview, 115 SketchUp application, 353–357 update frequency, 118–119 using .0bj file format, 357–359 interpolation curve, 119 ImportingGeometry project, 362 interpolation factor, 116, 117, 118, 126 Include in Project option, 66 interpolation technique, 115 index list, 326, 327 interpolation-based functions, changes to, 124– indexed triangles, 326–329 127 IndexedTriangles project, 329 interrogating timer, 121–124 indices parameter, 327 Interval property, 40 InitGL function, 254, 255, 256, 257, 260, 277, int.MaxValue value, 120 283, 284, 290 Invalidate method, 53, 90, 96, 101 InitGLDepthBuffer function, 317 InvalidOperationException message, 45

424  INDEX

IsChannelPlaying function, 175 LastXPos property, 86 IsDisposed property, 96 LastXPos variable, 127 IsDroppingQuickly property, 212 LastXScale property, 292 _isFallingQuickly variable, 213 LastYPos property, 86 IsModalPanelDisplayed function, 231 LastYPos variable, 127 IsMusic function, 172 LastYScale property, 292 IsNew property, 87 LastZPos property, 86 IsPointInObject Function, 132 LastZPos variable, 127 IsSmartphone function, 90, 107 LastZScale property, 292 IT files, 158 LatestVersion.xml file, 408 Italic font style, 62 lblNextPiece label, 185, 196 ItemControl property, 241 lblScore label, 185, 186 _items collection variable, 241 libgles_cm.dll file, 248, 253, 295 Library check box, 405  J library mode, 404, 405 JPG files, 69 light bulb image, 335 jump instruction, 406 Lightf function, 341, 345 Lightfv function, 341, 345  K Lightfv parameter, 344 keepUpVector parameter, 380 lighting keyboard input. See button and keyboard input adding light to game engine KeyChar property, KeyPressEventArgs object, adding game engine light functions, 147 341–342 KeyCode property, 148 creating directional lights, 343 KeyDown event, 148, 213, 214 creating point lights, 343–344 KeyEventArgs object, 148 creating spotlights, 344 KeyPress event, 147–148 enabling lighting, 340–341 keypresses, 149 OpenGL lighting in action, 346–347 KeyPressEventArgs object, 147 overview, 340 Keys enumeration, 148 setting material properties, 345–346 Keys.AltKey enumeration value, 149 setting scene's ambient light, 344–345 Keys.ControlKey enumeration value, 149 calculating light reflections in OpenGL Keys.ShiftKey enumeration value, 149 calculating normals, 338–339 KeyUp event, 149, 213, 214 describing triangle's face direction, 336– 338 kinetic dragging overview, 336 activating, 144 using surface normals and vertex preparing objects, 141 normals, 339–340 kinetic movement, 132 calculating normals programmatically, 347– _kineticFriction variable, 141 351 .kmz (Google Earth) files, 356 interaction with materials, 333 lights and materials, 329  L material properties, 332–333 labels, 35 moving camera in scene using, 370–371 landscape mode, 184

425  INDEX

multiple lights, 333 Materialfv function, 345 overview, 329 matrix transformations reusing lights, 334 applying multiple transformations, 267–269 types of, 329–331 applying rotation transformations, 265–266 types of light sources, 334–335 applying scaling transformations, 266–267 using normals with scaled objects, 351 applying translation transformations, 265 Lighting project, 340–347 overview, 264 LightModelfv function, 344 practicing with example projects linear interpolation, 115, 116 FractalTrees project, 271–273 linear movement, 114 orbits project, 269–271 LinearGradientBrush function, 56 pushing and popping matrix, 269 lines, 56–57, 274–275 setting identity matrix, 264 List of CHighScoreEntry objects, 236 specifying vertex positions, 269 List collection, 303 MatrixMode mode, 315 List control, 219 Maximized option, WindowState property, 33 ListView control, 236 MeasureString function, 62, 63 Load event, 96, 108, 186, 260, 296, 318 Medium table, 236 LoadCameraMatrix class, 367 Memory icon, 17 LoadCameraMatrix function, 367, 369, 371 menu bars LoadFromFile function, 359 MainMenu events, 38 LoadFromStream function, 359, 363 menu design considerations, 36–37 LoadFromString function, 359, 362 menu item naming, 39 LoadIdentity function, 264 overview, 36 LoadScores function, 234, 237 smart phone menus, 38 LoadScores_LoadTable function, 238 submenus, 37 LoadSettings method, 226 working with MainMenu controls, 38 LoadSoundEmbedded function, BASS, 170, 171 menu editor, 39 LoadSoundFile function, BASS, 170 Menu property, 38, 231 LoadStream method, 278 menus, adding, 144–146 local coordinate system, 267, 268, 269 MessageBox dialog box, 230 Location property, 34 MessageBox function, 23 long.MaxValue, 120 MessageBox project, 231 lossy compression, 157 MessageBox property, 231 MessageBox, replacing, 230–231  M MessageBox.Show function, 230 MainMenu controls, 36, 37, 39, 40, 185 MessageTextColor property, 230 MainMenu implementations, 36, 37 Microsoft Developer Network (MSDN), 24 MainMenu object, 231 Microsoft Developer Program, 400, 401 Manufacturer property, 393 Microsoft's Game API (GAPI), 26 mapping function, 306 Microsoft's Windows Mobile Developer Center, Marketplace program, 400, 401, 407 24 material properties, setting, 345–346 Microsoft.WindowsCE.Forms, 45 material shininess, 332 Microsoft.WindowsMobile.Forms, 45 Materialf function, 345 MIDI files

426  INDEX

defined, 158 .NET CF version 3.5, 13 playback quality, 169 .NET color functions, 54 Milliseconds property, 120 .NET Compact Framework (.NET CF), 3 Min calculations, 285 .NET for Windows Mobile minimize button, 31, 32 IDE features, 5–6 MinimizeBox property, 32, 34 language choices, 4 missingCaps variable, 107, 108 overview, 4 MOD files, 158 runtime libraries, 5 mode parameter, 274 .NET Framework, 3 modelMatrix, 306 Neutral Language field, Assembly Information model-view matrix, 264, 378 window, 387 monospace font, 62 New menu option, 64 MouseDown event, 131, 214, 306 NewEntryBackColor property, 232 MousePosition property, 130 NewEntryTextColor property, 232 MouseUp event, 131 newsgroups, 24 movement of gems, GemDrops game, 180, 181 newTime variable, 123 MoveMove event, 131–132 Next piece display, GemDrops game, 188, 194, MovePlayerGems function, 209 196 MovePlayerGemsToBoard function, 203 Niedergesaess, Bernd, 169 MoveToBack function, 137, 305 NoClip flag, 61 MoveToFront function, 137, 305 noncharacter keys, KeyDown event and, 148 MP3 files, defined, 157 None value, 31 MSDN (Microsoft Developer Network), 24 non-full-screen forms, 33–34 msnews.microsoft.com , 24 noninteger numbers, 86 multiple lights, 333 noninterpolation functions, changes to, 128 multiple transformations, applying, 267–269 non-uniform scaling, 266 multitasking, 112 Normal option, WindowState property, 33 multitouch input, 147 normalized vectors, 338 My Project node, 91 normalizing vectors, 153 _myGameEngine variable, 93 normals, 323, 336, 337, 347 _myGameEngine.RotateMatrixToCamera calculating, 338–339 function, 381 surface, 339–340 vertex, 339–340  N normals array, 350 \n character, 60 _normals array, 360 Name element, 236, 238 NotSupportedException, 35, 37, 40, 42, 44 Name must be at least 4 characters long NoWrap flag, 61 message, 406 NullReferenceException, 68 Name property, 278 numbers, noninteger, 86 navigation pad, four-directional, 8 near clip plane, 312, 313, 374  O NestedQuads project, 263, 266 obfuscation, 400 .NET CF (.NET Compact Framework), 3 adding obfuscated files to CAB setup .NET CF version 2.0, 13 projects, 407

427  INDEX

advanced, 405–407 and lighting, 346–347 with Dotfuscator Community Edition, 403– moving camera 405 adding camera objects to game engine, .obj files, 356, 357, 358, 362 365–369 _objDefinedNormals object, 362 optimizing camera calculation, 371–374 _objDefinedTexCoords object, 362 overview, 364 _objDefinedVertices object, 362 positioning camera, 364–365 object classes, 91 projection matrix, 374 object material, 329 in scene using lighting, 370–371 object property windows command, 23 overview, 353 objects rendering fog, 374–377 positions of, 116 OpenGL, creating 2D games with user-controlled, 118 adding OpenGL to game engine Objects component, 79 CGameEngineOpenGLBase class, 290 objx parameter, 306 CGameObjectOpenGLBase class, 294 objy parameter, 306 creating game form, 296–297 objz parameter, 306 overview, 289 off-screen buffer, 74 performing capabilities check, 294–296 OGG files, defined, 158 overview, 289 Ogg Vorbis algorithm, 158 using OpenGL game engine oloredCubes project, 323 overview, 298 OnPaintBackground function, 76, 91, 95, 145, playing game, 306–309 186, 261 preparing balloons game, 298–299 OnPaintBackground override, 297 rendering balloons, 301–303 on-screen buttons, 36 setting up projection matrix, 299–301 OnTheBoard function, 206 sorting balloons, 303–305 Open Containing Folder menu item, 66 OpenGL ES, 26 OpenFileDialog control, 42, 43 alpha blending, 284–285 OpenGL creating OpenGL program billboards, 377–381 adding form functions, 260–261 calculating light reflections in configuring project, 250–251 calculating normals, 338–339 creating OpenGL environment, 252–254 describing triangle's face direction, 336– initializing OpenGL, 254–256 338 overview, 250 overview, 336 rendering graphics in OpenGL, 256–260 using surface normals and vertex running program, 262 normals, 339–340 terminating OpenGL, 261–262 defining viewing frustum in, 315 drawing functions, 274–277 importing geometry features of, 246–247 into game engine, 359–364 matrix transformations overview, 353 applying multiple transformations, 267– SketchUp application, 353–357 269 using .0bj file format, 357–359 applying rotation transformations, 265– learning more about, 381 266

428  INDEX

applying scaling transformations, 266– creating setup project, 392–393 267 overview, 391 applying translation transformations, switching into release mode, 391–392 265 Paint event overview, 264 brushes, 56 practicing with example projects, 269– clearing background, 63 273 colors, 53–55 pushing and popping matrix, 269 displaying text, 60–63 setting identity matrix, 264 drawing coordinate system, 53 specifying vertex positions, 269 ellipses, 59–60 orthographic coordinate systems, 286–288 invalidating form, 53 overview, 245 lines, 56–57 preparing to use, 245–248 overview, 51 texture mapping pens, 55 cleaning up, 282 pixels, 60 loading graphics, 277–278 polygons, 57–58 overview, 277 rectangles, 59 rendering with textures, 278–280 Paint handler, 186 specifying texture coordinates, 280–281 painted form, 52 transparency, 282–283 PaintEventArgs type, 52 using in Visual Studio.NET, 248–250 Panel controls, 35, 236, 241 OpenGL Utility (GLU) library, 306 particle effects, 285 OpenGLES project, 251, 277, 306 PauseAllSounds function, BASS, 175 OpenGLES.dll file, 296, 395 _paused flag, 194 operations, drawing, 100 Paused property, 194 Orbits project, 269–271 _paused variable, 194 OrthoCoords property, 301 Pen class, 55, 63 _orthoCoords variable, 301 Pen object, 55 Orthof function, 287, 288 performance inconsistencies, overcoming orthographic coordinate systems, 286–288, 300, 301 dynamic update intervals, 113–115 orthographic projection, 299 fixed interval updates, 113 Other Project Types / Setup and Deployment interpolated updates item, 392 applying to game, 116–118 Output File Folder property, 22 distinguishing between updates and Output type field, 14 frames, 119 Output window, Visual Studio, 6, 23, 35 overview, 115 _outputNormals variable, 362 update frequency, 118–119 _outputTexCoords variable, 362 overview, 112 Perspective example, 316 P Perspective function, 256  Perspective project, 315, 316 packages, distribution perspective projection adding setup project's files, 393–395 defining viewing frustum in OpenGL, 315 building CAB file, 397 viewing frustum, 311–314 creating programs menu shortcut, 395–396

429  INDEX

PictureBox control, 31, 46 graphic file formats, 68–69 _pieceCount variable, 199 overview, 65 _piecesDropped property, 192 reading graphics from files, 68 _piecesDropped variable, 197, 200 Prepare function, 83, 92, 105, 190, 298 pins, 259 Present function, 91, 101, 103, 128 P/Invoke call, 120, 149 _presentRect variable, 101 P/Invoke functions, 121, 249 previous position, 116 P/Invoke Statements, PlaySound function, 160 PreviousRenderRect function, 99 piracy, minimizing, 401–402 primary market, 401 pixels, 60 Primary output item, 396 bitmap, 72 Primary Output option, 394 coordinates of, 247 primitives, drawing, 248 positions of, 86 private _outputVertices variable, 362 transparent, 71 private collection, 241 white, 72 private constructor, 90 _playerGems array, 204 private Dictionary object, 228 _playerGems variable, 197 private element, 404 _playerNextGems array, 198 private List objects, 362 _playerScore property, 192 private scope, 290 PlaySound API, 159, 160 processing and graphical complexity, 112 PlaySound function, 160–163, 170, 176, 308 processors, 9, 111 PlaySoundAndDispose function, 166 Product field, Assembly Information window, PlugIns menu, SketchUp, 356 386 plus (+) button, 66 ProductName property, 393 PNG (Portable Network Graphics) files, 69 Program Files directory, 20 pnlEnterName panel, 236 \Program Files directory, 397 Pocket PC, 7 Program Files folder, 393 Pocket PC 2003 platform, 13 programming language, Ruby, 356 point lights, 335, 343–344 Programs folder, 395, 396 Point objects, 217 Programs menu, 395, 396, 397 Point structures, 58 Programs menu icon, 397 point system, GemDrops game, 181 programs menu shortcut, creating, 395–396 Point variables, 57 Programs/Games folder, 396 points, drawing, 274 Project Output menu item, 407 PointToClient function, 130 Project Properties window, 14, 250 polygons, 57–58 Project types tree, 392 PopMatrix function, 269, 271 project versioning, 387–388 popping matrix, 269 projection calculation, 306 Popup event, 38, 40 projection matrix, 374 Portable Network Graphics (PNG) files, 69 Projects tab, 91 portrait mode, 184 projMatrix, 306 position variable, 211 promoting game, 409 predrawn graphics, creating bitmaps from properties embedding graphic resources, 66–68 read-only, 81

430  INDEX

virtual, 86 Reflector.NET protection, 406 Properties node, 250 registry editor, third-party, 22 Properties window, 15, 16, 22, 34, 104, 393 Regular font style, 62 public classes, 404 Release build, 391 public item, 241 Release configuration, 391 pushing matrix, 269 Release directory, 397 PushMatrix function, 269, 271 Release mode, switching into, 391–392 Push/Pull tool, 354 released code, vs. development mode, 112 Pythagorean theorem, 133, 339 Remove Programs list, 393 RemoveGemGroups function, 203, 216  Q RemoveGemGroups_FindGroup function, 217, quadColors array, 259 218, 219 quadrilaterals, rendering, 293–294 RemoveGemGroups_RemoveColor function, 221 quadVertices variable, 259 RemoveGemGroups_RemoveGroup function, Quarter VGA (QVGA) resolution, 9 217, 218 QueryPerformanceCounter function, 120 RemoveGems function, 215 QueryPerformanceFrequency function, 120 RemoveRainbowGems function, 220 QVGA (Quarter VGA) resolution, 9 RemoveTerminatedObjects function, 85, 102 QVGA screen, 112, 183, 186 removing hidden surfaces, 324–325 QVGA-style device, 184 render buffers, 297 Render code, 101, 258, 381  R Render function, 87, 88, 89, 101, 102, 189, 190, rainbow gem, GemDrops game, 182, 189 258, 259, 263 _rainbowGemFrame variable, 190 RenderBranch function, 273 _rainbowGemUpdateTime variable, 190 RenderColorAlphaTextureQuad function, 285 Random object, 301 RenderColorQuad function, 258, 263, 269, 274, RandomFloat class, 301 278, 280, 284, 292, 293 read-only property, 81 RenderColorTexture function, 303 Rectangle class, 53, 60, 71, 72, 91, 217, 220, 301 RenderColorTextureQuad function, 292, 293, Rectangle parameters, 91 294 Rectangle structure, 59, 63 RenderIndexedTriangles function, 329 Rectangle.FromLTRB function, 220 rendering rectangles, 59 in 3D, 247–248 Rectangles. Pixel, 70 defining 3D object, 318–323 Rectangle.Union method, 91 overview, 318 recursion concept, 272 removing hidden surfaces, 324–325 recursionLevel parameter, 273 using indexed triangles, 326–329 recursive algorithms, 272 billboards, 377–381 red, green, blue (RGB) model, 54, 247 fog, 374–377 red parameter, 54, 255 graphics in OpenGL, 256–260 redraw, of objects, 102 quadrilaterals, 293–294 References node, 91 with textures, 278–280 References tab, 91 transparent objects with depth buffer, 318 reflection, accessing DLL, 154 render/invalidate cycle, 261

431  INDEX

RenderLoop function, 95, 96, 104, 186 SaveSettings function, 226, 229 RenderTextureQuad function, 258, 278, 279, Scale function, 267 281, 292, 293, 294 ScaleObject function, 361, 362 RenderTriangles function, 320, 321, 323, 327 scaling, 246, 269 ReportMissingCapabilities function, 108, 156, scaling transformations, applying, 266–267 296 scheduled update, 117 Reset function, 83, 92, 97, 192, 193, 198, 299 score objects, in GemDrops game, 221–223 Resize event, 33, 105, 261, 290 _scoreEntries.Sort, 236 resolution screens, 183 _scoreMultiplier variable, 216, 218 resource protection, 407 _scoreText value, 221 Resources directory, 66, 67 _scoreText variable, 221 resources, embedded, 407 screen coordinate, 130 Resources panel, 390 screen divisions, 182, 183 ResumeAllSounds function, BASS, 175 screen resolution category, 106 reusable code library, 14 Screen.PrimaryScreen.Bounds.Height property, reverse engineering 184 adding obfuscated files to CAB setup screens projects, 407 size of, 9 obfuscating with Dotfuscator Community square, 33 Edition, 403–405 touch, 214 overview, 402 touch point accuracy in, 146 using advanced obfuscation, 405–407 Security Configuration tab, 21 RGB (red, green, blue) model, 54, 247 Security Off configuration, 21 rolling, camera, 364, 365 security warnings, 20 Rotatef function, 266 select-and-drag operation, finger-friendly RotateMatrixToCamera function, 380 games, 146 RotatePlayerGems function, 210 selecting objects, 132–138 rotation, 33, 246, 267–269 SelectObject function, 139 rotation transformations, applying, 265–266 SelectSingleNode method, 238 _rotation variable, 257, 258 Seligman, Scott, 151 Ruby language, 356 selling games Running Programs List, 17 creating evaluation applications, 397–398 Running Programs tab, 17, 32 minimizing piracy, 401–402 Running Programs window, 21 overview, 397 runtime libraries, .NET for Windows Mobile, 5 upgrading to full versions, 398–400 using Windows Marketplace for Mobile,  S 400–401 s axis, 280, 281 sender object, 52 s coordinate, 281 Sensors.HTCGSensor.GetGVector function, 154 S3M files, 158 separators, 38 sanity checks, 124 serif font, 62 sans-serif font, 62 SetAmbientLight function, 344 SaveFileDialog control, 42 SetColorKey class, 72 SaveScores method, 235, 236 SetColorKey function, 72

432  INDEX

SetFogParameter function, 375 SimpleDraw method, 74 SetLightParameter, 342 single-pixel drawing requests, 60 SetLightParameter function, 342 SIP (Soft Input Panel), 37, 43, 44 SetMaterialParameter function, 345 SIPEnabledChanged function, 106 SetModelviewMatrix function, 372, 373, 379 six-array element, 398 SetPixel method, 60 Size property, 33 SetScore function, 186 _size variable, 304 settings SketchUp application CSettings class creating 3D objects in, 354–356 accessing Settings object, 228 exporting 3D geometry, 356–357 loading and saving settings, 229 overview, 353 overview, 226 SketchUp Pro version, 354, 356 setting and retrieving values, 228–229 .skp file, 356, 357 overview, 225 Sleep method, 104 settings element, 229 Smart Device CAB Project, 392 Settings object, accessing, 228 Smart Device form designer, 15 Settings option, 17 Smart Device Programmability option, 10 Settings pages, Windows Mobile, 33 Smart Device project, 11, 12, 13 Settings project, 226, 228 smart phones Settings property, 226, 228 ContextMenu property compatibility, 145 Settings window, 17 developing user interface for, 29–30 Settings.dat file, 226 smooth animation, 72–76 setup project SmoothDraw method, 76 adding setup project's files, 393–395 SND_ASYNC flag, 161 creating, 392–393 SND_FILENAME flag, 161 setup project node, 393 SND_LOOP flag, 161 SetValue function, 226, 228 SND_MEMORY flag, 161 ShadeModel method, 255 SND_NOSTOP flag, 162 ShadeModel property, 257 SND_SYNC flag, 161 Shared folder box, 18 SndPlayAsync function, 167 shareware, 397 SndPlaySync function, 167 sharing files, with emulated device, 18–19 SndStop function, 169 shine effects, 332 Soft Input Panel (SIP), 37, 43, 44 shininess value, 332 soft key bar, 36, 37 shortcut number, 38 SolidBrush class, 56 Show All Files button, 66 Solution Configurations box, 391 Show( ) method, 40, 96 Solution Explorer panel, 66 Show skin in Windows Forms Designer option, Solution Explorer tree, 66, 250 14 sound APIs ShowDialog( ) method, 46, 230, 231, 234, 235, AygShell sound functions, 167–169 236 BASS.dll ShowScores function, 236 overview, 169 ShowTableBorder property, 232 using BASS and BASS.NET in projects, Simple Template options, SketchUp, 354 176

433  INDEX

wrapping BASS.NET, 170–175 swiping objects, 140–144 choosing, 177 switch on and play nature, 25 overview, 158–159 symbol renaming schemes, 406 PlaySound, 160–163 synchronous playback, AygShell sound System.Media.SoundPlayer, 164–167 functions, 167 sound effects, in GemDrops game, 183 System tab, 17 sound file types, 157–158 System.Diagnostics.Debug object, 23 SoundPlayer API, 160 System.Drawing.Brush class, 56 SoundPlayerWrapper class, 164 System.Drawing.Color function, 53 source color, 283 System.Drawing.Color.FromArgb function, 54 source factor, 283 System.Drawing.Pen object, 55 SourceAlpha function, 284 System.Media.SoundPlayer API, 159 SpaceAfter property, 239 System.Media.SoundPlayer class, 164–167 specular light, 331, 333 SystemParametersInfo function, 30 specular material, 332 System.Random class, 85 spotlights, 335, 344 System.Threading.Timer class, 41 sprites, 64 System.Windows.Forms.Application.DoEvents( square screens, 33 ) method, 41 srcRect image, 70 System.Windows.Forms.Control class, 130 stack, 269 standard colors, 53  T Start button, 17 t axis, 280, 281 Start using SketchUp option, 354 t coordinate, 281 StartupPosition property, 34 Table elements, 236, 237, 238 state machine, 254 tableName value, 238 static DateTime.Now property, 120 TableTextColor property, 232 static functions, 90 TableTextColor1 property, 232 static Graphics.FromImage function, 64 TableTextColor2 property, 232 static LoadStream method, 277 TEA (Tiny Encryption Algorithm), 237 static Sensors.GSensorFactory.CreateGSensor TEA algorithm, 398 function, 151 technologies used in this book, 27 static variable, 34 Templates selection, 392 Stop Debugging button, Visual Studio, 17, 18, Terminate flag, 102 250 Terminate property, 87 StopAllSounds function, 169 TestHit function, 308 Storage Card item, 18 Tetris game, 98 Stream object, 65, 277 texCoords array, 294, 322 stride parameter, 260 _texcoords array, 360 Strikeout font style, 62 text, displaying, 60–63 string encryption, 406 Text property, 32–33 string type, 226 TextAlign property, 185 StringFormat object, 61, 62 TextAlign setting, 35 subtractive colors, 54 TextColor property, 232, 239 surfaces, removing hidden, 324–325 Texture class, 277

434  INDEX

texture coordinates, 303, 327, 357, 358 TitleBackColor property, 230 texture mapping TitleTextColor property, 230 cleaning up, 282 Today page, 17 loading graphics, 277–278 Today screen, Windows Mobile, 5, 102 overview, 277 toolbar, Visual Studio, 391 rendering with textures, 278–280 Tools/Options option, 18 specifying texture coordinates, 280–281 Tools/Options window, 14 Texture objects, 277, 282, 291 TopPosition property, 241 TextureBrush class, 56 ToString method, 228 Texture.LoadStream function, 277 touch point, determining with Pythagorean textures, alpha blending with, 284–285 theorem, 133 Textures project, 277, 281, 282, 283 touch screen devices, developing user interface third-party registry editor, 22 for, 29–30 this.Font, 61 touch screen input Tick event, 40, 41 adding context menus, 144–146 TickCount value, 123, 124 dragging objects, 138–140 time updates, 114 events Timer control, 41, 53 Click, 130 Timer form control, 41 DoubleClick, 130 timer initialization, Frames Per Second, 96 MouseDown, 131 _timerFrequency variable, 122, 123 MouseUp, 131 _timerLastTime value, 123 MoveMove, 131–132 _timerLastTime variable, 122, 123, 124 overview, 129 timers, 40–41 multitouch input, 147 TimeSinceLastRender property, 190 overview, 129 timing selecting objects, 132–138 consistent, 111–112 swiping objects, 140–144 in game engine using finger-friendly input, 146 changes to interpolation-based touch screens, 8 functions, 124–127 TouchScreen flag, 107 changes to noninterpolation functions, TRA Change Target Platform menu option, 19 128 TRA Device Security Manager menu item, 21 initializing and interrogating timer, 121– TRA Options item, 32 124 tracker files, defined, 158 overview, 121 Trademark field, Assembly Information overcoming performance inconsistencies window, 387 dynamic update intervals, 113–115 transformation matrix, 370, 378 fixed interval updates, 113 transformations. See matrix transformations interpolated updates, 115–119 Translated function, 265 overview, 112 translation matrix, 265 overview, 111 translation transformations, applying, 265 using external timer, 120–121 transparency, 246–247, 282–283 Tiny Encryption Algorithm (TEA), 237 transparent objects, rendering with depth Title field, Assembly Information window, 386 buffer, 318

435  INDEX

transparent pixels, 71 time, 114 triangle strip, 319 UpdatesPerSecond property, 124 triangles upgrading, to full versions, 398–400 describing face direction of, 336–338 Use Textures option, 284 drawing, 275–277 user input indexed, 326–329 accelerometer triangulate, 356 initializing, 151–152 True value, 31, 32 overview, 151 try before you buy strategy, 401 reading data from, 152–154 try/catch block, 46, 68 supported, detecting presence of, 154– try/finally block, 41 156 txtName Textbox, 236 supporting devices with no accelerometer, 156 U button and keyboard  button and keyboard events, 147–149 Un4Seen Developments, 169 choosing keyboard input method, 150– Underline font style, 62 151 uniform scaling, 266 input from SIP, 150 Uninstall/Change option, Control Panel, 11 overview, 147 Unlock registry tool, CeRegEditor, 22 reading keyboard state, 149–150 unnormalized vectors, 338 design of, 156 UnProject function, 306, 308 overview, 129 unsafe code, 250 touch screen input unsafe keyword, 259 adding context menus, 144–146 up vector, 364, 365 dragging objects, 138–140 Update function, 84, 85, 113, 114, 194, 195, 206, events, 129–132 207, 212, 299 multitouch input, 147 UpdateCheck project, 407 overview, 129 _updateElapsedTime variable, 125 selecting objects, 132–138 UpdateForm ( ) method, 193, 216 swiping objects, 140–144 UpdatePreviousPosition function, 86, 128, 292, 293, 366 using finger-friendly input, 146 updates user interface dynamic update intervals, 113–115 busy cursor, 46 fixed interval, 113 controls frequency of, 119 buttons, 35–36 graphical, 112 capturing camera images, 45–46 interpolated context menus, 39–40 applying to game, 116–118 file dialog controls, 42–43 distinguishing between updates and forms, 31–35 frames, 119 input panels, 43–44 overview, 115 labels, 35 update frequency, 118–119 menu bars, 36–39 number of, 117 overview, 31 scheduled, 117 timers, 40–41

436  INDEX

developing for touch screen and smart viewing frustum phone devices, 29–30 defining in OpenGL, 315 overview, 29 overview, 311–314 user-controlled objects, 118 Viewport function, 256 View/Properties Window item, 16  V virtual function, 83, 290 v element, 357 virtual properties, 86 va array, 348 visible buffer, 75 validation code, 400 Visible property, 35, 231 values, elapsed, 124 VisibleDesktop property, 43 variables, class-level, 81, 96 Visual Basic 6 (VB6), 3 vb array, 348 Visual Basic for Applications (VBA), 3 VB6 (Visual Basic 6), 3 Visual Studio VBA (Visual Basic for Applications), 3 2005 Standard version, 4 .vbproj file, 390 2008 Professional version, 4 vector, 3D, 337 creating Windows Mobile project vector length, 339 overview, 11 vectors, 338 project templates, 14 velocity, 73 Visual Studio 2005, 12 velocity variable, swiping, 141 Visual Studio 2008, 12–13 Version object, 108 debugging, 22–23 versioning, 387–388 designing form, 14–16 versions of game, releasing, 407–408 emulators, 18–19 vertex 1 element, 357 Form designer, 35, 36 vertex 2 element, 357 getting help, 24 vertex array, 260 installing, 11–24 vertex colors, 327, 329, 334 overview, 10 vertex coordinates, 318, 326 running application, 16–18 vertex definition, 357 running on real device, 20–22 vertex index, 328, 358 targeting different platforms, 19–20 vertex normal (vn), 321, 322, 357 Visual Studio toolbar, 391 vertex positions, specifying, 269 Visual Studio.NET, using OpenGL ES in, 248– vertex texture (vt), 357 250 vertex0 array, 349 visualizers command, 23 vertex1 array, 349 vn (vertex normal), 321, 322, 357 vertex2 array, 349 vn vector, 350 VertexPointer function, 259 vt (vertex texture), 357 vertices, 248, 325 vertices array, 321, 328  W _vertices array, 360, 362 warning icon, 35, 36 VGA screen, 184, 186, 300 WAV files, defined, 157 VGA-style device, 184 Wavefront Technologies, 356 View Scores menu item, 235 white pixels, 72 viewing angle, 313 white specular component, 347

437  INDEX

Wide Quarter VGA (WQVGA), 9 XCenter property, 366 Wide VGA (WVGA), 9 XM files, 158 Width property, 55, 65, 93, 94, 189, 190, 292 XmlTextWriter, 229, 236 width value, 59, 94 XPath expression, 237, 238 Windows Marketplace for Mobile, 400–401 XPos property, 86, 88, 190, 196, 223 Windows Mobile 5.0, 36, 45 XPos variable, 301, 302 Windows Mobile 6 operating system, 107 XScale property, 292 Windows Mobile 6.5 SDK, 19 XUp property, 366 Windows Mobile 2003 SE operating system, 107 x/z plane, 354 Windows Mobile Classic, 7 Windows Mobile Device Centre application, 21  Y Windows Mobile emulators, 245 y axis, 53, 73, 265, 266, 267, 313 Windows Mobile for Pocket PC edition, 7 y coordinate, 53, 86, 113, 116, 188 Windows Mobile for Pocket PC Phone edition, 7 y value, 59 Windows Mobile for Smartphone edition, 7 YAngle property, 292 Windows Mobile Professional, 7 YCenter property, 366 Windows Mobile Standard, 7 yellow sun object, 269 Windows Mobile Unified Sensor API, 151 YPos property, 86, 88, 190, 196, 223 Windows Mobile versions and editions, 6–8 YPos variable, 301, 302 WindowState property, 33 YScale property, 292 winx value, 306 YUp property, 366 winy value, 306 winz coordinate, 306  Z world coordinate system, 267 z axis, 247, 257, 258, 266, 267, 312, 338, 377, 378 WQVGA (Wide Quarter VGA), 9 z buffer, 377 wrapper function, 306 z coordinate, 86, 259, 312, 319 WVGA (Wide VGA), 9 z positions, 312, 320 WVGA screen, 112, 183, 306 z value, 152, 266 ZAngle property, 292  X ZCenter property, 366 x axis, 53, 73, 265, 266, 267, 268, 269, 314, 338 ZIP file, 391 X button, 29, 32, 34, 103 zooming, 314 x coordinate, 53, 86, 116, 188 ZPos property, 86, 88, 315 x position, 187 ZScale property, 292 x value, 59 ZUp property, 366 XAngle property, 292

438