OpenGL Starter L01
-
Upload
mohammad-shaker -
Category
Education
-
view
688 -
download
1
description
Transcript of OpenGL Starter L01
![Page 1: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/1.jpg)
Mohammad Shakermohammadshaker.com mohammadshakergtr.wordpress.com
OpenGL Starter Course@ZGTRShaker
![Page 2: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/2.jpg)
This is a very short 2-slide intro to OpenGL
![Page 3: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/3.jpg)
References
![Page 4: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/4.jpg)
References (www.nehe.gamedev.net)
![Page 5: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/5.jpg)
Take a Look on XNA and My Other Courses @ http://www.slideshare.net/ZGTRZGTR
and @ http://mohammadshakergtr.wordpress.com/
Available courses to the date of this slide:
![Page 6: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/6.jpg)
Explore My
Authoring tool for Cut the Rope!A Full implementation of a clone of Cut the Rope for Research Purposes
mohammadshaker.com/ropossum
![Page 7: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/7.jpg)
![Page 8: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/8.jpg)
Let’s go OpenGling
![Page 9: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/9.jpg)
ART
![Page 10: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/10.jpg)
3D
![Page 11: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/11.jpg)
3Dimensions!
![Page 12: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/12.jpg)
3Dimensions!
![Page 13: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/13.jpg)
3Dimensions!
![Page 14: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/14.jpg)
3Dimensions!
![Page 15: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/15.jpg)
3Dimensions!
![Page 16: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/16.jpg)
Game Engines
![Page 17: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/17.jpg)
Game Engines
![Page 18: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/18.jpg)
Game Engines
![Page 19: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/19.jpg)
Game Engines
![Page 20: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/20.jpg)
Game Engines
![Page 21: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/21.jpg)
Game Engines
![Page 22: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/22.jpg)
Game Engines
![Page 23: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/23.jpg)
Game Engines
![Page 24: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/24.jpg)
Game Engines
![Page 25: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/25.jpg)
Game Engines
![Page 26: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/26.jpg)
Game Engines
![Page 27: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/27.jpg)
Game Engines
![Page 28: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/28.jpg)
Game Engines
![Page 29: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/29.jpg)
Game Engines
![Page 30: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/30.jpg)
Game Engines
![Page 31: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/31.jpg)
Game Engines
![Page 32: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/32.jpg)
Game Engines
![Page 33: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/33.jpg)
Next Generation Games
![Page 34: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/34.jpg)
Battlefield 3
![Page 35: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/35.jpg)
Battlefield 3
![Page 36: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/36.jpg)
Battlefield 3
![Page 37: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/37.jpg)
Battlefield 3
![Page 38: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/38.jpg)
Battlefield 3
![Page 39: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/39.jpg)
Battlefield 3
![Page 40: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/40.jpg)
Let’s dig deeper
![Page 41: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/41.jpg)
Viewing
![Page 42: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/42.jpg)
Cartesian viewing volume
![Page 43: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/43.jpg)
Library!
![Page 44: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/44.jpg)
Projection
![Page 45: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/45.jpg)
Projection?!
![Page 46: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/46.jpg)
Camera
![Page 47: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/47.jpg)
Real VS Illusion?!
![Page 48: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/48.jpg)
Perspective or Orthographic
![Page 49: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/49.jpg)
Perspective or Orthographic
![Page 50: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/50.jpg)
Perspective or Orthographic
![Page 51: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/51.jpg)
Perspective or Orthographic
![Page 52: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/52.jpg)
Perspective or Orthographic
![Page 53: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/53.jpg)
Perspective or Orthographic
![Page 54: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/54.jpg)
Perspective or Orthographic
![Page 55: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/55.jpg)
Perspective or Orthographic
![Page 56: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/56.jpg)
Perspective or Orthographic
![Page 57: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/57.jpg)
Camera
![Page 58: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/58.jpg)
Camera
![Page 59: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/59.jpg)
Camera
![Page 60: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/60.jpg)
Camera
![Page 61: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/61.jpg)
Camera
![Page 62: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/62.jpg)
Camera
![Page 63: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/63.jpg)
Camera
![Page 64: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/64.jpg)
Your First Polygon!
int DrawGLScene(GLvoid) // Here's Where We Do All The Drawing{
// Clear The Screen And The Depth Buffer glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity(); // Reset The View
glTranslatef(-1.5f,0.0f,-6.0f); // Move Left 1.5 Units And Into The Screen 6.0glBegin(GL_TRIANGLES); // Drawing Using Triangles
glVertex3f( 0.0f, 1.0f, 0.0f); // Top glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right
glEnd(); // Finished Drawing The Triangle
glTranslatef(3.0f,0.0f,0.0f); // Move Right 3 UnitsglBegin(GL_QUADS); // Draw A Quad
glVertex3f(-1.0f, 1.0f, 0.0f); // Top Left glVertex3f( 1.0f, 1.0f, 0.0f); // Top Right glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left
glEnd(); // Done Drawing The Quad return TRUE; // Keep Going
}
![Page 65: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/65.jpg)
Projection and Camera
Projection (GL_PROJECTION), gluPerspective
Camera (GL_MODELVIEW), gluLookAt
![Page 66: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/66.jpg)
Your First Polygon!
![Page 67: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/67.jpg)
Your First Polygon!
int DrawGLScene(GLvoid) // Here's Where We Do All The Drawing{
// Clear The Screen And The Depth Buffer glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity(); // Reset The View
glTranslatef(-1.5f,0.0f,-6.0f); // Move Left 1.5 Units And Into The Screen 6.0glBegin(GL_TRIANGLES); // Drawing Using Triangles
glVertex3f( 0.0f, 1.0f, 0.0f); // Top glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right
glEnd(); // Finished Drawing The Triangle
glTranslatef(3.0f,0.0f,0.0f); // Move Right 3 UnitsglBegin(GL_QUADS); // Draw A Quad
glVertex3f(-1.0f, 1.0f, 0.0f); // Top Left glVertex3f( 1.0f, 1.0f, 0.0f); // Top Right glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left
glEnd(); // Done Drawing The Quad return TRUE; // Keep Going
}
![Page 68: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/68.jpg)
Your First Polygon!
int DrawGLScene(GLvoid) // Here's Where We Do All The Drawing{
// Clear The Screen And The Depth Buffer glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity(); // Reset The View
glTranslatef(-1.5f,0.0f,-6.0f); // Move Left 1.5 Units And Into The Screen 6.0glBegin(GL_TRIANGLES); // Drawing Using Triangles
glVertex3f( 0.0f, 1.0f, 0.0f); // Top glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right
glEnd(); // Finished Drawing The Triangle
glTranslatef(3.0f,0.0f,0.0f); // Move Right 3 UnitsglBegin(GL_QUADS); // Draw A Quad
glVertex3f(-1.0f, 1.0f, 0.0f); // Top Left glVertex3f( 1.0f, 1.0f, 0.0f); // Top Right glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left
glEnd(); // Done Drawing The Quad return TRUE; // Keep Going
}
![Page 69: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/69.jpg)
Your First Polygon!
int DrawGLScene(GLvoid) // Here's Where We Do All The Drawing{
// Clear The Screen And The Depth Buffer glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity(); // Reset The View
glTranslatef(-1.5f,0.0f,-6.0f); // Move Left 1.5 Units And Into The Screen 6.0glBegin(GL_TRIANGLES); // Drawing Using Triangles
glVertex3f( 0.0f, 1.0f, 0.0f); // Top glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right
glEnd(); // Finished Drawing The Triangle
glTranslatef(3.0f,0.0f,0.0f); // Move Right 3 UnitsglBegin(GL_QUADS); // Draw A Quad
glVertex3f(-1.0f, 1.0f, 0.0f); // Top Left glVertex3f( 1.0f, 1.0f, 0.0f); // Top Right glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left
glEnd(); // Done Drawing The Quad return TRUE; // Keep Going
}
![Page 70: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/70.jpg)
Your First Polygon!
int DrawGLScene(GLvoid) // Here's Where We Do All The Drawing{
// Clear The Screen And The Depth Buffer glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity(); // Reset The View
glTranslatef(-1.5f,0.0f,-6.0f); // Move Left 1.5 Units And Into The Screen 6.0glBegin(GL_TRIANGLES); // Drawing Using Triangles
glVertex3f( 0.0f, 1.0f, 0.0f); // Top glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right
glEnd(); // Finished Drawing The Triangle
glTranslatef(3.0f,0.0f,0.0f); // Move Right 3 UnitsglBegin(GL_QUADS); // Draw A Quad
glVertex3f(-1.0f, 1.0f, 0.0f); // Top Left glVertex3f( 1.0f, 1.0f, 0.0f); // Top Right glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left
glEnd(); // Done Drawing The Quad return TRUE; // Keep Going
}
![Page 71: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/71.jpg)
Your First Polygon!
int DrawGLScene(GLvoid) // Here's Where We Do All The Drawing{
// Clear The Screen And The Depth Buffer glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity(); // Reset The View
glTranslatef(-1.5f,0.0f,-6.0f); // Move Left 1.5 Units And Into The Screen 6.0glBegin(GL_TRIANGLES); // Drawing Using Triangles
glVertex3f( 0.0f, 1.0f, 0.0f); // Top glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right
glEnd(); // Finished Drawing The Triangle
glTranslatef(3.0f,0.0f,0.0f); // Move Right 3 UnitsglBegin(GL_QUADS); // Draw A Quad
glVertex3f(-1.0f, 1.0f, 0.0f); // Top Left glVertex3f( 1.0f, 1.0f, 0.0f); // Top Right glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left
glEnd(); // Done Drawing The Quad return TRUE; // Keep Going
}
![Page 72: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/72.jpg)
Your First Polygon!
int DrawGLScene(GLvoid) // Here's Where We Do All The Drawing{
// Clear The Screen And The Depth Buffer glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity(); // Reset The View
glTranslatef(-1.5f,0.0f,-6.0f); // Move Left 1.5 Units And Into The Screen 6.0glBegin(GL_TRIANGLES); // Drawing Using Triangles
glVertex3f( 0.0f, 1.0f, 0.0f); // Top glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right
glEnd(); // Finished Drawing The Triangle
glTranslatef(3.0f,0.0f,0.0f); // Move Right 3 UnitsglBegin(GL_QUADS); // Draw A Quad
glVertex3f(-1.0f, 1.0f, 0.0f); // Top Left glVertex3f( 1.0f, 1.0f, 0.0f); // Top Right glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left
glEnd(); // Done Drawing The Quad return TRUE; // Keep Going
}
![Page 73: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/73.jpg)
Your First Polygon!
int DrawGLScene(GLvoid) // Here's Where We Do All The Drawing{
// Clear The Screen And The Depth Buffer glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity(); // Reset The View
glTranslatef(-1.5f,0.0f,-6.0f); // Move Left 1.5 Units And Into The Screen 6.0glBegin(GL_TRIANGLES); // Drawing Using Triangles
glVertex3f( 0.0f, 1.0f, 0.0f); // Top glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right
glEnd(); // Finished Drawing The Triangle
glTranslatef(3.0f,0.0f,0.0f); // Move Right 3 UnitsglBegin(GL_QUADS); // Draw A Quad
glVertex3f(-1.0f, 1.0f, 0.0f); // Top Left glVertex3f( 1.0f, 1.0f, 0.0f); // Top Right glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left
glEnd(); // Done Drawing The Quad return TRUE; // Keep Going
}
![Page 74: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/74.jpg)
Your First Polygon!
int DrawGLScene(GLvoid) // Here's Where We Do All The Drawing{
// Clear The Screen And The Depth Buffer glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity(); // Reset The View
glTranslatef(-1.5f,0.0f,-6.0f); // Move Left 1.5 Units And Into The Screen 6.0glBegin(GL_TRIANGLES); // Drawing Using Triangles
glVertex3f( 0.0f, 1.0f, 0.0f); // Top glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right
glEnd(); // Finished Drawing The Triangle
glTranslatef(3.0f,0.0f,0.0f); // Move Right 3 UnitsglBegin(GL_QUADS); // Draw A Quad
glVertex3f(-1.0f, 1.0f, 0.0f); // Top Left glVertex3f( 1.0f, 1.0f, 0.0f); // Top Right glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left
glEnd(); // Done Drawing The Quad return TRUE; // Keep Going
}
![Page 75: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/75.jpg)
Your First Polygon!
int DrawGLScene(GLvoid) // Here's Where We Do All The Drawing{
// Clear The Screen And The Depth Buffer glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity(); // Reset The View
glTranslatef(-1.5f,0.0f,-6.0f); // Move Left 1.5 Units And Into The Screen 6.0glBegin(GL_TRIANGLES); // Drawing Using Triangles
glVertex3f( 0.0f, 1.0f, 0.0f); // Top glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right
glEnd(); // Finished Drawing The Triangle
glTranslatef(3.0f,0.0f,0.0f); // Move Right 3 UnitsglBegin(GL_QUADS); // Draw A Quad
glVertex3f(-1.0f, 1.0f, 0.0f); // Top Left glVertex3f( 1.0f, 1.0f, 0.0f); // Top Right glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left
glEnd(); // Done Drawing The Quad return TRUE; // Keep Going
}
![Page 76: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/76.jpg)
Your First Polygon!
int DrawGLScene(GLvoid) // Here's Where We Do All The Drawing{
// Clear The Screen And The Depth Buffer glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity(); // Reset The View
glTranslatef(-1.5f,0.0f,-6.0f); // Move Left 1.5 Units And Into The Screen 6.0glBegin(GL_TRIANGLES); // Drawing Using Triangles
glVertex3f( 0.0f, 1.0f, 0.0f); // Top glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right
glEnd(); // Finished Drawing The Triangle
glTranslatef(3.0f,0.0f,0.0f); // Move Right 3 UnitsglBegin(GL_QUADS); // Draw A Quad
glVertex3f(-1.0f, 1.0f, 0.0f); // Top Left glVertex3f( 1.0f, 1.0f, 0.0f); // Top Right glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left
glEnd(); // Done Drawing The Quad return TRUE; // Keep Going
}
![Page 77: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/77.jpg)
Your First Polygon!
int DrawGLScene(GLvoid) // Here's Where We Do All The Drawing{
// Clear The Screen And The Depth Buffer glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity(); // Reset The View
glTranslatef(-1.5f,0.0f,-6.0f); // Move Left 1.5 Units And Into The Screen 6.0glBegin(GL_TRIANGLES); // Drawing Using Triangles
glVertex3f( 0.0f, 1.0f, 0.0f); // Top glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right
glEnd(); // Finished Drawing The Triangle
glTranslatef(3.0f,0.0f,0.0f); // Move Right 3 UnitsglBegin(GL_QUADS); // Draw A Quad
glVertex3f(-1.0f, 1.0f, 0.0f); // Top Left glVertex3f( 1.0f, 1.0f, 0.0f); // Top Right glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left
glEnd(); // Done Drawing The Quad return TRUE; // Keep Going
}
![Page 78: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/78.jpg)
Your First Polygon!
int DrawGLScene(GLvoid) // Here's Where We Do All The Drawing{
// Clear The Screen And The Depth Buffer glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity(); // Reset The View
glTranslatef(-1.5f,0.0f,-6.0f); // Move Left 1.5 Units And Into The Screen 6.0glBegin(GL_TRIANGLES); // Drawing Using Triangles
glVertex3f( 0.0f, 1.0f, 0.0f); // Top glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right
glEnd(); // Finished Drawing The Triangle
glTranslatef(3.0f,0.0f,0.0f); // Move Right 3 UnitsglBegin(GL_QUADS); // Draw A Quad
glVertex3f(-1.0f, 1.0f, 0.0f); // Top Left glVertex3f( 1.0f, 1.0f, 0.0f); // Top Right glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left
glEnd(); // Done Drawing The Quad return TRUE; // Keep Going
}
![Page 79: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/79.jpg)
Your First Polygon!
int DrawGLScene(GLvoid) // Here's Where We Do All The Drawing{
// Clear The Screen And The Depth Buffer glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity(); // Reset The View
glTranslatef(-1.5f,0.0f,-6.0f); // Move Left 1.5 Units And Into The Screen 6.0glBegin(GL_TRIANGLES); // Drawing Using Triangles
glVertex3f( 0.0f, 1.0f, 0.0f); // Top glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right
glEnd(); // Finished Drawing The Triangle
glTranslatef(3.0f,0.0f,0.0f); // Move Right 3 UnitsglBegin(GL_QUADS); // Draw A Quad
glVertex3f(-1.0f, 1.0f, 0.0f); // Top Left glVertex3f( 1.0f, 1.0f, 0.0f); // Top Right glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left
glEnd(); // Done Drawing The Quad return TRUE; // Keep Going
}
![Page 80: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/80.jpg)
Your First Polygon!
int DrawGLScene(GLvoid) // Here's Where We Do All The Drawing{
// Clear The Screen And The Depth Buffer glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity(); // Reset The View
glTranslatef(-1.5f,0.0f,-6.0f); // Move Left 1.5 Units And Into The Screen 6.0glBegin(GL_TRIANGLES); // Drawing Using Triangles
glVertex3f( 0.0f, 1.0f, 0.0f); // Top glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right
glEnd(); // Finished Drawing The Triangle
glTranslatef(3.0f,0.0f,0.0f); // Move Right 3 UnitsglBegin(GL_QUADS); // Draw A Quad
glVertex3f(-1.0f, 1.0f, 0.0f); // Top Left glVertex3f( 1.0f, 1.0f, 0.0f); // Top Right glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left
glEnd(); // Done Drawing The Quad return TRUE; // Keep Going
}
![Page 81: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/81.jpg)
Your First Polygon!
int DrawGLScene(GLvoid) // Here's Where We Do All The Drawing{
// Clear The Screen And The Depth Buffer glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity(); // Reset The View
glTranslatef(-1.5f,0.0f,-6.0f); // Move Left 1.5 Units And Into The Screen 6.0glBegin(GL_TRIANGLES); // Drawing Using Triangles
glVertex3f( 0.0f, 1.0f, 0.0f); // Top glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right
glEnd(); // Finished Drawing The Triangle
glTranslatef(3.0f,0.0f,0.0f); // Move Right 3 UnitsglBegin(GL_QUADS); // Draw A Quad
glVertex3f(-1.0f, 1.0f, 0.0f); // Top Left glVertex3f( 1.0f, 1.0f, 0.0f); // Top Right glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left
glEnd(); // Done Drawing The Quad return TRUE; // Keep Going
}
![Page 82: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/82.jpg)
Your First Polygon!
• Coloring!
![Page 83: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/83.jpg)
Your First Polygon!
• Coloring!
glBegin(GL_TRIANGLES); // Drawing Using TrianglesglColor3f(1.0f,0.0f,0.0f); // Set The Color To RedglVertex3f( 0.0f, 1.0f, 0.0f); // TopglColor3f(0.0f,1.0f,0.0f); // Set The Color To GreenglVertex3f(-1.0f,-1.0f, 0.0f); // Bottom LeftglColor3f(0.0f,0.0f,1.0f); // Set The Color To BlueglVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right
glEnd(); // Finished Drawing The Triangle
![Page 84: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/84.jpg)
Your First Polygon!
![Page 85: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/85.jpg)
Your First Polygon!
• Coloring!
glBegin(GL_TRIANGLES); // Drawing Using TrianglesglColor3f(1.0f,0.0f,0.0f); // Set The Color To RedglVertex3f( 0.0f, 1.0f, 0.0f); // TopglColor3f(0.0f,1.0f,0.0f); // Set The Color To GreenglVertex3f(-1.0f,-1.0f, 0.0f); // Bottom LeftglColor3f(0.0f,0.0f,1.0f); // Set The Color To BlueglVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right
glEnd(); // Finished Drawing The Triangle
![Page 86: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/86.jpg)
Transformations
![Page 87: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/87.jpg)
TransformationsGLfloat rtri; // Angle For The Triangle ( NEW )GLfloat rquad; // Angle For The Quad ( NEW )int DrawGLScene(GLvoid) // Here's Where We Do All The Drawing{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth BufferglLoadIdentity(); // Reset The Current Modelview MatrixglTranslatef(-1.5f,0.0f,-6.0f); // Move Left 1.5 Units And Into The Screen 6.0glRotatef(rtri,0.0f,1.0f,0.0f); // Rotate The Triangle On The Y axis ( NEW )glBegin(GL_TRIANGLES); // Start Drawing A Triangle
glColor3f(1.0f,0.0f,0.0f); // Set Top Point Of Triangle To RedglVertex3f( 0.0f, 1.0f, 0.0f); // First Point Of The TriangleglColor3f(0.0f,1.0f,0.0f); // Set Left Point Of Triangle To GreenglVertex3f(-1.0f,-1.0f, 0.0f); // Second Point Of The TriangleglColor3f(0.0f,0.0f,1.0f); // Set Right Point Of Triangle To BlueglVertex3f( 1.0f,-1.0f, 0.0f); // Third Point Of The Triangle
glEnd(); // Done Drawing The TriangleglLoadIdentity(); // Reset The Current Modelview MatrixglTranslatef(1.5f,0.0f,-6.0f); // Move Right 1.5 Units And Into The Screen 6.0glRotatef(rquad,1.0f,0.0f,0.0f); // Rotate The Quad On The X axis ( NEW )glColor3f(0.5f,0.5f,1.0f); // Set The Color To Blue One Time OnlyglBegin(GL_QUADS); // Draw A Quad
glVertex3f(-1.0f, 1.0f, 0.0f); // Top LeftglVertex3f( 1.0f, 1.0f, 0.0f); // Top RightglVertex3f( 1.0f,-1.0f, 0.0f); // Bottom RightglVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left
glEnd(); // Done Drawing The Quadrtri+=0.2f; // Increase The Rotation Variable For The Triangle ( NEW )rquad-=0.15f; // Decrease The Rotation Variable For The Quad ( NEW )return TRUE; // Keep Going
}
![Page 88: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/88.jpg)
TransformationsGLfloat rtri; // Angle For The Triangle ( NEW )GLfloat rquad; // Angle For The Quad ( NEW )int DrawGLScene(GLvoid) // Here's Where We Do All The Drawing{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth BufferglLoadIdentity(); // Reset The Current Modelview MatrixglTranslatef(-1.5f,0.0f,-6.0f); // Move Left 1.5 Units And Into The Screen 6.0glRotatef(rtri,0.0f,1.0f,0.0f); // Rotate The Triangle On The Y axis ( NEW )glBegin(GL_TRIANGLES); // Start Drawing A Triangle
glColor3f(1.0f,0.0f,0.0f); // Set Top Point Of Triangle To RedglVertex3f( 0.0f, 1.0f, 0.0f); // First Point Of The TriangleglColor3f(0.0f,1.0f,0.0f); // Set Left Point Of Triangle To GreenglVertex3f(-1.0f,-1.0f, 0.0f); // Second Point Of The TriangleglColor3f(0.0f,0.0f,1.0f); // Set Right Point Of Triangle To BlueglVertex3f( 1.0f,-1.0f, 0.0f); // Third Point Of The Triangle
glEnd(); // Done Drawing The TriangleglLoadIdentity(); // Reset The Current Modelview MatrixglTranslatef(1.5f,0.0f,-6.0f); // Move Right 1.5 Units And Into The Screen 6.0glRotatef(rquad,1.0f,0.0f,0.0f); // Rotate The Quad On The X axis ( NEW )glColor3f(0.5f,0.5f,1.0f); // Set The Color To Blue One Time OnlyglBegin(GL_QUADS); // Draw A Quad
glVertex3f(-1.0f, 1.0f, 0.0f); // Top LeftglVertex3f( 1.0f, 1.0f, 0.0f); // Top RightglVertex3f( 1.0f,-1.0f, 0.0f); // Bottom RightglVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left
glEnd(); // Done Drawing The Quadrtri+=0.2f; // Increase The Rotation Variable For The Triangle ( NEW )rquad-=0.15f; // Decrease The Rotation Variable For The Quad ( NEW )return TRUE; // Keep Going
}
![Page 89: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/89.jpg)
TransformationsGLfloat rtri; // Angle For The Triangle ( NEW )GLfloat rquad; // Angle For The Quad ( NEW )int DrawGLScene(GLvoid) // Here's Where We Do All The Drawing{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth BufferglLoadIdentity(); // Reset The Current Modelview MatrixglTranslatef(-1.5f,0.0f,-6.0f); // Move Left 1.5 Units And Into The Screen 6.0glRotatef(rtri,0.0f,1.0f,0.0f); // Rotate The Triangle On The Y axis ( NEW )glBegin(GL_TRIANGLES); // Start Drawing A Triangle
glColor3f(1.0f,0.0f,0.0f); // Set Top Point Of Triangle To RedglVertex3f( 0.0f, 1.0f, 0.0f); // First Point Of The TriangleglColor3f(0.0f,1.0f,0.0f); // Set Left Point Of Triangle To GreenglVertex3f(-1.0f,-1.0f, 0.0f); // Second Point Of The TriangleglColor3f(0.0f,0.0f,1.0f); // Set Right Point Of Triangle To BlueglVertex3f( 1.0f,-1.0f, 0.0f); // Third Point Of The Triangle
glEnd(); // Done Drawing The TriangleglLoadIdentity(); // Reset The Current Modelview MatrixglTranslatef(1.5f,0.0f,-6.0f); // Move Right 1.5 Units And Into The Screen 6.0glRotatef(rquad,1.0f,0.0f,0.0f); // Rotate The Quad On The X axis ( NEW )glColor3f(0.5f,0.5f,1.0f); // Set The Color To Blue One Time OnlyglBegin(GL_QUADS); // Draw A Quad
glVertex3f(-1.0f, 1.0f, 0.0f); // Top LeftglVertex3f( 1.0f, 1.0f, 0.0f); // Top RightglVertex3f( 1.0f,-1.0f, 0.0f); // Bottom RightglVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left
glEnd(); // Done Drawing The Quadrtri+=0.2f; // Increase The Rotation Variable For The Triangle ( NEW )rquad-=0.15f; // Decrease The Rotation Variable For The Quad ( NEW )return TRUE; // Keep Going
}
![Page 90: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/90.jpg)
TransformationsGLfloat rtri; // Angle For The Triangle ( NEW )GLfloat rquad; // Angle For The Quad ( NEW )int DrawGLScene(GLvoid) // Here's Where We Do All The Drawing{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth BufferglLoadIdentity(); // Reset The Current Modelview MatrixglTranslatef(-1.5f,0.0f,-6.0f); // Move Left 1.5 Units And Into The Screen 6.0glRotatef(rtri,0.0f,1.0f,0.0f); // Rotate The Triangle On The Y axis ( NEW )glBegin(GL_TRIANGLES); // Start Drawing A Triangle
glColor3f(1.0f,0.0f,0.0f); // Set Top Point Of Triangle To RedglVertex3f( 0.0f, 1.0f, 0.0f); // First Point Of The TriangleglColor3f(0.0f,1.0f,0.0f); // Set Left Point Of Triangle To GreenglVertex3f(-1.0f,-1.0f, 0.0f); // Second Point Of The TriangleglColor3f(0.0f,0.0f,1.0f); // Set Right Point Of Triangle To BlueglVertex3f( 1.0f,-1.0f, 0.0f); // Third Point Of The Triangle
glEnd(); // Done Drawing The Triangle
glLoadIdentity(); // Reset The Current Modelview MatrixglTranslatef(1.5f,0.0f,-6.0f); // Move Right 1.5 Units And Into The Screen 6.0glRotatef(rquad,1.0f,0.0f,0.0f); // Rotate The Quad On The X axis ( NEW )glColor3f(0.5f,0.5f,1.0f); // Set The Color To Blue One Time OnlyglBegin(GL_QUADS); // Draw A Quad
glVertex3f(-1.0f, 1.0f, 0.0f); // Top LeftglVertex3f( 1.0f, 1.0f, 0.0f); // Top RightglVertex3f( 1.0f,-1.0f, 0.0f); // Bottom RightglVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left
glEnd(); // Done Drawing The Quadrtri+=0.2f; // Increase The Rotation Variable For The Triangle ( NEW )rquad-=0.15f; // Decrease The Rotation Variable For The Quad ( NEW )return TRUE; // Keep Going
}
![Page 91: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/91.jpg)
TransformationsGLfloat rtri; // Angle For The Triangle ( NEW )GLfloat rquad; // Angle For The Quad ( NEW )int DrawGLScene(GLvoid) // Here's Where We Do All The Drawing{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth BufferglLoadIdentity(); // Reset The Current Modelview MatrixglTranslatef(-1.5f,0.0f,-6.0f); // Move Left 1.5 Units And Into The Screen 6.0glRotatef(rtri,0.0f,1.0f,0.0f); // Rotate The Triangle On The Y axis ( NEW )glBegin(GL_TRIANGLES); // Start Drawing A Triangle
glColor3f(1.0f,0.0f,0.0f); // Set Top Point Of Triangle To RedglVertex3f( 0.0f, 1.0f, 0.0f); // First Point Of The TriangleglColor3f(0.0f,1.0f,0.0f); // Set Left Point Of Triangle To GreenglVertex3f(-1.0f,-1.0f, 0.0f); // Second Point Of The TriangleglColor3f(0.0f,0.0f,1.0f); // Set Right Point Of Triangle To BlueglVertex3f( 1.0f,-1.0f, 0.0f); // Third Point Of The Triangle
glEnd(); // Done Drawing The Triangle
glLoadIdentity(); // Reset The Current Modelview MatrixglTranslatef(1.5f,0.0f,-6.0f); // Move Right 1.5 Units And Into The Screen 6.0glRotatef(rquad,1.0f,0.0f,0.0f); // Rotate The Quad On The X axis ( NEW )glColor3f(0.5f,0.5f,1.0f); // Set The Color To Blue One Time OnlyglBegin(GL_QUADS); // Draw A Quad
glVertex3f(-1.0f, 1.0f, 0.0f); // Top LeftglVertex3f( 1.0f, 1.0f, 0.0f); // Top RightglVertex3f( 1.0f,-1.0f, 0.0f); // Bottom RightglVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left
glEnd(); // Done Drawing The Quadrtri+=0.2f; // Increase The Rotation Variable For The Triangle ( NEW )rquad-=0.15f; // Decrease The Rotation Variable For The Quad ( NEW )return TRUE; // Keep Going
}
![Page 92: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/92.jpg)
Your First Polygon!
![Page 93: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/93.jpg)
Your First Polygon!
![Page 94: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/94.jpg)
Transformations – 3D Objects!
![Page 95: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/95.jpg)
![Page 96: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/96.jpg)
![Page 97: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/97.jpg)
![Page 98: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/98.jpg)
Transformations – Step forward!
![Page 99: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/99.jpg)
Transformations – Step forward!
• Pushing Matrices
• Popping Matrices
![Page 100: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/100.jpg)
Transformations – Local VS World
![Page 101: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/101.jpg)
Transformations – Local VS World
![Page 102: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/102.jpg)
Binding Textures
![Page 103: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/103.jpg)
Binding Textures
![Page 104: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/104.jpg)
Binding Textures
![Page 105: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/105.jpg)
Binding Textures
![Page 106: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/106.jpg)
Binding Textures
![Page 107: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/107.jpg)
Binding Textures
![Page 108: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/108.jpg)
Binding Textures
![Page 109: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/109.jpg)
Binding TexturesglBegin(GL_QUADS);
// Front FaceglTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f); // Bottom Left Of The Texture and QuadglTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f); // Bottom Right Of The Texture and QuadglTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, 1.0f); // Top Right Of The Texture and QuadglTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 1.0f); // Top Left Of The Texture and Quad// Back FaceglTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f); // Bottom Right Of The Texture and QuadglTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f); // Top Right Of The Texture and QuadglTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, 1.0f, -1.0f); // Top Left Of The Texture and QuadglTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f); // Bottom Left Of The Texture and Quad// Top FaceglTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f); // Top Left Of The Texture and QuadglTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, 1.0f, 1.0f); // Bottom Left Of The Texture and QuadglTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, 1.0f, 1.0f); // Bottom Right Of The Texture and QuadglTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, -1.0f); // Top Right Of The Texture and Quad// Bottom FaceglTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, -1.0f, -1.0f); // Top Right Of The Texture and QuadglTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, -1.0f, -1.0f); // Top Left Of The Texture and QuadglTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f); // Bottom Left Of The Texture and QuadglTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f); // Bottom Right Of The Texture and Quad// Right faceglTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f); // Bottom Right Of The Texture and QuadglTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, -1.0f); // Top Right Of The Texture and QuadglTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, 1.0f, 1.0f); // Top Left Of The Texture and QuadglTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f); // Bottom Left Of The Texture and Quad// Left FaceglTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f); // Bottom Left Of The Texture and QuadglTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f); // Bottom Right Of The Texture and QuadglTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 1.0f); // Top Right Of The Texture and QuadglTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f); // Top Left Of The Texture and Quad
glEnd();
![Page 110: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/110.jpg)
Binding TexturesglBegin(GL_QUADS);
// Front FaceglTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f); // Bottom Left Of The Texture and QuadglTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f); // Bottom Right Of The Texture and QuadglTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, 1.0f); // Top Right Of The Texture and QuadglTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 1.0f); // Top Left Of The Texture and Quad// Back FaceglTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f); // Bottom Right Of The Texture and QuadglTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f); // Top Right Of The Texture and QuadglTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, 1.0f, -1.0f); // Top Left Of The Texture and QuadglTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f); // Bottom Left Of The Texture and Quad// Top FaceglTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f); // Top Left Of The Texture and QuadglTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, 1.0f, 1.0f); // Bottom Left Of The Texture and QuadglTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, 1.0f, 1.0f); // Bottom Right Of The Texture and QuadglTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, -1.0f); // Top Right Of The Texture and Quad// Bottom FaceglTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, -1.0f, -1.0f); // Top Right Of The Texture and QuadglTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, -1.0f, -1.0f); // Top Left Of The Texture and QuadglTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f); // Bottom Left Of The Texture and QuadglTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f); // Bottom Right Of The Texture and Quad// Right faceglTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f); // Bottom Right Of The Texture and QuadglTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, -1.0f); // Top Right Of The Texture and QuadglTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, 1.0f, 1.0f); // Top Left Of The Texture and QuadglTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f); // Bottom Left Of The Texture and Quad// Left FaceglTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f); // Bottom Left Of The Texture and QuadglTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f); // Bottom Right Of The Texture and QuadglTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 1.0f); // Top Right Of The Texture and QuadglTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f); // Top Left Of The Texture and Quad
glEnd();
![Page 111: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/111.jpg)
Binding TexturesglBegin(GL_QUADS);
// Front FaceglTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f); // Bottom Left Of The Texture and QuadglTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f); // Bottom Right Of The Texture and QuadglTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, 1.0f); // Top Right Of The Texture and QuadglTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 1.0f); // Top Left Of The Texture and Quad// Back FaceglTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f); // Bottom Right Of The Texture and QuadglTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f); // Top Right Of The Texture and QuadglTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, 1.0f, -1.0f); // Top Left Of The Texture and QuadglTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f); // Bottom Left Of The Texture and Quad// Top FaceglTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f); // Top Left Of The Texture and QuadglTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, 1.0f, 1.0f); // Bottom Left Of The Texture and QuadglTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, 1.0f, 1.0f); // Bottom Right Of The Texture and QuadglTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, -1.0f); // Top Right Of The Texture and Quad// Bottom FaceglTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, -1.0f, -1.0f); // Top Right Of The Texture and QuadglTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, -1.0f, -1.0f); // Top Left Of The Texture and QuadglTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f); // Bottom Left Of The Texture and QuadglTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f); // Bottom Right Of The Texture and Quad// Right faceglTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f); // Bottom Right Of The Texture and QuadglTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, -1.0f); // Top Right Of The Texture and QuadglTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, 1.0f, 1.0f); // Top Left Of The Texture and QuadglTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f); // Bottom Left Of The Texture and Quad// Left FaceglTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f); // Bottom Left Of The Texture and QuadglTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f); // Bottom Right Of The Texture and QuadglTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 1.0f); // Top Right Of The Texture and QuadglTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f); // Top Left Of The Texture and Quad
glEnd();
// Front FaceglTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f); // Bottom Left Of The Texture and QuadglTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f); // Bottom Right Of The Texture and QuadglTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, 1.0f); // Top Right Of The Texture and QuadglTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 1.0f); // Top Left Of The Texture and Quad
![Page 112: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/112.jpg)
Binding TexturesglBegin(GL_QUADS);
// Front FaceglTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f); // Bottom Left Of The Texture and QuadglTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f); // Bottom Right Of The Texture and QuadglTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, 1.0f); // Top Right Of The Texture and QuadglTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 1.0f); // Top Left Of The Texture and Quad// Back FaceglTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f); // Bottom Right Of The Texture and QuadglTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f); // Top Right Of The Texture and QuadglTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, 1.0f, -1.0f); // Top Left Of The Texture and QuadglTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f); // Bottom Left Of The Texture and Quad// Top FaceglTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f); // Top Left Of The Texture and QuadglTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, 1.0f, 1.0f); // Bottom Left Of The Texture and QuadglTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, 1.0f, 1.0f); // Bottom Right Of The Texture and QuadglTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, -1.0f); // Top Right Of The Texture and Quad// Bottom FaceglTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, -1.0f, -1.0f); // Top Right Of The Texture and QuadglTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, -1.0f, -1.0f); // Top Left Of The Texture and QuadglTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f); // Bottom Left Of The Texture and QuadglTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f); // Bottom Right Of The Texture and Quad// Right faceglTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f); // Bottom Right Of The Texture and QuadglTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, -1.0f); // Top Right Of The Texture and QuadglTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, 1.0f, 1.0f); // Top Left Of The Texture and QuadglTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f); // Bottom Left Of The Texture and Quad// Left FaceglTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f); // Bottom Left Of The Texture and QuadglTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f); // Bottom Right Of The Texture and QuadglTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 1.0f); // Top Right Of The Texture and QuadglTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f); // Top Left Of The Texture and Quad
glEnd();
// Front FaceglTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f); // Bottom Left Of The Texture and QuadglTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f); // Bottom Right Of The Texture and QuadglTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, 1.0f); // Top Right Of The Texture and QuadglTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 1.0f); // Top Left Of The Texture and Quad
![Page 113: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/113.jpg)
![Page 114: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/114.jpg)
![Page 115: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/115.jpg)
![Page 116: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/116.jpg)
Texturing
![Page 117: OpenGL Starter L01](https://reader034.fdocuments.us/reader034/viewer/2022042507/5550c4b9b4c905fa618b55d3/html5/thumbnails/117.jpg)
That’s it for today!Hope you enjoy it! :D