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 this routine should really delete the attached ximage, etc. */
41 * Reallocate renderbuffer storage.
42 * This is called when the window's resized. It'll get called once for
43 * the front color renderbuffer and again for the back color renderbuffer.
46 xmesa_alloc_storage(GLcontext
*ctx
, struct gl_renderbuffer
*rb
,
47 GLenum internalFormat
, GLuint width
, GLuint height
)
49 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
52 /* Needed by PIXELADDR1 macro */
53 xrb
->width1
= xrb
->ximage
->bytes_per_line
;
54 xrb
->origin1
= (GLubyte
*) xrb
->ximage
->data
+ xrb
->width1
* (height
- 1);
56 /* Needed by PIXELADDR2 macro */
57 xrb
->width2
= xrb
->ximage
->bytes_per_line
/ 2;
58 xrb
->origin2
= (GLushort
*) xrb
->ximage
->data
+ xrb
->width2
* (height
- 1);
60 /* Needed by PIXELADDR3 macro */
61 xrb
->width3
= xrb
->ximage
->bytes_per_line
;
62 xrb
->origin3
= (GLubyte
*) xrb
->ximage
->data
+ xrb
->width3
* (height
- 1);
64 /* Needed by PIXELADDR4 macro */
65 xrb
->width4
= xrb
->ximage
->width
;
66 xrb
->origin4
= (GLuint
*) xrb
->ximage
->data
+ xrb
->width4
* (height
- 1);
72 /* for the FLIP macro: */
73 xrb
->bottom
= height
- 1;
77 rb
->InternalFormat
= internalFormat
;
83 struct xmesa_renderbuffer
*
84 xmesa_new_renderbuffer(GLcontext
*ctx
, GLuint name
, GLboolean rgbMode
)
86 struct xmesa_renderbuffer
*xrb
= CALLOC_STRUCT(xmesa_renderbuffer
);
89 _mesa_init_renderbuffer(&xrb
->Base
, name
);
91 xrb
->Base
.Delete
= xmesa_delete_renderbuffer
;
92 xrb
->Base
.AllocStorage
= xmesa_alloc_storage
;
95 xrb
->Base
.InternalFormat
= GL_RGBA
;
96 xrb
->Base
._BaseFormat
= GL_RGBA
;
97 xrb
->Base
.DataType
= GL_UNSIGNED_BYTE
;
100 xrb
->Base
.InternalFormat
= GL_COLOR_INDEX
;
101 xrb
->Base
._BaseFormat
= GL_COLOR_INDEX
;
102 xrb
->Base
.DataType
= GL_UNSIGNED_INT
;
104 xrb
->Base
.ComponentSizes
[0] = 0; /* XXX fix? */