Texture not loading/rendering correctly (using FreeImage)

Hello everyone,

first time beeing here :slight_smile: I couldn’t manage to make the links to the tutorial URL and the image URL because everytime I got this error message:
[NOTE]Post denied. New posts are limited by number of URLs it may contain and checked if it doesn’t contain forbidden words.[/NOTE]
So you have to copypaste the URLs and delete the space in “ht tp”. Are actually 2 URLs too many -.- this is really annoying if I can’t even link to 1 page or 1 image. well whatever…

I’m following this tutorial “ht tp://ogldev.atspace.co.uk/index.html” and I am at chapter 22 “Loading models using the Open Asset Import Library” now. You can see there what the model should look like but instead mine looks like this: “ht tp://postimg.org/image/6vq9ovbkx/”

In the tut he’s using ImageMagick but I’m useing FreeImage so I thought the bug might be when loading the texture.

bool Texture::Load()
	FIBITMAP* bitmap = FreeImage_Load(FreeImage_GetFileType(m_imagePath, 0), m_imagePath);
	printf("Loading texture: '%s'
", m_imagePath);

	glGenTextures(1, &m_textureObj);

	glBindTexture(m_textureTarget, m_textureObj);
	glTexParameteri(m_textureTarget, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
	glTexParameteri(m_textureTarget, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

	FIBITMAP *pImage = FreeImage_ConvertTo32Bits(bitmap);
	int nWidth = FreeImage_GetWidth(pImage);
	int nHeight = FreeImage_GetHeight(pImage);

	glTexImage2D(m_textureTarget, 0, GL_RGB, nWidth, nHeight, 0, GL_BGRA, GL_UNSIGNED_BYTE, (void*)FreeImage_GetBits(pImage));

	GLenum error = glGetError();
		printf("There was an error loading the texture


    return true;

From the look of my model I thought the problem might be the alpha channel but actually I’m using only RGB. Any ideas?

thanks in advance,

EDIT1: the model file is a .md2 and the texture file a .pcx (the source is also available here “ht tp://ogldev.atspace.co.uk/www/tutorial22/tutorial22.html”)

Ah I forgot glEnable(GL_DEPTH_TEST); but now nothing is rendered.

EDIT1: I read in other forums that the problem was that glClear(GL_COLOR_BUFFER_BIT) wasn’t set. I’m doing this in the render callback.

Ok I solved this problem too but it was somewhat strange. I set the distance of the near plane of my view field to 0.0f before which didn’t work. It only works for values > 0.0f (even thought it worked fine before with 0.0f without GL_DEPTH).
Also I have to set the projection matrix everytime the render callback is called now. Before it was enough to init the matrixe only once in the beginning. Can some explain this to me (only if it’s code independent)?