OpenGL Super Bible! Page 423 Interestingly enough, the
OpenGL Super Bible! Page 423 Interestingly enough, the Windows StretchBlt function can display bitmap images faster than glDrawPixels. Of course, StretchBlt cannot perform the glPixelMap and glPixelTransfer functions, though. The final code for the RepaintWindow function is in Listing 11-12. Listing 11-12 RepaintWindow function void RepaintWindow(RECT *rect) /* I - Client area rectangle */ { GLint xoffset, /* X offset of image */ yoffset; /* Y offset of image */ GLint xsize, /* X size of scaled image */ ysize; /* Y size of scaled image */ GLfloat xscale, /* Scaling in X direction */ yscale; /* Scaling in Y direction */ /* * Reset the viewport and clear the window to white */ glViewport(0, 0, rect- >right, rect->bottom); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0.0, rect->right - 1.0, 0.0, rect->bottom - 1.0, -1.0, 1.0); glMatrixMode(GL_MODELVIEW); glClearColor(1.0, 1.0, 1.0, 1.0); glClear(GL_COLOR_BUFFER_BIT); /* * If we have loaded a bitmap image, scale it to fit the window */ if (BitmapBits != NULL) { xsize = rect->right; ysize = BitmapInfo->bmiHeader.biHeight * xsize / BitmapInfo->bmiHeader.biWidth; if (ysize > rect->bottom) { ysize = rect->bottom; xsize = BitmapInfo->bmiHeader.biWidth * ysize / BitmapInfo->bmiHeader.biHeight; }; xscale = (float)xsize / (float)BitmapInfo->bmiHeader.biWidth; yscale = (float)ysize / (float)BitmapInfo->bmiHeader.biHeight; xoffset = (rect->right - xsize) * 0.5; yoffset = (rect->bottom - ysize) * 0.5;
We recommend cheap and reliable webhost to host and run your web applications: Coldfusion Web Hosting services.