Two questions about lesson 7 of OpenGL on http://nehe.gamedev.net

Started by
2 comments, last by Xiang 21 years, 1 month ago
I have posted the topic on other forum, but maybe I can get quick answer here, thanks. I''d like to say this is a very good turial of OpenGL. Question 1: I find the line below in the lesson, //---- start ---- glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[0]->sizeX, TextureImage[0]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data); //---- end ---- the statement is appeared 3 times with TextureImage[0]. I mean why we only use TextureImage[0], not TextureImage[1], TextureImage[2] and so on? If we needn''t use TextureImage[1] here, then when will we use it? Question 2: Lesson 7 teaches us how to use Lights, then in the lesson the program declares two lights, I don''t know why the program only use: glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient); glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse); to set up those lights? I mean I don''t know the first parameter of glLightfv, what is GL_LIGHT1? Anyone here please help me, thanks a lot. I WANT TO BELIEVE
I WANT TO BELIEVE
Advertisement
I am not an expert but I think I know the answer to your first question... TextureImage[0] is a pointer and since only one texture file was loaded you only need one pointer...although there are 3 variations in the filtering of the texture stored in texture[0], texture[1], and texture[2].

The second question is a good one and I was surprised I didn''t think of that when I went through that lesson. If you notice only one type of lighting takes place in the lesson. You toggle between ambient and diffuse by hitting the L key. I forgot what L actually does (check the code) but I think it changes between ambient and diffuse lighting (so there may not be a need for more than one light). I have the red book (I suggest you purchase it) and it says you can have parameter GL_LIGHT0 to GL_LIGHT7...so I am asumming only 8 lights are allowed in a scene...I am not sure about this though...
The first question is fairly simple. The reason it does it 3 times is for you filters. when you hit the ''f'' key while running the program the textures change quality. If you look the lesson always uses TextureImage[0] but changes texture[0] every time. So we are making 3 different quality textures from the same bmp.

As for the second question we only use one light in the scene. all that is doing is setting different properties of that one light. A single light can have both diffuse and ambient light. ambient lighting lights up everything no matter its orientation. diffuse lighting is more like a normal lamp, how much it lights and object depends on how the object faces the light.

glLightfv( Light#, property, value)

Hope that all make sense...
I'm don't know much but I can try to help... just email me at... Shadow_0f_Light@Yahoo.com(the '0' in 'Of' is a zero :P)
Thank you. I believe I can understand.
I WANT TO BELIEVE

This topic is closed to new replies.

Advertisement