My os is debian3.1.
The following code is made from Redbook example:
I have no idea what is wrong with the code, it just
showed a black window in my computer.
Where is the problem?
thx in advance.
#include <GL/glut.h>
#include <stdlib.h>
#include <stdio.h>
static GLubyte frontIndices[] = {4,5,6,7};
static GLubyte rightIndices[] = {1,2,6,5};
static GLubyte bottomIndices[] = {0,1,5,4};
static GLubyte backIndices[] = {0,3,2,1};
static GLubyte leftIndices[] = {0,4,7,3};
static GLubyte topIndices[] = {2,3,7,6};
void Init()
{
glClearColor(0.0,0.0,0.0,0.0);
glShadeModel(GL_FLAT);
}
void display()
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0,1.0,1.0);
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(4,GL_INT,0,frontIndices);
glVertexPointer(4,GL_INT,0,rightIndices);
glVertexPointer(4,GL_INT,0,bottomIndices);
glVertexPointer(4,GL_INT,0,backIndices);
glVertexPointer(4,GL_INT,0,leftIndices);
glVertexPointer(4,GL_INT,0,topIndices);
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);
glutSwapBuffers();
}
void reshape(int w, int h)
{
glViewport(0,0,(GLsizei)w,(GLsizei)h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0,5.0,0.0,5.0,0.0,5.0);
}
int main(int argc,char** argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGB);
glutInitWindowSize(400,400);
glutInitWindowPosition(100,100);
glutCreateWindow("Example2-11");
Init();
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutMainLoop();
return 0;
}