Archive for the 'Coldfusion' Category

OpenGL Super Bible! Page 471 * Range check (Web hosting unlimited bandwidth)

Saturday, January 12th, 2008

OpenGL Super Bible! Page 471 * 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); /* * Set the height of the terrain ‘cell . For water, the * height is constant at WATER_HEIGHT. For other types, * we add a random pertubation to make the terrain more * interesting/realistic. */ switch (TerrainCurrent) { case IDC_WATER : TerrainHeight[y][x] = WATER_HEIGHT; break; case IDC_GRASS : TerrainHeight[y][x] = GRASS_HEIGHT + 0.1 * (rand() % 5); break; case IDC_TREES : TerrainHeight[y][x] = TREES_HEIGHT + 0.1 * (rand() % 5); break; case IDC_ROCKS : TerrainHeight[y][x] = ROCKS_HEIGHT + 0.1 * (rand() % 5); break; case IDC_MOUNTAINS : TerrainHeight[y][x] = MOUNTAINS_HEIGHT + 0.15 * (rand() % 5); break; }; } /* * ‘DrawTerrain() - Draw a terrain cell at the given mouse * position. */ void DrawTerrain(int mousex, /* I - Horizontal mouse position */ int mousey) /* I - Vertical mouse position */ { int i, /* Looping var */
Visit our web design programs services for an affordable and reliable webhost to suit all your needs.

Page 470 OpenGL Super Bible! n[0][1] = ny (Database web hosting)

Friday, January 11th, 2008

Page 470 OpenGL Super Bible! n[0][1] = ny / d; n[0][2] = nz / d; }; /* * Set the top row of normals to be the same as the second -to* last row of normals. */ for (x = 0; x < TERRAIN_SIZE; x ++, n ++) { n[0][0] = n[-TERRAIN_SIZE][0]; n[0][1] = n[-TERRAIN_SIZE][1]; n[0][2] = n[- TERRAIN_SIZE][2]; }; } /* * 'InitializeTerrain() - Initialize the terrain arrays */ void InitializeTerrain(void) { int x, y; /* Terrain (x,y) location */ /* * Fill the terrain array with grass */ TerrainCurrent = IDC_WATER; for (y = 0; y < TERRAIN_SIZE; y ++) for (x = 0; x < TERRAIN_SIZE; x ++) { TerrainType[y][x] = IDC_GRASS; TerrainHeight[y][x] = GRASS_HEIGHT + 0.1 * (rand() % 5); }; /* * Update the lighting normals */ UpdateNormals(); } /* * 'draw_cell() - Draw (fill-in) a single terrain cell */ void draw_cell(int x, /* I - Terrain X location */ int y) /* I - Terrain Y location */ { /*
Visit our web design programs services for an affordable and reliable webhost to suit all your needs.

Web site designers - OpenGL Super Bible! Page 469 /* * ‘UpdateNormals()

Thursday, January 10th, 2008

OpenGL Super Bible! Page 469 /* * ‘UpdateNormals() - Update the lighting normals for the * terrain */ void UpdateNormals(void) { int x, y; /* Terrain (x,y) location */ GLfloat (*n)[3], /* Current terrain normal */ nx, ny, nz, /* Normal components */ d, /* Normal magnitude */ *height; /* Current terrain heig ht */ /* * Loop through the terrain arrays and regenerate the * lighting normals based on the terrain height. */ n = TerrainNormal[0]; height = TerrainHeight[0]; for (y = 0; y < (TERRAIN_SIZE - 1); y ++, n ++, height ++) { for (x = 0; x < (TERRAIN_SIZE - 1); x ++, n ++, height ++) { /* * Compute the cross product of the vectors above and to * the right (simplified for this special case). */ nx = height[0] - height[1]; ny = -1.0; nz = height[0] - height[TERRAIN_SIZE]; d = -sqrt(nx * nx + ny * ny + nz * nz); n[0][0] = nx / d; /* Normalize the normal vector */ n[0][1] = ny / d; n[0][2] = nz / d; }; /* * Compute the cross product of the vectors above and to * the left (simplified for this special case) for the last * column in the grid. */ nx = height[0] - height[-1]; ny = -1.0; nz = height[0] - height[TERRAIN_SIZE]; d = -sqrt(nx * nx + ny * ny + nz * nz); n[0][0] = nx / d; /* Normalize the normal vector */
You need excellent and relaible webhost company to host your web applications? Then pay a visit to Inexpensive Web Hosting services.

Page 468 OpenGL Super Bible! LoadAllTextures(void) { glNewList(SkyTexture (Dedicated web hosting)

Wednesday, January 9th, 2008

Page 468 OpenGL Super Bible! LoadAllTextures(void) { glNewList(SkyTexture = glGenLists(1), GL_COMPILE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); TextureLoadBitmap(’textures/sky.bmp ); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glEndList(); glNewList(RocksTexture = glGenLists(1), GL_COMPILE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); TextureLoadMipmap(’textures/rock.bmp ); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_ MIPMAP_LINEAR); glEndList(); glNewList(GrassTexture = glGenLists(1), GL_COMPILE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); TextureLoadMipmap(’textures/grass.bmp ); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_ MIPMAP_LINEAR); glEndList(); glNewList(WaterTexture = glGenLists(1), GL_COMPILE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); TextureLoadMipmap(’textures/water.bmp ); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEA REST_ MIPMAP_LINEAR); glEndList(); glNewList(TreesTexture = glGenLists(1), GL_COMPILE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); TextureLoadMipmap(’textures/trees.bmp ); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_ MIPMAP_LINEAR); glEndList(); glNewList(MountainsTexture = glGenLists(1), GL_COMPILE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); TextureLoadMipmap(’textures/mountain.bmp ); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_ MIPMAP_LINEAR); glEndList(); }
You need excellent and relaible webhost company to host your web applications? Then pay a visit to Inexpensive Web Hosting services.

