- shaders for both lightmapped objects with or without albedo maps
[laserbrain_demo] / src / mesh.cc
index e17b909..6a1faa7 100644 (file)
@@ -4,6 +4,7 @@
 #include <assert.h>
 #include "opengl.h"
 #include "mesh.h"
+#include "logger.h"
 //#include "xform_node.h"
 
 #define USE_OLDGL
@@ -154,12 +155,12 @@ void Mesh::clear()
 float *Mesh::set_attrib_data(int attrib, int nelem, unsigned int num, const float *data)
 {
        if(attrib < 0 || attrib >= NUM_MESH_ATTR) {
-               fprintf(stderr, "%s: invalid attrib: %d\n", __FUNCTION__, attrib);
+               error_log("%s: invalid attrib: %d\n", __FUNCTION__, attrib);
                return 0;
        }
 
        if(nverts && num != nverts) {
-               fprintf(stderr, "%s: attribute count missmatch (%d instead of %d)\n", __FUNCTION__, num, nverts);
+               error_log("%s: attribute count missmatch (%d instead of %d)\n", __FUNCTION__, num, nverts);
                return 0;
        }
        nverts = num;
@@ -180,7 +181,7 @@ float *Mesh::set_attrib_data(int attrib, int nelem, unsigned int num, const floa
 float *Mesh::get_attrib_data(int attrib)
 {
        if(attrib < 0 || attrib >= NUM_MESH_ATTR) {
-               fprintf(stderr, "%s: invalid attrib: %d\n", __FUNCTION__, attrib);
+               error_log("%s: invalid attrib: %d\n", __FUNCTION__, attrib);
                return 0;
        }
 
@@ -191,17 +192,17 @@ float *Mesh::get_attrib_data(int attrib)
 const float *Mesh::get_attrib_data(int attrib) const
 {
        if(attrib < 0 || attrib >= NUM_MESH_ATTR) {
-               fprintf(stderr, "%s: invalid attrib: %d\n", __FUNCTION__, attrib);
+               error_log("%s: invalid attrib: %d\n", __FUNCTION__, attrib);
                return 0;
        }
 
        if(!vattr[attrib].data_valid) {
 #if GL_ES_VERSION_2_0
-               fprintf(stderr, "%s: can't read back attrib data on CrippledGL ES\n", __FUNCTION__);
+               error_log("%s: can't read back attrib data on CrippledGL ES\n", __FUNCTION__);
                return 0;
 #else
                if(!vattr[attrib].vbo_valid) {
-                       fprintf(stderr, "%s: unavailable attrib: %d\n", __FUNCTION__, attrib);
+                       error_log("%s: unavailable attrib: %d\n", __FUNCTION__, attrib);
                        return 0;
                }
 
@@ -255,7 +256,7 @@ unsigned int *Mesh::set_index_data(int num, const unsigned int *indices)
 {
        int nidx = nfaces * 3;
        if(nidx && num != nidx) {
-               fprintf(stderr, "%s: index count mismatch (%d instead of %d)\n", __FUNCTION__, num, nidx);
+               error_log("%s: index count mismatch (%d instead of %d)\n", __FUNCTION__, num, nidx);
                return 0;
        }
        nfaces = num / 3;
@@ -283,11 +284,11 @@ const unsigned int *Mesh::get_index_data() const
 {
        if(!idata_valid) {
 #if GL_ES_VERSION_2_0
-               fprintf(stderr, "%s: can't read back index data in CrippledGL ES\n", __FUNCTION__);
+               error_log("%s: can't read back index data in CrippledGL ES\n", __FUNCTION__);
                return 0;
 #else
                if(!ibo_valid) {
-                       fprintf(stderr, "%s: indices unavailable\n", __FUNCTION__);
+                       error_log("%s: indices unavailable\n", __FUNCTION__);
                        return 0;
                }
 
@@ -631,14 +632,14 @@ bool Mesh::pre_draw() const
        ((Mesh*)this)->update_buffers();
 
        if(!vattr[MESH_ATTR_VERTEX].vbo_valid) {
-               fprintf(stderr, "%s: invalid vertex buffer\n", __FUNCTION__);
+               error_log("%s: invalid vertex buffer\n", __FUNCTION__);
                return false;
        }
 
        if(cur_sdr && use_custom_sdr_attr) {
                // rendering with shaders
                if(global_sdr_loc[MESH_ATTR_VERTEX] == -1) {
-                       fprintf(stderr, "%s: shader attribute location for vertices unset\n", __FUNCTION__);
+                       error_log("%s: shader attribute location for vertices unset\n", __FUNCTION__);
                        return false;
                }