Jeraldo
Jeraldo

Reputation: 1

OpenGL DevIL c++ source code

After spending hours searching for a simple way to to add an image to an openGL application written in C++, i failed, miserably. It is also apparent that many others have too.

I am fairly new to OpenGL, I have written my own win32 app with OpenGL using DevIL and you guessed it, i failed. The only way i could get DevIL to work was using Glut, which i dont want to use, or SDL or glaux.h

What i am looking for is code or a tutorial for a simple image loader in C++ with OpenGL and DevIL, Any help would be greatly appreciated.

Upvotes: 0

Views: 1627

Answers (1)

genpfault
genpfault

Reputation: 52167

If you're asking OpenGL to filter using mapmaps make sure to give it mipmaps to filter with.

Also, I'm pretty sure glTexParameteri() and glTexEnvf() only apply to the currently bound texture.

Try replacing your InitTextures() with this:

Tex1 = ilutGLLoadImage("tex1.bmp");
glBindTexture( GL_TEXTURE_2D, Tex1 );
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);

Tex2 = ilutGLLoadImage("tex2.bmp");
glBindTexture( GL_TEXTURE_2D, Tex2 );
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);

Upvotes: 1

Related Questions