Results 1 to 2 of 2

Thread: I still have a problem with my program

  1. #1
    Senior Member Regular Contributor
    Join Date
    Mar 2002
    Location
    France
    Posts
    286

    I still have a problem with my program

    I have a black window with that, and not cube !

    #include <GL/glut.h>
    #include <stdlib.h>

    void display (void)
    {

    glClearColor (0.0, 0.0, 0.0, 0.0) ;
    glClear (GL_COLOR_BUFFER_BIT) ;

    glPolygonMode (GL_FRONT , GL_LINE) ;
    glFrontFace (GL_CW) ;
    glEnable (GL_CULL_FACE) ;
    glCullFace (GL_BACK) ;
    static GLint vertices [] = {1,1,0, 10,1,0, 1,10,0, 10,10,0, 1,1,10, 10,1,10, 1,10,10,
    10,10,10};
    static GLfloat colors_RGB [] = {1.0, 0.2, 0.2, 0.2, 0.2, 1.0, 0.8, 1.0, 0.2, 0.75, 0.75, 0.75,
    0.35, 0.35, 0.35, 0.5, 0.5, 0.5};

    glEnableClientState (GL_COLOR_ARRAY);
    glEnableClientState (GL_VERTEX_ARRAY);
    glColorPointer (3, GL_FLOAT, 0, colors_RGB);
    glVertexPointer (3, GL_INT, 0, vertices);

    static GLubyte toutLesSommets [] = { 1,2,3,4,1,5,7,3,1,5,6,2,2,6,8,4,3,7,8,4,7,8,6,5};
    glDrawElements (GL_QUADS, 24, GL_UNSIGNED_BYTE, toutLesSommets) ;

    glutSwapBuffers() ;
    glFlush () ;
    }

    void main (int argc, char** argv)

    {
    glutInit (&argc, argv) ;
    glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH) ;
    glutInitWindowSize (640, 480) ;
    glutInitWindowPosition (250,250) ;
    glutCreateWindow (argv [0]) ;
    glutDisplayFunc (display) ;
    glutMainLoop () ;

    }

  2. #2
    Junior Member Newbie
    Join Date
    Jun 2002
    Location
    San Jose, CA, USA
    Posts
    9

    Re: I still have a problem with my program

    I changed your dislay() to this.
    I didn't get your object being draw, but I did get glut to draw a torus. perhaps you have a data problem?

    glClearColor (0.0, 0.0, 0.0, 0.0) ;
    glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) ;

    glMatrixMode( GL_PROJECTION );
    glLoadIdentity();


    glMatrixMode( GL_MODELVIEW );
    glLoadIdentity();

    glDisable( GL_LIGHTING );
    glDisable( GL_BLEND );
    glDisable( GL_DITHER );
    glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST );
    glHint( GL_POINT_SMOOTH_HINT, GL_FASTEST );
    glHint( GL_LINE_SMOOTH_HINT, GL_FASTEST );
    glHint( GL_FOG_HINT, GL_FASTEST );


    glLineWidth( 2.0f );
    glPointSize( 4.0f );


    glPolygonMode (GL_FRONT , GL_LINE) ;
    glFrontFace (GL_CW) ;
    glEnable (GL_CULL_FACE) ;
    glCullFace (GL_BACK) ;

    glColor3f( 1.0, 0.0, 0.0 );

    static GLint vertices [] = {1,1,0, 10,1,0, 1,10,0, 10,10,0, 1,1,10, 10,1,10, 1,10,10,10,10,10};
    static GLfloat colors_RGB [] = {1.0, 0.2, 0.2, 0.2, 0.2, 1.0, 0.8, 1.0, 0.2, 0.75, 0.75, 0.75,0.35, 0.35, 0.35, 0.5, 0.5, 0.5};

    glEnableClientState (GL_COLOR_ARRAY);
    glEnableClientState (GL_VERTEX_ARRAY);
    glColorPointer (3, GL_FLOAT, 0, colors_RGB);
    glVertexPointer (3, GL_INT, 0, vertices);

    static GLubyte toutLesSommets [] = { 1,2,3,4,1,5,7,3,1,5,6,2,2,6,8,4,3,7,8,4,7,8,6,5};
    glDrawElements (GL_QUADS, 24, GL_UNSIGNED_BYTE, toutLesSommets) ;

    glColor3f( 1.0, 0.0, 0.0 );
    glPushMatrix();

    glutSolidTorus( 0.5, 0.5, 32, 32 );

    glPopMatrix();


    glutSwapBuffers() ;
    glFlush () ;

Similar Threads

  1. Replies: 1
    Last Post: 05-14-2014, 04:58 PM
  2. 2 Little problem in My Program..=/
    By Heavens in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 06-09-2011, 04:48 PM
  3. Problem with First Program
    By zrawson in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 09-01-2008, 11:59 PM
  4. problem with my first program
    By eastypops in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 07-15-2003, 06:10 AM
  5. what is the problem with my little program ?
    By airseb in forum OpenGL: Basic Coding
    Replies: 6
    Last Post: 06-25-2002, 05:48 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean