Drawing A Bitmap From File

Is there an easy way to be able to draw a bitmap from file at specific coordinates on the screen? Thanks.

Yes, with drawpixels and rasterpos

I’ve seen that, but I was wondering how to use it…

You would properly also like to use glOrtho2D to set the model-view matrix for 2D rendering.
And then use glDrawPixels, like below (i.e pixels is a STL vector of your data)

glDrawPixels(512,512,GL_RGB,GL_UNSIGNED_BYTE, &pixels[0]);

well, yes, but what I am asking is how do I do it when I have a bitmap file

You first have to read the file and convert it to a data container in system memory before you can download it to the GPU.
Non-compressed file formats (bmp,ppm,…) usually take only a few lines of code to do this.
If you’re reading compressed textures (jpg,…) you’ll need an image library such as DevIL,imageMagick or whatever image library you prefer (these also work for non compressed image formats).

How to laod them?

Look at the end of this thread:


The data from GetBits() is what yopu have to put in glDrawPixels.

Have a look at

It might be of some help