what is wrong with this code?

Hi all, I’m a begin in graphic programming, I’m trying to draw a cube with glDrawElements() but the programme craches at running.
I figure not out what is wrong, could you help me ?
thanks. here is the code I want to run. I have not pasted the definitions in “points.h”

#include <GL/glut.h>
#include "points.h"

void init(void);
void display();
void reshape(GLsizei w, GLsizei h);


int main(int argc, char **argv)
{
    glutInit(&argc,argv);
    glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
    glutInitWindowSize(648,420);
    glutInitWindowPosition(100,100);
    glutCreateWindow("Maison de cyrildz V2");
    init();
    glutDisplayFunc(display);
    glutReshapeFunc(reshape);
    glutMainLoop();
    return 0;
}

void init(void)
{
     glClearColor(0.0,0.0,0.0,0.0);// set the screen to black color
     glShadeModel(GL_FLAT);
 }
 
 void display()
 {
      glClear(GL_COLOR_BUFFER_BIT);
      glEnableClientState(GL_VERTEX_ARRAY);
      glDrawElements(GL_QUADS,4,GL_UNSIGNED_BYTE,frontindices);
      glDrawElements(GL_QUADS,4,GL_UNSIGNED_BYTE,rightindices);
      glDrawElements(GL_QUADS,4,GL_UNSIGNED_BYTE,bottomindices);
      glDrawElements(GL_QUADS,4,GL_UNSIGNED_BYTE,backindices);
      glDrawElements(GL_QUADS,4,GL_UNSIGNED_BYTE,leftindices);
      glDrawElements(GL_QUADS,4,GL_UNSIGNED_BYTE,topindices);
      
      glFlush();
 }

 void reshape( GLsizei w, GLsizei h)
 {
      glViewport(0,0,(GLsizei)w,(GLsizei)h);
      glMatrixMode(GL_PROJECTION);
      glLoadIdentity();
      gluOrtho2D(0.0,(GLdouble)w,0.0,(GLdouble)h);
 }

sorry, I was wrong by posting here, I move it to the beginner’s corner. thanks

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