/* * Bind an OSMesaContext to an image buffer. The image buffer is just a * block of memory which the client provides. Its size must be at least * as large as width*height*sizeof(type). Its address should be a multiple * of 4 if using RGBA mode. * * Image data is stored in the order of glDrawPixels: row-major order * with the lower-left image pixel stored in the first array position * (ie. bottom-to-top). * * Since the only type initially supported is GL_UNSIGNED_BYTE, if the * context is in RGBA mode, each pixel will be stored as a 4-byte RGBA * value. If the context is in color indexed mode, each pixel will be * stored as a 1-byte value. * * If the context's viewport hasn't been initialized yet, it will now be * initialized to (0,0,width,height). * * Input: ctx - the rendering context * buffer - the image buffer memory * type - data type for pixel components, only GL_UNSIGNED_BYTE * supported now * width, height - size of image buffer in pixels, at least 1 * Return: GL_TRUE if success, GL_FALSE if error because of invalid ctx, * invalid buffer address, type!=GL_UNSIGNED_BYTE, width<1, height<1, * width>internal limit or height>internal limit. */ GLboolean OSMesaMakeCurrent( OSMesaContext ctx, void *buffer, GLenum type, GLsizei width, GLsizei height ) { if (!ctx || !buffer || type!=GL_UNSIGNED_BYTE || width<1 || height<1 || width>MAX_WIDTH || height>MAX_HEIGHT) { return GL_FALSE; } gl_make_current( ctx->gl_ctx, ctx->gl_buffer ); ctx->buffer = buffer; ctx->width = width; ctx->height = height; if (ctx->rowlength==0) { ctx->rowlength = width; } osmesa_setup_DD_pointers( ctx->gl_ctx ); #ifdef THREADS /* Set current context for the calling thread */ /* TODO */ #else /* Set current context for the address space, all threads */ Current = ctx; #endif compute_row_addresses( ctx ); /* init viewport */ if (ctx->gl_ctx->Viewport.Width==0) { /* initialize viewport and scissor box to buffer size */ gl_Viewport( ctx->gl_ctx, 0, 0, width, height ); ctx->gl_ctx->Scissor.Width = width; ctx->gl_ctx->Scissor.Height = height; } return GL_TRUE; }
GLboolean FBMesaMakeCurrent( __DRIcontextPrivate *driContextPriv, __DRIdrawablePrivate *driDrawPriv, __DRIdrawablePrivate *driReadPriv ) { //printf("FBMesaMakeCurrent 1\n"); if ( driContextPriv ) { //printf("FBMesaMakeCurrent 2\n"); radeonContextPtr rmesa = (radeonContextPtr)driContextPriv->driverPrivate; radeonCtx = radeonMakeCurrent( radeonCtx, rmesa, driDrawPriv ); gl_make_current2( radeonCtx->glCtx, driDrawPriv->mesaBuffer, driReadPriv->mesaBuffer ); if ( radeonCtx->driDrawable != driDrawPriv ) { radeonCtx->driDrawable = driDrawPriv; radeonCtx->dirty = RADEON_UPLOAD_ALL; } /* GH: We need this to correctly calculate the window offset * and aux scissor rects. */ radeonCtx->new_state = RADEON_NEW_WINDOW | RADEON_NEW_CLIP; if ( !radeonCtx->glCtx->Viewport.Width ) { gl_Viewport( radeonCtx->glCtx, 0, 0, driDrawPriv->w, driDrawPriv->h ); } } else { //printf("FBMesaMakeCurrent 3\n"); gl_make_current( 0, 0 ); radeonCtx = NULL; } return GL_TRUE; }