#include <GL/freeglut.h>
#include "fg_internal.h"
#include "fg_gl2.h"
+#include <math.h>
/*
* Need more types of polyhedra? See CPolyhedron in MRPT
{
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)
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)
);
}
-
- int i;
-
/* Draw per face (TODO: could use glMultiDrawArrays if available) */
for (i=0; i<numFaces; i++)
glDrawArrays(GL_LINE_LOOP, i*numEdgePerFace, numEdgePerFace);
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 (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)
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)
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);
}
for (i=1; i<size; i++)
{
+#ifdef __cplusplus
(*sint)[i] = sinf(angle*i);
(*cost)[i] = cosf(angle*i);
+#else
+ (*sint)[i] = (float)sin((double)(angle*i));
+ (*cost)[i] = (float)cos((double)(angle*i));
+#endif /* __cplusplus */
}
free(normals);
}
-#endif /* GL_ES_VERSION_2_0 */
/* -- INTERFACE FUNCTIONS ---------------------------------------------- */
fghSphere( radius, slices, stacks, TRUE );
}
+#endif /* GL_ES_VERSION_2_0 */
#ifndef EGL_VERSION_1_0
/*
/* Scaling factors for vertex normals */
+#ifdef __cplusplus
const GLfloat cosn = ( (GLfloat)height / sqrtf( height * height + base * base ));
const GLfloat sinn = ( (GLfloat)base / sqrtf( height * height + base * base ));
+#else
+ const GLfloat cosn = ( (GLfloat)height / (GLfloat)sqrt( (double)(height * height + base * base) ));
+ const GLfloat sinn = ( (GLfloat)base / (GLfloat)sqrt( (double)(height * height + base * base) ));
+#endif /* __cplusplus */
/* Pre-computed circle */
/* Scaling factors for vertex normals */
+#ifdef __cplusplus
const GLfloat cosn = ( (GLfloat)height / sqrtf( height * height + base * base ));
const GLfloat sinn = ( (GLfloat)base / sqrtf( height * height + base * base ));
+#else
+ const GLfloat cosn = ( (GLfloat)height / (GLfloat)sqrt( (double)(height * height + base * base) ));
+ const GLfloat sinn = ( (GLfloat)base / (GLfloat)sqrt( (double)(height * height + base * base) ));
+#endif /* __cplusplus */
/* Pre-computed circle */
for( j=0; j<nRings; j++ )
{
+#ifdef __cplusplus
cpsi = cosf( psi ) ;
spsi = sinf( psi ) ;
+#else
+ cpsi = (float)cos( (double)psi ) ;
+ spsi = (float)sin( (double)psi ) ;
+#endif /* __cplusplus */
phi = 0.0f;
for( i=0; i<nSides; i++ )
{
int offset = 3 * ( j * nSides + i ) ;
+#ifdef __cplusplus
cphi = cosf( phi ) ;
sphi = sinf( phi ) ;
+#else
+ cphi = (float)cos( (double)phi ) ;
+ sphi = (float)sin( (double)phi ) ;
+#endif /* __cplusplus */
*(vertex + offset + 0) = cpsi * ( oradius + cphi * iradius ) ;
*(vertex + offset + 1) = spsi * ( oradius + cphi * iradius ) ;
*(vertex + offset + 2) = sphi * iradius ;
for( j=0; j<nRings; j++ )
{
+#ifdef __cplusplus
cpsi = cosf( psi ) ;
spsi = sinf( psi ) ;
+#else
+ cpsi = (float)cos( (double)psi ) ;
+ spsi = (float)sin( (double)psi ) ;
+#endif /* __cplusplus */
phi = 0.0f;
for( i=0; i<nSides; i++ )
{
int offset = 3 * ( j * nSides + i ) ;
+#ifdef __cplusplus
cphi = cosf( phi ) ;
sphi = sinf( phi ) ;
+#else
+ cphi = (float)cos( (double)phi ) ;
+ sphi = (float)sin( (double)phi ) ;
+#endif /* __cplusplus */
*(vertex + offset + 0) = cpsi * ( oradius + cphi * iradius ) ;
*(vertex + offset + 1) = spsi * ( oradius + cphi * iradius ) ;
*(vertex + offset + 2) = sphi * iradius ;