I’m very new to openGL. I picked up a book and started reading, and im in the process of creating a game for my senior highschool project. Basically, i need to find out how to load a bmp or similar type if image to set as a background.
I know that you can load the bmp (or whatever) and then map it as a texture to a quad. Unfortunately, i don’t know how to load it (or map it, for that matter, but i have a general idea)
I visited NeHe, and their tutorial was confusing with all the Windows API stuff…i know nothing about windows programing, only C++.
I tried some sample code others have posted, but when Microsoft Visual C++ 6 tries to compile, it give an error with the FILE* bmpfile; declaration. Windows.h is included in my program.
Anyway, if anyone could help me out and point me to a place that tells how to load a bmp WITHOUT all the windows api stuff, or supply me with some code, i would be very grateful, as i am running out of time.
try using glfw
it provides a very easy interface to load targas
alternately you could include stdio.h and use the routines that others provided you with
At the GLFW site , you can find some OpenGL beginners tutorials (enough to get you started). Together with the comprehensive GLFW documentation and example programs, it should be a snap to get Targa texture loading and application running (hint: the glfwLoadTexture2D function loads a Targa from disk, and uploads it to texture memory, and even optionally builds all mipmap levels for you - in one function call).
errr, I suppose you could, but GLFW is really a replacements for GLUT, they might work in tandem, but it would be really ugly and i don’t recommend it. GLFW is really easy though, if you understand GLUT you could pick it up quickly
Whoa, GLFW is a pretty much replacement for GLUT, you may be able to use parts of them together but that would probably be a bad way of going about things.
For loading images with GLUT you may want to use DevIL or something similar, or throw GLUT away and just use GLFW. As has been said you could probably pick it up easily. http://openil.sourceforge.net/
Alternatively you could just visit NeHe and grab some simple texturing example code form there, and add it to what you have at the moment, it’s not really that tricky. http://nehe.gamedev.net/lesson.asp?index=02
You have done everything correctly, except that you need to add glfw.lib to your projects list of link libraries (I always forget where that is in the VC++ IDE, since I always run command line, but it’s where you have put opengl32.lib).
As mentioned earlier by other posts, GLFW is really a GLUT replacement (sorry for not making that clearer), but I figured that since you seem to be in the quite early stages of OpenGL development, it would not be too difficult to switch to another toolkit.
Theoretically, you could use the two together, but only in very special cases. GLFW texture loading requires a GLFW window, for instance, and will not work with a GLUT window. The threading, timing and joystick input functions can coexist with any environment though (even DirectX, if you wish). However, I do not recomment this kind of mixing.
Read the GLFW documentation, and see if it fits your needs. It’s really easy to use, and in many ways more modern and better suited for certain tasks than GLUT. If you’re not satisfied with GLFW, go for GLUT + DevIL.
[This message has been edited by marcus256 (edited 02-23-2004).]
Ok, thank you for your help marcus, and everyone else. Because i am running out of time, i think ill stick with GLUT for now. I am able to load textures and map them to a quad, but it seems i am limited to a 128 by 128 bitmap. Is there any reason why this is (i know that the sizes need to be powers of two, or at least thats what i understand, but 256 by 256 hasnt worked yet).
This does not look great set as a background in a 800 by 600 window
I do not have the code here now as i am at school, but ill post it later on, and i will be very grateful if anyone can help me out.