Search
lxdream.org :: lxdream/src/drivers/gl_fbo.c
lxdream 0.9.1
released Jun 29
Download Now
filename src/drivers/gl_fbo.c
changeset 1245:01e0020adf88
prev1228:8168aa94e6d7
next1251:b8ab59d39756
author nkeynes
date Fri Mar 02 23:49:10 2012 +1000 (9 years ago)
permissions -rw-r--r--
last change Android WIP:
* Rename gui_jni.c to gui_android.c - now quite android specific.
* Implement generic EGL driver with very minimal Java wrapper
* Run emulation in separate thread, and implement simple queue for
inter-thread communication.
* Add menu/action-bar items for start + reset
file annotate diff log raw
nkeynes@352
     1
/**
nkeynes@561
     2
 * $Id$
nkeynes@352
     3
 *
nkeynes@352
     4
 * GL framebuffer-based driver shell. This requires the EXT_framebuffer_object
nkeynes@352
     5
 * extension, but is much nicer/faster/etc than pbuffers when it's available.
nkeynes@352
     6
 * This is (optionally) used indirectly by the top-level GLX driver.
nkeynes@352
     7
 *
nkeynes@352
     8
 * Strategy-wise, we maintain 2 framebuffers with up to 4 target colour
nkeynes@352
     9
 * buffers a piece. Effectively this reserves one fb for display output,
nkeynes@352
    10
 * and the other for texture output (each fb has a single size).
nkeynes@352
    11
 *
nkeynes@352
    12
 * Copyright (c) 2005 Nathan Keynes.
nkeynes@352
    13
 *
nkeynes@352
    14
 * This program is free software; you can redistribute it and/or modify
nkeynes@352
    15
 * it under the terms of the GNU General Public License as published by
nkeynes@352
    16
 * the Free Software Foundation; either version 2 of the License, or
nkeynes@352
    17
 * (at your option) any later version.
nkeynes@352
    18
 *
nkeynes@352
    19
 * This program is distributed in the hope that it will be useful,
nkeynes@352
    20
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
nkeynes@352
    21
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
nkeynes@352
    22
 * GNU General Public License for more details.
nkeynes@352
    23
 */
nkeynes@352
    24
nkeynes@424
    25
#define GL_GLEXT_PROTOTYPES 1
nkeynes@424
    26
nkeynes@477
    27
#include <stdlib.h>
nkeynes@477
    28
#include "lxdream.h"
nkeynes@352
    29
#include "display.h"
nkeynes@635
    30
#include "drivers/video_gl.h"
nkeynes@635
    31
#include "pvr2/glutil.h"
nkeynes@352
    32
nkeynes@1210
    33
#if defined(HAVE_OPENGL_FBO) || defined(HAVE_OPENGL_FBO_EXT)
nkeynes@656
    34
nkeynes@352
    35
#define MAX_FRAMEBUFFERS 2
nkeynes@798
    36
#define MAX_TEXTURES_PER_FB 16
nkeynes@352
    37
nkeynes@805
    38
static render_buffer_t gl_fbo_create_render_buffer( uint32_t width, uint32_t height, GLuint tex_id );
nkeynes@352
    39
static void gl_fbo_destroy_render_buffer( render_buffer_t buffer );
nkeynes@352
    40
static gboolean gl_fbo_set_render_target( render_buffer_t buffer );
nkeynes@805
    41
static void gl_fbo_finish_render( render_buffer_t buffer );
nkeynes@669
    42
static void gl_fbo_display_render_buffer( render_buffer_t buffer );
nkeynes@477
    43
static void gl_fbo_load_frame_buffer( frame_buffer_t frame, render_buffer_t buffer );
nkeynes@669
    44
static void gl_fbo_display_blank( uint32_t colour );
nkeynes@1166
    45
static gboolean gl_fbo_test_framebuffer( );
nkeynes@477
    46
static gboolean gl_fbo_read_render_buffer( unsigned char *target, render_buffer_t buffer, int rowstride, int format );
nkeynes@352
    47
nkeynes@352
    48
extern uint32_t video_width, video_height;
nkeynes@352
    49
nkeynes@352
    50
/**
nkeynes@352
    51
 * Framebuffer info structure
nkeynes@352
    52
 */
nkeynes@352
    53
struct gl_fbo_info {
nkeynes@352
    54
    GLuint fb_id;
nkeynes@352
    55
    GLuint depth_id;
nkeynes@352
    56
    GLuint stencil_id;
nkeynes@352
    57
    GLuint tex_ids[MAX_TEXTURES_PER_FB];
nkeynes@352
    58
    int width, height;
nkeynes@352
    59
};
nkeynes@352
    60
nkeynes@798
    61
static GLint gl_fbo_max_attachments = 0;
nkeynes@863
    62
static gboolean gl_fbo_have_packed_stencil = FALSE;
nkeynes@352
    63
static struct gl_fbo_info fbo[MAX_FRAMEBUFFERS];
nkeynes@798
    64
nkeynes@1210
    65
#define ATTACHMENT_POINT(n) (GL_COLOR_ATTACHMENT0+(n))
nkeynes@352
    66
static int last_used_fbo;
nkeynes@352
    67
nkeynes@352
    68
gboolean gl_fbo_is_supported()
nkeynes@352
    69
{
nkeynes@1245
    70
    return isGLExtensionSupported("GL_EXT_framebuffer_object") || isOpenGLES2();
nkeynes@352
    71
}
nkeynes@352
    72
nkeynes@352
    73
/**
nkeynes@352
    74
 * Construct the initial frame buffers and allocate ids for everything.
nkeynes@352
    75
 * The render handling driver methods are set to the fbo versions.
nkeynes@352
    76
 */
nkeynes@352
    77
void gl_fbo_init( display_driver_t driver ) 
nkeynes@352
    78
{
nkeynes@352
    79
    int i,j;
nkeynes@424
    80
    GLuint fbids[MAX_FRAMEBUFFERS];
nkeynes@424
    81
    GLuint rbids[MAX_FRAMEBUFFERS*2]; /* depth buffer, stencil buffer per fb */
nkeynes@736
    82
nkeynes@1223
    83
    gl_fbo_max_attachments = glGetMaxColourAttachments();
nkeynes@1210
    84
    glGenFramebuffers( MAX_FRAMEBUFFERS, &fbids[0] );
nkeynes@1210
    85
    glGenRenderbuffers( MAX_FRAMEBUFFERS*2, &rbids[0] );
nkeynes@352
    86
    for( i=0; i<MAX_FRAMEBUFFERS; i++ ) {
nkeynes@736
    87
        fbo[i].fb_id = fbids[i];
nkeynes@736
    88
        fbo[i].depth_id = rbids[i*2];
nkeynes@736
    89
        fbo[i].stencil_id = rbids[i*2+1];
nkeynes@736
    90
        fbo[i].width = -1;
nkeynes@736
    91
        fbo[i].height = -1;
nkeynes@736
    92
        for( j=0; j<MAX_TEXTURES_PER_FB; j++ ) {
nkeynes@736
    93
            fbo[i].tex_ids[j] = -1;
nkeynes@736
    94
        }
nkeynes@352
    95
    }
nkeynes@352
    96
    last_used_fbo = 0;
nkeynes@352
    97
nkeynes@863
    98
    if( isGLExtensionSupported("GL_EXT_packed_depth_stencil" ) ) {
nkeynes@863
    99
        driver->capabilities.stencil_bits = 8;
nkeynes@863
   100
        gl_fbo_have_packed_stencil = TRUE;
nkeynes@863
   101
    } else {
nkeynes@863
   102
        driver->capabilities.stencil_bits = 0;
nkeynes@863
   103
        gl_fbo_have_packed_stencil = FALSE;
nkeynes@863
   104
        WARN( "Packed depth stencil not available - disabling shadow volumes" );
nkeynes@863
   105
    }
nkeynes@863
   106
nkeynes@352
   107
    driver->create_render_buffer = gl_fbo_create_render_buffer;
nkeynes@352
   108
    driver->destroy_render_buffer = gl_fbo_destroy_render_buffer;
nkeynes@352
   109
    driver->set_render_target = gl_fbo_set_render_target;
nkeynes@805
   110
    driver->finish_render = gl_fbo_finish_render;
nkeynes@352
   111
    driver->display_render_buffer = gl_fbo_display_render_buffer;
nkeynes@477
   112
    driver->load_frame_buffer = gl_fbo_load_frame_buffer;
nkeynes@352
   113
    driver->display_blank = gl_fbo_display_blank;
nkeynes@352
   114
    driver->read_render_buffer = gl_fbo_read_render_buffer;
nkeynes@445
   115
nkeynes@1166
   116
    gl_fbo_test_framebuffer();
nkeynes@1210
   117
    glBindFramebuffer(GL_FRAMEBUFFER, 0);
nkeynes@352
   118
}
nkeynes@352
   119
nkeynes@352
   120
void gl_fbo_shutdown()
nkeynes@352
   121
{
nkeynes@352
   122
    int i;
nkeynes@1210
   123
    glBindFramebuffer( GL_FRAMEBUFFER, 0 );
nkeynes@352
   124
    for( i=0; i<MAX_FRAMEBUFFERS; i++ ) {
nkeynes@1210
   125
        glDeleteFramebuffers( 1, &fbo[i].fb_id );
nkeynes@1210
   126
        glDeleteRenderbuffers( 2, &fbo[i].depth_id );
nkeynes@352
   127
    }
nkeynes@352
   128
}
nkeynes@352
   129
nkeynes@863
   130
static void gl_fbo_setup_framebuffer( int bufno, int width, int height )
nkeynes@352
   131
{
nkeynes@877
   132
    int i;
nkeynes@1210
   133
    glBindFramebuffer(GL_FRAMEBUFFER, fbo[bufno].fb_id);
nkeynes@877
   134
nkeynes@877
   135
    /* Clear out any existing texture attachments */
nkeynes@877
   136
    for( i=0; i<gl_fbo_max_attachments; i++ ) {
nkeynes@877
   137
        if( fbo[bufno].tex_ids[i] != -1 ) {
nkeynes@1210
   138
            glFramebufferTexture2D(GL_FRAMEBUFFER, ATTACHMENT_POINT(i),
nkeynes@1222
   139
                    GL_TEXTURE_2D, 0, 0);
nkeynes@877
   140
            fbo[bufno].tex_ids[i] = -1;
nkeynes@877
   141
        }
nkeynes@877
   142
    }
nkeynes@877
   143
nkeynes@877
   144
    /* Setup the renderbuffers */
nkeynes@863
   145
    if( gl_fbo_have_packed_stencil ) {
nkeynes@1210
   146
        glBindRenderbuffer(GL_RENDERBUFFER, fbo[bufno].depth_id);
nkeynes@1222
   147
        glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, width, height);
nkeynes@1210
   148
        glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
nkeynes@1210
   149
                                     GL_RENDERBUFFER, fbo[bufno].depth_id);
nkeynes@1210
   150
        glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT,
nkeynes@1210
   151
                                     GL_RENDERBUFFER, fbo[bufno].depth_id);
nkeynes@863
   152
    } else {
nkeynes@1210
   153
        glBindRenderbuffer(GL_RENDERBUFFER, fbo[bufno].depth_id);
nkeynes@1210
   154
        glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT24, width, height);
nkeynes@1210
   155
        glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
nkeynes@1210
   156
                                     GL_RENDERBUFFER, fbo[bufno].depth_id);
nkeynes@863
   157
        /* In theory you could attach a separate stencil buffer. In practice this 
nkeynes@863
   158
         * isn't actually supported by any hardware I've had access to, so we're
nkeynes@863
   159
         * stencil-less.
nkeynes@863
   160
         */
nkeynes@863
   161
    }
nkeynes@352
   162
    fbo[bufno].width = width;
nkeynes@352
   163
    fbo[bufno].height = height;
nkeynes@352
   164
}
nkeynes@352
   165
nkeynes@863
   166
