summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.org.uk>2009-09-20 18:27:33 +0100
committerThomas White <taw@bitwiz.org.uk>2009-09-20 18:28:53 +0100
commit8d9d4912284a4a057a667585e8ef71cf93a95f8b (patch)
tree5b4cc69d3cf2a816820f10f4393cf3c89216be36
parent91b25dd237781d76280968017cf66141674aed12 (diff)
Use correct colour for glClear()
-rw-r--r--src/mesa/drivers/dri/glamo/glamo_context.h7
-rw-r--r--src/mesa/drivers/dri/glamo/glamo_state.c22
2 files changed, 19 insertions, 10 deletions
diff --git a/src/mesa/drivers/dri/glamo/glamo_context.h b/src/mesa/drivers/dri/glamo/glamo_context.h
index ed4f525a8a..d02041d205 100644
--- a/src/mesa/drivers/dri/glamo/glamo_context.h
+++ b/src/mesa/drivers/dri/glamo/glamo_context.h
@@ -65,6 +65,8 @@ struct glamo_context {
unsigned int count; /**< Number of vertices */
} prim;
+ uint16_t col_clear;
+
};
#define GLAMO_CONTEXT(ctx) ((glamoContextPtr)(ctx->DriverCtx))
@@ -80,4 +82,9 @@ extern GLboolean glamoUnbindContext(__DRIcontext *driContextPriv);
extern void glamo_update_renderbuffers(__DRIcontext *context,
__DRIdrawable *drawable);
+#define GLAMO_PACKCOLOR565(r, g, b) \
+ ((((r) & 0xf8) << 8) \
+ | (((g) & 0xfc) << 3) \
+ | (((b) & 0xf8) >> 3))
+
#endif /* __GLAMO_CONTEXT_H */
diff --git a/src/mesa/drivers/dri/glamo/glamo_state.c b/src/mesa/drivers/dri/glamo/glamo_state.c
index d7bbf1c3fd..e93bc71a1c 100644
--- a/src/mesa/drivers/dri/glamo/glamo_state.c
+++ b/src/mesa/drivers/dri/glamo/glamo_state.c
@@ -110,7 +110,7 @@ static void glamoClear(GLcontext *ctx, GLbitfield mask)
grb->pitch & 0x7ff);
glamoDRMAddCommand(gCtx, GLAMO_REG_2D_DST_HEIGHT,
grb->height);
- glamoDRMAddCommand(gCtx, GLAMO_REG_2D_PAT_FG, 0xabcd);
+ glamoDRMAddCommand(gCtx, GLAMO_REG_2D_PAT_FG, gCtx->col_clear);
glamoDRMAddCommand(gCtx, GLAMO_REG_2D_COMMAND2, 0xf0 << 8);
glamoDRMAddCommand(gCtx, GLAMO_REG_2D_DST_X, fb->_Xmin);
glamoDRMAddCommand(gCtx, GLAMO_REG_2D_DST_Y, fb->_Ymin);
@@ -120,15 +120,6 @@ static void glamoClear(GLcontext *ctx, GLbitfield mask)
fb->_Ymax-fb->_Ymin);
glamoDRMAddCommand(gCtx, GLAMO_REG_2D_COMMAND3, 0);
- glamoDRMAddCommand(gCtx, GLAMO_REG_2D_PAT_FG, 0x1234);
- glamoDRMAddCommand(gCtx, GLAMO_REG_2D_DST_X, fb->_Xmin+1);
- glamoDRMAddCommand(gCtx, GLAMO_REG_2D_DST_Y, fb->_Ymin+1);
- glamoDRMAddCommand(gCtx, GLAMO_REG_2D_RECT_WIDTH,
- fb->_Xmax-fb->_Xmin-2);
- glamoDRMAddCommand(gCtx, GLAMO_REG_2D_RECT_HEIGHT,
- fb->_Ymax-fb->_Ymin-2);
- glamoDRMAddCommand(gCtx, GLAMO_REG_2D_COMMAND3, 0);
-
}
glamoDRMDispatch(gCtx);
@@ -137,8 +128,19 @@ static void glamoClear(GLcontext *ctx, GLbitfield mask)
static void glamoClearColor(GLcontext *ctx, const GLfloat color[4])
{
+ struct glamo_context *gCtx = GLAMO_CONTEXT(ctx);
+ GLubyte col_byte[4];
+
printf("glamoClearColor (%f %f %f %f)\n", color[0], color[1], color[2],
color[3]); fflush(stdout);
+
+ CLAMPED_FLOAT_TO_UBYTE(col_byte[0], color[0]);
+ CLAMPED_FLOAT_TO_UBYTE(col_byte[1], color[1]);
+ CLAMPED_FLOAT_TO_UBYTE(col_byte[2], color[2]);
+ CLAMPED_FLOAT_TO_UBYTE(col_byte[3], color[3]);
+
+ gCtx->col_clear = GLAMO_PACKCOLOR565(col_byte[0], col_byte[1],
+ col_byte[2]);
}