Jump to content
  • Advertisement
Sign in to follow this  
denebo

OpenGL Need help understanding this... (from The OpenGL Programming Guide - The Redbook)

This topic is 2752 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I decided to get this book and dive into graphics programming with OpenGL. The problem is I lack the necessary understanding that an advanced computer scientist or mathematician might have.

What does the book mean by "glEnable() and glDisable() can be stored in a display list, but the specification of vertex arrays cannot"?
in
"You might be asking yourself why the architects of OpenGL created these new (and long) command names, like gl*ClientState(), for example. Why can't you just call glEnable() and glDisable()? One reason is that glEnable() and glDisable() can be stored in a display list, but the specification of vertex arrays cannot, because the data remains on the client side."

Another quick question. From what I've read, I see we manually set our normal vector's values. This being said, is it possible to make a polygon with normal vectors pointing everywhere (like messy, messed up normals) and have it's lighting be all messed up? Just testing if I have the correct understanding of normal vectors in OpenGL.

Share this post


Link to post
Share on other sites
Advertisement
I believe display lists are just a series of command (that can be executed later). You can enable and disable things i n them (such as turning lighting on or off) but you can't setup avertex array in them (and why would you, setting up a vertex array is perhaps something you'd only do one but use many times, Just like a display list is something you probably setup one but use many times). If you setup somethign in a display list and use the display list many times then you will also do that set up everytime (no idea what would happen). I've never used display lists, thats just what I recall reading about them a very long time ago so it may be wrong.

It would be possible to have your normals as you describe. I guess you could use a noise texture and use each pixels value to set the normal. This would require the use of shaders though, take a look at normal mapping. Instead of using a normal texture you'd want to use a noise texture.

Share this post


Link to post
Share on other sites
I wouldn't worry too much about that, display lists are deprecated and not really used anymore.

But if you want to know, glEnable sends a command into the graphics card hardware that tells it to change some settings on the actual silicon, like turning on or off a certain part of the pipeline. When OpenGL talks about a "server" or a "client", the server is the graphics card, and the client is the rest of the computer on the other side of the PCI bus (or whatever is sending the commands to OpenGL). The clientState commands don't actually go to the gpu, but rather just tell the driver how to organize the data streams that it will eventually send to the GPU.

Display lists live inside the GPU only so they have no knowledge of the commands that are between the client<->driver.



This being said, is it possible to make a polygon with normal vectors pointing everywhere (like messy, messed up normals) and have it's lighting be all messed up?
[/quote]
Yes. Basically the normal vector just tells the client which way the polygon is facing. You can adjust this to get different visual effects like smooth surfaces or sharp edges. If you send garbage normals, than you'll have garbage lighting. In simple terms the lighting is calculating by taking the dot product of the normal vector with the light vector. Normals that face the light get brightly lit, while those that face away are dimly lit. So if you have them pointing in the wrong direction your lighting will be wrong.

Share this post


Link to post
Share on other sites
Got it. Thanks for the replies.
I've learned other APIs like Managed DX before, but I never really went too in depth about what the commands did behind the syntax cover. Although I did manage to create some neat games just like that, my lack of understanding of the actual API did limit me a lot in making high level, awesome stuff.

Finally getting around to changing my learning habits rolleyes.gif better now than later...

Share this post


Link to post
Share on other sites
About the normales, yes you can set them up however you want, and yes it will have an impact on the lighting. But this can be done to achieve some effect on purpose. For example you can render a quad that looks like a tube by setting up the normals slightly co-planar with the quad. With the interpolation and the lighting you will obtain a cheap tube.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!