static int gl_fbo_get_framebuffer( int width, int height ) 
nkeynes@352
   167
{
nkeynes@352
   168
    int bufno = -1, i;
nkeynes@352
   169
    /* find a compatible framebuffer context */
nkeynes@352
   170
    for( i=0; i<MAX_FRAMEBUFFERS; i++ ) {
nkeynes@736
   171
        if( fbo[i].width == -1 && bufno == -1 ) {
nkeynes@736
   172
            bufno = i;
nkeynes@736
   173
        } else if( fbo[i].width == width && fbo[i].height == height ) {
nkeynes@736
   174
            bufno = i;
nkeynes@736
   175
            break;
nkeynes@736
   176
        }
nkeynes@352
   177
    }
nkeynes@352
   178
    if( bufno == -1 ) {
nkeynes@736
   179
        bufno = last_used_fbo + 1;
nkeynes@877
   180
        if( bufno >= MAX_FRAMEBUFFERS ) {
nkeynes@736
   181
            bufno = 0;
nkeynes@736
   182
        }
nkeynes@736
   183
        last_used_fbo = bufno;
nkeynes@352
   184
    }
nkeynes@352
   185
    if( fbo[bufno].width == width && fbo[bufno].height == height ) {
nkeynes@1210
   186
        glBindFramebuffer( GL_FRAMEBUFFER, fbo[bufno].fb_id );
nkeynes@352
   187
    } else {
nkeynes@736
   188
        gl_fbo_setup_framebuffer( bufno, width, height );
nkeynes@352
   189
    } 
nkeynes@352
   190
    return bufno;
nkeynes@352
   191
}
nkeynes@352
   192
nkeynes@352
   193
/**
nkeynes@352
   194
 * Attach a texture to the framebuffer. The texture must already be initialized
nkeynes@352
   195
 * to the correct dimensions etc.
nkeynes@352
   196
 */
nkeynes@352
   197
static GLint gl_fbo_attach_texture( int fbo_no, GLint tex_id ) {
nkeynes@352
   198
    int attach = -1, i;
nkeynes@798
   199
    for( i=0; i<gl_fbo_max_attachments; i++ ) {
nkeynes@736
   200
        if( fbo[fbo_no].tex_ids[i] == tex_id ) {
nkeynes@1228
   201
#ifdef HAVE_OPENGL_DRAW_BUFFER
nkeynes@798
   202
            glDrawBuffer(ATTACHMENT_POINT(i));
nkeynes@798
   203
            glReadBuffer(ATTACHMENT_POINT(i)); 
nkeynes@1228
   204
#endif
nkeynes@798
   205
            return ATTACHMENT_POINT(i); // already attached
nkeynes@736
   206
        } else if( fbo[fbo_no].tex_ids[i] == -1 && attach == -1 ) {
nkeynes@736
   207
            attach = i;
nkeynes@736
   208
        }
nkeynes@352
   209
    }
nkeynes@352
   210
    if( attach == -1 ) {
nkeynes@736
   211
        attach = 0;
nkeynes@352
   212
    }
nkeynes@352
   213
    fbo[fbo_no].tex_ids[attach] = tex_id;
nkeynes@1222
   214
    glBindTexture( GL_TEXTURE_2D, 0 ); // Ensure the output texture is unbound
nkeynes@1210
   215
    glFramebufferTexture2D(GL_FRAMEBUFFER, ATTACHMENT_POINT(attach), 
nkeynes@1222
   216
                              GL_TEXTURE_2D, tex_id, 0 );
nkeynes@352
   217
    /* Set draw/read buffers by default */
nkeynes@1228
   218
#ifdef HAVE_OPENGL_DRAW_BUFFER    
nkeynes@798
   219
    glDrawBuffer(ATTACHMENT_POINT(attach));
nkeynes@798
   220
    glReadBuffer(ATTACHMENT_POINT(attach)); 
nkeynes@1228
   221
#endif
nkeynes@352
   222
nkeynes@1166
   223
    return ATTACHMENT_POINT(attach);
nkeynes@1166
   224
}
nkeynes@352
   225
nkeynes@1166
   226
static gboolean gl_fbo_test_framebuffer( )
nkeynes@1166
   227
{
nkeynes@1166
   228
    gboolean result = TRUE;
nkeynes@1166
   229
    glGetError(); /* Clear error state just in case */
nkeynes@1166
   230
    render_buffer_t buffer = gl_fbo_create_render_buffer( 640, 480, 0 );
nkeynes@1166
   231
    gl_fbo_set_render_target(buffer);
nkeynes@1166
   232
nkeynes@1210
   233
    GLint status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
nkeynes@1210
   234
    if( status != GL_FRAMEBUFFER_COMPLETE ) {
nkeynes@736
   235
        ERROR( "Framebuffer failure: %x", status );
nkeynes@1166
   236
        result = FALSE;
nkeynes@1166
   237
    }
nkeynes@1166
   238
    if( result ) {
nkeynes@1166
   239
        result = gl_check_error( "Setting up framebuffer" );
nkeynes@352
   240
    }
nkeynes@352
   241
nkeynes@1166
   242
    gl_fbo_destroy_render_buffer( buffer );
nkeynes@1166
   243
    return result;
nkeynes@352
   244
}
nkeynes@352
   245
