OpenGL Super Bible! Page 449 (Hp web site) The heart of

OpenGL Super Bible! Page 449 The heart of the drawing interface is in the DrawTerrain function. It uses the OpenGL selection mechanism to determine which terrain points are under the mouse pointer. Instead of drawing the terrain to the screen, selection rendering records hits inside the selection area (in this case, the mouse pointer) to a buffer you provide. In DrawTerrain, we record the (x,y) location of the terrain in the selection buffer, as in a paint-by-numbers book (see Figure 12-5). OpenGL selection is covered in more detail in Chapter 19. Figure 12-5 Picking a terrain cell Once we have the (x,y) terrain locations, we then reset the height and type of these points in the draw_cell function (Listing 12-4). Listing 12-4 The draw_cell function void draw_cell(int x, /* I - Terrain X location */ int y) /* I - Terrain Y location */ { /* * Range check the terrain location */ if (x < 0 || x >= TERRAIN_SIZE || y < 0 || y >= TERRAIN_SIZE) return; if (TerrainType[y][x] == TerrainCurrent) return; /* Already the right type */ TerrainType[y][x] = TerrainCurrent; /* * Force a redraw */ InvalidateRect(SceneWindow, NULL, TRUE);
Note: If you are looking for cheap and reliable webhost to host and run your mysql application check mysql web server services.

Leave a Reply