Cpw - Primitive Spheres

Hi Jim,

I wanted to let you know that there may be an issue with primitive spheres.

The SOLIDSPHERE is not being drawn, and the WIRESPHERE shows up as a single line.

Here is a code snippit:
//
/
OpenGL 3D Matrix Setup /
/
/

void set3DMatrix( void )
{
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
gluPerspective( 60, (float)windowInfo.width / (float)windowInfo.height, 1, 100 );
//printf("Set Perspective: Aspect Ratio = %f
", (float)windowInfo.width / (float)windowInfo.height); /* JP - Print Vars */
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
}

//
/
Draw Window One /
/
/

void drawWindowOne( pCpw cpw )
{
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
set3DMatrix();

/* draw something in the window with OpenGL */
glLoadIdentity();
glTranslatef(0.0f,0.0f,-6.0f);						// Move Left 1.5 Units And Into The Screen 6.0
glRotatef(-50.0f, 1.0f, 0.0f, 0.0f);
cpwSetPrimitiveOpt( cpw, CPW_PRIMOPT_TOPRADIUS, 2.0f );
cpwSetPrimitiveOpt( cpw, CPW_PRIMOPT_BASERADIUS, 2.0f );
cpwSetPrimitiveOpt( cpw, CPW_PRIMOPT_RADIUS, 1.0f );
cpwSetPrimitiveOpt( cpw, CPW_PRIMOPT_SLICES, 24.0f );
cpwSetPrimitiveOpt( cpw, CPW_PRIMOPT_STACKS, 1.0f );
cpwSetPrimitiveOpt( cpw, CPW_PRIMOPT_HEIGHT, 2 );
cpwSetPrimitiveOpt( cpw, CPW_PRIMOPT_SIZE, 2 );

//cpwDrawPrimitive( cpw, CPW_PRIM_3D_WIRECONE );
cpwDrawPrimitive( cpw, CPW_PRIM_3D_WIRESPHERE );
//cpwDrawPrimitive( cpw, CPW_PRIM_3D_SOLIDCUBE );

}

//
/
Window Draw Event callback /
/
/

void draw( pCpw cpw, uint_32 winid )
{
drawWindowOne( cpw );

cpwSwapWindowBuffers( cpw, winid );

}

//
/
Window Create / Destroy Event callback /
/
/

void window( pCpw cpw, uint_32 winid, bool flag )
{
/* creation event */

if ( flag == true ) {

    glShadeModel( GL_SMOOTH );
    glDepthFunc( GL_LEQUAL );
    glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST );
    glEnable( GL_LINE_SMOOTH );
    glEnable( GL_POLYGON_SMOOTH );
    glClearColor( 0.3f, 0.3f, 0.3f, 1.0f );
    return;
}

/* window close event */

if ( flag == false ) {
    cpwDestroyWindow( cpw, winid );
    return;
}

}

try this:

cpwSetPrimitiveOpt( cpw, CPW_PRIMOPT_RADIUS, 2.0f );
cpwSetPrimitiveOpt( cpw, CPW_PRIMOPT_SLICES, 24.0f );
cpwSetPrimitiveOpt( cpw, CPW_PRIMOPT_STACKS, 10.0f );

cpwDrawPrimitive( cpw, CPW_PRIM_3D_WIRESPHERE );
//cpwDrawPrimitive( cpw, CPW_PRIM_3D_SOLIDSPHERE );

Your stacks value was too low, you were basically requesting a very very thin sphere.

Regards,
Jim

Thanks for the help Jim,

That was my mistake, I should have rechecked my numbers. I will change the stack value and retest.

John Pummill