Hello to all.
I am new to the graphics world and I am completely lost !! I am trying to render a cube but with no results !! Thus I would like to show you my code and if possible to help me a bit.
It is quite simple I believe.
GLfloat white3[] = {1.0, 1.0, 1.0};
GLfloat verticesCube[] = {100.0, 100.0, 0.0,
0.0, 200.0, 0.0,
100.0, 300.0, 0.0,
200.0, 300.0, 0.0,
300.0, 200.0, 0.0,
200.0, 100.0, 0.0};
static GLubyte allIndices[] = {4, 5, 6, 7, 1, 2, 6, 5, 0, 1, 4, 5,
0, 3, 2, 1, 0, 4, 7, 3, 2, 3, 7, 6};
void displayCube(void)
{
// Clear all Pixels.
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Draw white Rectangle.
glColor3f(white3[0], white3[1], white3[2]);
// glVertexPointer(3, GL_FLOAT, 0, verticesCube);
//
// glDrawElements(GL_QUADS, 24, GL_UNSIGNED_BYTE, allIndices);
glutWireCube(20.0f);
glFlush();
}
void init(void)
{
// Background black color.
glClearColor(0.0, 0.0, 0.0, 0.0);
// Initialize viewing values.
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
// Set the Orthogonal System.
glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
}
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(width, height);
glutInitWindowPosition(100, 100);
glutCreateWindow("Hello World.");
init();
glutDisplayFunc(displayCube);
glutMainLoop();
return 0;
}
As you can see in the displayCube() I have tried 2 different methods, but none seems to work.
I compile it and everything is ok. But when running, all it presents is a black window with no cube inside. Apparently I am missing something, but I can’t find it.
If you could help me I would be really greatfull.