/* ** GLimp_EndFrame */ void GLimp_EndFrame (void) { // // swapinterval stuff // if ( r_swapInterval->modified ) { r_swapInterval->modified = qfalse; if ( !glConfig.stereoEnabled ) { // why? if ( qwglSwapIntervalEXT ) { qwglSwapIntervalEXT( r_swapInterval->integer ); } } } // don't flip if drawing to front buffer if ( Q_stricmp( r_drawBuffer->string, "GL_FRONT" ) != 0 ) { if ( glConfig.driverType > GLDRV_ICD ) { if ( !qwglSwapBuffers( glw_state.hDC ) ) { ri.Error( ERR_FATAL, "GLimp_EndFrame() - SwapBuffers() failed!\n" ); } } else { SwapBuffers( glw_state.hDC ); } } // check logging QGL_EnableLogging( r_logFile->integer ); }
/* ** GLimp_EndFrame */ void GLimp_EndFrame (void) { // // swapinterval stuff // if ( r_swapInterval->modified ) { r_swapInterval->modified = qfalse; if ( !glConfig.stereoEnabled ) { // why? if ( qwglSwapIntervalEXT ) { qwglSwapIntervalEXT( r_swapInterval->integer ); } } } // don't flip if drawing to front buffer if ( Q_stricmp( r_drawBuffer->string, "GL_FRONT" ) != 0 ) { SwapBuffers( glw_state.hDC ); } // check logging QGL_EnableLogging( (qboolean)r_logFile->integer ); }
/* ** GLimp_EndFrame ** ** Responsible for doing a swapbuffers and possibly for other stuff ** as yet to be determined. Probably better not to make this a GLimp ** function and instead do a call to GLimp_SwapBuffers. */ void GLimp_EndFrame( void ) { // don't flip if drawing to front buffer if ( Q_stricmp( r_drawBuffer->string, "GL_FRONT" ) != 0 ) { qglXSwapBuffers( dpy, win ); } // check logging QGL_EnableLogging( (qboolean)r_logFile->integer ); // bk001205 - was ->value }
/* ** GLimp_EndFrame */ void GLimp_EndFrame (void) { if (!androidSwapped) eglSwapBuffers( eglGetCurrentDisplay(), eglGetCurrentSurface( EGL_DRAW ) ); androidSwapped = false; // check logging QGL_EnableLogging( r_logFile->integer ); }
/* ** GLimp_EndFrame ** ** Responsible for doing a swapbuffers and possibly for other stuff ** as yet to be determined. Probably better not to make this a GLimp ** function and instead do a call to GLimp_SwapBuffers. */ void GLimp_EndFrame( void ) { // don't flip if drawing to front buffer #ifdef HAVE_GLES eglSwapBuffers(g_EGLDisplay, g_EGLWindowSurface); #else if ( Q_stricmp( r_drawBuffer->string, "GL_FRONT" ) != 0 ) { qglXSwapBuffers( dpy, win ); } // check logging QGL_EnableLogging( (qboolean)r_logFile->integer ); // bk001205 - was ->value #endif }
/* ** GLimp_EndFrame ** ** Responsible for doing a swapbuffers and possibly for other stuff ** as yet to be determined. Probably better not to make this a GLimp ** function and instead do a call to GLimp_SwapBuffers. */ void GLimp_EndFrame (void) { // don't flip if drawing to front buffer if ( Q_stricmp( r_drawBuffer->string, "GL_FRONT" ) != 0 ) { SDL_GL_SwapBuffers(); } if( r_fullscreen->modified ) { qboolean fullscreen; qboolean sdlToggled = qfalse; SDL_Surface *s = SDL_GetVideoSurface( ); if( s ) { // Find out the current state if( s->flags & SDL_FULLSCREEN ) fullscreen = qtrue; else fullscreen = qfalse; // Is the state we want different from the current state? if( !!r_fullscreen->integer != fullscreen ) sdlToggled = SDL_WM_ToggleFullScreen( s ); else sdlToggled = qtrue; } // SDL_WM_ToggleFullScreen didn't work, so do it the slow way if( !sdlToggled ) Cbuf_AddText( "vid_restart" ); r_fullscreen->modified = qfalse; } // check logging QGL_EnableLogging( (qboolean)r_logFile->integer ); // bk001205 - was ->value }
/* ** GLimp_EndFrame ** ** Responsible for doing a swapbuffers and possibly for other stuff ** as yet to be determined. Probably better not to make this a GLimp ** function and instead do a call to GLimp_SwapBuffers. */ void GLimp_EndFrame (void) { #if 0 int err; if ( !glState.finishCalled ) qglFinish(); // check for errors if ( !gl_ignore_errors->value ) { if ( ( err = qglGetError() ) != GL_NO_ERROR ) { ri.Error( ERR_FATAL, "GLimp_EndFrame() - glGetError() failed (0x%x)!\n", err ); } } #endif // don't flip if drawing to front buffer if ( stricmp( r_drawBuffer->string, "GL_FRONT" ) != 0 ) { qglXSwapBuffers(dpy, win); } // check logging QGL_EnableLogging( r_logFile->value ); #if 0 GLimp_LogComment( "*** RE_EndFrame ***\n" ); // decrement log if ( gl_log->value ) { ri.Cvar_Set( "gl_log", va("%i",gl_log->value - 1 ) ); } #endif }
// This is responsible for binding our qgl function pointers to the // appropriate GL stuff. void QGL_Init() { common->Printf( "...initializing QGL\n" ); #define GLF_0( r, n ) qgl ## n = gl ## n; #define GLF_V0( n ) qgl ## n = gl ## n; #define GLF_1( r, n, t1, p1 ) qgl ## n = gl ## n; #define GLF_V1( n, t1, p1 ) qgl ## n = gl ## n; #define GLF_V2( n, t1, p1, t2, p2 ) qgl ## n = gl ## n; #define GLF_3( r, n, t1, p1, t2, p2, t3, p3 ) qgl ## n = gl ## n; #define GLF_V3( n, t1, p1, t2, p2, t3, p3 ) qgl ## n = gl ## n; #define GLF_V4( n, t1, p1, t2, p2, t3, p3, t4, p4 ) qgl ## n = gl ## n; #define GLF_V5( n, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5 ) qgl ## n = gl ## n; #define GLF_V6( n, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5, t6, p6 ) qgl ## n = gl ## n; #define GLF_V7( n, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5, t6, p6, t7, p7 ) qgl ## n = gl ## n; #define GLF_V8( n, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5, t6, p6, t7, p7, t8, p8 ) qgl ## n = gl ## n; #define GLF_V9( n, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5, t6, p6, t7, p7, t8, p8, t9, p9 ) qgl ## n = gl ## n; #define GLF_V10( n, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5, t6, p6, t7, p7, t8, p8, t9, p9, t10, p10 ) qgl ## n = gl ## n; #include "qgl_functions.h" #undef GLF_0 #undef GLF_V0 #undef GLF_1 #undef GLF_V1 #undef GLF_V2 #undef GLF_3 #undef GLF_V3 #undef GLF_V4 #undef GLF_V5 #undef GLF_V6 #undef GLF_V7 #undef GLF_V8 #undef GLF_V9 #undef GLF_V10 qglActiveTextureARB = NULL; qglClientActiveTextureARB = NULL; qglMultiTexCoord2fARB = NULL; qglLockArraysEXT = NULL; qglUnlockArraysEXT = NULL; qglPointParameterfEXT = NULL; qglPointParameterfvEXT = NULL; qglPNTrianglesiATI = NULL; qglPNTrianglesfATI = NULL; #ifdef _WIN32 qwglSwapIntervalEXT = NULL; #else qglXSwapIntervalSGI = NULL; #endif common->Printf( "Initializing OpenGL extensions\n" ); // GL_S3_s3tc glConfig.textureCompression = TC_NONE; if ( CheckExtension( "GL_EXT_texture_compression_s3tc" ) ) { if ( r_ext_compressed_textures->integer ) { glConfig.textureCompression = TC_EXT_COMP_S3TC; common->Printf( "...using GL_EXT_texture_compression_s3tc\n" ); } else { glConfig.textureCompression = TC_NONE; common->Printf( "...ignoring GL_EXT_texture_compression_s3tc\n" ); } } else if ( CheckExtension( "GL_S3_s3tc" ) ) { if ( r_ext_compressed_textures->integer ) { glConfig.textureCompression = TC_S3TC; common->Printf( "...using GL_S3_s3tc\n" ); } else { glConfig.textureCompression = TC_NONE; common->Printf( "...ignoring GL_S3_s3tc\n" ); } } else { common->Printf( "...GL_S3_s3tc not found\n" ); } // GL_ARB_multitexture if ( CheckExtension( "GL_ARB_multitexture" ) ) { if ( r_ext_multitexture->integer ) { qglMultiTexCoord2fARB = ( void ( APIENTRY* )( GLenum target, GLfloat s, GLfloat t ) )GLimp_GetProcAddress( "glMultiTexCoord2fARB" ); qglActiveTextureARB = ( void ( APIENTRY* )( GLenum target ) )GLimp_GetProcAddress( "glActiveTextureARB" ); qglClientActiveTextureARB = ( void ( APIENTRY* )( GLenum target ) )GLimp_GetProcAddress( "glClientActiveTextureARB" ); if ( qglActiveTextureARB ) { qglGetIntegerv( GL_MAX_TEXTURE_UNITS_ARB, &glConfig.maxActiveTextures ); if ( glConfig.maxActiveTextures > 1 ) { common->Printf( "...using GL_ARB_multitexture\n" ); } else { qglMultiTexCoord2fARB = NULL; qglActiveTextureARB = NULL; qglClientActiveTextureARB = NULL; common->Printf( "...not using GL_ARB_multitexture, < 2 texture units\n" ); } } } else { common->Printf( "...ignoring GL_ARB_multitexture\n" ); } } else { common->Printf( "...GL_ARB_multitexture not found\n" ); } // GL_EXT_texture_env_add glConfig.textureEnvAddAvailable = false; if ( CheckExtension( "GL_EXT_texture_env_add" ) ) { if ( r_ext_texture_env_add->integer ) { glConfig.textureEnvAddAvailable = true; common->Printf( "...using GL_EXT_texture_env_add\n" ); } else { glConfig.textureEnvAddAvailable = false; common->Printf( "...ignoring GL_EXT_texture_env_add\n" ); } } else { common->Printf( "...GL_EXT_texture_env_add not found\n" ); } #ifdef _WIN32 // WGL_EXT_swap_control if ( CheckExtension( "WGL_EXT_swap_control" ) ) { if ( r_ext_gamma_control->integer ) { qwglSwapIntervalEXT = ( BOOL ( WINAPI* )( int ) )GLimp_GetProcAddress( "wglSwapIntervalEXT" ); if ( qwglSwapIntervalEXT ) { common->Printf( "...using WGL_EXT_swap_control\n" ); r_swapInterval->modified = true; // force a set next frame } else { common->Printf( "...WGL_EXT_swap_control not found\n" ); } } else { common->Printf( "...ignoring WGL_EXT_swap_control\n" ); } } else { common->Printf( "...WGL_EXT_swap_control not found\n" ); } #else // GLX_SGI_swap_control if ( CheckSystemExtension( "GLX_SGI_swap_control" ) ) { qglXSwapIntervalSGI = ( int ( * )( int interval ) )GLimp_GetProcAddress( "glXSwapIntervalSGI" ); common->Printf( "...using GLX_SGI_swap_control\n" ); } else { common->Printf( "... GLX_SGI_swap_control not found\n" ); } #endif // GL_EXT_compiled_vertex_array if ( CheckExtension( "GL_EXT_compiled_vertex_array" ) ) { if ( r_ext_compiled_vertex_array->integer ) { common->Printf( "...using GL_EXT_compiled_vertex_array\n" ); qglLockArraysEXT = ( void ( APIENTRY* )( int, int ) )GLimp_GetProcAddress( "glLockArraysEXT" ); qglUnlockArraysEXT = ( void ( APIENTRY* )() )GLimp_GetProcAddress( "glUnlockArraysEXT" ); if ( !qglLockArraysEXT || !qglUnlockArraysEXT ) { common->FatalError( "bad getprocaddress" ); } } else { common->Printf( "...ignoring GL_EXT_compiled_vertex_array\n" ); } } else { common->Printf( "...GL_EXT_compiled_vertex_array not found\n" ); } if ( CheckExtension( "GL_EXT_point_parameters" ) ) { if ( r_ext_point_parameters->integer ) { common->Printf( "...using GL_EXT_point_parameters\n" ); qglPointParameterfEXT = ( void ( APIENTRY* )( GLenum, GLfloat ) )GLimp_GetProcAddress( "glPointParameterfEXT" ); qglPointParameterfvEXT = ( void ( APIENTRY* )( GLenum, const GLfloat* ) )GLimp_GetProcAddress( "glPointParameterfvEXT" ); if ( !qglPointParameterfEXT || !qglPointParameterfvEXT ) { common->FatalError( "bad getprocaddress" ); } } else { common->Printf( "...ignoring GL_EXT_point_parameters\n" ); } } else { common->Printf( "...GL_EXT_point_parameters not found\n" ); } // GL_NV_fog_distance glConfig.NVFogAvailable = false; glConfig.NVFogMode = 0; if ( CheckExtension( "GL_NV_fog_distance" ) ) { if ( r_ext_NV_fog_dist->integer ) { glConfig.NVFogAvailable = true; common->Printf( "...using GL_NV_fog_distance\n" ); } else { common->Printf( "...ignoring GL_NV_fog_distance\n" ); } } else { common->Printf( "...GL_NV_fog_distance not found\n" ); } // GL_EXT_texture_filter_anisotropic if ( CheckExtension( "GL_EXT_texture_filter_anisotropic" ) ) { if ( r_ext_texture_filter_anisotropic->integer ) { glConfig.anisotropicAvailable = true; common->Printf( "...using GL_EXT_texture_filter_anisotropic\n" ); } else { common->Printf( "...ignoring GL_EXT_texture_filter_anisotropic\n" ); } } else { common->Printf( "... GL_EXT_texture_filter_anisotropic not found\n" ); } // GL_ATI_pn_triangles - ATI PN-Triangles if ( CheckExtension( "GL_ATI_pn_triangles" ) ) { if ( r_ext_ATI_pntriangles->integer ) { common->Printf( "...using GL_ATI_pn_triangles\n" ); qglPNTrianglesiATI = ( PFNGLPNTRIANGLESIATIPROC )GLimp_GetProcAddress( "glPNTrianglesiATI" ); qglPNTrianglesfATI = ( PFNGLPNTRIANGLESFATIPROC )GLimp_GetProcAddress( "glPNTrianglesfATI" ); if ( !qglPNTrianglesiATI || !qglPNTrianglesfATI ) { common->FatalError( "bad getprocaddress 0" ); } } else { common->Printf( "...ignoring GL_ATI_pn_triangles\n" ); } } else { common->Printf( "...GL_ATI_pn_triangles not found\n" ); } // check logging QGL_EnableLogging( !!r_logFile->integer ); }
// *INDENT-OFF* int QGL_Init() { ri.Printf(PRINT_ALL, "...initializing QGL\n"); if(GLimp_sdl_init_video() == qfalse) return qfalse; qglBindTexture = dllBindTexture = GPA( "glBindTexture" ); qglBlendFunc = dllBlendFunc = GPA( "glBlendFunc" ); qglClear = dllClear = GPA( "glClear" ); qglClearColor = dllClearColor = GPA( "glClearColor" ); qglClearDepth = dllClearDepth = GPA( "glClearDepth" ); qglClearStencil = dllClearStencil = GPA( "glClearStencil" ); qglColorMask = dllColorMask = GPA( "glColorMask" ); qglCopyPixels = dllCopyPixels = GPA( "glCopyPixels" ); qglCopyTexImage1D = dllCopyTexImage1D = GPA( "glCopyTexImage1D" ); qglCopyTexImage2D = dllCopyTexImage2D = GPA( "glCopyTexImage2D" ); qglCopyTexSubImage1D = dllCopyTexSubImage1D = GPA( "glCopyTexSubImage1D" ); qglCopyTexSubImage2D = dllCopyTexSubImage2D = GPA( "glCopyTexSubImage2D" ); qglCullFace = dllCullFace = GPA( "glCullFace" ); qglDeleteTextures = dllDeleteTextures = GPA( "glDeleteTextures" ); qglDepthFunc = dllDepthFunc = GPA( "glDepthFunc" ); qglDepthMask = dllDepthMask = GPA( "glDepthMask" ); qglDepthRange = dllDepthRange = GPA( "glDepthRange" ); qglDisable = dllDisable = GPA( "glDisable" ); qglDrawArrays = dllDrawArrays = GPA( "glDrawArrays" ); qglDrawBuffer = dllDrawBuffer = GPA( "glDrawBuffer" ); qglDrawElements = dllDrawElements = GPA( "glDrawElements" ); qglEnable = dllEnable = GPA( "glEnable" ); qglFinish = dllFinish = GPA( "glFinish" ); qglFlush = dllFlush = GPA( "glFlush" ); qglFrontFace = dllFrontFace = GPA( "glFrontFace" ); qglGenTextures = dllGenTextures = GPA( "glGenTextures" ); qglGetBooleanv = dllGetBooleanv = GPA( "glGetBooleanv" ); qglGetError = dllGetError = GPA( "glGetError" ); qglGetFloatv = dllGetFloatv = GPA( "glGetFloatv" ); qglGetIntegerv = dllGetIntegerv = GPA( "glGetIntegerv" ); qglGetString = dllGetString = GPA( "glGetString" ); qglGetTexParameterfv = dllGetTexParameterfv = GPA( "glGetTexParameterfv" ); qglGetTexParameteriv = dllGetTexParameteriv = GPA( "glGetTexParameteriv" ); qglHint = dllHint = GPA( "glHint" ); qglIsEnabled = dllIsEnabled = GPA( "glIsEnabled" ); qglIsTexture = dllIsTexture = GPA( "glIsTexture" ); qglLineWidth = dllLineWidth = GPA( "glLineWidth" ); qglPolygonMode = dllPolygonMode = GPA( "glPolygonMode" ); qglPolygonOffset = dllPolygonOffset = GPA( "glPolygonOffset" ); qglReadPixels = dllReadPixels = GPA( "glReadPixels" ); qglScissor = dllScissor = GPA( "glScissor" ); qglStencilFunc = dllStencilFunc = GPA( "glStencilFunc" ); qglStencilMask = dllStencilMask = GPA( "glStencilMask" ); qglStencilOp = dllStencilOp = GPA( "glStencilOp" ); qglTexImage1D = dllTexImage1D = GPA( "glTexImage1D" ); qglTexImage2D = dllTexImage2D = GPA( "glTexImage2D" ); qglTexParameterf = dllTexParameterf = GPA( "glTexParameterf" ); qglTexParameterfv = dllTexParameterfv = GPA( "glTexParameterfv" ); qglTexParameteri = dllTexParameteri = GPA( "glTexParameteri" ); qglTexParameteriv = dllTexParameteriv = GPA( "glTexParameteriv" ); qglTexSubImage1D = dllTexSubImage1D = GPA( "glTexSubImage1D" ); qglTexSubImage2D = dllTexSubImage2D = GPA( "glTexSubImage2D" ); qglViewport = dllViewport = GPA( "glViewport" ); // check logging QGL_EnableLogging(r_logFile->integer); return qtrue; }