-/* $Id: fakeglx.c,v 1.48 2001/03/23 21:37:05 brianp Exp $ */
+/* $Id: fakeglx.c,v 1.49 2001/04/27 21:18:25 brianp Exp $ */
/*
* Mesa 3-D graphics library
if (v->display == dpy
&& v->level == level
&& v->ximage_flag == ximageFlag
- && v->gl_visual->rgbMode == rgbFlag
- && v->gl_visual->doubleBufferMode == dbFlag
- && v->gl_visual->stereoMode == stereoFlag
- && (v->gl_visual->alphaBits > 0) == alphaFlag
- && (v->gl_visual->depthBits >= depth_size || depth_size == 0)
- && (v->gl_visual->stencilBits >= stencil_size || stencil_size == 0)
- && (v->gl_visual->accumRedBits >= accumRedSize || accumRedSize == 0)
- && (v->gl_visual->accumGreenBits >= accumGreenSize || accumGreenSize == 0)
- && (v->gl_visual->accumBlueBits >= accumBlueSize || accumBlueSize == 0)
- && (v->gl_visual->accumAlphaBits >= accumAlphaSize || accumAlphaSize == 0)) {
+ && v->mesa_visual.rgbMode == rgbFlag
+ && v->mesa_visual.doubleBufferMode == dbFlag
+ && v->mesa_visual.stereoMode == stereoFlag
+ && (v->mesa_visual.alphaBits > 0) == alphaFlag
+ && (v->mesa_visual.depthBits >= depth_size || depth_size == 0)
+ && (v->mesa_visual.stencilBits >= stencil_size || stencil_size == 0)
+ && (v->mesa_visual.accumRedBits >= accumRedSize || accumRedSize == 0)
+ && (v->mesa_visual.accumGreenBits >= accumGreenSize || accumGreenSize == 0)
+ && (v->mesa_visual.accumBlueBits >= accumBlueSize || accumBlueSize == 0)
+ && (v->mesa_visual.accumAlphaBits >= accumAlphaSize || accumAlphaSize == 0)) {
/* now either compare XVisualInfo pointers or visual IDs */
if ((!comparePointers && v->visinfo->visualid == vinfo->visualid)
|| (comparePointers && v->vishandle == vinfo)) {
*value = glxvis->level;
return 0;
case GLX_RGBA:
- if (glxvis->gl_visual->rgbMode) {
+ if (glxvis->mesa_visual.rgbMode) {
*value = True;
}
else {
}
return 0;
case GLX_DOUBLEBUFFER:
- *value = (int) glxvis->gl_visual->doubleBufferMode;
+ *value = (int) glxvis->mesa_visual.doubleBufferMode;
return 0;
case GLX_STEREO:
- *value = (int) glxvis->gl_visual->stereoMode;
+ *value = (int) glxvis->mesa_visual.stereoMode;
return 0;
case GLX_AUX_BUFFERS:
*value = (int) False;
return 0;
case GLX_RED_SIZE:
- *value = glxvis->gl_visual->redBits;
+ *value = glxvis->mesa_visual.redBits;
return 0;
case GLX_GREEN_SIZE:
- *value = glxvis->gl_visual->greenBits;
+ *value = glxvis->mesa_visual.greenBits;
return 0;
case GLX_BLUE_SIZE:
- *value = glxvis->gl_visual->blueBits;
+ *value = glxvis->mesa_visual.blueBits;
return 0;
case GLX_ALPHA_SIZE:
- *value = glxvis->gl_visual->alphaBits;
+ *value = glxvis->mesa_visual.alphaBits;
return 0;
case GLX_DEPTH_SIZE:
- *value = glxvis->gl_visual->depthBits;
+ *value = glxvis->mesa_visual.depthBits;
return 0;
case GLX_STENCIL_SIZE:
- *value = glxvis->gl_visual->stencilBits;
+ *value = glxvis->mesa_visual.stencilBits;
return 0;
case GLX_ACCUM_RED_SIZE:
- *value = glxvis->gl_visual->accumRedBits;
+ *value = glxvis->mesa_visual.accumRedBits;
return 0;
case GLX_ACCUM_GREEN_SIZE:
- *value = glxvis->gl_visual->accumGreenBits;
+ *value = glxvis->mesa_visual.accumGreenBits;
return 0;
case GLX_ACCUM_BLUE_SIZE:
- *value = glxvis->gl_visual->accumBlueBits;
+ *value = glxvis->mesa_visual.accumBlueBits;
return 0;
case GLX_ACCUM_ALPHA_SIZE:
- *value = glxvis->gl_visual->accumAlphaBits;
+ *value = glxvis->mesa_visual.accumAlphaBits;
return 0;
/*
}
else if (glxvis->level>0) {
/* overlay */
- if (glxvis->gl_visual->rgbMode) {
+ if (glxvis->mesa_visual.rgbMode) {
*value = GLX_TRANSPARENT_RGB_EXT;
}
else {
-/* $Id: xm_api.c,v 1.20 2001/04/10 15:25:45 brianp Exp $ */
+/* $Id: xm_api.c,v 1.21 2001/04/27 21:18:25 brianp Exp $ */
/*
* Mesa 3-D graphics library
#endif
}
}
+
+ _mesa_free_framebuffer_data(&buffer->mesa_buffer);
FREE(buffer);
+
return;
}
/* continue search */
prevBuffer = find_xmesa_buffer(v->display, cmap, buffer);
if (prevBuffer &&
- (buffer->xm_visual->gl_visual->rgbMode ==
- prevBuffer->xm_visual->gl_visual->rgbMode)) {
+ (buffer->xm_visual->mesa_visual.rgbMode ==
+ prevBuffer->xm_visual->mesa_visual.rgbMode)) {
/* Copy colormap stuff from previous XMesaBuffer which uses same
* X colormap. Do this to avoid time spent in noFaultXAllocColor.
*/
prevBuffer = find_xmesa_buffer(v->display, cmap, buffer);
if (prevBuffer &&
- (buffer->xm_visual->gl_visual->rgbMode ==
- prevBuffer->xm_visual->gl_visual->rgbMode)) {
+ (buffer->xm_visual->mesa_visual.rgbMode ==
+ prevBuffer->xm_visual->mesa_visual.rgbMode)) {
/* Copy colormap stuff from previous, matching XMesaBuffer.
* Do this to avoid time spent in noFaultXAllocColor.
*/
b->frontbuffer = window;
- assert( v->gl_visual );
-
/* Setup for single/double buffering */
- if (v->gl_visual->doubleBufferMode) {
+ if (v->mesa_visual.doubleBufferMode) {
/* Double buffered */
#ifndef XFree86Server
b->shm = check_for_xshm( v->display );
if (alpha_flag && alpha_bits == 0)
alpha_bits = 8;
- v->gl_visual = _mesa_create_visual( rgb_flag, db_flag, stereo_flag,
- red_bits, green_bits,
- blue_bits, alpha_bits,
- v->index_bits,
- depth_size,
- stencil_size,
- accum_red_size, accum_green_size,
- accum_blue_size, accum_alpha_size,
- 0 );
- if (!v->gl_visual) {
-#ifndef XFree86Server
- FREE(v->visinfo);
-#endif
- FREE(v);
- return NULL;
- }
-
+ _mesa_initialize_visual( &v->mesa_visual,
+ rgb_flag, db_flag, stereo_flag,
+ red_bits, green_bits,
+ blue_bits, alpha_bits,
+ v->index_bits,
+ depth_size,
+ stencil_size,
+ accum_red_size, accum_green_size,
+ accum_blue_size, accum_alpha_size,
+ 0 );
return v;
}
void XMesaDestroyVisual( XMesaVisual v )
{
- _mesa_destroy_visual( v->gl_visual );
#ifndef XFree86Server
FREE(v->visinfo);
#endif
return NULL;
}
- ctx = c->gl_ctx = _mesa_create_context( v->gl_visual,
+ ctx = c->gl_ctx = _mesa_create_context( &v->mesa_visual,
share_list ? share_list->gl_ctx : (GLcontext *) NULL,
(void *) c, direct );
if (!c->gl_ctx) {
#endif
/* determine back buffer implementation */
- if (v->gl_visual->doubleBufferMode) {
+ if (v->mesa_visual.doubleBufferMode) {
if (v->ximage_flag) {
b->db_state = BACK_XIMAGE;
}
b->db_state = 0;
}
- b->gl_buffer = _mesa_create_framebuffer( v->gl_visual,
- v->gl_visual->depthBits > 0,
- v->gl_visual->stencilBits > 0,
- v->gl_visual->accumRedBits > 0,
- v->gl_visual->alphaBits > 0 );
- if (!b->gl_buffer) {
- free_xmesa_buffer(client, b);
- return NULL;
- }
+ _mesa_initialize_framebuffer(&b->mesa_buffer,
+ &v->mesa_visual,
+ v->mesa_visual.depthBits > 0,
+ v->mesa_visual.stencilBits > 0,
+ v->mesa_visual.accumRedBits > 0,
+ v->mesa_visual.alphaBits > 0 );
- if (!initialize_visual_and_buffer( client, v, b, v->gl_visual->rgbMode,
+ if (!initialize_visual_and_buffer( client, v, b, v->mesa_visual.rgbMode,
(XMesaDrawable)w, b->cmap )) {
- _mesa_destroy_framebuffer( b->gl_buffer );
free_xmesa_buffer(client, b);
return NULL;
}
int attribs[100];
int numAttribs = 0;
int hw;
- if (v->gl_visual->depthBits > 0) {
+ if (v->mesa_visual.depthBits > 0) {
attribs[numAttribs++] = FXMESA_DEPTH_SIZE;
attribs[numAttribs++] = 1;
}
- if (v->gl_visual->doubleBufferMode) {
+ if (v->mesa_visual.doubleBufferMode) {
attribs[numAttribs++] = FXMESA_DOUBLEBUFFER;
}
- if (v->gl_visual->accumRedBits > 0) {
+ if (v->mesa_visual.accumRedBits > 0) {
attribs[numAttribs++] = FXMESA_ACCUM_SIZE;
- attribs[numAttribs++] = v->gl_visual->accumRedBits;
+ attribs[numAttribs++] = v->mesa_visual.accumRedBits;
}
- if (v->gl_visual->stencilBits > 0) {
+ if (v->mesa_visual.stencilBits > 0) {
attribs[numAttribs++] = FXMESA_STENCIL_SIZE;
- attribs[numAttribs++] = v->gl_visual->stencilBits;
+ attribs[numAttribs++] = v->mesa_visual.stencilBits;
}
- if (v->gl_visual->alphaBits > 0) {
+ if (v->mesa_visual.alphaBits > 0) {
attribs[numAttribs++] = FXMESA_ALPHA_SIZE;
attribs[numAttribs++] = 1;
}
b->cmap = cmap;
/* determine back buffer implementation */
- if (v->gl_visual->doubleBufferMode) {
+ if (v->mesa_visual.doubleBufferMode) {
if (v->ximage_flag) {
b->db_state = BACK_XIMAGE;
}
b->db_state = 0;
}
- b->gl_buffer = _mesa_create_framebuffer( v->gl_visual,
- v->gl_visual->depthBits > 0,
- v->gl_visual->stencilBits > 0,
- v->gl_visual->accumRedBits +
- v->gl_visual->accumGreenBits +
- v->gl_visual->accumBlueBits > 0,
- v->gl_visual->alphaBits > 0 );
- if (!b->gl_buffer) {
- free_xmesa_buffer(client, b);
- return NULL;
- }
+ _mesa_initialize_framebuffer(&b->mesa_buffer,
+ &v->mesa_visual,
+ v->mesa_visual.depthBits > 0,
+ v->mesa_visual.stencilBits > 0,
+ v->mesa_visual.accumRedBits +
+ v->mesa_visual.accumGreenBits +
+ v->mesa_visual.accumBlueBits > 0,
+ v->mesa_visual.alphaBits > 0 );
- if (!initialize_visual_and_buffer(client, v, b, v->gl_visual->rgbMode,
+ if (!initialize_visual_and_buffer(client, v, b, v->mesa_visual.rgbMode,
(XMesaDrawable)p, cmap)) {
- _mesa_destroy_framebuffer( b->gl_buffer );
free_xmesa_buffer(client, b);
return NULL;
}
if (b->xm_context)
b->xm_context->xm_buffer = NULL;
- _mesa_destroy_framebuffer( b->gl_buffer );
free_xmesa_buffer(client, b);
}
c->xm_read_buffer = readBuffer;
c->use_read_buffer = (drawBuffer != readBuffer);
- _mesa_make_current2(c->gl_ctx, drawBuffer->gl_buffer, readBuffer->gl_buffer);
+ _mesa_make_current2(c->gl_ctx,
+ &drawBuffer->mesa_buffer,
+ &readBuffer->mesa_buffer);
if (c->gl_ctx->Viewport.Width == 0) {
/* initialize viewport to window size */
c->gl_ctx->Scissor.Height = drawBuffer->height;
}
- if (c->xm_visual->gl_visual->rgbMode) {
+ if (c->xm_visual->mesa_visual.rgbMode) {
/*
* Must recompute and set these pixel values because colormap
* can be different for different windows.
{
if (c) {
if (c->gl_ctx != _mesa_get_current_context()) {
- _mesa_make_current(c->gl_ctx, c->xm_buffer->gl_buffer);
+ _mesa_make_current(c->gl_ctx, &c->xm_buffer->mesa_buffer);
}
}
else {
GLboolean XMesaGetDepthBuffer( XMesaBuffer b, GLint *width, GLint *height,
GLint *bytesPerValue, void **buffer )
{
- if ((!b->gl_buffer) || (!b->gl_buffer->DepthBuffer)) {
+ if (!b->mesa_buffer.DepthBuffer) {
*width = 0;
*height = 0;
*bytesPerValue = 0;
return GL_FALSE;
}
else {
- *width = b->gl_buffer->Width;
- *height = b->gl_buffer->Height;
+ *width = b->mesa_buffer.Width;
+ *height = b->mesa_buffer.Height;
*bytesPerValue = sizeof(GLdepth);
- *buffer = b->gl_buffer->DepthBuffer;
+ *buffer = b->mesa_buffer.DepthBuffer;
return GL_TRUE;
}
}