X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Ffg_geometry.c;h=312acfc9095050befbcb327f27e5787a16433110;hb=b74f83d18107d99e535dcc5934e282db069bdaef;hp=e589d4c2ed77be693bf05fa22f22e18af27e95d8;hpb=18b98d967eff786c89bfeed8e1f636f686bb1b10;p=freeglut diff --git a/src/fg_geometry.c b/src/fg_geometry.c index e589d4c..312acfc 100644 --- a/src/fg_geometry.c +++ b/src/fg_geometry.c @@ -28,6 +28,7 @@ #include #include "fg_internal.h" #include "fg_gl2.h" +#include /* * Need more types of polyhedra? See CPolyhedron in MRPT @@ -71,24 +72,26 @@ static void fghDrawGeometryWire20(GLfloat *vertices, GLfloat *normals, GLsizei n { GLuint vbo_coords, vbo_normals; GLuint numVertices = numFaces * numEdgePerFace; - + + int i; + if (numVertices > 0 && attribute_v_coord != -1) { fghGenBuffers(1, &vbo_coords); - fghBindBuffer(GL_ARRAY_BUFFER, vbo_coords); - fghBufferData(GL_ARRAY_BUFFER, numVertices * 3 * sizeof(vertices[0]), - vertices, GL_STATIC_DRAW); + fghBindBuffer(FGH_ARRAY_BUFFER, vbo_coords); + fghBufferData(FGH_ARRAY_BUFFER, numVertices * 3 * sizeof(vertices[0]), + vertices, FGH_STATIC_DRAW); } if (numVertices > 0 && attribute_v_normal != -1) { fghGenBuffers(1, &vbo_normals); - fghBindBuffer(GL_ARRAY_BUFFER, vbo_normals); - fghBufferData(GL_ARRAY_BUFFER, numVertices * 3 * sizeof(normals[0]), - normals, GL_STATIC_DRAW); + fghBindBuffer(FGH_ARRAY_BUFFER, vbo_normals); + fghBufferData(FGH_ARRAY_BUFFER, numVertices * 3 * sizeof(normals[0]), + normals, FGH_STATIC_DRAW); } if (vbo_coords) { fghEnableVertexAttribArray(attribute_v_coord); - fghBindBuffer(GL_ARRAY_BUFFER, vbo_coords); + fghBindBuffer(FGH_ARRAY_BUFFER, vbo_coords); fghVertexAttribPointer( attribute_v_coord, // attribute 3, // number of elements per vertex, here (x,y,z) @@ -101,7 +104,7 @@ static void fghDrawGeometryWire20(GLfloat *vertices, GLfloat *normals, GLsizei n if (vbo_normals) { fghEnableVertexAttribArray(attribute_v_normal); - fghBindBuffer(GL_ARRAY_BUFFER, vbo_normals); + fghBindBuffer(FGH_ARRAY_BUFFER, vbo_normals); fghVertexAttribPointer( attribute_v_normal, // attribute 3, // number of elements per vertex, here (x,y,z) @@ -112,9 +115,6 @@ static void fghDrawGeometryWire20(GLfloat *vertices, GLfloat *normals, GLsizei n ); } - - int i; - /* Draw per face (TODO: could use glMultiDrawArrays if available) */ for (i=0; i 0 && attribute_v_coord != -1) { fghGenBuffers(1, &vbo_coords); - fghBindBuffer(GL_ARRAY_BUFFER, vbo_coords); - fghBufferData(GL_ARRAY_BUFFER, numVertices * 3 * sizeof(vertices[0]), - vertices, GL_STATIC_DRAW); + fghBindBuffer(FGH_ARRAY_BUFFER, vbo_coords); + fghBufferData(FGH_ARRAY_BUFFER, numVertices * 3 * sizeof(vertices[0]), + vertices, FGH_STATIC_DRAW); } if (numVertices > 0 && attribute_v_normal != -1) { fghGenBuffers(1, &vbo_normals); - fghBindBuffer(GL_ARRAY_BUFFER, vbo_normals); - fghBufferData(GL_ARRAY_BUFFER, numVertices * 3 * sizeof(normals[0]), - normals, GL_STATIC_DRAW); + fghBindBuffer(FGH_ARRAY_BUFFER, vbo_normals); + fghBufferData(FGH_ARRAY_BUFFER, numVertices * 3 * sizeof(normals[0]), + normals, FGH_STATIC_DRAW); } if (vertIdxs != NULL) { fghGenBuffers(1, &ibo_elements); - fghBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo_elements); - fghBufferData(GL_ELEMENT_ARRAY_BUFFER, numVertIdxs * sizeof(vertIdxs[0]), - vertIdxs, GL_STATIC_DRAW); + fghBindBuffer(FGH_ELEMENT_ARRAY_BUFFER, ibo_elements); + fghBufferData(FGH_ELEMENT_ARRAY_BUFFER, numVertIdxs * sizeof(vertIdxs[0]), + vertIdxs, FGH_STATIC_DRAW); } if (vbo_coords) { fghEnableVertexAttribArray(attribute_v_coord); - fghBindBuffer(GL_ARRAY_BUFFER, vbo_coords); + fghBindBuffer(FGH_ARRAY_BUFFER, vbo_coords); fghVertexAttribPointer( attribute_v_coord, // attribute 3, // number of elements per vertex, here (x,y,z) @@ -219,7 +219,7 @@ static void fghDrawGeometrySolid20(GLfloat *vertices, GLfloat *normals, GLubyte if (vbo_normals) { fghEnableVertexAttribArray(attribute_v_normal); - fghBindBuffer(GL_ARRAY_BUFFER, vbo_normals); + fghBindBuffer(FGH_ARRAY_BUFFER, vbo_normals); fghVertexAttribPointer( attribute_v_normal, // attribute 3, // number of elements per vertex, here (x,y,z) @@ -233,7 +233,7 @@ static void fghDrawGeometrySolid20(GLfloat *vertices, GLfloat *normals, GLubyte if (vertIdxs == NULL) { glDrawArrays(GL_TRIANGLES, 0, numVertices); } else { - fghBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo_elements); + fghBindBuffer(FGH_ELEMENT_ARRAY_BUFFER, ibo_elements); glDrawElements(GL_TRIANGLES, numVertIdxs, GL_UNSIGNED_BYTE, 0); } @@ -1147,7 +1147,6 @@ static void fghSphere( double radius, GLint slices, GLint stacks, GLboolean useW free(normals); } -#endif /* GL_ES_VERSION_2_0 */ /* -- INTERFACE FUNCTIONS ---------------------------------------------- */ @@ -1173,6 +1172,7 @@ void FGAPIENTRY glutWireSphere(double radius, GLint slices, GLint stacks) fghSphere( radius, slices, stacks, TRUE ); } +#endif /* GL_ES_VERSION_2_0 */ #ifndef EGL_VERSION_1_0 /*