You Like My Tutorials? Click The Banner To Keep 'Em Coming!

glGameDeveloper(): The Game Developer's Source for OpenGL Coding
Main Menu
Latest News
Archived News
Tutorials
Links
E-Mail Me

Other
Message Board
My Guestbook

Tutorials -- Drawing Triangles
 


Drawing Triangles in OpenGL Page 3 of 4
< Previous Jump to Page: 1 | 2 | 3 | 4 Next >

The Code (con't)

Now we'll get into lighting.

GLfloat LightAmbient[]  = { 0.75f, 0.75f, 0.75f, 1.0f};
GLfloat LightDiffuse[]  = { 1.0f, 1.0f, 1.0f, 0.9f};
GLfloat LightSpecular[] = { 0.8f, 0.8f, 0.8f, 1.0f};

glEnable(GL_LIGHT0);
glLightfv(GL_LIGHT0, GL_AMBIENT, LightAmbient);
glLightfv(GL_LIGHT0, GL_DIFFUSE, LightDiffuse);
glLightfv(GL_LIGHT0, GL_SPECULAR, LightSpecular);

This code first sets our variables for lighting up our scene. I'm not much of an expert on this, but using these gives a good effect. You can tweak around with them to see what happens, which can make things appear different colors and stuff. Later I'll have a tutorial on lighting, like positional vertex lighting, and even light maps once I figure those out. =]

Drawing Triangles in OpenGL Page 3 of 4
< Previous Jump to Page: 1 | 2 | 3 | 4 Next >

This site best viewed with MS Internet Explorer 5.0 at 16-bit color and at least 800x600.

All Contents of this site are Copyright 1999, 2000 Joe Zimmerman. No part of this site (code, HTML, etc.) may be reproduced without my permission.

Click Here!