January 3rd, 2008
OpenGL Super Bible! Page 461 pfd.cColorBits = 0; /* Best color buffer please */ pfd.cDepthBits = 32; /* Need a depth buffer */ pfd.cStencilBits = 0; /* No stencil buffer */ pfd.cAccumBits = 0; /* No accumulation buffer */ pf = ChoosePixelFormat(SceneDC, &pfd); if (pf == 0) DisplayErrorMessage(’texscene was unable to choose a suitable pixel format! ); else if (!SetPixelFormat(SceneDC, pf, &pfd)) DisplayErrorMessage(’texscene was unable to set the pixel format! ); MakePalette(pf); SceneRC = wglCreateContext(SceneDC); wglMakeCurrent(SceneDC, SceneRC); /* * Load all the texture images into display lists */ LoadAllTextures(); break; case WM_SIZE : case WM_PAINT : /* * Repaint the client area with our bitmap */ BeginPaint(hWnd, &ps); GetClientRect(hWnd, &rect); RepaintWindow(&rect); EndPaint(hWnd, &ps); break; case WM_COMMAND : /* * Handle menu selections */ switch (LOWORD(wParam)) { case IDM_FILE_SAVEAS : SaveBitmapFile(); break; case IDM_FILE_PRINT : PrintBitmap(); break; case IDM_FILE_EXIT :
You want to have a cheap webhost for your apache application, then check apache web hosting services.
Posted in Coldfusion | No Comments »
January 2nd, 2008
Page 460 OpenGL Super Bible! for (i = 0; i < nColors; i ++) { pPal->palPalEntry[i].peRed = 255 * ((i >> pfd.cRedShift) & rmax) / rmax; pPal->palPalEntry[i].peGreen = 255 * ((i >> pfd.cGreenShift) & gmax) / gmax; pPal->palPalEntry[i].peBlue = 255 * ((i >> pfd.cBlueShift) & bmax) / bmax; pPal->palPalEntry[i].peFlags = 0; }; /* * Create, select, and realize the palette */ ScenePalette = CreatePalette(pPal); SelectPalette(SceneDC, ScenePalette, FALSE); RealizePalette(SceneDC); free(pPal); } /* * ‘SceneProc() - Handle window events in the viewing window. */ LRESULT CALLBACK SceneProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { int PIXELFORMATDESCRIPTOR PAINTSTRUCT RECT pf; pfd; ps; rect; /* I - Window triggering this event */ /* I - Message type */ /* I - ‘word parameter value */ /* I - ‘long parameter value */ /* Pixel format ID */ /* Pixel format information */ /* WM_PAINT message info */ /* Current client area rectangle */ switch (uMsg) { case WM_CREATE : /* * ‘Create’ message. Get device and rendering contexts, and * setup the client area for OpenGL drawing */ SceneDC = GetDC(hWnd); pfd.nSize = sizeof(pfd); pfd.nVersion = 1; pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER; /* Do OpenGL drawing */ pfd.dwLayerMask = PFD_MAIN_PLANE; /* Main drawing plane */ pfd.iPixelType = PFD_TYPE_RGBA; /* RGB color buffer */
Searching for affordable and reliable webhost to host and run your web applications? Go to our java web server services and you will be pleased.
Posted in Coldfusion | No Comments »
January 1st, 2008
OpenGL Super Bible! Page 459 MessageBeep(MB_ICONEXCLAMATION); MessageBox(NULL, s, ‘Error , MB_OK | MB_ICONEXCLAMATION); } /* * ‘MakePalette() - Make a color palette for RGB colors if necessary. */ void MakePalette(int pf) /* I - Pixel format ID */ { PIXELFORMATDESCRIPTOR pfd; /* Pixel format information */ LOGPALETTE *pPal; /* Pointer to logical palette */ int nColors; /* Number of entries in palette */ int i, /* Color index */ rmax, /* Maximum red value */ gmax, /* Maximum green va6lue */ bmax; /* Maximum blue value */ /* * Find out if we need to define a color palette */ DescribePixelFormat(SceneDC, pf, sizeof(PIXELFORMATDESCRIPTOR), &pfd); if (!(pfd.dwFlags & PFD_NEED_PALETTE)) { ScenePalette = NULL; return; }; /* * Allocate memory for a color palette */ nColors = 1 << pfd.cColorBits; pPal = (LOGPALETTE *)malloc(sizeof(LOGPALETTE) + nColors * sizeof(PALETTEENTRY)); pPal->palVersion = 0×300; pPal->palNumEntries = nColors; /* * Get the maximum values for red, green, and blue. Then build ‘nColors * colors */ rmax = (1 << pfd.cRedBits) - 1; gmax = (1 << pfd.cGreenBits) - 1; bmax = (1 << pfd.cBlueBits) - 1;
From our experience, we can recommend PHP Web Hosting services, if you need affordable webhost to host and run your web application.
Posted in Coldfusion | No Comments »
December 30th, 2007
Page 458 OpenGL Super Bible! TerrainWindow = CreateDialog(hInst, MAKEINTRESOURCE(IDD_TERRAIN_DIALOG), SceneWindow, (DLGPROC)TerrainDlgProc); /* * Loop on events until the user quits this application */ while (TRUE) { /* * Process all messages in the queue */ while (!Moving || PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE) == TRUE) if (GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } else return (1); /* * Handle flying as necessary */ GetCursorPos(&pos); FlyTerrain(pos.x, pos.y); }; return (msg.wParam); } /* * ‘DisplayErrorMessage() - Display an error message dialog. */ void DisplayErrorMessage(char *format, /* I - printf() style format string */ …) /* I - Other arguments as necessary */ { va_list ap; /* Argument pointer */ char s[1024]; /* Output string */ if (format == NULL) return; va_start(ap, format); vsprintf(s, format, ap); va_end(ap);
Visit our web design programs services for an affordable and reliable webhost to suit all your needs.
Posted in Coldfusion | No Comments »
December 29th, 2007
OpenGL Super Bible! Page 457 WNDCLASS wc; /* Window class */ POINT pos; /* Current mouse pos */ /* * Initialize the terrain to all grasslands */ InitializeTerrain(); /* * Register main window */ wc.style = 0; wc.lpfnWndProc = (WNDPROC)SceneProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInst; wc.hIcon = NULL; wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = 0; wc.lpszMenuName = MAKEINTRESOURCE(IDR_MENU1); wc.lpszClassName = ‘Textured Scene ; if (RegisterClass(&wc) == 0) { DisplayErrorMessage(’Unable to register window class! ); return (FALSE); }; /* * Then create it */ SceneWindow = CreateWindow(’Textured Scene , ‘Textured Scene , WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, 32, 32, 400, 300, NULL, NULL, hInst, NULL); if (SceneWindow == NULL) { DisplayErrorMessage(’Unable to create window! ); return (FALSE); }; ShowWindow(SceneWindow, nCmdShow); UpdateWindow(SceneWindow); /* * Load the bitmaps for the buttons, and then create the terrain * editing dialog. */ LoadAllBitmaps(hInst);
You need excellent and relaible webhost company to host your web applications? Then pay a visit to Inexpensive Web Hosting services.
Posted in Coldfusion | No Comments »
December 28th, 2007
Page 456 OpenGL Super Bible! TreesSelectBitmap, MountainsDownBitmap, MountainsUpBitmap, MountainsSelectBitmap; HWND TerrainWindow; /* Terrain dialog */ int TerrainCurrent = IDC_WATER; int TerrainType[TERRAIN_SIZE][TERRAIN_SIZE]; GLfloat TerrainHeight[TERRAIN_SIZE][TERRAIN_SIZE]; GLfloat TerrainNormal[TERRAIN_SIZE][TERRAIN_SIZE][3]; double MoveTime; /* Last update time */ GLboolean Moving = GL_FALSE, /* GL_TRUE if flying */ Drawing = GL_FALSE; /* GL_TRUE if drawing */ POINT CenterMouseXY; /* Initial mouse pos */ GLfloat Position[3] = { 0.0, TERRAIN_SCALE, 0.0 }; /* Viewer position */ GLfloat Heading = 0.0, /* Viewer heading */ Pitch = 0.0, /* Viewer pitch */ Roll = 0.0; /* Viewer roll */ /* * Local functions */ void DisplayErrorMessage(char *, ); void MakePalette(int); LRESULT CALLBACK SceneProc(HWND, UINT, WPARAM, LPARAM); UINT CALLBACK TerrainDlgProc(HWND, UINT, WPARAM, LPARAM); void InitializeTerrain(void); void LoadAllTextures(void); void LoadAllBitmaps(HINSTANCE); void DrawTerrain(int, int); void FlyTerrain(int, int); void RepaintWindow(RECT *); void SaveBitmapFile(void); void PrintBitmap(void); double GetClock(void); /* * ‘WinMain() - Main entry */ int APIENTRY WinMain(HINSTANCE hInst, /* I - Current process instance */ HINSTANCE hPrevInstance, /* I - Parent process instance */ LPSTR lpCmdLine, /* I - Command-line arguments */ int nCmdShow) /* I - Show window at startup? */ { MSG msg; /* Window UI event */
We recommend high quality webhost to host and run your jsp application: christian web host services.
Posted in Coldfusion | No Comments »
December 28th, 2007
OpenGL Super Bible! Page 455 Now here is Listing 12-5, the complete terrain viewing program, TEXSCENE.C. Listing 12-5 TEXSCENE.C: The terrain viewing program #include ‘texture.h #include ‘texscene.h #include #include
#ifndef M_PI # define M_PI (double)3.14159265358979323846 #endif /* !M_PI */ /* * Constants */ #define TERRAIN_SIZE 21 #define TERRAIN_EDGE ((TERRAIN_SIZE - 1) / 2) #define TERRAIN_SCALE (500.0 / TERRAIN_EDGE) #define GRASS_HEIGHT 0.0 #define WATER_HEIGHT 0.0 #define TREES_HEIGHT 0.0 #define ROCKS_HEIGHT 0.5 #define MOUNTAINS_HEIGHT 1.0 /* * Globals */ HWND SceneWindow; /* Scene window */ HPALETTE ScenePalette; /* Color palette (if necessary) */ HDC SceneDC; /* Drawing context */ HGLRC SceneRC; /* OpenGL rendering context */ GLuint SkyTexture, /* Sky texture image */ GrassTexture, /* Grass */ RocksTexture, /* Rock */ WaterTexture, /* Water */ TreesTexture, /* Trees */ MountainsTexture; /* Mountains */ HBITMAP GrassDownBitmap, /* Grass button down image */ GrassUpBitmap, /* Grass button up image */ GrassSelectBitmap, /* Grass button selected image */ RocksDownBitmap, /* */ RocksUpBitmap, RocksSelectBitmap, WaterDownBitmap, WaterUpBitmap, WaterSelectBitmap, TreesDownBitmap, TreesUpBitmap,
Please visit Domain Name Hosting services for high quality webhost to host and run your jsp applications.
Posted in Coldfusion | No Comments »
December 27th, 2007
Page 454 OpenGL Super Bible! Summary In this chapter you ve learned how to texture-map images onto polygons and other primitives using OpenGL. Texturing can provide that extra measure of realism that makes computer graphics so exciting to work with. The OpenGL glTexParameter functions provide many ways to improve the quality of texture images when they are drawn. Mipmapped texture images provide multiple levels of detail that improve rendering quality and speed. Linear interpolation of texture images can improve certain types of textures, such as the sky texture used in the example project. The glTexGen functions can simplify generation of texture coordinates by removing unnecessary or tedious calculations. By removing large amounts of conditional glTexCoord calls, automatic coordinate generation also simplifies programs that must display both textured and nontextured scenes For games and other interactive, animated displays, you may want to support both textured and nontextured displays until accelerated OpenGL graphics boards become more widely available.
Visit our web design programs services for an affordable and reliable webhost to suit all your needs.
Posted in Coldfusion | No Comments »
December 25th, 2007
OpenGL Super Bible! Page 453 void glTexGeniv(GLenum coord, GLenum pname, GLint *params) where the coord parameter specifies which texture image coordinate to generate, GL_S or GL_T, and the pname parameter specifies the vector to define; in this case GL_OBJECT_PLANE. Finally, the params array specifies the object plane vector that is used to compute the texture coordinate. The previous code for our terrain would generate these coordinates: S = 2 * X T = 2 * Z To make OpenGL use these generated coordinates, you must enable texture coordinate generation, as follows: glEnable(GL_TEXTURE_GEN_S); glEnable(GL_TEXTURE_GEN_T); The file TEXSCENE.C contains a version of our terrain viewing program that uses generated texture coordinates. The same techniques can be used with a 1D texture image. For the 1D image, you d probably generate the S coordinate from the height (Y) to color the terrain based upon the height of the terrain. Generating texture coordinates is usually faster than specifying them manually in immediate mode, but is slower when using display lists. Flying Through the Terrain When the user is flying through the terrain, we need to regulate the flying speed based on the update rate of our scene. Rather than trying to maintain a fixed update rate which can vary depending on the graphics card and CPU being used we will measure the elapsed time from the last update to the current time. The FlyTerrain function manages this by measuring the time in milliseconds between each call, and moving the viewer forward at a fixed speed relative to the elapsed time.
Please visit Domain Name Hosting services for high quality webhost to host and run your jsp applications.
Posted in Coldfusion | No Comments »
December 24th, 2007
Page 452 OpenGL Super Bible! Figure 12-6 The terrain-drawing algorithm As you can see, this algorithm won t track the terrain exactly, but it is fast and simple to implement. It scans the terrain from left to right and from bottom to top, and starts a new GL_QUAD_STRIP primitive whenever the terrain type changes. Along the way it assigns lighting normals and texture coordinates for each point on the terrain. Automatically Generating Texture Coordinates Generating all those texture coordinates can be tedious. Fortunately, OpenGL has an answer that we can use! In the current drawing code, we issue glTexCoord2i calls glTexCoord2i(x * 2, y * 2); for each and every point in the terrain. But instead of doing this for each point, we can use the glTexGen functions to define the S and T coordinates in terms of the X and Z position in the scene (Y is used for the height). To generate coordinates for our terrain, then, we can use the following: static GLint s_vector[4] = { 2, 0, 0, 0 }; static GLint t_vector[4] = { 0, 0, 2, 0 }; glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); glTexGeniv(GL_S, GL_OBJECT_PLANE, s_vector); glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); glTexGeniv(GL_T, GL_OBJECT_PLANE, t_vector); Here the GL_OBJECT_LINEAR mapping mode maps the texture coordinates from object coordinates: coordinate = X * vector[0] + Y * vector[1] + Z * vector[2] + W * vector[3] The vector array is specified with glTexGen function:
From our experience, we are can tell you that you can find a reliable and cheap webhost service at Java Web Hosting services.
Posted in Coldfusion | No Comments »