OpenGL Super Bible! Page (Vps web hosting) 467 }; return (FALSE);

Tuesday, January 8th, 2008

OpenGL Super Bible! Page 467 }; return (FALSE); } /* * ‘LoadAllBitmaps() - Load bitmap images for the terrain control buttons. */ void LoadAllBitmaps(HINSTANCE hInstance) /* I - Process instance */ { GrassDownBitmap = LoadBitmap((HANDLE)hInstance, MAKEINTRESOURCE(IDB_GRASS_DOWN)); GrassSelectBitmap = LoadBitmap((HANDLE)hInstance, MAKEINTRESOURCE(IDB_GRASS_SELECT)); GrassUpBitmap = LoadBitmap((HANDLE)hInstance, MAKEINTRESOURCE(IDB_GRASS_UP)); WaterDownBitmap = LoadBitmap((HANDLE)hInstance, MAKEINTRESOURCE(IDB_WATER_DOWN)); WaterSelectBitmap = LoadBitmap((HANDLE)hInstance, MAKEINTRESOURCE(IDB_WATER_SELECT)); WaterUpBitmap = LoadBitmap((HANDLE)hInstance, MAKEINTRESOURCE(IDB_WATER_UP)); RocksDownBitmap = LoadBitmap((HANDLE)hInstance, MAKEINTRESOURCE(IDB_ROCKS_DOWN)); RocksSelectBitmap = LoadBitmap((HANDLE)hInstance, MAKEINTRESOURCE(IDB_ROCKS_SELECT)); RocksUpBitmap = LoadBitmap((HANDLE)hInstance, MAKEINTRESOURCE(IDB_ROCKS_UP)); TreesDownBitmap = LoadBitmap((HANDLE)hInstance, MAKEINTRESOURCE(IDB_TREES_DOWN)); TreesSelectBitmap = LoadBitmap((HANDLE)hInstance, MAKEINTRESOURCE(IDB_TREES_SELECT)); TreesUpBitmap = LoadBitmap((HANDLE)hInstance, MAKEINTRESOURCE(IDB_TREES_UP)); MountainsDownBitmap = LoadBitmap((HANDLE)hInstance, MAKEINTRESOURCE(IDB_MOUNTAINS_DOWN)); MountainsSelectBitmap = LoadBitmap((HANDLE)hInstance, MAKEINTRESOURCE(IDB_MOUNTAINS_ SELECT)); MountainsUpBitmap = LoadBitmap((HANDLE)hInstance, MAKEINTRESOURCE(IDB_MOUNTAINS_UP)); } /* * ‘LoadAllTextures() - Load texture images for the scene. */ void
In case you need affordable webhost to host your website, our recommendation is ecommerce web host services.

