Fix double-precision build blibli

This commit is contained in:
rdb 2015-07-29 14:07:06 +02:00
parent 64144955a0
commit f22cc71995
7 changed files with 52 additions and 23 deletions

View File

@ -23,13 +23,9 @@
#define GLP(name) gl##name
#ifndef STDFLOAT_DOUBLE
// OpenGL ES does not support double-precision.
#define GLPf(name) gl ## name ## f
#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 GLPREFIX_QUOTED "gl"

View File

@ -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
////////////////////////////////////////////////////////////////////
// Function: GLGraphicsStateGuardian::call_glFogfv

View File

@ -112,6 +112,14 @@ null_glDrawRangeElements(GLenum mode, GLuint start, GLuint end,
}
#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
null_glActiveTexture(GLenum gl_texture_stage) {
// If we don't support multitexture, we'd better not try to request
@ -1521,7 +1529,7 @@ reset() {
_glUniformMatrix4fv = glUniformMatrix4fv;
_glValidateProgram = glValidateProgram;
_glVertexAttrib4fv = glVertexAttrib4fv;
_glVertexAttrib4dv = NULL;
_glVertexAttrib4dv = null_glVertexAttrib4dv;
_glVertexAttribPointer = glVertexAttribPointer;
_glVertexAttribIPointer = NULL;
_glVertexAttribLPointer = NULL;
@ -3003,7 +3011,7 @@ prepare_lens() {
}
glMatrixMode(GL_PROJECTION);
GLPf(LoadMatrix)(_projection_mat->get_mat().get_data());
call_glLoadMatrix(_projection_mat->get_mat());
report_my_gl_errors();
do_point_size();
@ -4373,7 +4381,7 @@ end_draw_primitives() {
#ifdef SUPPORT_FIXED_FUNCTION
if (_transform_stale) {
glMatrixMode(GL_MODELVIEW);
GLPf(LoadMatrix)(_internal_transform->get_mat().get_data());
call_glLoadMatrix(_internal_transform->get_mat());
}
if (_data_reader->is_vertex_transformed()) {
@ -5854,7 +5862,7 @@ do_issue_transform() {
DO_PSTATS_STUFF(_transform_state_pcollector.add_level(1));
glMatrixMode(GL_MODELVIEW);
GLPf(LoadMatrix)(transform->get_mat().get_data());
call_glLoadMatrix(transform->get_mat());
#endif
_transform_stale = false;
@ -9083,7 +9091,7 @@ begin_bind_lights() {
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
GLPf(LoadMatrix)(render_transform->get_mat().get_data());
call_glLoadMatrix(render_transform->get_mat());
}
#endif // SUPPORT_FIXED_FUNCTION
@ -9153,7 +9161,7 @@ begin_bind_clip_planes() {
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
GLPf(LoadMatrix)(render_transform->get_mat().get_data());
call_glLoadMatrix(render_transform->get_mat());
}
#endif // SUPPORT_FIXED_FUNCTION
@ -10062,7 +10070,7 @@ do_issue_tex_matrix() {
_target_rs->get_attrib_def(target_tex_matrix);
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 {
glLoadIdentity();
@ -10072,7 +10080,7 @@ do_issue_tex_matrix() {
// an identity matrix does work. But this buggy-driver
// workaround might have other performance implications, so I
// leave it out.
// GLPf(LoadMatrix)(LMatrix4::ident_mat().get_data());
// call_glLoadMatrix(LMatrix4::ident_mat());
}
}
report_my_gl_errors();
@ -10247,7 +10255,7 @@ do_issue_tex_gen() {
// load the coordinate-system transform.
glMatrixMode(GL_MODELVIEW);
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_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
@ -10276,7 +10284,7 @@ do_issue_tex_gen() {
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
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_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);

View File

@ -472,6 +472,7 @@ protected:
INLINE void clear_color_write_mask();
#ifdef SUPPORT_FIXED_FUNCTION
INLINE void call_glLoadMatrix(const LMatrix4 &mat);
INLINE void call_glFogfv(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);

View File

@ -1991,7 +1991,7 @@ update_shader_vertex_arrays(ShaderContext *prev, bool force) {
}
if (p == _color_attrib_index) {
// 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());
#else
_glgsg->_glVertexAttrib4fv(p, color_attrib->get_color().get_data());

View File

@ -55,6 +55,8 @@ place(PNMImage &dest_image, int xp, int yp, const LColor &fg) {
return;
}
LColorf fgf = LCAST(float, fg);
int left = xp + _left;
int top = yp - _top;
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++) {
double gval = get_value(x - left, y - top);
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) {
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;
}
LColorf fgf = LCAST(float, fg);
LColorf interiorf = LCAST(float, interior);
int left = xp + _left;
int top = yp - _top;
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++) {
double gval = get_value(x - left, y - top);
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) {
bool is_interior = get_interior_flag(x - left, y - top);
LColorf bg;
if (is_interior) {
bg = interior;
bg = interiorf;
} else {
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
bool is_interior = get_interior_flag(x - left, y - top);
if (is_interior) {
dest_image.set_xel_a(x, y, interior);
dest_image.set_xel_a(x, y, interiorf);
}
}
}

View File

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