nkeynes@805
   246
static render_buffer_t gl_fbo_create_render_buffer( uint32_t width, uint32_t height, GLuint tex_id )
nkeynes@352
   247
{
nkeynes@352
   248
    render_buffer_t buffer = calloc( sizeof(struct render_buffer), 1 );
nkeynes@352
   249
    buffer->width = width;
nkeynes@352
   250
    buffer->height = height;
nkeynes@805
   251
    buffer->tex_id = tex_id;
nkeynes@805
   252
    if( tex_id == 0 ) {
nkeynes@805
   253
        GLuint tex;
nkeynes@805
   254
        glGenTextures( 1, &tex );
nkeynes@805
   255
        buffer->buf_id = tex;
nkeynes@805
   256
    } else {
nkeynes@805
   257
        buffer->buf_id = tex_id;
nkeynes@1222
   258
        glBindTexture( GL_TEXTURE_2D, tex_id );
nkeynes@805
   259
    }
nkeynes@1222
   260
    glBindTexture( GL_TEXTURE_2D, buffer->buf_id );
nkeynes@1222
   261
    glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL );
nkeynes@1223
   262
    glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
nkeynes@1223
   263
    glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
nkeynes@1222
   264
    glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
nkeynes@1222
   265
    glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
nkeynes@352
   266
    return buffer;
nkeynes@352
   267
}
nkeynes@352
   268
nkeynes@805
   269
/**
nkeynes@805
   270
 * Ensure the texture in the given render buffer is not attached to a 
nkeynes@805
   271
 * framebuffer (ie, so we can safely use it as a texture during the rendering
nkeynes@805
   272
 * cycle, or before deletion).
nkeynes@805
   273
 */
nkeynes@805
   274
static void gl_fbo_detach_render_buffer( render_buffer_t buffer )
nkeynes@805
   275
{
nkeynes@805
   276
    int i,j;
nkeynes@805
   277
    for( i=0; i<MAX_FRAMEBUFFERS; i++ ) {
nkeynes@805
   278
        if( fbo[i].width == buffer->width && fbo[i].height == buffer->height ) {
nkeynes@805
   279
            for( j=0; j<gl_fbo_max_attachments; j++ ) {
nkeynes@805
   280
                if( fbo[i].tex_ids[j] == buffer->buf_id ) {
nkeynes@1210
   281
                    glBindFramebuffer(GL_FRAMEBUFFER, fbo[i].fb_id);
nkeynes@1210
   282
                    glFramebufferTexture2D(GL_FRAMEBUFFER, ATTACHMENT_POINT(j), 
nkeynes@1222
   283
                                              GL_TEXTURE_2D, GL_NONE, 0 );
nkeynes@805
   284
                    fbo[i].tex_ids[j] = -1;
nkeynes@805
   285
                    return;
nkeynes@805
   286
                }                    
nkeynes@805
   287
            }
nkeynes@805
   288
            break;
nkeynes@805
   289
        }
nkeynes@805
   290
    }
nkeynes@805
   291
}
nkeynes@805
   292
nkeynes@352
   293
static void gl_fbo_destroy_render_buffer( render_buffer_t buffer )
nkeynes@352
   294
{
nkeynes@352
   295
    int i,j;
nkeynes@805
   296
nkeynes@805
   297
    gl_fbo_detach_render_buffer( buffer );
nkeynes@805
   298
nkeynes@805
   299
    if( buffer->buf_id != buffer->tex_id ) {
nkeynes@805
   300
        // If tex_id was set at buffer creation, we don't own the texture.
nkeynes@805
   301
        // Otherwise, delete it now.
nkeynes@805
   302
        GLuint tex = buffer->buf_id; 
nkeynes@805
   303
        glDeleteTextures( 1, &tex );
nkeynes@352
   304
    }
nkeynes@352
   305
    buffer->buf_id = 0;
nkeynes@805
   306
    buffer->tex_id = 0;
nkeynes@352
   307
    free( buffer );
nkeynes@352
   308
}
nkeynes@352
   309
