From 3f5acfe7bbd0b739a0c6075897309ebc9d55a008 Mon Sep 17 00:00:00 2001 From: David Rose Date: Sat, 3 May 2008 01:39:56 +0000 Subject: [PATCH] tweaks --- .../tinydisplay/tinyGraphicsStateGuardian.cxx | 18 +++++++++++++++++- panda/src/tinydisplay/zbuffer.h | 12 ++++++------ 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx b/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx index c5380d20cb..ba032dad49 100644 --- a/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx +++ b/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx @@ -21,6 +21,7 @@ #include "tinyTextureContext.h" #include "config_tinydisplay.h" #include "pStatTimer.h" +#include "geomVertexReader.h" extern "C" { #include "zgl.h" @@ -202,6 +203,7 @@ reset() { _color_scale_via_lighting = false; _alpha_scale_via_texture = false; + _runtime_color_scale = true; // Now that the GSG has been initialized, make it available for // optimizations. @@ -578,7 +580,6 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader, if (!needs_color) { if (_has_scene_graph_color) { - cerr << "sg color\n"; const Colorf &d = _scene_graph_color; _c->current_color.X = d[0]; _c->current_color.Y = d[1]; @@ -603,6 +604,21 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader, GeomVertexReader rvertex(data_reader, InternalName::get_vertex()); rvertex.set_row(_min_vertex); + if (!needs_color) { + if (_c->color_material_enabled) { + float *d = _c->current_color.v; + GLParam q[7]; + q[0].op = OP_Material; + q[1].i = _c->current_color_material_mode; + q[2].i = _c->current_color_material_type; + q[3].f = d[0]; + q[4].f = d[1]; + q[5].f = d[2]; + q[6].f = d[3]; + glopMaterial(_c, q); + } + } + for (i = 0; i < num_used_vertices; ++i) { GLVertex *v = &_vertices[i]; const LVecBase4f &d = rvertex.get_data4f(); diff --git a/panda/src/tinydisplay/zbuffer.h b/panda/src/tinydisplay/zbuffer.h index 60c6f63775..9c74eaf756 100644 --- a/panda/src/tinydisplay/zbuffer.h +++ b/panda/src/tinydisplay/zbuffer.h @@ -33,13 +33,13 @@ #define ZB_NB_COLORS 225 /* number of colors for 8 bit display */ #define RGB_TO_PIXEL(r,g,b) \ - ((((r) << 8) & 0xff0000) | ((g) & 0xff00) | ((b) >> 8)) + ((((unsigned int)(r) << 8) & 0xff0000) | ((unsigned int)(g) & 0xff00) | ((unsigned int)(b) >> 8)) #define RGBA_TO_PIXEL(r,g,b,a) \ - ((((a) << 16) & 0xff000000) | (((r) << 8) & 0xff0000) | ((g) & 0xff00) | ((b) >> 8)) -#define PIXEL_R(p) (((p) & 0xff0000) >> 8) -#define PIXEL_G(p) ((p) & 0xff00) -#define PIXEL_B(p) (((p) & 0x00ff) << 8) -#define PIXEL_A(p) (((p) & 0xff000000) >> 16) + ((((unsigned int)(a) << 16) & 0xff000000) | (((unsigned int)(r) << 8) & 0xff0000) | ((unsigned int)(g) & 0xff00) | ((unsigned int)(b) >> 8)) +#define PIXEL_R(p) (((unsigned int)(p) & 0xff0000) >> 8) +#define PIXEL_G(p) ((unsigned int)(p) & 0xff00) +#define PIXEL_B(p) (((unsigned int)(p) & 0x00ff) << 8) +#define PIXEL_A(p) (((unsigned int)(p) & 0xff000000) >> 16) typedef unsigned int PIXEL; #define PSZB 4 #define PSZSH 5