Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

SimpleDude

OpenGL OpenGL Game Programming questions

This topic is 5933 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

Hey all, I''m currently reading through OpenGL game programming, and I have some questions I hope you could answer about bitmaps and images in OpenGL: What are the uses for glPixelStorei() ? The book says that this is used to manage the allignment of bytes in the memory; whats the optimal alignment ? How do you find whats the optimal alignment is for different computers ? Does it really matter ? The book swaps RGB to BGR when loading bitmap files, why does OpenGL require that? The chart with pixel formats shows that both GL_RGB and GL_BGR exist, why is that ? What is the Color Buffer (GL_COLOR), depth buffer (GL_DEPTH) and stencil buffer (GL_STENCIL) ? Hope I didnt scare you with all the different questions Thanks in advance,

Share this post


Link to post
Share on other sites
Advertisement
I''m really not sure how much I can help here, I''m no expert, but you could read the descriptions of the functions at: http://www.eecs.tulane.edu/www/graphics/doc/OpenGL-Man-Pages/opengl_index_alpha.html

It helps me when I need to know exactly what a GL function does.

Share this post


Link to post
Share on other sites
quote:
Original post by SimpleDude
What are the uses for glPixelStorei() ? The book says that this is used to manage the allignment of bytes in the memory; whats the optimal alignment ? How do you find whats the optimal alignment is for different computers ? Does it really matter ?

It''s not really an issue of using an "optimal" alignment. glPixelStorei() is there to help you ensure that the way you are using data and the way OpenGL is using data are consistent with each other. It''s a little complication, but the MSDN documentation of this function should help explain things a bit.
quote:
Original post by SimpleDude
The book swaps RGB to BGR when loading bitmap files, why does OpenGL require that? The chart with pixel formats shows that both GL_RGB and GL_BGR exist, why is that ?

OpenGL 1.1 only supported the RGB format. In 1.2, the BGR format was added. Because using 1.2 under Windows requires the use of extensions, swapping the color components is the "safest" way to ensure that the program will work on a wide range of cards. In practice, though, the EXT_bgra extension is very widely supported, and is very easy to use (it''s just a constant after all), so we should have covered it in the book.
quote:
Original post by SimpleDude
What is the Color Buffer (GL_COLOR), depth buffer (GL_DEPTH) and stencil buffer (GL_STENCIL) ?

Read chapter 12. It covers all of them.

Share this post


Link to post
Share on other sites
quote:
I''m really not sure how much I can help here, I''m no expert, but you could read the descriptions of the functions at: http://www.eecs.tulane.edu/www/graphics/doc/OpenGL-Man-Pages/opengl_index_alpha.html


Thanks a lot, I''ve looked over it and it appears to be very useful.

quote:
It''s not really an issue of using an "optimal" alignment. glPixelStorei() is there to help you ensure that the way you are using data and the way OpenGL is using data are consistent with each other. It''s a little complication, but the MSDN documentation of this function should help explain things a bit.


Can you please tell me if this function is widely used and should I bother looking into it ?
I''ve looked through several tutorial over at NeHe and I dont think I''ve seen it (although it might be in some of the tutorials I didnt look over)


quote:
OpenGL 1.1 only supported the RGB format. In 1.2, the BGR format was added. Because using 1.2 under Windows requires the use of extensions, swapping the color components is the "safest" way to ensure that the program will work on a wide range of cards. In practice, though, the EXT_bgra extension is very widely supported, and is very easy to use (it''s just a constant after all), so we should have covered it in the book.


Thanks, that makes more sense. Cuz'' I was sitting there and reading the code and glancing over at the chart and got really confused.

Share this post


Link to post
Share on other sites
I am having a problem when I try to swap the red and blue... if I leave it BGR it looks fine, but if I un-comment out the swapping loop I get a very grey toned version of the image with lines through it. What''s that all about?

Share this post


Link to post
Share on other sites
All i know about gray textures, is that whenever its not a power of 2 it becomes black and white and lines everywhere, happened to me a lots of times because i had no idea it had to be a power of two! Stupid me! It just was weird, i always create my logo''s as 512 x 512. At least im good with it now

Share this post


Link to post
Share on other sites

  • 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!