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 805:b355f7b3ff2e
prev736:a02d1475ccfd
next806:6ef1ce4a9dbc
author nkeynes
date Thu Aug 07 23:53:17 2008 +0000 (11 years ago)
permissions -rw-r--r--
last change Add ability to bind a render buffer to a texture, with output going to the texture.
(RTT work in progress)
file annotate diff log raw
1.1 --- a/src/drivers/video_glx.c Mon Jul 14 07:44:42 2008 +0000
1.2 +++ b/src/drivers/video_glx.c Thu Aug 07 23:53:17 2008 +0000
1.3 @@ -44,9 +44,10 @@
1.4
1.5 /* Prototypes for pbuffer support methods */
1.6 static void glx_pbuffer_init( display_driver_t driver );
1.7 -static render_buffer_t glx_pbuffer_create_render_buffer( uint32_t width, uint32_t height );
1.8 +static render_buffer_t glx_pbuffer_create_render_buffer( uint32_t width, uint32_t height, GLuint tex_id );
1.9 static void glx_pbuffer_destroy_render_buffer( render_buffer_t buffer );
1.10 static gboolean glx_pbuffer_set_render_target( render_buffer_t buffer );
1.11 +static void glx_pbuffer_finish_render( render_buffer_t buffer );
1.12 static void glx_pbuffer_display_render_buffer( render_buffer_t buffer );
1.13 static void glx_pbuffer_load_frame_buffer( frame_buffer_t frame, render_buffer_t buffer );
1.14 static void glx_pbuffer_display_blank( uint32_t colour );
1.15 @@ -265,6 +266,7 @@
1.16 driver->create_render_buffer = glx_pbuffer_create_render_buffer;
1.17 driver->destroy_render_buffer = glx_pbuffer_destroy_render_buffer;
1.18 driver->set_render_target = glx_pbuffer_set_render_target;
1.19 + driver->finish_render = glx_pbuffer_finish_render;
1.20 driver->display_render_buffer = glx_pbuffer_display_render_buffer;
1.21 driver->load_frame_buffer = glx_pbuffer_load_frame_buffer;
1.22 driver->display_blank = glx_pbuffer_display_blank;
1.23 @@ -276,7 +278,7 @@
1.24 glDeleteTextures( 1, &glx_pbuffer_texture );
1.25 }
1.26
1.27 -static render_buffer_t glx_pbuffer_create_render_buffer( uint32_t width, uint32_t height )
1.28 +static render_buffer_t glx_pbuffer_create_render_buffer( uint32_t width, uint32_t height, GLuint tex_id )
1.29 {
1.30 int attribs[] = { GLX_PBUFFER_WIDTH, width, GLX_PBUFFER_HEIGHT, height,
1.31 GLX_PRESERVED_CONTENTS, True, 0 };
1.32 @@ -289,6 +291,7 @@
1.33 buffer->width = width;
1.34 buffer->height = height;
1.35 buffer->buf_id = pb;
1.36 + buffer->tex_id = tex_id;
1.37 return buffer;
1.38 }
1.39
1.40 @@ -312,6 +315,18 @@
1.41 return TRUE;
1.42 }
1.43
1.44 +static void glx_pbuffer_finish_render( render_buffer_t buffer )
1.45 +{
1.46 + glFinish();
1.47 + if( buffer->tex_id != 0 ) {
1.48 + // The pbuffer should already be the current context, but just in case...
1.49 + glXMakeContextCurrent( video_x11_display, (GLXPbuffer)buffer->buf_id, (GLXPbuffer)buffer->buf_id, glx_context );
1.50 + glBindTexture( GL_TEXTURE_RECTANGLE_ARB, buffer->tex_id );
1.51 + glCopyTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, 0, 0, buffer->width, buffer->height, 0 );
1.52 + }
1.53 +}
1.54 +
1.55 +
1.56 /**
1.57 * Render the texture holding the given buffer to the front window
1.58 * buffer.
.