Open GL Computer Graphics using Open GL Open

  • Slides: 44
Download presentation
������ Open. GL (Computer Graphics using Open. GL) ����������� Open. GL (Computer Graphics 1

������ Open. GL (Computer Graphics using Open. GL) ����������� Open. GL (Computer Graphics 1

����� 3 แนะนำ Open. GL (Introduction to Open. GL) ����������� Open. GL (Computer Graphics

����� 3 แนะนำ Open. GL (Introduction to Open. GL) ����������� Open. GL (Computer Graphics 2

ฟงกชน init () สำหรบกำหนดคาเรมตน ตวอยางการกำหนดฟงกชน init () เชน void init (void) { gl. Clear.

ฟงกชน init () สำหรบกำหนดคาเรมตน ตวอยางการกำหนดฟงกชน init () เชน void init (void) { gl. Clear. Color (1. 0, 0. 0); // Set display-window color to white. gl. Point. Size (4. 0); // Set Point size to 4. 0 pixel gl. Line. Width (4. 0); // Set Line width to 4. 0 pixel gl. Matrix. Mode (GL_PROJECTION); // Set projection parameters. glu. Ortho 2 D (0. 0, 200. 0, 150. 0); } ����������� Open. GL (Computer Graphics 30

ฟงกชนสำหรบสรางงานกราฟก ตวอยางการสรางรปสเหลยมและลากเสนตรง เปนดงน void Line. And. Rectangle (void) { gl. Clear (GL_COLOR_BUFFER_BIT); // Clear

ฟงกชนสำหรบสรางงานกราฟก ตวอยางการสรางรปสเหลยมและลากเสนตรง เปนดงน void Line. And. Rectangle (void) { gl. Clear (GL_COLOR_BUFFER_BIT); // Clear display-window. gl. Color 3 f (0. 0, 1. 0); // Set object color to blue. gl. Rectf(180. 0, 280. 0); // Draw rectangle gl. Begin (GL_LINES); gl. Color 3 f (1. 0, 0. 0); // Set line segment color to red. gl. Vertex 2 i (20, 20); // Specify first vertex of line. gl. Vertex 2 i (150, 150); // Specify second vertex of line. gl. End ( ); gl. Flush ( ); // Process all Open. GL routines as quickly as possible. } ����������� Open. GL (Computer Graphics 32

ตวอยางการสรางงานกราฟก #include <GL/glut. h> // (or others, depending on the system in use) void

ตวอยางการสรางงานกราฟก #include <GL/glut. h> // (or others, depending on the system in use) void init (void) { gl. Clear. Color (1. 0, 0. 0); // Set display-window color to white. gl. Line. Width (4. 0); // Set Line width to 4. 0 pixel gl. Matrix. Mode (GL_PROJECTION); // Set projection parameters. glu. Ortho 2 D (0. 0, 300. 0); } ����������� Open. GL (Computer Graphics 35

ตวอยางการสรางงานกราฟก void Line. And. Rectangle (void) { gl. Clear (GL_COLOR_BUFFER_BIT); // Clear display-window. gl.

ตวอยางการสรางงานกราฟก void Line. And. Rectangle (void) { gl. Clear (GL_COLOR_BUFFER_BIT); // Clear display-window. gl. Color 3 f (0. 0, 1. 0); // Set object color to blue. gl. Rectf(180. 0, 280. 0); // Draw rectangle gl. Begin (GL_LINES); gl. Color 3 f (1. 0, 0. 0); // Set line segment color to red. gl. Vertex 2 i (20, 20); // Specify first vertex of line. ����������� Open. GL (Computer Graphics 36

ตวอยางการสรางงานกราฟก gl. Vertex 2 i (150, 150); // Specify second vertex of line. gl.

ตวอยางการสรางงานกราฟก gl. Vertex 2 i (150, 150); // Specify second vertex of line. gl. End ( ); gl. Flush ( ); // Process all Open. GL routines as quickly as possible. } void main (int argc, char** argv) { glut. Init (&argc, argv); // Initialize GLUT. glut. Init. Display. Mode (GLUT_SINGLE | GLUT_RGB); // Set mode. ����������� Open. GL (Computer Graphics 37

ตวอยางการสรางงานกราฟก glut. Init. Window. Position (50, 100); // Set top-left display-window glut. Init. Window.

ตวอยางการสรางงานกราฟก glut. Init. Window. Position (50, 100); // Set top-left display-window glut. Init. Window. Size (400, 400); // Set display-window width and height. glut. Create. Window ("An Example Open. GL Program"); // Create display window. init ( ); // Execute initialization procedure. glut. Display. Func (Line. And. Rectangle); // Send graphics to display window. ����������� Open. GL (Computer Graphics 38

ตวอยางการสรางงานกราฟก glut. Main. Loop ( ); // Display everything and wait. } ����������� Open.

ตวอยางการสรางงานกราฟก glut. Main. Loop ( ); // Display everything and wait. } ����������� Open. GL (Computer Graphics 39

การเขยนโปรแกรม Open. GL ใน Microsoft VC++ ตดตง Microsoft Visual Studio 6. 0 ในระบบใหเรยบรอย ดาวน

การเขยนโปรแกรม Open. GL ใน Microsoft VC++ ตดตง Microsoft Visual Studio 6. 0 ในระบบใหเรยบรอย ดาวน โหลดไฟล glut-3. 7. 6 -bin. zip แลวแตก zip นำไฟลไปไวในโฟลเดอร ดงน glut. h ไปไวใน C: Program FilesMicrosoft Visual StudioVC 98IncludeGL glut 32. lib ไปไวใน C: Program FilesMicrosoft Visual StudioVC 98Lib glut 32. dll ไปไวใน C: WINDOWSSYSTEM ����������� Open. GL (Computer Graphics 40

����������� Open. GL (Computer Graphics 44

����������� Open. GL (Computer Graphics 44