Problem with a sphere

Hi to all!
I’ve made a sphere to import in my Symbian app, but I’ve this problem: if I made a sphere with less than 20 slices and 20 stacks is all ok, but if I make it with more slices and stacks it’s wrong drawed! I’ve tryed to made it with milkshape 3d and 3d studio max but it’s the same thing, is a problem of the API of what?
Thanks for your support!

Hi Giacomo,

No, there’s nothing in the API that restricts you from drawing 800 TRIangles, or 400 QUADs, and OpenGL ES can’t render quads. It must be somewhere else.

  • 43rp

Hi!
Very strange…I’ve tryed to make a lot of sphere with milkshape and 3d studio but there’s the same error! why under 20 segments the sphere is corretly drawed? I export the model in the same way!

Hi, I’m telling you, man, there’s no such restriction in the spec. The reason might be that you are using bytes as indices, and when you’re generating the indices to your vertices, you run out of unsigned_byte range after 15*15 or so. Change it to GL_SHORT.

I’ve changed in GL_SHORT but now my model is not drawed!

ok, did you remember to change the C++ datatype also?

Yes:
glDrawElements(GL_TRIANGLES,612*3,GL_SHORT,obj1_indices);

yep, I know. Did you change the type of obj1_indices? I mean, you must change them to GLshort.

Yes I’ve also changed the type:
static const GLshort obj1_indices[] = {
0, 1, 2,
3, 4, 5, and so on…

and for draw:


void CTexture::DrawObj1(TInt aFrame,TInt dirx,TInt diry,TInt dirz)
{

	glLoadIdentity();
	glTranslatef(dirx,diry,dirz);
	glRotatex( aFrame << 16,1<<16,0,0);
	glRotatex( aFrame << 16,0,0,1<<16);
	glScalex( 26 << 11, 26 << 11, 26 << 11);

	glEnable(GL_TEXTURE_2D);
	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);  
    glBindTexture(  GL_TEXTURE_2D, iNokTexObjects[5] );
	glVertexPointer(   3, GL_FLOAT, 0, obj1_vertices);
    glTexCoordPointer( 2, GL_FLOAT	, 0, obj1_uv);
	glNormalPointer(   GL_BYTE, 0, obj1_normal);
    glDrawElements(GL_TRIANGLES,612*3,GL_SHORT,obj1_indices);
	glDisable(GL_TEXTURE_2D);
	counter+=612;
}

Does the program you use to convert the Milkshape / 3DS format to C arrays do a cast on the data?

I resolve in this way:
static const unsigned short obj1_indices[] = {

DELETED

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.