How do you render images (.bmp and .jpeg) using OpenGL ?
I’ve come across some tutorials, but they were for C# not C/C++.
The reason I want to render images, is because I want to draw a spaceship(for a game). I could use a OpenGL primitive, but it doesn’t really look that great. The other option is to draw the spaceship using co-ordinates, but that would take ages, and wouldnt look as good.
running the following snippet always returns failed:
#include <iostream>
#include <GL/glfw.h>
using namespace std;
int main()
{
GLFWimage image;
if(glfwReadImage("ship.tga", &image, GLFW_ORIGIN_UL_BIT)!=GL_TRUE);
cout << "FAILED";
system("PAUSE");
return 0;
}
What am I doing wrong ?
Poorly written code. Sorry about that. Works now
By texturing a Quad (or better yet, two Triangles).
Unless you really need
.bmpor.jpeg, I would suggest that you use.tga(Targa) images as they are more commonly used and support alpha channel.Some C++ resources:
http://nehe.gamedev.net/tutorial/loading_compressed_and_uncompressed_tgas/22001/
http://nehe.gamedev.net/tutorial/texture_mapping/12038/
http://www.lonesock.net/soil.html (a great little image library for OpenGL. Supports bmp, jpg, png, tga, etc.)