Advertisement

Loading Images

Started by January 04, 2002 08:16 PM
5 comments, last by FERNANDO-BRASIL 23 years, 1 month ago
People, I''m a new user to OpenGL, and I would like to know a few things about Loading Images (sorry for the long text). Well, let''s say I have a JPG image, a GIF Image, A Tif Image, A Bmp Image and a Tga Image. How do I do to load those? I''ll express my thinkings about these... (I don''t know If they are correct. I would like you to tell me if those are. :-) ). Well, I tried to get some tutorials about Loading Images in Nehes Home page, and I found 2 that teachs you how to load and show a BMP and a TGA image. I''ve noted in both two, that in the final, they use glGenTextures, glBindTexture and glTextImage to Load the images, and I conclused that Every image you''ll load, have to pass through these functions. (AM''I correct?) Ok, now, my questions are: 1) To load any type of image, all that I want to do is how the Image is structured in a file, and read it? 2) If that was correct, then, Do I have to get the Data that I read from the file Image and After, config that in a way that OpenGL can understand? (Like RGB, not BGR like BMP). Because, all the images, have a different shape of storaging, and just Read it, in my mind is not all. After read, we have to reshape the data, in a way that the Functions glGenTextures, glBind... etc can Understand. Am''I correct? 3) Ok, If both two were correct, How Do I have to format the data, that OpenGL functions can understand it? Ok guys, sorry for the long text, those were my 3 question, and I hope one of you will response!! Thank you very mutch!
1) pretty much, yeah. Compressed stuff like JPG is obviously more complex tho ;¬)

2)yes, but opengl can be told to understand a few different things - eg you can say "from now on all colour info will be BGR" or whatever.

3) check in the red book and blue book (OpenGL programming guide and spec). I think theres a link to online versions from NeHe''s main page.

My personal advice would be to check out DevIL at

http://openil.sourceforge.net

it will handle almost any image format, and will load and ready an image for opengl texture usage with just one call - a function in the IL utility library.

Dan

[size="1"]
Advertisement
Thank you very very mutch mrbastard! You cleared all my questions! :-)

I''ll try experience that Library and try to get some tutorials of Image Format (to open Images by hand).

Do you know some websites about that?
Guys, I was thinking about this topic, and I''ve made a conclusion. I don''t Know if it''s right or no.

For example. If I have 3 pictures. They have the same image, the same colors, the same width, the same height, but Different types.

Let''s say they are .Bmp, .Jpg and .Gif and have a size of 2 MB, 300KB, and 700 KB respectively.

If I import then and show these images with OpenGL, in the final, they''ll spend the same space in memory.... Am''I correct?

thanks again!
Not if you load them as different textures.
Huuuummmm ok..!!!

And what do you mean "Different Textures"?

Thank you!
Advertisement
it all depends on the parameters for the textures. if they are all loaded as 32bit 512x512 textures with no mipmapping then they all should take up the same amount of ram.

This topic is closed to new replies.

Advertisement