* \return GL_TRUE=success, GL_FALSE=failure
*/
static GLboolean
-initialize_visual_and_buffer(int client, XMesaVisual v, XMesaBuffer b,
+initialize_visual_and_buffer(XMesaVisual v, XMesaBuffer b,
GLboolean rgb_flag, XMesaDrawable window,
XMesaColormap cmap)
{
+ int client = 0;
+
+#ifdef XFree86Server
+ client = (window) ? CLIENT_ID(window->id) : 0;
+#endif
+
ASSERT(!b || b->xm_visual == v);
/* Save true bits/pixel */
}
if (b && window) {
+ char *data;
+
/* Do window-specific initializations */
/* these should have been set in create_xmesa_buffer */
}
/* Initialize the row buffer XImage for use in write_color_span() */
+ data = (char*) MALLOC(MAX_WIDTH*4);
#ifdef XFree86Server
- b->rowimage = XMesaCreateImage(GET_VISUAL_DEPTH(v), MAX_WIDTH, 1,
- (char *)MALLOC(MAX_WIDTH*4));
+ b->rowimage = XMesaCreateImage(GET_VISUAL_DEPTH(v), MAX_WIDTH, 1, data);
#else
b->rowimage = XCreateImage( v->display,
v->visinfo->visual,
v->visinfo->depth,
ZPixmap, 0, /*format, offset*/
- (char*) MALLOC(MAX_WIDTH*4), /*data*/
+ data, /*data*/
MAX_WIDTH, 1, /*width, height*/
32, /*bitmap_pad*/
0 /*bytes_per_line*/ );
if (alpha_flag)
v->mesa_visual.alphaBits = 8;
- (void) initialize_visual_and_buffer( 0, v, NULL, rgb_flag, 0, 0 );
+ (void) initialize_visual_and_buffer( v, NULL, rgb_flag, 0, 0 );
{
const int xclass = v->mesa_visual.visualType;
#ifndef XFree86Server
XWindowAttributes attr;
#endif
- int client = 0;
XMesaBuffer b;
XMesaColormap cmap;
+ int depth;
assert(v);
assert(w);
/* Check that window depth matches visual depth */
#ifdef XFree86Server
- client = CLIENT_ID(((XMesaDrawable)w)->id);
-
- if (GET_VISUAL_DEPTH(v) != ((XMesaDrawable)w)->depth) {
- _mesa_warning(NULL, "XMesaCreateWindowBuffer: depth mismatch between visual (%d) and window (%d)!\n",
- GET_VISUAL_DEPTH(v), ((XMesaDrawable) w)->depth);
- return NULL;
- }
+ depth = ((XMesaDrawable)w)->depth;
#else
XGetWindowAttributes( v->display, w, &attr );
-
- if (GET_VISUAL_DEPTH(v) != attr.depth) {
+ depth = attr.depth;
+#endif
+ if (GET_VISUAL_DEPTH(v) != depth) {
_mesa_warning(NULL, "XMesaCreateWindowBuffer: depth mismatch between visual (%d) and window (%d)!\n",
- GET_VISUAL_DEPTH(v), attr.depth);
+ GET_VISUAL_DEPTH(v), depth);
return NULL;
}
-#endif
/* Find colormap */
#ifdef XFree86Server
if (!b)
return NULL;
- if (!initialize_visual_and_buffer( client, v, b, v->mesa_visual.rgbMode,
+ if (!initialize_visual_and_buffer( v, b, v->mesa_visual.rgbMode,
(XMesaDrawable) w, cmap )) {
xmesa_free_buffer(b);
return NULL;
PUBLIC XMesaBuffer
XMesaCreatePixmapBuffer(XMesaVisual v, XMesaPixmap p, XMesaColormap cmap)
{
- int client = 0;
XMesaBuffer b;
assert(v);
if (!b)
return NULL;
-#ifdef XFree86Server
- client = CLIENT_ID(((XMesaDrawable)p)->id);
-#endif
-
- if (!initialize_visual_and_buffer(client, v, b, v->mesa_visual.rgbMode,
+ if (!initialize_visual_and_buffer(v, b, v->mesa_visual.rgbMode,
(XMesaDrawable) p, cmap)) {
xmesa_free_buffer(b);
return NULL;
XMesaCreatePBuffer(XMesaVisual v, XMesaColormap cmap,
unsigned int width, unsigned int height)
{
-#ifdef XFree86Server
- return 0;
-#else
- int client = 0;
+#ifndef XFree86Server
XMesaWindow root;
XMesaDrawable drawable; /* X Pixmap Drawable */
XMesaBuffer b;
if (!b)
return NULL;
- if (!initialize_visual_and_buffer(client, v, b, v->mesa_visual.rgbMode,
+ if (!initialize_visual_and_buffer(v, b, v->mesa_visual.rgbMode,
drawable, cmap)) {
xmesa_free_buffer(b);
return NULL;
}
return b;
+#else
+ return 0;
#endif
}