Skip to main content
gamedev.net
🔒 Locked

Image file types

Started by BloodLust666 12 replies 1.4k views
Original Post
BloodLust666
BloodLust666
what files types can be loaded into opengl?
-------------------------Unless specified otherwise, my questions pertain:Windows Platform (with the mindset to keep things multi-platform as possible)C++Visual Studio 2008OpenGL with SFML
nolongerhere
nolongerhere
Anything you can find/make a loader for. OpenGL itself doesnt have any image loaders (glaux might?), you have to write them yourself(or download them like, SDL_image)

Hope that helps!
BloodLust666
BloodLust666
how would i make one for myself? is there a tutorial or maybe someone that could show me?
-------------------------Unless specified otherwise, my questions pertain:Windows Platform (with the mindset to keep things multi-platform as possible)C++Visual Studio 2008OpenGL with SFML
nolongerhere
nolongerhere
Its entirely dependent on the format...if you know the language your using well enough it shouldnt be a problem. You may have to do some research on the file format your wanting to use also.

If you dont know how to do that...then your best off using sdl_image or going to learn that language your using better.
BloodLust666
BloodLust666
i just got the SDL_image thing (since i use SDL anyway so it's all good), but i can't download the docs for it for some reason... is there another link for it?
-------------------------Unless specified otherwise, my questions pertain:Windows Platform (with the mindset to keep things multi-platform as possible)C++Visual Studio 2008OpenGL with SFML
BloodLust666
BloodLust666
Say i load an image:

SDL_Surface *image;
image = IMG_Load("image.png");

what do i do to that surface to bind it to a texture in opengl?

edit: by the way, this is using SDL_Image lib
-------------------------Unless specified otherwise, my questions pertain:Windows Platform (with the mindset to keep things multi-platform as possible)C++Visual Studio 2008OpenGL with SFML
BloodLust666
BloodLust666
ok, i found a site that had this:
GLuint texture;//Load BitmapSDL_Surface* bmpFile = SDL_LoadBMP("data/test.bmp"); /* Standard OpenGL texture creation code */glPixelStorei(GL_UNPACK_ALIGNMENT,4); 		glGenTextures(1,&texture);glBindTexture(GL_TEXTURE_2D,texture); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,minFilter);glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,magFilter); 		gluBuild2DMipmaps(GL_TEXTURE_2D,3,bmpFile->w,   bmpFile->h,GL_BGR_EXT,   GL_UNSIGNED_BYTE,bmpFile->pixels); //Free surface after using itSDL_FreeSurface(bmpFile);


i just have one question about glGenTextures()...
what's the first parameter for? at first i thought it was to specific the texture number; like if i put 1, then make another texture with 1, it would over write that... what's it for?
-------------------------Unless specified otherwise, my questions pertain:Windows Platform (with the mindset to keep things multi-platform as possible)C++Visual Studio 2008OpenGL with SFML
Kambiz
Kambiz
You can easily use DevIL(OpenIL) to load most of the common image formats.
Here a link!
BloodLust666
BloodLust666
sweet!! i'm looking at that and it looks like i can do that thing i'm always wanted to do but couldn't, where i have a mapped texture, then when i load each tile i can write it to a separte texture, then when rendering i can just render that big texture instead of drawing every tile. will i be able to do that with OpenIL?
-------------------------Unless specified otherwise, my questions pertain:Windows Platform (with the mindset to keep things multi-platform as possible)C++Visual Studio 2008OpenGL with SFML
BloodLust666
BloodLust666
i've been reading through the OIL docs and i saw nothing about loading an image with a keycolor... used for a transparent pixel color.. how would i do that then?
-------------------------Unless specified otherwise, my questions pertain:Windows Platform (with the mindset to keep things multi-platform as possible)C++Visual Studio 2008OpenGL with SFML
AAAP
AAAP
while converting the image to a format you can upload to video thru opengl, make the pixels with the "key color" 0 0 0 0, so its transparent pixel in openGL. there might be other ways, as well. a good idea is to just use a format that natively has alpha channel
|aaap.penopticon.com| My website, including game projects. Collaboration/comments are welcome, please visit :)
StPapyna
StPapyna
Why not use the JPEG ?

To download the INTEL JPEG LIBRARY ....
deavik
deavik
Quote:
Original post by EvilKnuckles666
i just have one question about glGenTextures()...
what's the first parameter for? at first i thought it was to specific the texture number; like if i put 1, then make another texture with 1, it would over write that... what's it for?

It denotes the number of texture objects generated by opengl, which are stored in an array, the pointer to the first element of which you provide in the second parameter.

/edit: Forgot the most important thing [smile] ... so in other words, you can use 1 as many times as you want.

And about the image loading thing, I have used SDL_image, and it's good but since it has to support a large number of file formats, I found it a little bloated (with 3 or 4 dll's having to accompany the executable). You will realistically) only need support for 1 or maybe 2 formats, and you're perhaps better off writing the loader to that yourself. TGA is a format that supports an alpha channel, the compression algorithm is extrememly simple and is on the whole very easy to parse,

Go to wotsit.org for file specs.
AAAP
AAAP
you could compile its dependencies as static libs and link with the static libs, fyi <_<
|aaap.penopticon.com| My website, including game projects. Collaboration/comments are welcome, please visit :)

Topic Locked

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

Sign in to reply to this topic.