Browse Source

Fix double-precision build blibli

rdb 10 years ago
parent
commit
f22cc71995

+ 1 - 5
panda/src/glesgsg/glesgsg.h

@@ -23,13 +23,9 @@
 
 
 #define GLP(name) gl##name
 #define GLP(name) gl##name
 
 
-#ifndef STDFLOAT_DOUBLE
+// OpenGL ES does not support double-precision.
 #define GLPf(name) gl ## name ## f
 #define GLPf(name) gl ## name ## f
 #define GLPfv(name) gl ## name ## fv
 #define GLPfv(name) gl ## name ## fv
-#else  // STDFLOAT_DOUBLE
-#define GLPf(name) gl ## name ## d
-#define GLPfv(name) gl ## name ## dv
-#endif  // STDFLOAT_DOUBLE
 
 
 #define CLP(name) GLES##name
 #define CLP(name) GLES##name
 #define GLPREFIX_QUOTED "gl"
 #define GLPREFIX_QUOTED "gl"

+ 19 - 0
panda/src/glstuff/glGraphicsStateGuardian_src.I

@@ -644,6 +644,25 @@ clear_color_write_mask() {
   }
   }
 }
 }
 
 
+#ifdef SUPPORT_FIXED_FUNCTION
+////////////////////////////////////////////////////////////////////
+//     Function: GLGraphicsStateGuardian::call_glLoadMatrix
+//       Access: Public
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE void CLP(GraphicsStateGuardian)::
+call_glLoadMatrix(const LMatrix4 &mat) {
+#if defined(OPENGLES) && defined(STDFLOAT_DOUBLE)
+  LMatrix4f matf = LCAST(float, mat);
+  glLoadMatrixf(matf.get_data());
+#elif defined(STDFLOAT_DOUBLE)
+  glLoadMatrixd(mat.get_data());
+#else
+  glLoadMatrixf(mat.get_data());
+#endif
+}
+#endif
+
 #ifdef SUPPORT_FIXED_FUNCTION
 #ifdef SUPPORT_FIXED_FUNCTION
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: GLGraphicsStateGuardian::call_glFogfv
 //     Function: GLGraphicsStateGuardian::call_glFogfv

+ 18 - 10
panda/src/glstuff/glGraphicsStateGuardian_src.cxx

@@ -112,6 +112,14 @@ null_glDrawRangeElements(GLenum mode, GLuint start, GLuint end,
 }
 }
 #endif
 #endif
 
 
