Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Write a program using openGL to draw some points
- #include<windows.h>
- #include<stdio.h>
- #include<stdlib.h>
- #include<GL/glut.h>
- void myInit(void)
- {
- glClearColor(1.0, 1.0, 1.0, 0.0); //BG color is white
- glColor3f(0.0f,0.0f,0.0f); //drawing color is black
- glPointSize(4.0);// a dot is 2 by 2 pixels
- //init view (simple orthographic projection)
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- glOrtho(-1.0,1.0,-1.0,1.0,-1.0,1.0);
- //set the viewing coordinates
- gluOrtho2D(0.0,640.0,0.0,480.0);
- }
- void myDisplay(void)
- {
- glClear(GL_COLOR_BUFFER_BIT); //clear the screen
- glBegin(GL_POINTS);
- {
- glVertex2i(20,10);
- glVertex2i(50,10);
- glVertex2i(20,80);
- glVertex2i(50,80);
- }
- glEnd();
- glFlush();
- }
- int main(int argc, char** argv)
- {
- glutInit(&argc,argv);//init the toolkit
- glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); //set the display
- glutInitWindowSize(640,480);//set window size
- //set window position on screen
- glutInitWindowPosition(100,150);
- //open the screen window and set the name
- glutCreateWindow("My First Window");
- //register the callback functions
- glutDisplayFunc(myDisplay);
- myInit();
- glutMainLoop(); //go into a perpetual loop
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement