Presentation is loading. Please wait.

Presentation is loading. Please wait.

Doç. Dr. Cemil Öz SAÜ Bilgisayar Mühendisliği Dr. Cemil Öz.

Similar presentations


Presentation on theme: "Doç. Dr. Cemil Öz SAÜ Bilgisayar Mühendisliği Dr. Cemil Öz."— Presentation transcript:

1 Doç. Dr. Cemil Öz SAÜ Bilgisayar Mühendisliği Dr. Cemil Öz

2 #include #pragma comment(lib,"opengl32.lib") #pragma comment(lib,"glu32.lib") #pragma comment(lib,"glut32.lib") Örnek 1

3 void myInit(void) { glClearColor(1.0,1.0,1.0,0.0); // beyaz zemin glColor3f(0.0f,0.0f,0.0f); // siyah çizim rengi glPointSize(4.0); // çizgi kalınlığı 4x4 piksel glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluOrtho2D(0.0,800.0,0.0,600.0); } void myDisplay(void) { glClear(GL_COLOR_BUFFER_BIT);// ekranı temizle glBegin(GL_POINTS); // üç nokta çizer //for(GLdouble x=0; x<4.0; x+=0.005) //{ //Gldouble func=exp(-x)*cos(2*3.14159265*x); //glVertex2d(A*x+B, C*func+D);} glVertex2i(100,50); glVertex2i(100,130); glVertex2i(150,130); glEnd(); glFlush(); // çizimleri ekrana gönderir }

4 int main(int argc, char** argv) { glutInit(&argc, argv); //toolkit i ilk değerlerini verme glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB); // diplay modunu set etme glutInitWindowSize(800,600); // pencere boyutunu belirleme glutInitWindowPosition(200,250); glutCreateWindow(" Çizim örneği"); glutDisplayFunc(myDisplay); myInit(); glutMainLoop(); }

5 #include #pragma comment(lib,"opengl32.lib") #pragma comment(lib,"glu32.lib") #pragma comment(lib,"glut32.lib") void init(void) { /* select clearing (background) color */ glClearColor(0.0, 0.0, 0.0, 0.0); /* initialize viewing values */ glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0); } /* Declare initial window size, position, and display mode * (single buffer and RGBA). Open window with “hello” * in its title bar. Call initialization routines. * Register callback function to display graphics. * Enter main loop and process events.*/ Örnek 2

6 void display(void) { /* clear all pixels */ glClear(GL_COLOR_BUFFER_BIT); /* draw white polygon (rectangle) with corners at * (0.25, 0.25, 0.0) and (0.75, 0.75, 0.0) */ glColor3f(1.0, 1.0, 1.0); glBegin(GL_POLYGON); glVertex3f(0.25, 0.25, 0.0); glVertex3f(0.75, 0.25, 0.0); glVertex3f(0.75, 0.75, 0.0); glVertex3f(0.25, 0.75, 0.0); glEnd(); /* don’t wait! * start processing buffered OpenGL routines */ glFlush(); } Örnek 2

7 int main(int argc, char** argv) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); glutInitWindowSize(250, 250); glutInitWindowPosition(100, 100); glutCreateWindow(“hello”); init(); glutDisplayFunc(display); glutMainLoop(); return 0; /* ISO C requires main to return int. */ }

8 static GLfloat spin = 0.0; void init(void) { glClearColor(0.0, 0.0, 0.0, 0.0); glShadeModel(GL_FLAT); } void display(void) { glClear(GL_COLOR_BUFFER_BIT); glPushMatrix(); glRotatef(spin, 0.0, 0.0, 1.0); glColor3f(1.0, 1.0, 1.0); glRectf(-25.0, -25.0, 25.0, 25.0); glPopMatrix(); glutSwapBuffers(); } Örnek 3

9 void spinDisplay(void) { spin = spin + 2.0; if (spin > 360.0) spin = spin - 360.0; glutPostRedisplay(); } void reshape(int w, int h) { glViewport(0, 0, (GLsizei) w, (GLsizei) h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(-50.0, 50.0, -50.0, 50.0, -1.0, 1.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); }

10 void mouse(int button, int state, int x, int y) { switch (button) { case GLUT_LEFT_BUTTON: if (state == GLUT_DOWN) glutIdleFunc(spinDisplay); break; case GLUT_MIDDLE_BUTTON: if (state == GLUT_DOWN) glutIdleFunc(NULL); break; default: break; } /* * Request double buffer display mode. * Register mouse input callback functions */

11 int main(int argc, char** argv) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB); glutInitWindowSize(250, 250); glutInitWindowPosition(100, 100); glutCreateWindow(argv[0]); init(); glutDisplayFunc(display); glutReshapeFunc(reshape); glutMouseFunc(mouse); glutMainLoop(); Return 0; }


Download ppt "Doç. Dr. Cemil Öz SAÜ Bilgisayar Mühendisliği Dr. Cemil Öz."

Similar presentations


Ads by Google