PDA

View Full Version : Lighting a textured cube(how);



Phillfrog
05-29-2002, 09:18 PM
Ok, i have limited knowledge of c++, but i have managed to get a rotating textured cube (using vc++6) but how do i light it, and what does this do?
glTexCoord2f(0.0f, 1.0f);
i want to add at least one light to it, but i can't find a tutorial that works. nehe's doesn't seem to look any different from what i already have. and is bump mapping hard? or just a lot of work?

if u can halp. fanx

Phillfrog
05-29-2002, 09:19 PM
...also, what is Glut??????

chmod
05-29-2002, 11:47 PM
Regarding Glut; Glut is an API that handles window management and input for you, by letting you register callbacks for special events (like keypresses, mouse-clicks,etc.). It will also setup a openGL capable window for you.
(search opengl.org for GLUT, you'll find some interesting stuff. I think the page you would want to visit is nate robins' page (ported GLUT to MS.) He's got some excelent tut's.

You'll notice that for each glVertex*() call you make, you also make a glTexCoord*() call. openGL needs this information so that it knows what elements in texture space (basically your 2d bitmap) is to be mapped onto your polygon. (Nate's tut's give a great example of what this is and how it works.)

jono_123
05-29-2002, 11:54 PM
hi there
im not very experienced and this is off the top of my head so here goes :
for ligting all you really need to do is
call glEnable(GL_LIGHT0); and glEnable(GL_LIGHTING); and it should light it up alright i think.

glTexCoord2f(0.0f, 1.0f); is saying that you are telling opengl to do something with the top right hand corner of a 2d texture (x,y) = (0.0f,1.0f)

i dont know anything about bump mapping so i can't help there

glut has things like glutSolidCube(); glutSolidSphere(); etc and a few other things like that

if you need any more help email me at jono_123_2000@hotmail.com

http://www.opengl.org/discussion_boards/ubb/smile.gif

Deiussum
05-30-2002, 04:29 AM
For lighting, you also have to specify normals, which is basically a direction vector that is used to calculate how to light your model.