OpenGL using glut ,how to modify my code to draw a cube

dear all
i am a newbie to openGL, and i just typed codes in my book,but it seemed to have
problems there. when the programme run,nothing showed except for a black backgounded window.

Hope you guys help me out.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <stdio.h>
#include <GL/glut.h>

#pragma comment(lib,"opengl32.lib");
#pragma comment(lib,"glu32.lib");
#pragma comment(lib,"glut32.lib");
//#pragma comment(lib,"glaux32.lib");
void myInit();
void myReshape(int w,int h);
void display();
int main(int argc, char *argv[])
{
    glutInit(&argc,argv);
	glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
	glutInitWindowPosition(800,200);
	glutInitWindowSize(400,400);
	glutCreateWindow(argv[0]);
	myInit();
	glutDisplayFunc(display);
	glutReshapeFunc(myReshape);	
	glutMainLoop();
	
	return 0;
}

void myReshape(int width,int height){
	
     glMatrixMode(GL_FLAT);
     glLoadIdentity();
     glFrustum(-1.0,1.0,-1.0,1.0,1.5,20.0);
     glMatrixMode(GL_MODELVIEW);
     glViewport(0,0,width,height);
     
}
void display()
{ 
   //glClearColor(1.0,1.0,1.0,0.0);
   //glClearColor(8);
	glClear(GL_COLOR_BUFFER_BIT);
	glColor3f(1.0,1.0,1.0); // set the color white
	glLoadIdentity();
	glTranslatef(0.0,0.0,-5.0);
	glScalef(1.0,2.0,1.0);
	glutWireCube(1.0);   //draw a cube
	glFlush();
}
void myInit(){
 	glShadeModel(GL_FLAT);
}

Oh,i worked in MS visual studio 2008.
thanks in advance.
Topic archived. No new replies allowed.