static void Init_WGL_ARB_extensions(_THIS) { HWND hwnd; HDC hdc; HGLRC hglrc; int pformat; const char * (WINAPI *wglGetExtensionsStringARB)(HDC) = 0; const char *extensions; hwnd = CreateWindow(SDL_Appname, SDL_Appname, WS_POPUP | WS_DISABLED, 0, 0, 10, 10, NULL, NULL, SDL_Instance, NULL); WIN_FlushMessageQueue(); hdc = GetDC(hwnd); pformat = ChoosePixelFormat(hdc, &GL_pfd); SetPixelFormat(hdc, pformat, &GL_pfd); hglrc = this->gl_data->wglCreateContext(hdc); if ( hglrc ) { this->gl_data->wglMakeCurrent(hdc, hglrc); } wglGetExtensionsStringARB = (const char * (WINAPI *)(HDC)) this->gl_data->wglGetProcAddress("wglGetExtensionsStringARB"); if( wglGetExtensionsStringARB ) { extensions = wglGetExtensionsStringARB(hdc); } else { extensions = NULL; } this->gl_data->WGL_ARB_pixel_format = 0; if( ExtensionSupported("WGL_ARB_pixel_format", extensions) ) { this->gl_data->wglChoosePixelFormatARB = (BOOL (WINAPI *)(HDC, const int *, const FLOAT *, UINT, int *, UINT *)) this->gl_data->wglGetProcAddress("wglChoosePixelFormatARB"); this->gl_data->wglGetPixelFormatAttribivARB = (BOOL (WINAPI *)(HDC, int, int, UINT, const int *, int *)) this->gl_data->wglGetProcAddress("wglGetPixelFormatAttribivARB"); if( (this->gl_data->wglChoosePixelFormatARB != NULL) && (this->gl_data->wglGetPixelFormatAttribivARB != NULL) ) { this->gl_data->WGL_ARB_pixel_format = 1; } } if ( hglrc ) { this->gl_data->wglMakeCurrent(NULL, NULL); this->gl_data->wglDeleteContext(hglrc); } ReleaseDC(hwnd, hdc); DestroyWindow(hwnd); WIN_FlushMessageQueue(); }
static int ChoosePixelFormatARB(_THIS, const int *iAttribs, const FLOAT *fAttribs) { HWND hwnd; HDC hdc; HGLRC hglrc; const char * (WINAPI *wglGetExtensionsStringARB)(HDC) = 0; const char *extensions; int pformat = 0; UINT matches = 0; hwnd = CreateWindow(SDL_Appname, SDL_Appname, WS_POPUP | WS_DISABLED, 0, 0, 10, 10, NULL, NULL, SDL_Instance, NULL); WIN_FlushMessageQueue(); hdc = GetDC(hwnd); SetPixelFormat(hdc, ChoosePixelFormat(hdc, &GL_pfd), &GL_pfd); hglrc = this->gl_data->wglCreateContext(hdc); if ( hglrc ) { this->gl_data->wglMakeCurrent(hdc, hglrc); } wglGetExtensionsStringARB = (const char * (WINAPI *)(HDC)) this->gl_data->wglGetProcAddress("wglGetExtensionsStringARB"); if( wglGetExtensionsStringARB ) { extensions = wglGetExtensionsStringARB(hdc); } else { extensions = NULL; } this->gl_data->WGL_ARB_pixel_format = 0; if( ExtensionSupported("WGL_ARB_pixel_format", extensions) ) { BOOL (WINAPI *wglChoosePixelFormatARB)(HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); wglChoosePixelFormatARB = (BOOL (WINAPI *)(HDC, const int *, const FLOAT *, UINT, int *, UINT *)) this->gl_data->wglGetProcAddress("wglChoosePixelFormatARB"); if( wglChoosePixelFormatARB && wglChoosePixelFormatARB(hdc, iAttribs, fAttribs, 1, &pformat, &matches) && pformat ) { this->gl_data->WGL_ARB_pixel_format = 1; } } if ( hglrc ) { this->gl_data->wglMakeCurrent(NULL, NULL); this->gl_data->wglDeleteContext(hglrc); } ReleaseDC(hwnd, hdc); DestroyWindow(hwnd); WIN_FlushMessageQueue(); return pformat; }
bool EnableGLExtensions() { const char* Extensions = (const char*)glGetString(GL_EXTENSIONS); if(ExtensionSupported(Extensions, "WGL_EXT_swap_control")) { wglSwapIntervalEXT = (PFNWGLSWAPINTERVALPROC)wglGetProcAddress("wglSwapIntervalEXT"); wglGetSwapIntervalEXT = (PFNWGLGETSWAPINTERVALPROC)wglGetProcAddress("wglGetSwapIntervalEXT"); } return true; }
void glWindow::InitMultitexture () { if (ExtensionSupported ("GL_ARB_multitexture")) { glMultiTexCoord2f = (PFNGLMULTITEXCOORD2FARBPROC) wglGetProcAddress ("glMultiTexCoord2fARB"); glMultiTexCoord2d = (PFNGLMULTITEXCOORD2DARBPROC) wglGetProcAddress ("glMultiTexCoord2dARB"); glActiveTexture = (PFNGLACTIVETEXTUREARBPROC) wglGetProcAddress ("glActiveTextureARB"); } else { glMultiTexCoord2f = NULL; glMultiTexCoord2d = NULL; glActiveTexture = NULL; } }
/* Make the current context active */ int X11_GL_MakeCurrent(_THIS) { int retval; retval = 0; if ( ! this->gl_data->glXMakeCurrent(GFX_Display, SDL_Window, glx_context) ) { SDL_SetError("Unable to make GL context current"); retval = -1; } XSync( GFX_Display, False ); /* * The context is now current, check for glXReleaseBuffersMESA() * extension. If extension is _not_ supported, destroy the pointer * (to make sure it will not be called in X11_GL_Shutdown() ). * * DRI/Mesa drivers include glXReleaseBuffersMESA() in the libGL.so, * but there's no need to call it (is is only needed for some old * non-DRI drivers). * * When using for example glew (http://glew.sf.net), dlsym() for * glXReleaseBuffersMESA() returns the pointer from the glew library * (namespace conflict). * * The glXReleaseBuffersMESA() pointer in the glew is NULL, if the * driver doesn't support this extension. So blindly calling it will * cause segfault with DRI/Mesa drivers! * */ if ( ! ExtensionSupported("glXReleaseBuffersMESA") ) { this->gl_data->glXReleaseBuffersMESA = NULL; } /* More Voodoo X server workarounds... Grr... */ SDL_Lock_EventThread(); X11_CheckDGAMouse(this); SDL_Unlock_EventThread(); return(retval); }
bool Renderer_OpenGL::Initialize_Windows(const RenderInitParameter& init_param) { if (m_hWnd == nullptr) { MASSERT_MSG(0, "Need a hwnd to initialize openGL"); return false; } // fill out PIXELFORMATDESCRIPTOR PIXELFORMATDESCRIPTOR pfd; memset(&pfd, 0, sizeof(PIXELFORMATDESCRIPTOR)); pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR); pfd.nVersion = 1; pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER; pfd.iPixelType = PFD_TYPE_RGBA; pfd.cColorBits = MG_IMG_FMT_SIZE[init_param.rt_format]; pfd.cDepthBits = 24; pfd.cStencilBits = 8; pfd.iLayerType = PFD_MAIN_PLANE; // create simple context CreateSimpleContext_Windows(init_param, &pfd); // initialize glad if (!gladLoadGL()) { MASSERT_MSG(0, "Failed initialize glad"); return false; } // create proper context if (!CreateProperContext_Windows(init_param, &pfd)) { return false; } // verify swap interval support if (!ExtensionSupported("WGL_EXT_swap_control")) { MASSERT_MSG(0, "Can't find WGL_EXT_swap_control in GL Extension supported"); return false; } wglSwapIntervalEXT = (void*)wglGetProcAddress("wglSwapIntervalEXT"); if (wglSwapIntervalEXT == nullptr) { MASSERT_MSG(0, "Don't support wglSwapIntervalEXT"); return false; } // set vsync if (init_param.vsync) { ((PFNWGLSWAPINTERVALEXTPROC)wglSwapIntervalEXT)(1); } else { ((PFNWGLSWAPINTERVALEXTPROC)wglSwapIntervalEXT)(0); } return true; }
void QGL_InitExtensions() { int i, j; extInfo_t *ext; const char *ext1, *ext2; guard(QGL_InitExtensions); #if 0 // init cvars for controlling extensions for (i = 0, ext = extInfo; i < NUM_EXTENSIONS; i++, ext++) if (ext->cvar) Cvar_Get(ext->cvar, "1", CVAR_ARCHIVE); #endif gl_config.extensionMask = 0; unsigned notFoundExt = 0; gl_config.disabledExt = gl_config.ignoredExt = 0; gl_config.extensions = ext1 = (char*)glGetString(GL_EXTENSIONS); const char *ver = (const char*)glGetString(GL_VERSION); float glVersion = atof(ver); // appPrintf("GL version: %f\n", glVersion); ext2 = NULL; #if _WIN32 && !USE_SDL //?? from wglext.h -- later, when use this header, remove line typedef const char * (WINAPI * PFNWGLGETEXTENSIONSSTRINGARBPROC) (HDC hdc); PFNWGLGETEXTENSIONSSTRINGARBPROC wglGetExtensionsStringARB = (PFNWGLGETEXTENSIONSSTRINGARBPROC)wglGetProcAddress("wglGetExtensionsStringARB"); if (wglGetExtensionsStringARB) ext2 = wglGetExtensionsStringARB(gl_hDC); #endif gl_config.extensions2 = ext2; #if NUM_EXTENSIONS for (i = 0, ext = extInfo; i < NUM_EXTENSIONS; i++, ext++) { bool enable = false; if (ext->names[0] >= '0' && ext->names[0] <= '9') { float extVersion = atof(ext->names); enable = (glVersion >= extVersion-0.0001f); // FP precision fix ... ext->name = ext->names; } else if (ExtensionSupported(ext, ext1, ext2)) { // if (!ext->cvar || Cvar_VariableInt(ext->cvar)) { enable = true; // if (gl_config.bugExt & (1 << i)) // enable = false; } /* else { gl_config.disabledExt |= 1 << i; } */ } else notFoundExt |= 1 << i; if (enable) { gl_config.extensionMask |= 1 << i; for (j = ext->first; j < ext->first + ext->count; j++) { dummyFunc_t func; #if USE_SDL func = (dummyFunc_t) SDL_GL_GetProcAddress(GLNames[j]); #elif _WIN32 func = (dummyFunc_t) (wglGetProcAddress(GLNames[j])); #else libGL.GetProc(GLNames[j], &func); #endif GlFunc(GL, j) = GlFunc(lib, j) = func; if (!func) { appWPrintf("Inconsistent extension %s: function %s is not found\n", ext->name, GLNames[j]); enable = false; break; } } } // (theoretically) can get "enable == false" in previous block if (!enable) { gl_config.extensionMask &= ~(1 << i); for (j = ext->first; j < ext->first + ext->count; j++) GlFunc(GL, j) = NULL; } } /*-------------- check requirements -------------*/ for (i = 0, ext = extInfo; i < NUM_EXTENSIONS; i++, ext++) { if (!(gl_config.extensionMask & (1 << i))) continue; if ((gl_config.extensionMask & ext->require) != ext->require) { if (gl_config.disabledExt & ext->require) // require disabled extension gl_config.disabledExt |= 1 << i; // mark this extension as disabled too else { unsigned tmp = (gl_config.extensionMask ^ ext->require) & ext->require; // display error for (j = 0; j < NUM_EXTENSIONS; j++) { if ((1 << j) & tmp) appWPrintf("%s required for %s\n", extInfo[j].names, ext->name); } // // disable extension // gl_config.ignoredExt |= 1 << i; } gl_config.extensionMask &= ~(1 << i); } } /*-------- choose preferred extensions ----------*/ if (gl_config.extensionMask) { // appPrintf("...used extensions:\n"); for (i = 0, ext = extInfo; i < NUM_EXTENSIONS; i++, ext++) { if (!(gl_config.extensionMask & (1 << i))) continue; unsigned tmp = gl_config.extensionMask & ext->deprecate; if (tmp) { // display error for (j = 0; j < NUM_EXTENSIONS; j++) { if ((1 << j) & tmp) Com_DPrintf(" %s ignored in favor of %s\n", ext->name, extInfo[j].name); } // disable extension gl_config.extensionMask &= ~(1 << i); gl_config.ignoredExt |= 1 << i; } // else // appPrintf(" %s\n", ext->name); } } // else // appWPrintf("...no extensions was found\n"); #if 0 /*---------- notify disabled extensions ---------*/ if (gl_config.disabledExt) { appPrintf(S_CYAN"...disabled extensions:\n"); for (i = 0, ext = extInfo; i < NUM_EXTENSIONS; i++, ext++) if (gl_config.disabledExt & (1 << i)) appPrintf(S_CYAN" %s\n", ext->name); } /*----------- notify extension absence ----------*/ if (notFoundExt) { appPrintf("...missing extensions:\n"); for (i = 0, ext = extInfo; i < NUM_EXTENSIONS; i++, ext++) { if (!(notFoundExt & (1 << i))) continue; unsigned tmp = gl_config.extensionMask & ext->deprecate; if (tmp) { // display error for (j = 0; j < NUM_EXTENSIONS; j++) { if ((1 << j) & tmp) { Com_DPrintf(" %s is covered by %s\n", ext->name, extInfo[j].name); break; // ignore other exteensions } } } else appPrintf(" %s\n", ext->name); } appPrintf("\n"); } #endif #endif // NUM_EXTENSIONS #if !NO_GL_LOG GL = logFuncs; //!! LOGGING #endif unguard; }
bool glWindow::ResetGL () { if (m_resetGLMode == RGM_RECREATEWINDOW) { RecreateWindow (m_fullScreen, m_border, m_width, m_height, m_bpp, m_stencil, m_title, m_allowResizing, m_fitToWorkArea); return true; } else if (m_resetGLMode == RGM_RECREATECONTEXT) { RecreateGLContext (); return true; } // Setup OpenGL defaults. // This should reset as much as possible back to the initial state of OpenGL. // Exceptions: // * Projection matrix is initialised to a perspective transform // End current gl block try { glEnd (); } catch (...) { ; } m_dontPaint = false; // Intialise matrices try { glMatrixMode (GL_PROJECTION); ClearGLMatrix (); } catch (...) { ; } try { glMatrixMode (GL_TEXTURE); ClearGLMatrix (); } catch (...) { ; } try { glMatrixMode (GL_MODELVIEW); ClearGLMatrix (); } catch (...) { ; } // Initialise state int i; try { glColor4f (1, 1, 1, 1); } catch (...) { ; } try { glIndexi (1); } catch (...) { ; } try { glTexCoord4f (0, 0, 0, 1); } catch (...) { ; } try { glNormal3f (0, 0, 1); } catch (...) { ; } // try { glRasterPos4f (0, 0, 0, 1); } catch (...) { ; } try { glEdgeFlag (GL_TRUE); } catch (...) { ; } try { glDisable (GL_VERTEX_ARRAY); } catch (...) { ; } try { glDisable (GL_NORMAL_ARRAY); } catch (...) { ; } try { glDisable (GL_COLOR_ARRAY); } catch (...) { ; } try { glDisable (GL_INDEX_ARRAY); } catch (...) { ; } try { glDisable (GL_TEXTURE_COORD_ARRAY); } catch (...) { ; } try { glDisable (GL_EDGE_FLAG_ARRAY); } catch (...) { ; } try { glDepthRange (0, 1); } catch (...) { ; } try { glDisable (GL_NORMALIZE); } catch (...) { ; } for (i = 0; i < GL_MAX_CLIP_PLANES; i++) try { glDisable (GL_CLIP_PLANE0 + i); } catch (...) { ; } GLfloat fog[] = {0, 0, 0, 0}; try { glFogfv (GL_FOG_COLOR, fog); } catch (...) { ; } try { glFogi (GL_FOG_INDEX, 0); } catch (...) { ; } try { glFogf (GL_FOG_DENSITY, 1.0); } catch (...) { ; } try { glFogf (GL_FOG_START, 0.0); } catch (...) { ; } try { glFogf (GL_FOG_END, 1.0); } catch (...) { ; } try { glFogi (GL_FOG_MODE, GL_EXP); } catch (...) { ; } try { glDisable (GL_FOG); } catch (...) { ; } try { glShadeModel (GL_SMOOTH); } catch (...) { ; } try { glDisable (GL_LIGHTING); } catch (...) { ; } try { glDisable (GL_COLOR_MATERIAL); } catch (...) { ; } try { glColorMaterial (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE); } catch (...) { ; } GLfloat ambient[] = { 0.2, 0.2, 0.2, 1.0 }, diffuse[] = { 0.8, 0.8, 0.8, 1.0 }, specular[] = { 0.0, 0.0, 0.0, 1.0 }, emission[] = { 0.0, 0.0, 0.0, 1.0 }, shininess[] = { 0.0 }; try { glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT, ambient); } catch (...) { ; } try { glMaterialfv (GL_FRONT_AND_BACK, GL_DIFFUSE, diffuse); } catch (...) { ; } try { glMaterialfv (GL_FRONT_AND_BACK, GL_SPECULAR, specular); } catch (...) { ; } try { glMaterialfv (GL_FRONT_AND_BACK, GL_EMISSION, emission); } catch (...) { ; } try { glMaterialfv (GL_FRONT_AND_BACK, GL_SHININESS, shininess); } catch (...) { ; } try { glLightModelfv (GL_LIGHT_MODEL_AMBIENT, ambient); } catch (...) { ; } try { glLightModeli (GL_LIGHT_MODEL_LOCAL_VIEWER, GL_FALSE); } catch (...) { ; } try { glLightModeli (GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE); } catch (...) { ; } GLfloat lambient[] = { 0.0, 0.0, 0.0, 1.0 }, ldiffuse0[] = { 1.0, 1.0, 1.0, 1.0 }, ldiffuse1[] = { 0.0, 0.0, 0.0, 1.0 }, lspecular0[] = { 1.0, 1.0, 1.0, 1.0 }, lspecular1[] = { 0.0, 0.0, 0.0, 1.0 }, lposition[] = { 0.0, 0.0, 1.0, 0.0 }; for (i = 0; i < 8; i++) { try { glLightfv (GL_LIGHT0 + i, GL_AMBIENT, lambient); } catch (...) { ; } try { glLightfv (GL_LIGHT0 + i, GL_DIFFUSE, i == 0 ? ldiffuse0 : ldiffuse1); } catch (...) { ; } try { glLightfv (GL_LIGHT0 + i, GL_SPECULAR, i == 0 ? lspecular0 : lspecular1); } catch (...) { ; } try { glLightfv (GL_LIGHT0 + i, GL_POSITION, lposition); } catch (...) { ; } try { glLightf (GL_LIGHT0 + i, GL_SPOT_EXPONENT, 0.0); } catch (...) { ; } try { glLightf (GL_LIGHT0 + i, GL_CONSTANT_ATTENUATION, 1.0); } catch (...) { ; } try { glLightf (GL_LIGHT0 + i, GL_LINEAR_ATTENUATION, 0.0); } catch (...) { ; } try { glLightf (GL_LIGHT0 + i, GL_QUADRATIC_ATTENUATION, 0.0); } catch (...) { ; } try { glDisable (GL_LIGHT0 + i); } catch (...) { ; } } try { glPointSize (1.0); } catch (...) { ; } try { glDisable (GL_POINT_SMOOTH); } catch (...) { ; } try { glLineWidth (1.0); } catch (...) { ; } try { glDisable (GL_LINE_SMOOTH); } catch (...) { ; } try { glLineStipple (1, 0xffff); } catch (...) { ; } try { glDisable (GL_LINE_STIPPLE); } catch (...) { ; } try { glDisable (GL_CULL_FACE); } catch (...) { ; } try { glCullFace (GL_BACK); } catch (...) { ; } try { glFrontFace (GL_CCW); } catch (...) { ; } try { glDisable (GL_POLYGON_SMOOTH); } catch (...) { ; } try { glPolygonMode (GL_FRONT_AND_BACK, GL_FILL); } catch (...) { ; } try { glDisable (GL_TEXTURE_1D); } catch (...) { ; } try { glDisable (GL_TEXTURE_2D); } catch (...) { ; } try { glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST); } catch (...) { ; } try { glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); } catch (...) { ; } try { glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); } catch (...) { ; } try { glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); } catch (...) { ; } GLfloat texBorder[] = {0, 0, 0, 0}; try { glTexParameterfv (GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, texBorder); } catch (...) { ; } try { glDisable (GL_TEXTURE_GEN_T); } catch (...) { ; } try { glDisable (GL_TEXTURE_GEN_S); } catch (...) { ; } try { glDisable (GL_TEXTURE_GEN_R); } catch (...) { ; } try { glDisable (GL_TEXTURE_GEN_Q); } catch (...) { ; } for (i = 0; i < 4; i++) { GLenum coord; switch (i) { case 0: coord = GL_T; break; case 1: coord = GL_S; break; case 2: coord = GL_R; break; case 3: coord = GL_Q; break; } try { glTexGeni (coord, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR); } catch (...) { ; } } try { glDisable (GL_SCISSOR_TEST); } catch (...) { ; } try { glDisable (GL_ALPHA_TEST); } catch (...) { ; } try { glAlphaFunc (GL_ALWAYS, 0); } catch (...) { ; } try { glDisable (GL_STENCIL_TEST); } catch (...) { ; } try { glStencilFunc (GL_ALWAYS, 0, 0xffffffff); } catch (...) { ; } try { glStencilOp (GL_KEEP, GL_KEEP, GL_KEEP); } catch (...) { ; } try { glDisable (GL_DEPTH_TEST); } catch (...) { ; } try { glDepthFunc (GL_LESS); } catch (...) { ; } try { glDisable (GL_BLEND); } catch (...) { ; } try { glBlendFunc (GL_ONE, GL_ZERO); } catch (...) { ; } try { glDrawBuffer (GL_BACK); } catch (...) { ; } try { glColorMask (GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); } catch (...) { ; } try { glDepthMask (GL_TRUE); } catch (...) { ; } try { glClearAccum (0, 0, 0, 0); } catch (...) { ; } try { glClearColor (0, 0, 0, 0); } catch (...) { ; } try { glClearDepth (1); } catch (...) { ; } try { glClearIndex (0); } catch (...) { ; } try { glClearStencil (0); } catch (...) { ; } try { glPixelStorei (GL_PACK_SWAP_BYTES, GL_FALSE); } catch (...) { ; } try { glPixelStorei (GL_PACK_LSB_FIRST, GL_FALSE); } catch (...) { ; } try { glPixelStoref (GL_PACK_ROW_LENGTH, 0); } catch (...) { ; } try { glPixelStoref (GL_PACK_SKIP_PIXELS, 0); } catch (...) { ; } try { glPixelStorei (GL_PACK_ALIGNMENT, 4); } catch (...) { ; } try { glPixelStorei (GL_UNPACK_SWAP_BYTES, GL_FALSE); } catch (...) { ; } try { glPixelStorei (GL_UNPACK_LSB_FIRST, GL_FALSE); } catch (...) { ; } try { glPixelStoref (GL_UNPACK_ROW_LENGTH, 0); } catch (...) { ; } try { glPixelStoref (GL_UNPACK_SKIP_PIXELS, 0); } catch (...) { ; } try { glPixelStorei (GL_UNPACK_ALIGNMENT, 4); } catch (...) { ; } try { glPixelTransferi (GL_MAP_COLOR, GL_FALSE); } catch (...) { ; } try { glPixelTransferi (GL_MAP_STENCIL, GL_FALSE); } catch (...) { ; } try { glPixelTransferi (GL_INDEX_SHIFT, 0); } catch (...) { ; } try { glPixelTransferi (GL_INDEX_OFFSET, 0); } catch (...) { ; } try { glPixelTransferf (GL_RED_SCALE, 1.0); } catch (...) { ; } try { glPixelTransferf (GL_GREEN_SCALE, 1.0); } catch (...) { ; } try { glPixelTransferf (GL_BLUE_SCALE, 1.0); } catch (...) { ; } try { glPixelTransferf (GL_ALPHA_SCALE, 1.0); } catch (...) { ; } try { glPixelTransferf (GL_DEPTH_SCALE, 1.0); } catch (...) { ; } try { glPixelTransferf (GL_RED_BIAS, 0.0); } catch (...) { ; } try { glPixelTransferf (GL_GREEN_BIAS, 0.0); } catch (...) { ; } try { glPixelTransferf (GL_BLUE_BIAS, 0.0); } catch (...) { ; } try { glPixelTransferf (GL_ALPHA_BIAS, 0.0); } catch (...) { ; } try { glPixelTransferf (GL_DEPTH_BIAS, 0.0); } catch (...) { ; } try { glHint (GL_PERSPECTIVE_CORRECTION_HINT, GL_DONT_CARE); } catch (...) { ; } try { glHint (GL_POINT_SMOOTH_HINT, GL_DONT_CARE); } catch (...) { ; } try { glHint (GL_LINE_SMOOTH_HINT, GL_DONT_CARE); } catch (...) { ; } try { glHint (GL_POLYGON_SMOOTH_HINT, GL_DONT_CARE); } catch (...) { ; } try { glHint (GL_FOG_HINT, GL_DONT_CARE); } catch (...) { ; } // Multitexturing if (ExtensionSupported ("GL_ARB_multitexture")) { // Disable texturing for all texture units int units; try { glGetIntegerv (GL_MAX_TEXTURE_UNITS_ARB, &units); } catch (...) { ; } for (int i = 0; i < units; i++) { if (glActiveTexture != NULL) glActiveTexture (GL_TEXTURE0_ARB + i); try { glDisable (GL_TEXTURE_2D); } catch (...) { ; } try { glDisable (GL_TEXTURE_1D); } catch (...) { ; } if (i == 0) try { glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); } catch (...) { ; } else try { glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_BLEND); } catch (...) { ; } } if (glActiveTexture != NULL) try { glActiveTexture (GL_TEXTURE0_ARB); } catch (...) { ; } } // Setup OpenGL defaults OpenGLDefaults (); return TRUE; // Initialization Went OK }