tavli
diff src/mesh.cc @ 1:3fcd7b4d631f
board mesh generation
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Mon, 22 Jun 2015 05:05:37 +0300 |
parents | 52e0dd47753b |
children | a0d30f6f20d4 |
line diff
1.1 --- a/src/mesh.cc Sun Jun 21 06:30:39 2015 +0300 1.2 +++ b/src/mesh.cc Mon Jun 22 05:05:37 2015 +0300 1.3 @@ -5,15 +5,16 @@ 1.4 #include "opengl.h" 1.5 #include "mesh.h" 1.6 //#include "xform_node.h" 1.7 -#include "shader.h" 1.8 1.9 -int Mesh::global_sdr_loc[NUM_MESH_ATTR] = { 1.10 +int Mesh::global_sdr_loc[NUM_MESH_ATTR] = { 0, 1, 2, 3, 4, 5, 6 }; 1.11 +/* 1.12 (int)SDR_ATTR_VERTEX, 1.13 (int)SDR_ATTR_NORMAL, 1.14 (int)SDR_ATTR_TANGENT, 1.15 (int)SDR_ATTR_TEXCOORD, 1.16 (int)SDR_ATTR_COLOR, 1.17 -1, -1}; 1.18 +*/ 1.19 unsigned int Mesh::intersect_mode = ISECT_DEFAULT; 1.20 float Mesh::vertex_sel_dist = 0.01; 1.21 float Mesh::vis_vecsize = 1.0; 1.22 @@ -555,12 +556,9 @@ 1.23 1.24 void Mesh::draw() const 1.25 { 1.26 -#ifdef GL_ES_VERSION_2_0 1.27 - if(!SdrProg::active) { 1.28 - fprintf(stderr, "%s: CrippledGL ES can't draw without a shader\n", __FUNCTION__); 1.29 - return; 1.30 - } 1.31 -#endif 1.32 + int cur_sdr; 1.33 + glGetIntegerv(GL_CURRENT_PROGRAM, &cur_sdr); 1.34 + 1.35 1.36 ((Mesh*)this)->update_buffers(); 1.37 1.38 @@ -569,7 +567,7 @@ 1.39 return; 1.40 } 1.41 1.42 - if(SdrProg::active) { 1.43 + if(cur_sdr) { 1.44 // rendering with shaders 1.45 if(global_sdr_loc[MESH_ATTR_VERTEX] == -1) { 1.46 fprintf(stderr, "%s: shader attribute location for vertices unset\n", __FUNCTION__); 1.47 @@ -618,7 +616,7 @@ 1.48 glDrawArrays(GL_TRIANGLES, 0, nverts); 1.49 } 1.50 1.51 - if(SdrProg::active) { 1.52 + if(cur_sdr) { 1.53 // rendered with shaders 1.54 for(int i=0; i<NUM_MESH_ATTR; i++) { 1.55 int loc = global_sdr_loc[i]; 1.56 @@ -1128,7 +1126,6 @@ 1.57 1.58 glDisableVertexAttribArray(vloc); 1.59 glDisableVertexAttribArray(nloc); 1.60 - CHECK_GLERROR; 1.61 } 1.62 1.63 void Triangle::draw_wire() const 1.64 @@ -1142,7 +1139,6 @@ 1.65 glDrawElements(GL_LINES, 6, GL_UNSIGNED_INT, idxarr); 1.66 1.67 glDisableVertexAttribArray(vloc); 1.68 - CHECK_GLERROR; 1.69 } 1.70 1.71 Vector3 Triangle::calc_barycentric(const Vector3 &pos) const