Jump to content
  • Advertisement
Sign in to follow this  
Merlino

OpenGL Targa Texture Functions Problem

This topic is 4280 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, i'm writing because I get an error when compiling a certain code: I have a class called OpenGL, and another one called CTargaImage. So here is the code that generates the error:
void genTexture(unsigned int textureObject, CTargaImage *targaImage)
{
    glGenTextures(1, &textureObject);
    glBindTexture(GL_TEXTURE_2D, textureObject);

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

	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, targaImage->GetWidth(), targaImage->GetHeight(), 0, GL_RGB, GL_UNSIGNED_BYTE, targaImage->GetImage());
}

bool OpenGL::Init()
{
	glClearColor(0.0, 0.0, 0.0, 0.0);
	
	m_tga = new CTargaImage;
	m_tga->Load("line.tga");
    
    genTexture(textureObjectOne, m_tga)
	return true;
}

Note: textureObjectOne is an unsigned int that is part of OpenGL; I use CodeBlocks and this is the error message "Linking executable: Cosmos.exe .objs\CGfxOpenGL.o:CGfxOpenGL.cpp:(.text+0x15b): undefined reference to `OpenGL::genTexture(unsigned int, CTargaImage*)' collect2: ld returned 1 exit status Process terminated with status 1 (0 minutes, 0 seconds)" But when I use this code the application runs fine:
bool OpenGL::Init()
{
	glClearColor(0.0, 0.0, 0.0, 0.0);

	m_tga = new CTargaImage;
	m_tga->Load("line.tga");

    glEnable(GL_TEXTURE_2D);
    glGenTextures(1, &textureObjectOne);
    glBindTexture(GL_TEXTURE_2D, textureObjectOne);

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

	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, m_tga->GetWidth(), m_tga->GetHeight(), 0, GL_RGB, GL_UNSIGNED_BYTE, m_tga->GetImage());

	return true;
}

Does anybody know why I get the error when I use the genTexture function??? Thanks a lot in advance, Merlino

Share this post


Link to post
Share on other sites
Advertisement
I'm SO stupid, I just forgot to put "OpenGL::" before the function declaration.

Sorry for idiot post!!! ^^.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!