Search
lxdream.org :: lxdream/src/drivers/video_glx.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/drivers/video_glx.c
changeset 736:a02d1475ccfd
prev703:585c66692be7
next805:b355f7b3ff2e
author nkeynes
date Sun Jul 20 11:37:47 2008 +0000 (15 years ago)
permissions -rw-r--r--
last change Commit testta changes for sort-dma tests
file annotate diff log raw
1.1 --- a/src/drivers/video_glx.c Sun Jun 22 21:27:28 2008 +0000
1.2 +++ b/src/drivers/video_glx.c Sun Jul 20 11:37:47 2008 +0000
1.3 @@ -58,7 +58,7 @@
1.4 * @return TRUE if supported, otherwise FALSE.
1.5 */
1.6 gboolean isServerGLXExtensionSupported( Display *display, int screen,
1.7 - const char *extension )
1.8 + const char *extension )
1.9 {
1.10 const char *extensions = NULL;
1.11 const char *start;
1.12 @@ -67,18 +67,18 @@
1.13 /* Extension names should not have spaces. */
1.14 where = strchr(extension, ' ');
1.15 if (where || *extension == '\0')
1.16 - return 0;
1.17 + return 0;
1.18 extensions = glXQueryServerString(display, screen, GLX_EXTENSIONS);
1.19 start = extensions;
1.20 for (;;) {
1.21 - where = strstr((const char *) start, extension);
1.22 - if (!where)
1.23 - break;
1.24 - terminator = where + strlen(extension);
1.25 - if (where == start || *(where - 1) == ' ')
1.26 - if (*terminator == ' ' || *terminator == '\0')
1.27 - return TRUE;
1.28 - start = terminator;
1.29 + where = strstr((const char *) start, extension);
1.30 + if (!where)
1.31 + break;
1.32 + terminator = where + strlen(extension);
1.33 + if (where == start || *(where - 1) == ' ')
1.34 + if (*terminator == ' ' || *terminator == '\0')
1.35 + return TRUE;
1.36 + start = terminator;
1.37 }
1.38 return FALSE;
1.39 }
1.40 @@ -95,45 +95,45 @@
1.41 if( result != False ) {
1.42 glx_version = (major*100) + minor;
1.43 }
1.44 -
1.45 +
1.46 glx_fbconfig_supported = (glx_version >= 103 ||
1.47 - isServerGLXExtensionSupported(display, screen,
1.48 - "GLX_SGIX_fbconfig") );
1.49 + isServerGLXExtensionSupported(display, screen,
1.50 + "GLX_SGIX_fbconfig") );
1.51 glx_pbuffer_supported = (glx_version >= 103 ||
1.52 - isServerGLXExtensionSupported(display, screen,
1.53 - "GLX_SGIX_pbuffer") );
1.54 + isServerGLXExtensionSupported(display, screen,
1.55 + "GLX_SGIX_pbuffer") );
1.56 if( glx_fbconfig_supported ) {
1.57 - int nelem;
1.58 + int nelem;
1.59 int fb_attribs[] = { GLX_DRAWABLE_TYPE,
1.60 - GLX_PBUFFER_BIT|GLX_WINDOW_BIT,
1.61 - GLX_RENDER_TYPE, GLX_RGBA_BIT,
1.62 - GLX_DEPTH_SIZE, 24, 0 };
1.63 - GLXFBConfig *configs = glXChooseFBConfig( display, screen,
1.64 - fb_attribs, &nelem );
1.65 + GLX_PBUFFER_BIT|GLX_WINDOW_BIT,
1.66 + GLX_RENDER_TYPE, GLX_RGBA_BIT,
1.67 + GLX_DEPTH_SIZE, 24, 0 };
1.68 + GLXFBConfig *configs = glXChooseFBConfig( display, screen,
1.69 + fb_attribs, &nelem );
1.70
1.71 - if( configs == NULL || nelem == 0 ) {
1.72 - /* Try a 16-bit depth buffer and see if it helps */
1.73 - fb_attribs[5] = 16;
1.74 - configs = glXChooseFBConfig( display, screen, fb_attribs, &nelem );
1.75 - if( nelem > 0 ) {
1.76 + if( configs == NULL || nelem == 0 ) {
1.77 + /* Try a 16-bit depth buffer and see if it helps */
1.78 + fb_attribs[5] = 16;
1.79 + configs = glXChooseFBConfig( display, screen, fb_attribs, &nelem );
1.80 + if( nelem > 0 ) {
1.81 WARN( "Using a 16-bit depth buffer - expect video glitches" );
1.82 }
1.83
1.84 }
1.85 if( configs == NULL || nelem == 0 ) {
1.86 - /* Still didn't work. Fallback to 1.2 methods */
1.87 - glx_fbconfig_supported = FALSE;
1.88 - glx_pbuffer_supported = FALSE;
1.89 - } else {
1.90 - glx_fbconfig = configs[0];
1.91 - glx_visual = glXGetVisualFromFBConfig(display, glx_fbconfig);
1.92 - XFree(configs);
1.93 - }
1.94 + /* Still didn't work. Fallback to 1.2 methods */
1.95 + glx_fbconfig_supported = FALSE;
1.96 + glx_pbuffer_supported = FALSE;
1.97 + } else {
1.98 + glx_fbconfig = configs[0];
1.99 + glx_visual = glXGetVisualFromFBConfig(display, glx_fbconfig);
1.100 + XFree(configs);
1.101 + }
1.102 }
1.103
1.104 if( !glx_fbconfig_supported ) {
1.105 int attribs[] = { GLX_RGBA, GLX_DEPTH_SIZE, 24, 0 };
1.106 - glx_visual = glXChooseVisual( display, screen, attribs );
1.107 + glx_visual = glXChooseVisual( display, screen, attribs );
1.108 if( glx_visual == NULL ) {
1.109 /* Try the 16-bit fallback here too */
1.110 attribs[2] = 16;
1.111 @@ -156,34 +156,34 @@
1.112 {
1.113 if( glx_fbconfig_supported ) {
1.114 glx_context = glXCreateNewContext( display, glx_fbconfig,
1.115 - GLX_RGBA_TYPE, NULL, True );
1.116 - if( glx_context == NULL ) {
1.117 - ERROR( "Unable to create a GLX Context.");
1.118 - return FALSE;
1.119 - }
1.120 + GLX_RGBA_TYPE, NULL, True );
1.121 + if( glx_context == NULL ) {
1.122 + ERROR( "Unable to create a GLX Context.");
1.123 + return FALSE;
1.124 + }
1.125
1.126 - if( glXMakeContextCurrent( display, window, window,
1.127 - glx_context ) == False ) {
1.128 - ERROR( "Unable to prepare GLX context for drawing" );
1.129 - glXDestroyContext( display, glx_context );
1.130 - return FALSE;
1.131 - }
1.132 + if( glXMakeContextCurrent( display, window, window,
1.133 + glx_context ) == False ) {
1.134 + ERROR( "Unable to prepare GLX context for drawing" );
1.135 + glXDestroyContext( display, glx_context );
1.136 + return FALSE;
1.137 + }
1.138 } else {
1.139 glx_context = glXCreateContext( display, glx_visual, None, True );
1.140 - if( glx_context == NULL ) {
1.141 - ERROR( "Unable to create a GLX Context.");
1.142 - return FALSE;
1.143 - }
1.144 -
1.145 - if( glXMakeCurrent( display, window, glx_context ) == False ) {
1.146 - ERROR( "Unable to prepare GLX context for drawing" );
1.147 - glXDestroyContext( display, glx_context );
1.148 - return FALSE;
1.149 - }
1.150 + if( glx_context == NULL ) {
1.151 + ERROR( "Unable to create a GLX Context.");
1.152 + return FALSE;
1.153 + }
1.154 +
1.155 + if( glXMakeCurrent( display, window, glx_context ) == False ) {
1.156 + ERROR( "Unable to prepare GLX context for drawing" );
1.157 + glXDestroyContext( display, glx_context );
1.158 + return FALSE;
1.159 + }
1.160 }
1.161
1.162 if( !glXIsDirect(display, glx_context) ) {
1.163 - WARN( "Not using direct rendering - this is likely to be slow" );
1.164 + WARN( "Not using direct rendering - this is likely to be slow" );
1.165 }
1.166
1.167 video_x11_display = display;
1.168 @@ -195,13 +195,13 @@
1.169 gboolean video_glx_init_driver( display_driver_t driver )
1.170 {
1.171 if( gl_fbo_is_supported() ) { // First preference
1.172 - gl_fbo_init(driver);
1.173 + gl_fbo_init(driver);
1.174 } else if( glx_pbuffer_supported ) {
1.175 - glx_pbuffer_init(driver);
1.176 + glx_pbuffer_init(driver);
1.177 } else {
1.178 ERROR( "Unable to create render buffers (requires either EXT_framebuffer_object or GLX 1.3+)" );
1.179 video_glx_shutdown();
1.180 - return FALSE;
1.181 + return FALSE;
1.182 }
1.183 return TRUE;
1.184 }
1.185 @@ -209,15 +209,15 @@
1.186
1.187 void video_glx_shutdown()
1.188 {
1.189 - // texcache_gl_shutdown();
1.190 + // texcache_gl_shutdown();
1.191 glx_is_initialized = FALSE;
1.192 if( glx_context != NULL ) {
1.193 glXDestroyContext( video_x11_display, glx_context );
1.194 - glx_context = NULL;
1.195 + glx_context = NULL;
1.196 }
1.197 if( glx_visual != NULL ) {
1.198 XFree(glx_visual);
1.199 - glx_visual = NULL;
1.200 + glx_visual = NULL;
1.201 }
1.202 }
1.203
1.204 @@ -233,8 +233,8 @@
1.205 int lists;
1.206 XFontStruct *font = XLoadQueryFont(video_x11_display, font_name );
1.207 if (font == NULL)
1.208 - return -1;
1.209 -
1.210 + return -1;
1.211 +
1.212 lists = glGenLists(96);
1.213 glXUseXFont(font->fid, 32, 96, lists);
1.214 XFreeFont(video_x11_display, font);
1.215 @@ -279,11 +279,11 @@
1.216 static render_buffer_t glx_pbuffer_create_render_buffer( uint32_t width, uint32_t height )
1.217 {
1.218 int attribs[] = { GLX_PBUFFER_WIDTH, width, GLX_PBUFFER_HEIGHT, height,
1.219 - GLX_PRESERVED_CONTENTS, True, 0 };
1.220 + GLX_PRESERVED_CONTENTS, True, 0 };
1.221 GLXPbuffer pb = glXCreatePbuffer( video_x11_display, glx_fbconfig, attribs );
1.222 if( pb == (GLXPbuffer)NULL ) {
1.223 - ERROR( "Unable to create pbuffer" );
1.224 - return NULL;
1.225 + ERROR( "Unable to create pbuffer" );
1.226 + return NULL;
1.227 }
1.228 render_buffer_t buffer = calloc( sizeof(struct render_buffer), 1 );
1.229 buffer->width = width;
1.230 @@ -303,12 +303,12 @@
1.231 {
1.232 glFinish();
1.233 if( glXMakeContextCurrent( video_x11_display, (GLXPbuffer)buffer->buf_id, (GLXPbuffer)buffer->buf_id, glx_context ) == False ) {
1.234 - ERROR( "Make context current (pbuffer) failed!" );
1.235 + ERROR( "Make context current (pbuffer) failed!" );
1.236 }
1.237 /* setup the gl context */
1.238 glViewport( 0, 0, buffer->width, buffer->height );
1.239 glDrawBuffer(GL_FRONT);
1.240 -
1.241 +
1.242 return TRUE;
1.243 }
1.244
1.245 @@ -336,7 +336,7 @@
1.246 GLenum format = colour_formats[frame->colour_format].format;
1.247 int bpp = colour_formats[frame->colour_format].bpp;
1.248 int rowstride = (frame->rowstride / bpp) - frame->width;
1.249 -
1.250 +
1.251 gl_reset_state();
1.252 glPixelStorei( GL_UNPACK_ROW_LENGTH, rowstride );
1.253 glRasterPos2f(0.375, frame->height-0.375);
1.254 @@ -353,7 +353,7 @@
1.255 }
1.256
1.257 static gboolean glx_pbuffer_read_render_buffer( unsigned char *target, render_buffer_t buffer,
1.258 - int rowstride, int format )
1.259 + int rowstride, int format )
1.260 {
1.261 glXMakeCurrent( video_x11_display, (GLXDrawable)buffer->buf_id, glx_context );
1.262 glReadBuffer( GL_FRONT );
.