nkeynes@352
   310
static gboolean gl_fbo_set_render_target( render_buffer_t buffer )
nkeynes@352
   311
{
nkeynes@352
   312
    int fb = gl_fbo_get_framebuffer( buffer->width, buffer->height );
nkeynes@424
   313
    gl_fbo_attach_texture( fb, buffer->buf_id );
nkeynes@352
   314
    /* setup the gl context */
nkeynes@352
   315
    glViewport( 0, 0, buffer->width, buffer->height );
nkeynes@736
   316
nkeynes@352
   317
    return TRUE;
nkeynes@352
   318
}
nkeynes@352
   319
nkeynes@805
   320
static void gl_fbo_finish_render( render_buffer_t buffer )
nkeynes@805
   321
{
nkeynes@805
   322
    glFinish();
nkeynes@805
   323
    gl_fbo_detach_render_buffer(buffer);
nkeynes@805
   324
}
nkeynes@805
   325
nkeynes@352
   326
/**
nkeynes@352
   327
 * Render the texture holding the given buffer to the front window
nkeynes@352
   328
 * buffer.
nkeynes@352
   329
 */
nkeynes@669
   330
static void gl_fbo_display_render_buffer( render_buffer_t buffer )
nkeynes@352
   331
{
nkeynes@477
   332
    gl_fbo_detach();
nkeynes@477
   333
    gl_display_render_buffer( buffer );
nkeynes@352
   334
}
nkeynes@352
   335
nkeynes@477
   336
static void gl_fbo_load_frame_buffer( frame_buffer_t frame, render_buffer_t buffer )
nkeynes@477
   337
{
nkeynes@477
   338
    gl_fbo_detach();
nkeynes@545
   339
    gl_load_frame_buffer( frame, buffer->buf_id );
nkeynes@477
   340
}
nkeynes@477
   341
nkeynes@669
   342
static void gl_fbo_display_blank( uint32_t colour )
nkeynes@477
   343
{
nkeynes@477
   344
    gl_fbo_detach();
nkeynes@669
   345
    gl_display_blank( colour );
nkeynes@477
   346
}
nkeynes@477
   347
nkeynes@477
   348
void gl_fbo_detach()
nkeynes@352
   349
{
nkeynes@1210
   350
    glBindFramebuffer( GL_FRAMEBUFFER, 0 );
nkeynes@1076
   351
    /* Make sure texture attachment is not a current draw/read buffer */
nkeynes@1228
   352
#ifdef HAVE_OPENGL_DRAW_BUFFER
nkeynes@352
   353
    glDrawBuffer( GL_FRONT );
nkeynes@352
   354
    glReadBuffer( GL_FRONT );
nkeynes@1228
   355
#endif
nkeynes@1245
   356
    if( display_driver->swap_buffers )
nkeynes@1245
   357
        display_driver->swap_buffers();
nkeynes@477
   358
}    
nkeynes@352
   359
nkeynes@477
   360
static gboolean gl_fbo_read_render_buffer( unsigned char *target, render_buffer_t buffer, 
nkeynes@736
   361
                                           int rowstride, int format )
nkeynes@352
   362
{
nkeynes@352
   363
    int fb = gl_fbo_get_framebuffer( buffer->width, buffer->height );
nkeynes@424
   364
    gl_fbo_attach_texture( fb, buffer->buf_id );
nkeynes@477
   365
    return gl_read_render_buffer( target, buffer, rowstride, format );
nkeynes@352
   366
}
nkeynes@352
   367
nkeynes@656
   368
#else
nkeynes@656
   369
gboolean gl_fbo_is_supported()
nkeynes@656
   370
{
nkeynes@656
   371
    return FALSE;
nkeynes@656
   372
}
nkeynes@656
   373
nkeynes@656
   374
void gl_fbo_init( display_driver_t driver ) 
nkeynes@656
   375
{
nkeynes@656
   376
}
nkeynes@656
   377
nkeynes@656
   378
#endif
.