Page 466 OpenGL Super Bible! else SelectObject(hdc, RocksUpBitmap); (Web servers)

Monday, January 7th, 2008

Page 466 OpenGL Super Bible! else SelectObject(hdc, RocksUpBitmap); break; case IDC_MOUNTAINS : if (lpdis- >itemState & ODS_SELECTED) SelectObject(hdc, MountainsDownBitmap); else if (TerrainCurrent == IDC_MOUNTAINS) SelectObject(hdc, MountainsSelectBitmap); else SelectObject(hdc, MountainsUpBitmap); break; }; /* * Stretch the bitmap to fit the button area */ StretchBlt(lpdis->hDC, lpdis- >rcItem.left, lpdis->rcItem.top, lpdis->rcItem.right, lpdis->rcItem.bottom, hdc, 0, 0, 24, 24, SRCCOPY); DeleteDC(hdc); break; case WM_CLOSE : /* * Close the window (hide it) and turn the check mark off * in the main menu. */ ShowWindow(TerrainWindow, SW_HIDE); CheckMenuItem(GetMenu(SceneWindow), IDM_WINDOW_TERRAIN, MF_BYCOMMAND | MF_UNCHECKED); break; case WM_COMMAND : /* * A button was selected - choose the new current terrain * type. */ switch (LOWORD(wParam)) { case IDC_GRASS : case IDC_TREES : case IDC_ROCKS : case IDC_WATER : case IDC_MOUNTAINS : TerrainCurrent = LOWORD(wParam); InvalidateRect(TerrainWindow, NULL, TRUE); UpdateWindow(TerrainWindow); return (TRUE); }; break;
Visit our web design programs services for an affordable and reliable webhost to suit all your needs.

OpenGL Super Bible! Page 465 */ UINT CALLBACK (Submit web site)

Sunday, January 6th, 2008