+#if defined(OPENGLES) && !defined(OPENGLES_1)
+static void APIENTRY
+null_glVertexAttrib4dv(GLuint index, const GLdouble *v) {
+  GLfloat vf[4] = {(GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2], (GLfloat)v[3]};
+  glVertexAttrib4fv(index, vf);
+}
+#endif
+
 static void APIENTRY
 static void APIENTRY
 null_glActiveTexture(GLenum gl_texture_stage) {
 null_glActiveTexture(GLenum gl_texture_stage) {
   // If we don't support multitexture, we'd better not try to request
   // If we don't support multitexture, we'd better not try to request
@@ -1521,7 +1529,7 @@ reset() {
   _glUniformMatrix4fv = glUniformMatrix4fv;
   _glUniformMatrix4fv = glUniformMatrix4fv;
   _glValidateProgram = glValidateProgram;
   _glValidateProgram = glValidateProgram;
   _glVertexAttrib4fv = glVertexAttrib4fv;
   _glVertexAttrib4fv = glVertexAttrib4fv;
-  _glVertexAttrib4dv = NULL;
+  _glVertexAttrib4dv = null_glVertexAttrib4dv;
   _glVertexAttribPointer = glVertexAttribPointer;
   _glVertexAttribPointer = glVertexAttribPointer;
   _glVertexAttribIPointer = NULL;
   _glVertexAttribIPointer = NULL;
   _glVertexAttribLPointer = NULL;
   _glVertexAttribLPointer = NULL;
@@ -3003,7 +3011,7 @@ prepare_lens() {
   }
   }
 
 
   glMatrixMode(GL_PROJECTION);
   glMatrixMode(GL_PROJECTION);
-  GLPf(LoadMatrix)(_projection_mat->get_mat().get_data());
+  call_glLoadMatrix(_projection_mat->get_mat());
   report_my_gl_errors();
   report_my_gl_errors();
 
 
   do_point_size();
   do_point_size();
@@ -4373,7 +4381,7 @@ end_draw_primitives() {
 #ifdef SUPPORT_FIXED_FUNCTION
 #ifdef SUPPORT_FIXED_FUNCTION
   if (_transform_stale) {
   if (_transform_stale) {
     glMatrixMode(GL_MODELVIEW);
     glMatrixMode(GL_MODELVIEW);
-    GLPf(LoadMatrix)(_internal_transform->get_mat().get_data());
+    call_glLoadMatrix(_internal_transform->get_mat());
   }
   }
 
 
   if (_data_reader->is_vertex_transformed()) {
   if (_data_reader->is_vertex_transformed()) {
@@ -5854,7 +5862,7 @@ do_issue_transform() {
 
 
   DO_PSTATS_STUFF(_transform_state_pcollector.add_level(1));
   DO_PSTATS_STUFF(_transform_state_pcollector.add_level(1));
   glMatrixMode(GL_MODELVIEW);
   glMatrixMode(GL_MODELVIEW);
-  GLPf(LoadMatrix)(transform->get_mat().get_data());
+  call_glLoadMatrix(transform->get_mat());
 #endif
 #endif
   _transform_stale = false;
   _transform_stale = false;
 
 
@@ -9083,7 +9091,7 @@ begin_bind_lights() {
 
 
   glMatrixMode(GL_MODELVIEW);
   glMatrixMode(GL_MODELVIEW);
   glPushMatrix();
   glPushMatrix();
-  GLPf(LoadMatrix)(render_transform->get_mat().get_data());
+  call_glLoadMatrix(render_transform->get_mat());
 }
 }
 #endif  // SUPPORT_FIXED_FUNCTION
 #endif  // SUPPORT_FIXED_FUNCTION
 
 
@@ -9153,7 +9161,7 @@ begin_bind_clip_planes() {
 
 
   glMatrixMode(GL_MODELVIEW);
   glMatrixMode(GL_MODELVIEW);
   glPushMatrix();
   glPushMatrix();
-  GLPf(LoadMatrix)(render_transform->get_mat().get_data());
+  call_glLoadMatrix(render_transform->get_mat());
 }
 }
 #endif  // SUPPORT_FIXED_FUNCTION
 #endif  // SUPPORT_FIXED_FUNCTION
 
 
@@ -10062,7 +10070,7 @@ do_issue_tex_matrix() {
     _target_rs->get_attrib_def(target_tex_matrix);
     _target_rs->get_attrib_def(target_tex_matrix);
 
 
     if (target_tex_matrix->has_stage(stage)) {
     if (target_tex_matrix->has_stage(stage)) {
-      GLPf(LoadMatrix)(target_tex_matrix->get_mat(stage).get_data());
+      call_glLoadMatrix(target_tex_matrix->get_mat(stage));
     } else {
     } else {
       glLoadIdentity();
       glLoadIdentity();
 
 
@@ -10072,7 +10080,7 @@ do_issue_tex_matrix() {
       // an identity matrix does work.  But this buggy-driver
       // an identity matrix does work.  But this buggy-driver
       // workaround might have other performance implications, so I
       // workaround might have other performance implications, so I
       // leave it out.
       // leave it out.
-      // GLPf(LoadMatrix)(LMatrix4::ident_mat().get_data());
+      // call_glLoadMatrix(LMatrix4::ident_mat());
     }
     }
   }
   }
   report_my_gl_errors();
   report_my_gl_errors();
@@ -10247,7 +10255,7 @@ do_issue_tex_gen() {
       // load the coordinate-system transform.
       // load the coordinate-system transform.
       glMatrixMode(GL_MODELVIEW);
       glMatrixMode(GL_MODELVIEW);
       glPushMatrix();
       glPushMatrix();
-      GLPf(LoadMatrix)(_cs_transform->get_mat().get_data());
+      call_glLoadMatrix(_cs_transform->get_mat());
 
 
       glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
       glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
       glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
       glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
@@ -10276,7 +10284,7 @@ do_issue_tex_gen() {
         glMatrixMode(GL_MODELVIEW);
         glMatrixMode(GL_MODELVIEW);
         glPushMatrix();
         glPushMatrix();
         CPT(TransformState) root_transform = _cs_transform->compose(_scene_setup->get_world_transform());
         CPT(TransformState) root_transform = _cs_transform->compose(_scene_setup->get_world_transform());
-        GLPf(LoadMatrix)(root_transform->get_mat().get_data());
+        call_glLoadMatrix(root_transform->get_mat());
         glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
         glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
         glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
         glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
         glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
         glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);

+ 1 - 0
panda/src/glstuff/glGraphicsStateGuardian_src.h

@@ -472,6 +472,7 @@ protected:
   INLINE void clear_color_write_mask();
   INLINE void clear_color_write_mask();
 
 
 #ifdef SUPPORT_FIXED_FUNCTION
 #ifdef SUPPORT_FIXED_FUNCTION
+  INLINE void call_glLoadMatrix(const LMatrix4 &mat);
   INLINE void call_glFogfv(GLenum pname, const LColor &color);
   INLINE void call_glFogfv(GLenum pname, const LColor &color);
   INLINE void call_glMaterialfv(GLenum face, GLenum pname, const LColor &color);
   INLINE void call_glMaterialfv(GLenum face, GLenum pname, const LColor &color);
   INLINE void call_glLightfv(GLenum light, GLenum pname, const LVecBase4 &value);
   INLINE void call_glLightfv(GLenum light, GLenum pname, const LVecBase4 &value);

+ 1 - 1
panda/src/glstuff/glShaderContext_src.cxx

@@ -1991,7 +1991,7 @@ update_shader_vertex_arrays(ShaderContext *prev, bool force) {
         }
         }
         if (p == _color_attrib_index) {
         if (p == _color_attrib_index) {
           // Vertex colors are disabled or not present.  Apply flat color.
           // Vertex colors are disabled or not present.  Apply flat color.
-#if defined(STDFLOAT_DOUBLE) && !defined(OPENGLES)
+#ifdef STDFLOAT_DOUBLE
           _glgsg->_glVertexAttrib4dv(p, color_attrib->get_color().get_data());
           _glgsg->_glVertexAttrib4dv(p, color_attrib->get_color().get_data());
 #else
 #else
           _glgsg->_glVertexAttrib4fv(p, color_attrib->get_color().get_data());
           _glgsg->_glVertexAttrib4fv(p, color_attrib->get_color().get_data());

+ 11 - 6
panda/src/pnmtext/pnmTextGlyph.cxx

@@ -55,6 +55,8 @@ place(PNMImage &dest_image, int xp, int yp, const LColor &fg) {
     return;
     return;
   }
   }
 
 
+  LColorf fgf = LCAST(float, fg);
+
   int left = xp + _left;
   int left = xp + _left;
   int top = yp - _top;
   int top = yp - _top;
   int right = left + _image.get_x_size();
   int right = left + _image.get_x_size();
@@ -70,11 +72,11 @@ place(PNMImage &dest_image, int xp, int yp, const LColor &fg) {
     for (int x = cleft; x < cright; x++) {
     for (int x = cleft; x < cright; x++) {
       double gval = get_value(x - left, y - top);
       double gval = get_value(x - left, y - top);
       if (gval == 1.0) {
       if (gval == 1.0) {
-        dest_image.set_xel_a(x, y, fg);
+        dest_image.set_xel_a(x, y, fgf);
 
 
       } else if (gval > 0.0) {
       } else if (gval > 0.0) {
         LColorf bg = dest_image.get_xel_a(x, y);
         LColorf bg = dest_image.get_xel_a(x, y);
-        dest_image.set_xel_a(x, y, fg * gval + bg * (1.0 - gval));
+        dest_image.set_xel_a(x, y, fgf * gval + bg * (1.0 - gval));
       }
       }
     }
     }
   }
   }
@@ -95,6 +97,9 @@ place(PNMImage &dest_image, int xp, int yp, const LColor &fg,
     return;
     return;
   }
   }
 
 
+  LColorf fgf = LCAST(float, fg);
+  LColorf interiorf = LCAST(float, interior);
+
   int left = xp + _left;
   int left = xp + _left;
   int top = yp - _top;
   int top = yp - _top;
   int right = left + _image.get_x_size();
   int right = left + _image.get_x_size();
@@ -110,22 +115,22 @@ place(PNMImage &dest_image, int xp, int yp, const LColor &fg,
     for (int x = cleft; x < cright; x++) {
     for (int x = cleft; x < cright; x++) {
       double gval = get_value(x - left, y - top);
       double gval = get_value(x - left, y - top);
       if (gval == 1.0) {
       if (gval == 1.0) {
-        dest_image.set_xel_a(x, y, fg);
+        dest_image.set_xel_a(x, y, fgf);
 
 
       } else if (gval > 0.0) {
       } else if (gval > 0.0) {
         bool is_interior = get_interior_flag(x - left, y - top);
         bool is_interior = get_interior_flag(x - left, y - top);
         LColorf bg;
         LColorf bg;
         if (is_interior) {
         if (is_interior) {
-          bg = interior;
+          bg = interiorf;
         } else {
         } else {
           bg = dest_image.get_xel_a(x, y);
           bg = dest_image.get_xel_a(x, y);
         }
         }
 
 
-        dest_image.set_xel_a(x, y, fg * gval + bg * (1.0 - gval));
+        dest_image.set_xel_a(x, y, fgf * gval + bg * (1.0 - gval));
       } else { // gval == 0.0
       } else { // gval == 0.0
         bool is_interior = get_interior_flag(x - left, y - top);
         bool is_interior = get_interior_flag(x - left, y - top);
         if (is_interior) {
         if (is_interior) {
-          dest_image.set_xel_a(x, y, interior);
+          dest_image.set_xel_a(x, y, interiorf);
         }
         }
       }
       }
     }
     }

+ 1 - 1
pandatool/src/assimp/assimpLoader.cxx

@@ -230,7 +230,7 @@ load_texture_stage(const aiMaterial &mat, const aiTextureType &ttype, CPT(Textur
   aiString path;
   aiString path;
   aiTextureMapping mapping;
   aiTextureMapping mapping;
   unsigned int uvindex;
   unsigned int uvindex;
-  PN_stdfloat blend;
+  float blend;
   aiTextureOp op;
   aiTextureOp op;
   aiTextureMapMode mapmode;
   aiTextureMapMode mapmode;