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

Started by
1 comment, last by Xiang 21 years, 1 month ago
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
To your second question:
When you set up a light in OpenGL, you have to declare what kind of light it is going to be. In the case that you have -->

glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient);
glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse);

It''s saying to apply the Ambient and the Diffuse lights to the first light that you created. If you had, for example, 2 lights all together, then to declare them you would do:

glLightfv(GL_LIGHT0, GL_AMBIENT, LightAmbient); //First light
glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient); //Second light
//same with diffuse, if you wish to use that too

The reference to lights with OpenGL is the same with arrays, they start at index zero.

I hope that answered your second question. I''m not really sure about the first one, but it might be, that you just place the textures in one address of the array and then will call all of the textures out of that one. But like I said, I''m not entirely sure.
I have post the question on another forum and got the answer, maybe you can understand the questions there. http://gamedev.net/community/forums/topic.asp?topic_id=147082

Thank you.

I WANT TO BELIEVE
I WANT TO BELIEVE

This topic is closed to new replies.

Advertisement