what is the easiest way to load images?

I want to load a menu image onto the screen. I am doing some sample 3D animation showing movements. But before that, I want to load some Menu image, like an introduction. I would like to load an image when the user presses certain keys during the animation too.

So what I want to know is

  1. Whats the easiest way to load a menu image onto the screen?
    2.Does it matter what size the image is?
    3.Will OpenGL automatically resize it to fit the screen?

I plan on making some images using photoshop. We are simply displaying a still image until a user presses a button.

  1. easiest way is probably loading uncompressed TGA files, just read the header, extract the x,y bitdepth parameters and just read a large chunk of data, if done right the code for the whole operation is about a page long, if you want compressed images then the whole thing gets a bit more complicated, but it’s still manageable.
    You could also use an image loading library, but i think that’s cheating.

  2. not anymore, but i think it works best if the size is a power of 2 (like 512x128 or 1024x1024 and so on)

  3. yes, if you want it to.

As a side note i think when it comes to a menu it’s better to have multiple smaller images (especially for the menu choices), that way it’s a bit more flexible and you can introduce some movements in it, which can make it a little bit better.
But that is only something to add in the end if time permits.

oh but i am allowed to use libraries. esp GLUT and other libraries. so i was hoping there was an easy way. u know something like:

loadImageToScreen(a.bmp);

and this automatically just puts that image on the screen.

so if i had a displayFunc it would have:
if (animation == FALSE)
loadImageToScreen(a.bmp);
else
glVertex3f()…

and so on

im kinda strapped for time and only need very very basic stuff.

OR is this method easier:

  • load text during the displayFunc. if thats even possible. so u just load 2D text onto the screen.

loadImageToScreen(a.bmp);

I can’t imagine a use for such a function. It goes straight from a file to “the screen?” It doesn’t take window-space coordinates to draw to; it just stretch-blits to what I can assume to be the entire viewport. It doesn’t take parameters saying what kind of interpolation to use. More importantly, wouldn’t that mean that, every frame, you have to keep loading the image again and again? Just like every frame you have to submit your geometry again, since OpenGL doesn’t retain information about what was rendered the previous frame?

In any case, no. No one has written such a library. You’re going to have to use an image loading library and draw a textured quad. Which requires perhaps 20 lines of code.

Also, loading anything is something that should be done at the beginning of your program. Just keep the texture around until you need to display it.

I have a simple OpenGL demo that loads and displays .bmp files either as images or as textures.
It is self-contained which means it contains all the code you need, so you don’t have to link with any libraries.
It’s at -

OpenGL Image Loading Demo

Good luck.