OpenGL Super Bible! Page 465 */ UINT CALLBACK TerrainDlgProc(HWND hWnd, /* I - Source window */ UINT uMsg, /* I - Message type */ WPARAM wParam, /* I - ‘word’ parameter value */ LPARAM lParam) /* I - ‘long’ parameter value */ { HDC LPDRAWITEMSTRUCT UINT hdc; lpdis; idCtl; /* Drawing context for buttons */ /* Button state info */ /* Button ID */ switch (uMsg) { case WM_DRAWITEM /* : * Windows wants us to draw a button. Figure out which * button it is, and display as necessary */ idCtl = (UINT)wParam; lpdis = (LPDRAWITEMSTRUCT)lParam; hdc = CreateCompatibleDC(lpdis->hDC); switch (idCtl) { case IDC_WATER : if (lpdis->itemState & ODS_SELECTED) SelectObject(hdc, WaterDownBitmap); else if (TerrainCurrent == IDC_WATER) SelectObject(hdc, WaterSelectBitmap); else SelectObject(hdc, WaterUpBitmap); break; case IDC_GRASS : if (lpdis->itemState & ODS_SELECTED) SelectObject(hdc, GrassDownBitmap); else if (TerrainCurrent == IDC_GRASS) SelectObject(hdc, GrassSelectBitmap); else SelectObject(hdc, GrassUpBitmap); break; case IDC_TREES : if (lpdis->itemState & ODS_SELECTED) SelectObject(hdc, TreesDownBitmap); else if (TerrainCurrent == IDC_TREES) SelectObject(hdc, TreesSelectBitmap); else SelectObject(hdc, TreesUpBitmap); break; case IDC_ROCKS : if (lpdis->itemState & ODS_SELECTED) SelectObject(hdc, RocksDownBitmap); else if (TerrainCurrent == IDC_ROCKS) SelectObject(hdc, RocksSelectBitmap);
From our experience, we can recommend PHP Web Hosting services, if you need affordable webhost to host and run your web application.

Page 464 OpenGL Super Bible! SetCapture(SceneWindow); if (IsWindowVisible(TerrainWindow)) (Web site design)

Saturday, January 5th, 2008

Page 464 OpenGL Super Bible! SetCapture(SceneWindow); if (IsWindowVisible(TerrainWindow)) { DrawTerrain(LOWORD(lParam), HIWORD(lParam)); Drawing = GL_TRUE; } else { GetCursorPos(&CenterMouseXY); Moving = GL_TRUE; MoveTime = GetClock(); }; break; case WM_MOUSEMOVE : /* * The mouse pointer moved. If we are in the process of * drawing some terrain, do it. * * Otherwise, ignore the message because we fly from the * main loop. */ if (Drawing) DrawTerrain(LOWORD(lParam), HIWORD(lParam)); break; case WM_LBUTTONUP : /* * The user released the left mouse button. Stop drawing * or flying */ Moving = GL_FALSE; Drawing = GL_FALSE; ReleaseCapture(); InvalidateRect(SceneWindow, NULL, TRUE); break; default : /* * Pass all other messages through the default window * procedure */ return (DefWindowProc(hWnd, uMsg, wParam, lParam)); }; return (FALSE); } /* * ‘TerrainDlgProc()’ - Process messages in the terrain dialog window.
In case you need quality webspace to host and run your web applications, try our personal web hosting services.

OpenGL Super Bible! Page 463 * Release and (Adelphia web hosting)

Friday, January 4th, 2008

OpenGL Super Bible! Page 463 * Release and free the device context, rendering * context, and color palette */ if (SceneRC) wglDeleteContext(SceneRC); if (SceneDC) ReleaseDC(SceneWindow, SceneDC); if (ScenePalette) DeleteObject(ScenePalette); PostQuitMessage(0); break; case WM_QUERYNEWPALETTE : /* * Realize the color palette if necessary */ if (ScenePalette) { SelectPalette(SceneDC, ScenePalette, FALSE); RealizePalette(SceneDC); InvalidateRect(hWnd, NULL, FALSE); return (TRUE); }; break; case WM_PALETTECHANGED: /* * Reselect our color palette if necessary */ if (ScenePalette && (HWND)wParam != hWnd) { SelectPalette(SceneDC, ScenePalette, FALSE); RealizePalette(SceneDC); UpdateColors(SceneDC); }; break; case WM_LBUTTONDOWN : /* * The left mouse button just was pressed. If we have * the terrain dialog window open, then this signifies * the beginning of drawing. * * Otherwise, set the ‘Moving flag to true to indicate * flying. */
In case you need quality webspace to host and run your web applications, try our personal web hosting services.

Page 462 OpenGL Super Bible! DestroyWindow(SceneWindow); break; case

Thursday, January 3rd, 2008

Page 462 OpenGL Super Bible! DestroyWindow(SceneWindow); break; case IDM_WINDOW_TERRAIN : /* * Toggle the terrain dialog window on and off */ if (GetMenuState(GetMenu(SceneWindow), IDM_WINDOW_TERRAIN, MF_BYCOMMAND) & MF_CHECKED) { CheckMenuItem(GetMenu(SceneWindow), IDM_WINDOW_TERRAIN, MF_BYCOMMAND | MF_UNCHECKED); ShowWindow(TerrainWindow, SW_HIDE); } else { CheckMenuItem(GetMenu(SceneWindow), IDM_WINDOW_TERRAIN, MF_BYCOMMAND | MF_CHECKED); ShowWindow(TerrainWindow, SW_SHOW); }; break; }; break; case WM_QUIT : case WM_CLOSE : /* * Destroy the windows and bitmaps and exit */ DestroyWindow(SceneWindow); DestroyWindow(TerrainWindow); DeleteObject(GrassDownBitmap); DeleteObject(GrassSelectBitmap); DeleteObject(GrassUpBitmap); DeleteObject(WaterDownBitmap); DeleteObject(WaterSelectBitmap); DeleteObject(WaterUpBitmap); DeleteObject(RocksDownBitmap); DeleteObject(RocksSelectBitmap); DeleteObject(RocksUpBitmap); DeleteObject(TreesDownBitmap); DeleteObject(TreesSelectBitmap); DeleteObject(TreesUpBitmap); DeleteObject(MountainsDownBitmap); DeleteObject(MountainsSelectBitmap); DeleteObject(MountainsUpBitmap); exit(0); break; case WM_DESTROY : /*
Searching for affordable and proven webhost to host and run your servlet applications? Go to Linux Web Hosting services and you will find it.