View Full Version : Drawing A Bitmap From File
03-01-2008, 12:29 PM
Is there an easy way to be able to draw a bitmap from file at specific coordinates on the screen? Thanks.
03-01-2008, 01:30 PM
Yes, with drawpixels (http://www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/drawpixels.html) and rasterpos (http://www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/rasterpos.html)
03-01-2008, 03:17 PM
I've seen that, but I was wondering how to use it...
03-01-2008, 04:16 PM
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)
03-01-2008, 05:46 PM
well, yes, but what I am asking is how do I do it when I have a bitmap file
03-01-2008, 05:53 PM
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 (http://openil.sourceforge.net/),imageMagick (http://www.imagemagick.org) 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.
03-03-2008, 10:52 AM
Have a look at
It might be of some help
Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.