Init.cpp
上传用户:sz83729876
上传日期:2013-03-07
资源大小:4140k
文件大小:5k
- ///////////////////////////////// SET UP PIXEL FORMAT \\\\\\\\\\\\\\\\*
- /////
- ///// This function sets the pixel format for OpenGL.
- /////
- ///////////////////////////////// SET UP PIXEL FORMAT \\\\\\\\\\\\\\\\*
- #include "main.h"
- #include "core.h"
- bool gribSetupPixelFormat(HDC hdc)
- {
- PIXELFORMATDESCRIPTOR pfd;
- int pixelformat;
-
- pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR); // Set the size of the structure
- pfd.nVersion = 1; // Always set this to 1
- // Pass in the appropriate OpenGL flags
- pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
- pfd.dwLayerMask = PFD_MAIN_PLANE; // We want the standard mask (this is ignored anyway)
- pfd.iPixelType = PFD_TYPE_RGBA; // We want RGB and Alpha pixel type
- pfd.cColorBits = ScreenDeph; // Here we use our #define for the color bits
- pfd.cDepthBits = ScreenDeph; // Depthbits is ignored for RGBA, but we do it anyway
- pfd.cAccumBits = 0; // No special bitplanes needed
- pfd.cStencilBits = 0; // We desire no stencil bits
-
- // This gets us a pixel format that best matches the one passed in from the device
- if ( (pixelformat = ChoosePixelFormat(hdc, &pfd)) == FALSE )
- {
- MessageBox(NULL, "ChoosePixelFormat failed", "Error", MB_OK);
- return FALSE;
- }
-
- // This sets the pixel format that we extracted from above
- if (SetPixelFormat(hdc, pixelformat, &pfd) == FALSE)
- {
- MessageBox(NULL, "SetPixelFormat failed", "Error", MB_OK);
- return FALSE;
- }
-
- return TRUE; // Return a success!
- }
- //////////////////////////// RESIZE OPENGL SCREEN \\\\\\\\\\\\\\\\*
- /////
- ///// This function resizes the viewport for OpenGL.
- /////
- //////////////////////////// RESIZE OPENGL SCREEN \\\\\\\\\\\\\\\\*
- void griSizeOpenGLScreen(int width, int height) // Initialize The GL Window
- {
- if (height==0) // Prevent A Divide By Zero error
- {
- height=1; // Make the Height Equal One
- }
- // glEnable(GL_DEPTH_TEST);
-
- glEnable(GL_TEXTURE_2D); // 朽琊屮屙桢 磬腩驽龛