Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: Cpw - Primitive Spheres

Hybrid View

  1. #1
    Intern Contributor
    Join Date
    Dec 2001
    Posts
    93

    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\n", (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;
    }
    }

  2. #2
    Junior Member Regular Contributor
    Join Date
    Feb 2002
    Posts
    133

    Re: Cpw - Primitive Spheres

    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
    --
    Jim Mathies http://www.mathies.com/

    \"The best way to predict the future is to invent it."

  3. #3
    Intern Contributor
    Join Date
    Dec 2001
    Posts
    93

    Re: Cpw - Primitive Spheres

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •