David Rose 17 years ago
parent
commit
3f5acfe7bb

+ 17 - 1
panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx

@@ -21,6 +21,7 @@
 #include "tinyTextureContext.h"
 #include "tinyTextureContext.h"
 #include "config_tinydisplay.h"
 #include "config_tinydisplay.h"
 #include "pStatTimer.h"
 #include "pStatTimer.h"
+#include "geomVertexReader.h"
 
 
 extern "C" {
 extern "C" {
 #include "zgl.h"
 #include "zgl.h"
@@ -202,6 +203,7 @@ reset() {
 
 
   _color_scale_via_lighting = false;
   _color_scale_via_lighting = false;
   _alpha_scale_via_texture = false;
   _alpha_scale_via_texture = false;
+  _runtime_color_scale = true;
 
 
   // Now that the GSG has been initialized, make it available for
   // Now that the GSG has been initialized, make it available for
   // optimizations.
   // optimizations.
@@ -578,7 +580,6 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader,
 
 
   if (!needs_color) {
   if (!needs_color) {
     if (_has_scene_graph_color) {
     if (_has_scene_graph_color) {
-      cerr << "sg color\n";
       const Colorf &d = _scene_graph_color;
       const Colorf &d = _scene_graph_color;
       _c->current_color.X = d[0];
       _c->current_color.X = d[0];
       _c->current_color.Y = d[1];
       _c->current_color.Y = d[1];
@@ -603,6 +604,21 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader,
   GeomVertexReader rvertex(data_reader, InternalName::get_vertex()); 
   GeomVertexReader rvertex(data_reader, InternalName::get_vertex()); 
   rvertex.set_row(_min_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) {
   for (i = 0; i < num_used_vertices; ++i) {
     GLVertex *v = &_vertices[i];
     GLVertex *v = &_vertices[i];
     const LVecBase4f &d = rvertex.get_data4f();
     const LVecBase4f &d = rvertex.get_data4f();

+ 6 - 6
panda/src/tinydisplay/zbuffer.h

@@ -33,13 +33,13 @@
 #define ZB_NB_COLORS    225 /* number of colors for 8 bit display */
 #define ZB_NB_COLORS    225 /* number of colors for 8 bit display */
 
 
 #define RGB_TO_PIXEL(r,g,b) \
 #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)                                   \
 #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;
 typedef unsigned int PIXEL;
 #define PSZB 4
 #define PSZB 4
 #define PSZSH 5
 #define PSZSH 5