Jump to content

  • Log In with Google      Sign In   
  • Create Account


GL_TEXTURE_MIN_FILTER boggs down program


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 Funkyjive   Members   -  Reputation: 125

Like
0Likes
Like

Posted 16 December 2007 - 04:47 AM

I am trying to create a simple game engine using openGL but have run into a problem when trying to add texture mapping. I think I have it down to one line of code. The line is ...
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
When this line is commented out the program runs fine except the texture does not show. It is just a colored rectangle where the texture should be. When I uncomment this line the program displays the texture appropriatly however there are a few side effects. The biggest one is that the program gets demolished when it comes to framerate. I am barely hitting 1FPS. Also my images(targas) and simple shapes like lines all turn black. Here is the source code of the problem areas...
void GameStart(Engine* eschelon)
{
      //Ommited for clarity

	if (targa->Load("Graphics/Funkyjive.tga")==false)
	{
	    MessageBox(NULL, "Targa load Error!", "Funkyjive Game Studios", MB_ICONEXCLAMATION | MB_OK);
	}

        glEnable(GL_TEXTURE_2D);

	glGenTextures(2, textureobjects);
	glBindTexture(GL_TEXTURE_2D, textureobjects[0]);

	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, targa->GetWidth(), targa->GetHeight(), 0, GL_RGBA, GL_UNSIGNED_BYTE, targa->Image());

	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
}

void GameRender(Engine* eschelon)
{
	camera.Ortho(800,600);
	camera.Position(0,0,5,0,0,0);

	targa->Render(400-(targa->GetWidth()/2),300-(targa->GetHeight()/2));
	targa2->Render(0,0);

	glBindTexture(GL_TEXTURE_2D, textureobjects[0]);
	glBegin(GL_QUADS);
		glTexCoord2f(0,0); glVertex3f(300,0,0);
		glTexCoord2f(1,0); glVertex3f(800,0,0);
		glTexCoord2f(1,1); glVertex3f(800,300,0);
		glTexCoord2f(0,1); glVertex3f(300,300,0);
	glEnd();

        //Ommited for clarity
}
Is there any suggestions that could be causeing the problems? Thank you, Funkyjive

Sponsor:

#2 Funkyjive   Members   -  Reputation: 125

Like
0Likes
Like

Posted 16 December 2007 - 05:25 AM

Sorry to double post but it has been solved! I just had to do glEnable(GL_TEXTURE_2D) //drawing functions then I relized I didnt have a glDisable before the rest of my drawing stuff. Works good now.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS