Upcoming SlideShare
×

# OpenGL Starter L02

799 views
652 views

Published on

A Short 2-slide Starter Course of OpenGL.

1 Like
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

Views
Total views
799
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
123
0
Likes
1
Embeds 0
No embeds

No notes for slide

### OpenGL Starter L02

2. 2. Cube Maps
3. 3. Cube Maps
4. 4. Cube Maps glBegin(GL_QUADS); // Negative X glTexCoord3f(-1.0f, -1.0f, 1.0f); glVertex3f(-fExtent, -fExtent, fExtent); glTexCoord3f(-1.0f, -1.0f, -1.0f); glVertex3f(-fExtent, -fExtent, -fExtent); glTexCoord3f(-1.0f, 1.0f, -1.0f); glVertex3f(-fExtent, fExtent, -fExtent); glTexCoord3f(-1.0f, 1.0f, 1.0f); glVertex3f(-fExtent, fExtent, fExtent); …..
5. 5. Texture Mapping
6. 6. FPS
7. 7. FPS Frame Per Second
8. 8. Lighting and Blending!
9. 9. Lighting and Blending!
10. 10. Combining light and texture
11. 11. Lighting
12. 12. Lighting
13. 13. Lighting
14. 14. Lighting
15. 15. Lighting
16. 16. Lighting
17. 17. Lighting
18. 18. Lighting
19. 19. Lighting
20. 20. Lighting
21. 21. Lighting - Types • Ambient Light: doesn’t come from any particular direction. It has an original source somewhere, but the rays of light have bounced around the room or scene and become directionless.
22. 22. Lighting - Types • Diffuse Light: The diffuse part of an OpenGL light is the directional component that appears to come from a particular direction and is reflected off a surface with an intensity proportional to the angle at which the light rays strike the surface. Thus, the object surface is brighter if the light is pointed directly at the surface than if the light grazes the surface from a greater angle.
23. 23. Lighting - Types • Specular light: Like diffuse light, specular light is a highly directional property, but it interacts more sharply with the surface and in a particular direction.
24. 24. Lighting The per-vertex specular highlight is improved by using separate specular or a specular exponent texture.
25. 25. Lighting • An unlit jet reflects no light.
26. 26. Lighting The output from the completed AMBIENT sample program. The output from the AMBIENT program when the light source is cut in half.
27. 27. Lighting GLfloat LightDiffuse[]= { 1.0f, 1.0f, 1.0f, 1.0f }; // Diffuse Light Values GLfloat LightAmbient[]= { 0.5f, 0.5f, 0.5f, 1.0f }; // Ambient Light Values GLfloat LightPosition[]= { 0.0f, 0.0f, 2.0f, 1.0f }; // Light Position
28. 28. Lighting GLfloat LightDiffuse[]= { 1.0f, 1.0f, 1.0f, 1.0f }; // Diffuse Light Values GLfloat LightAmbient[]= { 0.5f, 0.5f, 0.5f, 1.0f }; // Ambient Light Values glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse); // Setup The Diffuse Light glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient); // Setup The Ambient Light glLightfv(GL_LIGHT1, GL_POSITION,LightPosition); // Position The Light GLfloat LightPosition[]= { 0.0f, 0.0f, 2.0f, 1.0f }; // Light Position
29. 29. Lighting GLfloat LightDiffuse[]= { 1.0f, 1.0f, 1.0f, 1.0f }; // Diffuse Light Values GLfloat LightAmbient[]= { 0.5f, 0.5f, 0.5f, 1.0f }; // Ambient Light Values glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse); // Setup The Diffuse Light glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient); // Setup The Ambient Light glLightfv(GL_LIGHT1, GL_POSITION,LightPosition); // Position The Light glEnable(GL_LIGHT1); // Enable Light One GLfloat LightPosition[]= { 0.0f, 0.0f, 2.0f, 1.0f }; // Light Position
30. 30. Lighting GLfloat LightAmbient[]= { 0.5f, 0.5f, 0.5f, 1.0f }; // Ambient Light Values GLfloat LightDiffuse[]= { 1.0f, 1.0f, 1.0f, 1.0f }; // Diffuse Light Values GLfloat LightPosition[]= { 0.0f, 0.0f, 2.0f, 1.0f }; // Light Position if (keys['B']) // Is B Key Pressed And bp FALSE? { bp=TRUE; // If So, bp Becomes TRUE blend =!blend; // Toggle blend TRUE / FALSE if(blend) // Is blend TRUE? { glEnable(GL_BLEND); // Turn Blending On glDisable(GL_DEPTH_TEST); // Turn Depth Testing Off } else // Otherwise { glDisable(GL_BLEND); // Turn Blending Off glEnable(GL_DEPTH_TEST); // Turn Depth Testing On } }
31. 31. Blending
32. 32. Blending glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
33. 33. Blending glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
34. 34. Blending
35. 35. Wire Framing
36. 36. Wire Framing
42. 42. Shadowing // Draw objects in the scene, including base plane DrawModels(GL_TRUE); // Enable alpha test so that shadowed fragments are discarded glAlphaFunc(GL_GREATER, 0.9f); glEnable(GL_ALPHA_TEST); glLightfv(GL_LIGHT0, GL_AMBIENT, ambientLight); glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuseLight); // Set up shadow comparison glEnable(GL_TEXTURE_2D); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE,GL_COMPARE_R_TO_TEXTURE); // Set up the eye plane for projecting the shadow map on the scene glEnable(GL_TEXTURE_GEN_S); glEnable(GL_TEXTURE_GEN_T); glEnable(GL_TEXTURE_GEN_R); glEnable(GL_TEXTURE_GEN_Q); …. DrawModels(GL_TRUE);
43. 43. Depth Buffer
44. 44. Fog
45. 45. Fog • Why Fog?!
46. 46. Blurring
47. 47. Blurring
48. 48. Blurring
49. 49. Blurring
50. 50. Blurring
51. 51. Dynamic environment mapping
52. 52. Dynamic environment mapping
53. 53. Camera
54. 54. Camera
55. 55. Camera
56. 56. Camera
57. 57. Camera
58. 58. Clipping
59. 59. Clipping
60. 60. Reflection
61. 61. Reflection
62. 62. Brightening
63. 63. Brightening
64. 64. Blooming!
65. 65. Blooming!
66. 66. Blooming!
67. 67. Antialiasing
68. 68. Anitalysing
69. 69. Particles System
70. 70. Particles System
71. 71. Particles System
72. 72. Particles System
73. 73. Simple Particle System • glTexCoord2d(); typedef struct // Create A Structure For Particle { bool active; // Active (Yes/No) float life; // Particle Life float fade; // Fade Speed float r; // Red Value float g; // Green Value float b; // Blue Value float x; // X Position float y; // Y Position float z; // Z Position float xi; // X Direction float yi; // Y Direction float zi; // Z Direction float xg; // X Gravity float yg; // Y Gravity float zg; // Z Gravity } particles; // Particles particles particle[MAX_PARTICLES]; // Particle Array (Room For Particle Info)
74. 74. LensFlare
75. 75. LensFlare