bmp file loading

This is a discussion on bmp file loading within the Game Programming forums, part of the General Programming Boards category; Does anyone know of a good way to load a bmp to a texture in OpenGl besides the one on ...

  1. #1
    Registered User linuxdude's Avatar
    Join Date
    Mar 2003
    Location
    Louisiana
    Posts
    926

    bmp file loading

    Does anyone know of a good way to load a bmp to a texture in OpenGl besides the one on NeHe, it is buggy and doesn't work on most bmps. I know of the SDL_LoadBMP, but I don't want to use SDL yet. I don't think glut has one.

  2. #2
    Banned
    Join Date
    Dec 2003
    Posts
    367
    There are several several ways to do this, as there are several several libraries for doing this. I myself used PNG files and used http://linux.tucows.com/preview/47311.html to load them. glpng is the easiest way to do this IMHO, but of course you have to use PNG, which is generally A Good Thing (TM). If you are hellbent on using bmp files, then you could download the specification off of Wotsit's File Format library and write some code yourself. You could also find a way to convert a HBITMAP into a OpenGL texture. You could also use DevIL, which is a very nice library.

    Another route you could take is to use google. Never hurts

  3. #3
    'AlHamdulillah
    Join Date
    Feb 2003
    Posts
    790
    if you want some code that you can build off of, I have so far programmed up the loading of both BMP and TARGA(both RLE and RAW) files from scratch and can give you the code probably later today or tommorrow if you want.
    there used to be something here, but not anymore

  4. #4
    Registered User linuxdude's Avatar
    Join Date
    Mar 2003
    Location
    Louisiana
    Posts
    926
    I would like to use glpng, but I can't seem to get it working. I used the makefile to build the .o file. I put it in my /usr/X11R6/lib then used -L/usr/X11R6, but no avail. What did you do bludstayne?

  5. #5
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,584
    Loading the BMP is easy. Then you simply need to place the bmp onto the texture surface for GL...but I don't do GL so I'm not sure what you need to do.

  6. #6
    C++ n00bie :D
    Join Date
    Jul 2004
    Posts
    63
    Try looking in wotsit.com, on the first page of the 'windows' area.

  7. #7
    Registered User linuxdude's Avatar
    Join Date
    Mar 2003
    Location
    Louisiana
    Posts
    926
    I knew all this. I just wanted to know if there was a good one written; right now I am not really interested in loading textures, but writing a simple game. I just want to get this freaking glpng thing working.

  8. #8
    'AlHamdulillah
    Join Date
    Feb 2003
    Posts
    790
    Loading the BMP is easy. Then you simply need to place the bmp onto the texture surface for GL...but I don't do GL so I'm not sure what you need to do
    he is reffering to the actual loading of the data from the file which has to be done before you can create a texture out of the bytes of data.
    there used to be something here, but not anymore

  9. #9
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    Quote Originally Posted by linuxdude
    I would like to use glpng, but I can't seem to get it working. I used the makefile to build the .o file. I put it in my /usr/X11R6/lib then used -L/usr/X11R6, but no avail. What did you do bludstayne?
    is it a .o or a .so ( or even a .a) If it is a library you'll need someting like "-lglpng" to link it. are you getting compiler errors or runtime errors? more info needed....

  10. #10
    Registered User linuxdude's Avatar
    Join Date
    Mar 2003
    Location
    Louisiana
    Posts
    926
    d with the -lglpng. I had to put libglpng.a to my /usr/X11R6/lib directory also thanx.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. File Writing Problem
    By polskash in forum C Programming
    Replies: 3
    Last Post: 02-13-2009, 09:47 AM
  2. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 12:13 AM
  3. Possible circular definition with singleton objects
    By techrolla in forum C++ Programming
    Replies: 3
    Last Post: 12-26-2004, 09:46 AM
  4. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 10:12 PM
  5. simulate Grep command in Unix using C
    By laxmi in forum C Programming
    Replies: 6
    Last Post: 05-10-2002, 04:10 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21