revision 1251:b8ab59d39756
summary |
tree |
shortlog |
changelog |
graph |
changeset |
raw | bz2 | zip | gz changeset | 1251:b8ab59d39756 |
parent | 1250:204dae47ab7a |
child | 1252:2fb29172ee79 |
author | nkeynes |
date | Sat Mar 03 16:11:28 2012 +1000 (12 years ago) |
Support depth component 16 as well as 24 (add capability flag for the available bits)
Put remaining TODOs inside HAVE_OPENGL_FIXEDFUNC blocks
Add swap-buffer calls for EGL (does not appear to support rendering directly
to front-buffer)
Put remaining TODOs inside HAVE_OPENGL_FIXEDFUNC blocks
Add swap-buffer calls for EGL (does not appear to support rendering directly
to front-buffer)
1.1 --- a/src/display.h Sat Mar 03 16:08:48 2012 +10001.2 +++ b/src/display.h Sat Mar 03 16:11:28 2012 +10001.3 @@ -110,6 +110,7 @@1.5 struct display_capabilities {1.6 gboolean has_gl;1.7 + int depth_bits;1.8 int stencil_bits; /* 0 = no stencil buffer */1.9 };
2.1 --- a/src/drivers/gl_fbo.c Sat Mar 03 16:08:48 2012 +10002.2 +++ b/src/drivers/gl_fbo.c Sat Mar 03 16:11:28 2012 +10002.3 @@ -59,6 +59,7 @@2.4 };2.6 static GLint gl_fbo_max_attachments = 0;2.7 +static GLint gl_fbo_depth_component;2.8 static gboolean gl_fbo_have_packed_stencil = FALSE;2.9 static struct gl_fbo_info fbo[MAX_FRAMEBUFFERS];2.11 @@ -103,6 +104,11 @@2.12 gl_fbo_have_packed_stencil = FALSE;2.13 WARN( "Packed depth stencil not available - disabling shadow volumes" );2.14 }2.15 + if( driver->capabilities.depth_bits >= 24 ) {2.16 + gl_fbo_depth_component = GL_DEPTH_COMPONENT24;2.17 + } else {2.18 + gl_fbo_depth_component = GL_DEPTH_COMPONENT16;2.19 + }2.21 driver->create_render_buffer = gl_fbo_create_render_buffer;2.22 driver->destroy_render_buffer = gl_fbo_destroy_render_buffer;2.23 @@ -151,7 +157,7 @@2.24 GL_RENDERBUFFER, fbo[bufno].depth_id);2.25 } else {2.26 glBindRenderbuffer(GL_RENDERBUFFER, fbo[bufno].depth_id);2.27 - glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT24, width, height);2.28 + glRenderbufferStorage(GL_RENDERBUFFER, gl_fbo_depth_component, width, height);2.29 glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,2.30 GL_RENDERBUFFER, fbo[bufno].depth_id);2.31 /* In theory you could attach a separate stencil buffer. In practice this2.32 @@ -331,6 +337,8 @@2.33 {2.34 gl_fbo_detach();2.35 gl_display_render_buffer( buffer );2.36 + if( display_driver->swap_buffers )2.37 + display_driver->swap_buffers();2.38 }2.40 static void gl_fbo_load_frame_buffer( frame_buffer_t frame, render_buffer_t buffer )2.41 @@ -343,6 +351,8 @@2.42 {2.43 gl_fbo_detach();2.44 gl_display_blank( colour );2.45 + if( display_driver->swap_buffers )2.46 + display_driver->swap_buffers();2.47 }2.49 void gl_fbo_detach()2.50 @@ -353,8 +363,6 @@2.51 glDrawBuffer( GL_FRONT );2.52 glReadBuffer( GL_FRONT );2.53 #endif2.54 - if( display_driver->swap_buffers )2.55 - display_driver->swap_buffers();2.56 }2.58 static gboolean gl_fbo_read_render_buffer( unsigned char *target, render_buffer_t buffer,
3.1 --- a/src/drivers/video_egl.c Sat Mar 03 16:08:48 2012 +10003.2 +++ b/src/drivers/video_egl.c Sat Mar 03 16:11:28 2012 +10003.3 @@ -122,7 +122,8 @@3.4 }3.6 if( gl_fbo_is_supported() ) {3.7 - display_gl_driver.capabilities.has_gl = TRUE;3.8 + display_egl_driver.capabilities.has_gl = TRUE;3.9 + display_egl_driver.capabilities.depth_bits = 16; /* TODO: get from config info */3.10 gl_fbo_init(&display_egl_driver);3.11 gl_vbo_init(&display_egl_driver);3.12 fbo_created = TRUE;3.13 @@ -131,6 +132,7 @@3.14 video_egl_clear_window();3.15 return FALSE;3.16 }3.17 + gl_set_video_size(width, height, 0);3.18 pvr2_setup_gl_context();3.19 INFO( "Initialised EGL %d.%d\n", major, minor );3.20 return TRUE;3.21 @@ -154,6 +156,10 @@3.22 eglTerminate(display);3.23 }3.25 +static void video_egl_swap_buffers()3.26 +{3.27 + eglSwapBuffers(display, surface);3.28 +}3.31 /**3.32 @@ -164,5 +170,5 @@3.33 NULL, NULL, NULL,3.34 NULL, NULL, NULL, NULL,3.35 gl_load_frame_buffer, gl_display_render_buffer, gl_display_blank,3.36 - NULL, gl_read_render_buffer, NULL, NULL3.37 + video_egl_swap_buffers, gl_read_render_buffer, NULL, NULL3.38 };
4.1 --- a/src/drivers/video_gl.c Sat Mar 03 16:08:48 2012 +10004.2 +++ b/src/drivers/video_gl.c Sat Mar 03 16:11:28 2012 +10004.3 @@ -44,12 +44,18 @@4.4 struct video_vertex invert_view[4];4.5 } video_box;4.7 -void gl_set_video_size( uint32_t width, uint32_t height )4.8 +void gl_set_video_size( uint32_t width, uint32_t height, int flipped )4.9 {4.10 video_width = width;4.11 video_height = height;4.13 int x1=0,y1=0,x2=video_width,y2=video_height;4.14 + int top = 0, bottom = 1;4.15 +4.16 + if( flipped ) {4.17 + top = 1;4.18 + bottom = 0;4.19 + }4.21 int ah = video_width * 0.75;4.23 @@ -80,17 +86,17 @@4.24 }4.26 video_box.video_view[0].x = x1; video_box.video_view[0].y = y1;4.27 - video_box.video_view[0].u = 0; video_box.video_view[0].v = 0;4.28 + video_box.video_view[0].u = top; video_box.video_view[0].v = top;4.29 video_box.video_view[1].x = x2; video_box.video_view[1].y = y1;4.30 - video_box.video_view[1].u = 1; video_box.video_view[1].v = 0;4.31 + video_box.video_view[1].u = bottom; video_box.video_view[1].v = top;4.32 video_box.video_view[2].x = x1; video_box.video_view[2].y = y2;4.33 - video_box.video_view[2].u = 0; video_box.video_view[2].v = 1;4.34 + video_box.video_view[2].u = top; video_box.video_view[2].v = bottom;4.35 video_box.video_view[3].x = x2; video_box.video_view[3].y = y2;4.36 - video_box.video_view[3].u = 1; video_box.video_view[3].v = 1;4.37 + video_box.video_view[3].u = bottom; video_box.video_view[3].v = bottom;4.39 memcpy( &video_box.invert_view, &video_box.video_view, sizeof(video_box.video_view) );4.40 - video_box.invert_view[0].v = 1; video_box.invert_view[1].v = 1;4.41 - video_box.invert_view[2].v = 0; video_box.invert_view[3].v = 0;4.42 + video_box.invert_view[0].v = bottom; video_box.invert_view[1].v = bottom;4.43 + video_box.invert_view[2].v = top; video_box.invert_view[3].v = top;4.45 defineOrthoMatrix(video_box.viewMatrix, video_width, video_height, 0, 65535);4.46 }4.47 @@ -175,6 +181,7 @@4.48 {4.49 /* Set video box tex alpha to 1 */4.50 video_box.video_view[0].a = video_box.video_view[1].a = video_box.video_view[2].a = video_box.video_view[3].a = 1;4.51 + video_box.invert_view[0].a = video_box.invert_view[1].a = video_box.invert_view[2].a = video_box.invert_view[3].a = 1;4.53 /* Reset display parameters */4.54 gl_framebuffer_setup();4.55 @@ -186,8 +193,8 @@4.56 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);4.57 glDrawArrays(GL_TRIANGLE_STRIP, inverted ? 12 : 8, 4);4.58 glDisable(GL_TEXTURE_2D);4.59 + gl_framebuffer_cleanup();4.60 glFlush();4.61 - gl_framebuffer_cleanup();4.62 }4.64 gboolean gl_load_frame_buffer( frame_buffer_t frame, int tex_id )4.65 @@ -221,8 +228,8 @@4.66 glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);4.67 glDrawArrays(GL_TRIANGLE_STRIP, 4, 4);4.68 glDrawArrays(GL_TRIANGLE_STRIP, 8, 4);4.69 + gl_framebuffer_cleanup();4.70 glFlush();4.71 - gl_framebuffer_cleanup();4.72 }4.74 /**
5.1 --- a/src/drivers/video_gl.h Sat Mar 03 16:08:48 2012 +10005.2 +++ b/src/drivers/video_gl.h Sat Mar 03 16:11:28 2012 +10005.3 @@ -28,7 +28,7 @@5.4 /**5.5 * Set the video size used by the frame blits5.6 */5.7 -void gl_set_video_size( uint32_t width, uint32_t height );5.8 +void gl_set_video_size( uint32_t width, uint32_t height, int flipped );5.10 /**5.11 * Generic GL routine to draw the given frame buffer into a texture
6.1 --- a/src/drivers/video_glx.c Sat Mar 03 16:08:48 2012 +10006.2 +++ b/src/drivers/video_glx.c Sat Mar 03 16:11:28 2012 +10006.3 @@ -41,6 +41,7 @@6.4 static gboolean glx_fbconfig_supported = FALSE;6.5 static gboolean glx_pbuffer_supported = FALSE;6.6 static GLuint glx_pbuffer_texture = 0;6.7 +static int glx_depth_bits = 0;6.9 static void video_glx_swap_buffers( void );6.10 static void video_glx_print_info( FILE *out );6.11 @@ -119,6 +120,7 @@6.12 // glx_fbconfig_supported = FALSE;6.13 if( glx_fbconfig_supported ) {6.14 int nelem;6.15 + glx_depth_bits = 24;6.16 int fb_attribs[] = { GLX_DRAWABLE_TYPE,6.17 GLX_PBUFFER_BIT|GLX_WINDOW_BIT,6.18 GLX_RENDER_TYPE, GLX_RGBA_BIT,6.19 @@ -130,6 +132,7 @@6.20 if( configs == NULL || nelem == 0 ) {6.21 /* Try a 16-bit depth buffer and see if it helps */6.22 fb_attribs[5] = 16;6.23 + glx_depth_bits = 16;6.24 configs = glXChooseFBConfig( display, screen, fb_attribs, &nelem );6.25 if( nelem > 0 ) {6.26 WARN( "Using a 16-bit depth buffer - expect video glitches" );6.27 @@ -148,10 +151,12 @@6.28 }6.30 if( !glx_fbconfig_supported ) {6.31 + glx_depth_bits = 24;6.32 int attribs[] = { GLX_RGBA, GLX_DEPTH_SIZE, 24, GLX_STENCIL_SIZE, 8, 0 };6.33 glx_visual = glXChooseVisual( display, screen, attribs );6.34 if( glx_visual == NULL ) {6.35 /* Try the 16-bit fallback here too */6.36 + glx_depth_bits = 16;6.37 attribs[2] = 16;6.38 glx_visual = glXChooseVisual( display, screen, attribs );6.39 if( glx_visual != NULL ) {6.40 @@ -234,6 +239,7 @@6.41 driver->swap_buffers = video_glx_swap_buffers;6.42 driver->print_info = video_glx_print_info;6.43 driver->capabilities.has_gl = TRUE;6.44 + driver->capabilities.depth_bits = glx_depth_bits;6.45 if( gl_fbo_is_supported() ) { // First preference6.46 gl_fbo_init(driver);6.47 } else if( glx_pbuffer_supported ) {
7.1 --- a/src/drivers/video_gtk.c Sat Mar 03 16:08:48 2012 +10007.2 +++ b/src/drivers/video_gtk.c Sat Mar 03 16:11:28 2012 +10007.3 @@ -144,7 +144,7 @@7.5 gboolean video_gtk_resize_callback(GtkWidget *widget, GdkEventConfigure *event, gpointer data )7.6 {7.7 - gl_set_video_size(event->width, event->height);7.8 + gl_set_video_size(event->width, event->height, 0);7.9 pvr2_draw_frame();7.10 return TRUE;7.11 }7.12 @@ -278,7 +278,7 @@7.13 return FALSE;7.14 }7.16 - gl_set_video_size(gtk_video_drawable->allocation.width, gtk_video_drawable->allocation.height);7.17 + gl_set_video_size(gtk_video_drawable->allocation.width, gtk_video_drawable->allocation.height, 0);7.18 #ifdef HAVE_OSMESA7.19 video_gdk_init_driver( &display_gtk_driver );7.20 #else
8.1 --- a/src/drivers/video_nsgl.m Sat Mar 03 16:08:48 2012 +10008.2 +++ b/src/drivers/video_nsgl.m Sat Mar 03 16:11:28 2012 +10008.3 @@ -42,6 +42,7 @@8.4 [pool release];8.5 driver->swap_buffers = video_nsgl_swap_buffers;8.6 driver->capabilities.has_gl = TRUE;8.7 + driver->capabilities.depth_bits = 24;8.8 if( gl_fbo_is_supported() ) {8.9 gl_fbo_init(driver);8.10 } else {
9.1 --- a/src/drivers/video_osx.m Sat Mar 03 16:08:48 2012 +10009.2 +++ b/src/drivers/video_osx.m Sat Mar 03 16:11:28 2012 +10009.3 @@ -120,7 +120,7 @@9.4 {9.5 NSSize size = [self frame].size;9.6 if( video_width != size.width || video_height != size.height ) {9.7 - gl_set_video_size(size.width, size.height);9.8 + gl_set_video_size(size.width, size.height, 0);9.9 video_nsgl_update();9.10 }9.11 pvr2_draw_frame();
10.1 --- a/src/pvr2/glrender.c Sat Mar 03 16:08:48 2012 +100010.2 +++ b/src/pvr2/glrender.c Sat Mar 03 16:11:28 2012 +100010.3 @@ -73,12 +73,15 @@10.5 static void drawrect2d( uint32_t tile_bounds[], float z )10.6 {10.7 + /* FIXME: Find a non-fixed-func way to do this */10.8 +#ifdef HAVE_OPENGL_FIXEDFUNC10.9 glBegin( GL_TRIANGLE_STRIP );10.10 glVertex3f( tile_bounds[0], tile_bounds[2], z );10.11 glVertex3f( tile_bounds[1], tile_bounds[2], z );10.12 glVertex3f( tile_bounds[0], tile_bounds[3], z );10.13 glVertex3f( tile_bounds[1], tile_bounds[3], z );10.14 glEnd();10.15 +#endif10.16 }10.18 static void pvr2_scene_load_textures()10.19 @@ -116,8 +119,11 @@10.20 if( !glsl_load_shaders( ) ) {10.21 WARN( "Unable to load GL shaders" );10.22 } else {10.23 + INFO( "Shaders loaded successfully" );10.24 have_shaders = TRUE;10.25 }10.26 + } else {10.27 + INFO( "Shaders not supported" );10.28 }10.30 #ifdef APPLE_BUILD10.31 @@ -172,9 +178,9 @@10.32 */10.33 static void render_set_tsp_context( uint32_t poly1, uint32_t poly2 )10.34 {10.35 +#ifdef HAVE_OPENGL_FIXEDFUNC10.36 glShadeModel( POLY1_SHADE_MODEL(poly1) );10.38 -#ifdef HAVE_OPENGL_FIXEDFUNC10.39 if( !have_shaders ) {10.40 if( POLY1_TEXTURED(poly1) ) {10.41 if( POLY2_TEX_BLEND(poly2) == 2 )
.