From 38af3c363f39b393fe466510f2d1c2de8cde0beb Mon Sep 17 00:00:00 2001 From: Sylvain Beucler Date: Sat, 31 Mar 2012 20:03:01 +0000 Subject: [PATCH] fg_geometry: sphere: GL_UNSIGNED_INT->GL_UNSIGNED_SHORT for OpenGL ES 1.0 support git-svn-id: svn+ssh://svn.code.sf.net/p/freeglut/code/trunk/freeglut/freeglut@1219 7f0cb862-5218-0410-a997-914c9d46530a --- include/GL/freeglut_std.h | 4 ++-- src/fg_geometry.c | 35 +++++++++++++++++++---------------- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/include/GL/freeglut_std.h b/include/GL/freeglut_std.h index f5b1ebf..ce0ad2a 100644 --- a/include/GL/freeglut_std.h +++ b/include/GL/freeglut_std.h @@ -528,10 +528,10 @@ FGAPI int FGAPIENTRY glutStrokeLength( void* font, const unsigned char* stri #ifndef GL_ES_VERSION_2_0 FGAPI void FGAPIENTRY glutWireCube( double size ); FGAPI void FGAPIENTRY glutSolidCube( double size ); -#endif -#ifndef EGL_VERSION_1_0 FGAPI void FGAPIENTRY glutWireSphere( double radius, GLint slices, GLint stacks ); FGAPI void FGAPIENTRY glutSolidSphere( double radius, GLint slices, GLint stacks ); +#endif +#ifndef EGL_VERSION_1_0 FGAPI void FGAPIENTRY glutWireCone( double base, double height, GLint slices, GLint stacks ); FGAPI void FGAPIENTRY glutSolidCone( double base, double height, GLint slices, GLint stacks ); #endif diff --git a/src/fg_geometry.c b/src/fg_geometry.c index 97d1534..4dbee68 100644 --- a/src/fg_geometry.c +++ b/src/fg_geometry.c @@ -823,6 +823,9 @@ static void fghSphere( double radius, GLint slices, GLint stacks, GLboolean useW int i,j,idx, nVert; GLfloat *vertices, *normals; + if (slices * stacks > 65535) + fgWarning("fghSphere: too many slices or stacks requested, indices will wrap"); + /* Generate vertices and normals */ fghGenerateSphere((GLfloat)radius,slices,stacks,&vertices,&normals,&nVert); @@ -832,19 +835,19 @@ static void fghSphere( double radius, GLint slices, GLint stacks, GLboolean useW if (useWireMode) { - GLuint *sliceIdx, *stackIdx; + GLushort *sliceIdx, *stackIdx; /* First, generate vertex index arrays for drawing with glDrawElements * We have a bunch of line_loops to draw for each stack, and a * bunch for each slice. */ - sliceIdx = malloc(slices*(stacks+1)*sizeof(GLuint)); - stackIdx = malloc(slices*(stacks-1)*sizeof(GLuint)); + sliceIdx = malloc(slices*(stacks+1)*sizeof(GLushort)); + stackIdx = malloc(slices*(stacks-1)*sizeof(GLushort)); /* generate for each stack */ for (i=0,idx=0; i