2 * Mesa 3-D graphics library
5 * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 #include "glxheader.h"
30 #include "renderbuffer.h"
34 xmesa_delete_renderbuffer(struct gl_renderbuffer
*rb
)
36 /* XXX Note: the ximage or Pixmap attached to this renderbuffer
37 * should probably get freed here, but that's currently done in
38 * XMesaDestroyBuffer().
45 * Reallocate renderbuffer storage for front color buffer.
48 xmesa_alloc_front_storage(GLcontext
*ctx
, struct gl_renderbuffer
*rb
,
49 GLenum internalFormat
, GLuint width
, GLuint height
)
51 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
53 /* just clear these to be sure we don't accidentally use them */
58 /* for the FLIP macro: */
59 xrb
->bottom
= height
- 1;
63 rb
->InternalFormat
= internalFormat
;
70 * Reallocate renderbuffer storage for back color buffer.
71 * XXX we should resize the back pixmap/ximage here.
74 xmesa_alloc_back_storage(GLcontext
*ctx
, struct gl_renderbuffer
*rb
,
75 GLenum internalFormat
, GLuint width
, GLuint height
)
77 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
79 /* same as front buffer */
80 (void) xmesa_alloc_front_storage(ctx
, rb
, internalFormat
, width
, height
);
84 /* Needed by PIXELADDR1 macro */
85 xrb
->width1
= xrb
->ximage
->bytes_per_line
;
86 xrb
->origin1
= (GLubyte
*) xrb
->ximage
->data
+ xrb
->width1
* (height
- 1);
88 /* Needed by PIXELADDR2 macro */
89 xrb
->width2
= xrb
->ximage
->bytes_per_line
/ 2;
90 xrb
->origin2
= (GLushort
*) xrb
->ximage
->data
+ xrb
->width2
* (height
- 1);
92 /* Needed by PIXELADDR3 macro */
93 xrb
->width3
= xrb
->ximage
->bytes_per_line
;
94 xrb
->origin3
= (GLubyte
*) xrb
->ximage
->data
+ xrb
->width3
* (height
- 1);
96 /* Needed by PIXELADDR4 macro */
97 xrb
->width4
= xrb
->ximage
->width
;
98 xrb
->origin4
= (GLuint
*) xrb
->ximage
->data
+ xrb
->width4
* (height
- 1);
101 /* this assertion will fail if we happend to run out of memory */
102 /*assert(xrb->pixmap);*/
109 struct xmesa_renderbuffer
*
110 xmesa_new_renderbuffer(GLcontext
*ctx
, GLuint name
, GLboolean rgbMode
,
111 GLboolean backBuffer
)
113 struct xmesa_renderbuffer
*xrb
= CALLOC_STRUCT(xmesa_renderbuffer
);
116 _mesa_init_renderbuffer(&xrb
->Base
, name
);
118 xrb
->Base
.Delete
= xmesa_delete_renderbuffer
;
120 xrb
->Base
.AllocStorage
= xmesa_alloc_back_storage
;
122 xrb
->Base
.AllocStorage
= xmesa_alloc_front_storage
;
125 xrb
->Base
.InternalFormat
= GL_RGBA
;
126 xrb
->Base
._BaseFormat
= GL_RGBA
;
127 xrb
->Base
.DataType
= GL_UNSIGNED_BYTE
;
130 xrb
->Base
.InternalFormat
= GL_COLOR_INDEX
;
131 xrb
->Base
._BaseFormat
= GL_COLOR_INDEX
;
132 xrb
->Base
.DataType
= GL_UNSIGNED_INT
;
134 /* only need to set Red/Green/EtcBits fields for user-created RBs */