Skip to main content
GameDev.net gamedev.net
🔒 Locked

Loading Texture

Started by tnutty Mar 3, 2009 at 10:31 PM 6 replies 1k views
Original Post
tnutty
tnutty
hi, Does anyone know how to load a jpeg image and add it as a texture. So far I learned how to load bmp and raw files. But most picture that are descent are in jpeg format. I know loading jpeg is harder than the other formats. Just wondering if anyone knows a descent way to load jpeg into visual studio C++. Or if you know other ways to load texture for any formats, please feel free to post it here, so I and others can learn from them. regards, TNUTTY
Our whole life is a opengl application.
wicked357
wicked357
try having a look at this post maybe it can help you,

http://www.gamedev.net/community/forums/topic.asp?topic_id=350342
XTAL256
XTAL256
Quote:
Original post by tnutty
...most pictures that are descent are in jpeg format.

Actually, most images (for games but also other things) use a format like PNG or TGA. PNG files are lossless compression meaning that they don't go all blurry like jpegs do.
But whatever format you want to load, i recommend the SOIL library.
[Window Detective] - Windows UI spy utility for programmers
tnutty
tnutty
Why woulld jpeg go blurry?

Is there other specefic reason why game programmers use tga or png to load textures?
Our whole life is a opengl application.
tnutty
tnutty
1 more things, I just want to learn loading most textures first before I use someone else's. I hate using something that confuses me on how it works.
Our whole life is a opengl application.
XTAL256
XTAL256
Quote:
Original post by tnutty
Why woulld jpeg go blurry?
Is there other specefic reason why game programmers use tga or png to load textures?

JPEG is called "lossy" compression which means that some image data is lost as a result of it being converted to jpeg format. This is generally ok for photos, no one is likely to notice because of the large size and the distortion is only around small edges of objects in the photo. But for a game this is not really wanted because the images are smaller and probably more detailed.
EDIT: oh, just to clarify, jpegs don't "go" blurry when loaded or drawn, they are already like that depending on the quality of the compression.

Quote:
I just want to learn loading most textures first before I use someone else's. I hate using something that confuses me on how it works.

If you just want to use jpegs then a library saves you the hassle of doing it all yourself. But if you want to learn how to load the jpeg format yourself then i'm sure there's a lot of stuff on google. SOIL is open source anyway so you can have a little look through it's jpeg loading code to see how it's done.
[Window Detective] - Windows UI spy utility for programmers
tnutty
tnutty
Thanks 4 the reply Xtal,

If there is anyone else that would like to help me with this "quest", then
please help me.
Our whole life is a opengl application.
Khaos Dragon
Khaos Dragon
I would recommend learning how to load the texture using the SOIL API. This is very simple and once you have gotten this far, note the SOIL functions you used and analyze their source code. It actually is not too difficult to get to the jpeg loading part of the SOIL source code as it is a pretty small library.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.