{
const OSMesaContext osmesa = OSMESA_CONTEXT(ctx);
+ /* Note: we can ignoring internalFormat for "window-system" renderbuffers */
if (osmesa->format == OSMESA_RGBA) {
rb->GetRow = get_row_RGBA;
rb->GetValues = get_values_RGBA;
rb->PutMonoRow = put_mono_row_RGBA;
rb->PutValues = put_values_RGBA;
rb->PutMonoValues = put_mono_values_RGBA;
+ rb->RedBits =
+ rb->GreenBits =
+ rb->BlueBits =
+ rb->AlphaBits = 8 * sizeof(GLchan);
}
else if (osmesa->format == OSMESA_BGRA) {
rb->GetRow = get_row_BGRA;
rb->PutMonoRow = put_mono_row_BGRA;
rb->PutValues = put_values_BGRA;
rb->PutMonoValues = put_mono_values_BGRA;
+ rb->RedBits =
+ rb->GreenBits =
+ rb->BlueBits =
+ rb->AlphaBits = 8 * sizeof(GLchan);
}
else if (osmesa->format == OSMESA_ARGB) {
rb->GetRow = get_row_ARGB;
rb->PutMonoRow = put_mono_row_ARGB;
rb->PutValues = put_values_ARGB;
rb->PutMonoValues = put_mono_values_ARGB;
+ rb->RedBits =
+ rb->GreenBits =
+ rb->BlueBits =
+ rb->AlphaBits = 8 * sizeof(GLchan);
}
else if (osmesa->format == OSMESA_RGB) {
rb->GetRow = get_row_RGB;
rb->PutMonoRow = put_mono_row_RGB;
rb->PutValues = put_values_RGB;
rb->PutMonoValues = put_mono_values_RGB;
+ rb->RedBits =
+ rb->GreenBits =
+ rb->BlueBits = 8 * sizeof(GLchan);
}
else if (osmesa->format == OSMESA_BGR) {
rb->GetRow = get_row_BGR;
rb->PutMonoRow = put_mono_row_BGR;
rb->PutValues = put_values_BGR;
rb->PutMonoValues = put_mono_values_BGR;
+ rb->RedBits =
+ rb->GreenBits =
+ rb->BlueBits = 8 * sizeof(GLchan);
}
#if CHAN_TYPE == GL_UNSIGNED_BYTE
else if (osmesa->format == OSMESA_RGB_565) {
rb->PutMonoRow = put_mono_row_RGB_565;
rb->PutValues = put_values_RGB_565;
rb->PutMonoValues = put_mono_values_RGB_565;
+ rb->RedBits = 5;
+ rb->GreenBits = 6;
+ rb->BlueBits = 5;
}
#endif
else if (osmesa->format == OSMESA_COLOR_INDEX) {
rb->PutMonoRow = put_mono_row_CI;
rb->PutValues = put_values_CI;
rb->PutMonoValues = put_mono_values_CI;
+ rb->IndexBits = 8;
}
else {
_mesa_problem(ctx, "bad pixel format in osmesa renderbuffer_storage");
#define FLIP(Y) (rb->Height - (Y) - 1)
-/* SINGLE BUFFER */
-
-/* These are slow, but work with all non-indexed visual types */
+/**
+ ** Front Buffer reading/writing
+ ** These are slow, but work with all non-indexed visual types.
+ **/
/* Write a horizontal span of RGBA color pixels with a boolean mask. */
-static void write_rgba_span_single(const GLcontext *ctx,
+static void write_rgba_span_front(const GLcontext *ctx,
struct gl_renderbuffer *rb,
GLuint n, GLint x, GLint y,
const GLubyte rgba[][4],
}
/* Write a horizontal span of RGB color pixels with a boolean mask. */
-static void write_rgb_span_single(const GLcontext *ctx,
+static void write_rgb_span_front(const GLcontext *ctx,
struct gl_renderbuffer *rb,
GLuint n, GLint x, GLint y,
const GLubyte rgb[][3],
* Write a horizontal span of pixels with a boolean mask. The current color
* is used for all pixels.
*/
-static void write_mono_rgba_span_single(const GLcontext *ctx,
+static void write_mono_rgba_span_front(const GLcontext *ctx,
struct gl_renderbuffer *rb,
GLuint n, GLint x, GLint y,
const GLchan color[4],
}
/* Write an array of RGBA pixels with a boolean mask. */
-static void write_rgba_pixels_single(const GLcontext *ctx,
+static void write_rgba_pixels_front(const GLcontext *ctx,
struct gl_renderbuffer *rb,
GLuint n,
const GLint x[], const GLint y[],
* Write an array of pixels with a boolean mask. The current color
* is used for all pixels.
*/
-static void write_mono_rgba_pixels_single(const GLcontext *ctx,
+static void write_mono_rgba_pixels_front(const GLcontext *ctx,
struct gl_renderbuffer *rb,
GLuint n,
const GLint x[], const GLint y[],
}
/* Read a horizontal span of color pixels. */
-static void read_rgba_span_single(const GLcontext *ctx,
+static void read_rgba_span_front(const GLcontext *ctx,
struct gl_renderbuffer *rb,
GLuint n, GLint x, GLint y,
GLubyte rgba[][4] )
/* Read an array of color pixels. */
-static void read_rgba_pixels_single(const GLcontext *ctx,
+static void read_rgba_pixels_front(const GLcontext *ctx,
struct gl_renderbuffer *rb,
GLuint n, const GLint x[], const GLint y[],
GLubyte rgba[][4])
return GL_TRUE;
}
+
+/**
+ * Plug in the Get/PutRow/Values functions for a renderbuffer depending
+ * on if we're drawing to the front or back color buffer.
+ */
void wmesa_set_renderbuffer_funcs(struct gl_renderbuffer *rb, int pixelformat,
int double_buffer)
{
if (double_buffer) {
+ /* back buffer */
/* Picking the correct span functions is important because
* the DIB was allocated with the indicated depth. */
switch(pixelformat) {
rb->PutMonoValues = write_mono_rgba_pixels_16;
rb->GetRow = read_rgba_span_16;
rb->GetValues = read_rgba_pixels_16;
+ rb->RedBits = 5;
+ rb->GreenBits = 6;
+ rb->BlueBits = 5;
break;
case PF_8R8G8B:
rb->PutRow = write_rgba_span_32;
rb->PutMonoValues = write_mono_rgba_pixels_32;
rb->GetRow = read_rgba_span_32;
rb->GetValues = read_rgba_pixels_32;
+ rb->RedBits = 8;
+ rb->GreenBits = 8;
+ rb->BlueBits = 8;
break;
default:
break;
}
}
- else { /* single buffer */
- rb->PutRow = write_rgba_span_single;
- rb->PutRowRGB = write_rgb_span_single;
- rb->PutMonoRow = write_mono_rgba_span_single;
- rb->PutValues = write_rgba_pixels_single;
- rb->PutMonoValues = write_mono_rgba_pixels_single;
- rb->GetRow = read_rgba_span_single;
- rb->GetValues = read_rgba_pixels_single;
+ else {
+ /* front buffer (actual Windows window) */
+ rb->PutRow = write_rgba_span_front;
+ rb->PutRowRGB = write_rgb_span_front;
+ rb->PutMonoRow = write_mono_rgba_span_front;
+ rb->PutValues = write_rgba_pixels_front;
+ rb->PutMonoValues = write_mono_rgba_pixels_front;
+ rb->GetRow = read_rgba_span_front;
+ rb->GetValues = read_rgba_pixels_front;
+ rb->RedBits = 8; /* XXX fix these (565?) */
+ rb->GreenBits = 8;
+ rb->BlueBits = 8;
}
}
pwfb = wmesa_new_framebuffer(hdc, visual);
/* need a color renderbuffer */
+ /* XXX we need to make two renderbuffers if double-buffering,
+ * one for front color buffer and one for the back.
+ */
rb = wmesa_new_renderbuffer();
if (c->db_flag)
_mesa_add_renderbuffer(&pwfb->Base, BUFFER_BACK_LEFT, rb);
struct xmesa_renderbuffer *
-xmesa_new_renderbuffer(GLcontext *ctx, GLuint name, GLboolean rgbMode,
+xmesa_new_renderbuffer(GLcontext *ctx, GLuint name, const GLvisual *visual,
GLboolean backBuffer)
{
struct xmesa_renderbuffer *xrb = CALLOC_STRUCT(xmesa_renderbuffer);
else
xrb->Base.AllocStorage = xmesa_alloc_front_storage;
- if (rgbMode) {
+ if (visual->rgbMode) {
xrb->Base.InternalFormat = GL_RGBA;
xrb->Base._BaseFormat = GL_RGBA;
xrb->Base.DataType = GL_UNSIGNED_BYTE;
+ xrb->Base.RedBits = visual->redBits;
+ xrb->Base.GreenBits = visual->greenBits;
+ xrb->Base.BlueBits = visual->blueBits;
+ xrb->Base.AlphaBits = visual->alphaBits;
}
else {
xrb->Base.InternalFormat = GL_COLOR_INDEX;
xrb->Base._BaseFormat = GL_COLOR_INDEX;
xrb->Base.DataType = GL_UNSIGNED_INT;
+ xrb->Base.IndexBits = visual->indexBits;
}
/* only need to set Red/Green/EtcBits fields for user-created RBs */
}