loading tga file

Started by
8 comments, last by Palidine 13 years, 4 months ago
I am attempting to load a tga file.I dont know what files to include.I am using the following.
#include <windows.h>
#include "GL/glew.h"
#include "GL/glut.h"
I am getting the following error.
1>ImageLoad.obj : error LNK2019: unresolved external symbol _gltLoadTGA referenced in function _RenderScene
1>C:\Users\Owner\Documents\Visual Studio 2008\Projects\imageload\Debug\imageload.exe : fatal error LNK1120: 1 unresolved externals
1>Build log was saved at "file://c:\Users\Owner\Documents\Visual Studio 2008\Projects\imageload\imageload\Debug\BuildLog.htm"
Advertisement
Show code.
ok here is my code
//#include <math.h>#include <windows.h>#include "GL/glew.h"#include "GL/glut.h"//#include <stdlib.h>//#include "OpenGLSB.h"	// System and OpenGL Stuff//#include "GLTools.h"	// OpenGL toolkit// #include "glext.h"        //////////////////////////////////////////////////////////////////// This function does any needed initialization on the rendering// context. void SetupRC()    {    // Black background    glClearColor(0.0f, 0.0f, 0.0f, 0.0f);	}///////////////////////////////////////////////////////////////////////        // Called to draw scenevoid RenderScene(void)    {	GLubyte *pImage = NULL;	GLint iWidth, iHeight, iComponents;	GLenum eFormat;	    // Clear the window with current clearing color    glClear(GL_COLOR_BUFFER_BIT);        // Targa's are 1 byte aligned	glPixelStorei(GL_UNPACK_ALIGNMENT, 1);    // Load the TGA file, get width, height, and component/format information	pImage = gltLoadTGA("fire.tga", &iWidth, &iHeight, &iComponents, &eFormat);	    // Use Window coordinates to set raster position	glRasterPos2i(0, 0);	    // Draw the pixmap    if(pImage != NULL)        glDrawPixels(iWidth, iHeight, eFormat, GL_UNSIGNED_BYTE, pImage);	    // Don't need the image data anymore	free(pImage);		    // Do the buffer Swap    glutSwapBuffers();    }//////////////////////////////////////////////////////////////// For this example, it really doesn't matter what the // projection is since we are using glWindowPosvoid ChangeSize(int w, int h)    {    // Prevent a divide by zero, when window is too short    // (you cant make a window of zero width).    if(h == 0)        h = 1;    glViewport(0, 0, w, h);        	// Reset the coordinate system before modifying    glMatrixMode(GL_PROJECTION);    glLoadIdentity();	    // Set the clipping volume    gluOrtho2D(0.0f, (GLfloat) w, 0.0, (GLfloat) h);            glMatrixMode(GL_MODELVIEW);    glLoadIdentity();        }/////////////////////////////////////////////////////////////// Main program entrypointint main(int argc, char* argv[])    {    glutInit(&argc, argv);    glutInitDisplayMode(GLUT_RGB | GL_DOUBLE);    glutInitWindowSize(512 ,512);    glutCreateWindow("OpenGL Image Loading");    glutReshapeFunc(ChangeSize);    glutDisplayFunc(RenderScene);        SetupRC();    glutMainLoop();    return 0;    }

gltLoadTGA() is part of an external lib? Is it yours? Where does it come from? Seems you may have included the header its declared in, but didnt link to the lib its defined in. If its defined by you in cpp file, you need to add that to the build.

Edit: I also doubt you want to load the file everytime the scene renders, might want to do that at initialize time.
well I put the gltools.lib in the linker but it still does not work.
Where does that function come from? I can't find any documentation for it on the web. It's not a standard part of glut from what I can tell. But it means you're not linking against the library that defines it. Are you sure you have a library that defines it?

-me
I am trying to compile and link a program from the opengl superbible 3rd ed.
Quote:Original post by phil67rpg
I am trying to compile and link a program from the opengl superbible 3rd ed.


So then you need to link against whatever libraries that the book provided. Are you sure you're linking against the correct ones? It should be described somewhere in the book which ones you need to link against

-me
do you have any idea what lib file I need to include
Quote:Original post by phil67rpg
do you have any idea what lib file I need to include


From some quick googling about this issue, I'm pretty sure that it's on the CD that comes with the book. It's not any standard lib, just something custom that was written by the author of the book.

-me

This topic is closed to new replies.

Advertisement