Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma comment (lib,"glut32.lib")
- #include<stdio.h>
- #include<stdlib.h>
- #include<math.h>
- #include<GL/glut.h>
- #define BLACK 0.9, .9, 0.9
- void display(){
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- glClearColor(BLACK, 0); //color black
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
- gluLookAt( .01, 0, 150, 0,0,0, 0,0,1);
- glMatrixMode(GL_MODELVIEW);
- /****************************
- / Add your objects from here
- ****************************/
- /*
- Task: Draw A T
- */
- glColor3f(1, 0, 0);
- glBegin(GL_LINES);{
- float i=50;
- // Vertical Line |
- glVertex3f(-i,0,0);//x
- glVertex3f(i,-50,0);
- // Vertical Line |
- glColor3f(1, 0, 0);
- glVertex3f(i,50,0);//x
- glVertex3f(-i,0,0);
- // Horizontal Line ---
- glColor3f(.75, 0, .55);
- glVertex3f(0,-25,0);//y
- glVertex3f(0,25,0);
- }glEnd();
- glutSwapBuffers();
- }
- void animate(){
- //codes for any changes in Models, Camera
- }
- void init(){
- //codes for initialization
- //clear the screen
- glClearColor(BLACK, 0);
- /************************
- / set-up projection here
- ************************/
- //load the PROJECTION matrix
- glMatrixMode(GL_PROJECTION);
- //initialize the matrix
- glLoadIdentity();
- //give PERSPECTIVE parameters
- gluPerspective(70, 1, 0.1, 10000.0);
- //field of view in the Y (vertically)
- //aspect ratio that determines the field of view in the X direction (horizontally)
- //near distance
- //far distance
- }
- int main(int argc, char **argv){
- glutInit(&argc,argv);
- glutInitWindowSize(500, 500);
- glutInitWindowPosition(0, 0);
- glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGB); //Depth, Double buffer, RGB color
- glutCreateWindow("My OpenGL Program");
- init();
- glEnable(GL_DEPTH_TEST); //enable Depth Testing
- glutDisplayFunc(display); //display callback function
- glutIdleFunc(animate); //what you want to do in the idle time (when no drawing is occuring)
- glutMainLoop(); //The main loop of OpenGL
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement