trying to understand new error

Started by
1 comment, last by nick2price 15 years, 5 months ago
I have my program, and i have completely changed it so that i dont use glaux. Everything seems ok but i am getting this error

1>------ Build started: Project: skybox, Configuration: Debug Win32 ------
1>Linking...
1>skybox.obj : error LNK2019: unresolved external symbol "public: unsigned int __thiscall skybox::LoadTexture(char const *)" (?LoadTexture@skybox@@QAEIPBD@Z) referenced in function "public: void __thiscall skybox::Init(void)" (?Init@skybox@@QAEXXZ)
1>C:\Users\Nick\Desktop\University\Graphics, C++\skybox\Debug\skybox.exe : fatal error LNK1120: 1 unresolved externals
1>Build log was saved at "file://c:\Users\Nick\Desktop\University\Graphics, C++\skybox\skybox\Debug\BuildLog.htm"


I am not to sure why i am getting this. The code i think it relates to is

#include "stdafx.h"
#include <GL/glut.h>
#include <windows.h>
#include <stdio.h>  //for file access							
#include <gl\gl.h>													
#include "skybox.h"
#include "glbmp.h"


GLuint LoadTexture(const char * bitmap_file)
{
   GLuint texture = 0; //OpenGL texture to create and return
   glbmp_t bitmap;     //object to fill with data from glbmp
 
   
   if(!glbmp_LoadBitmap(bitmap_file, 0, &bitmap))
   {
      fprintf(stderr, "Error loading bitmap file: %s\n", bitmap_file);
   }
 
   //generate and bind the OpenGL texture
   glGenTextures(1, &texture);
   glBindTexture(GL_TEXTURE_2D, texture);
 
   //copy data from bitmap into texture
   glTexImage2D(GL_TEXTURE_2D, 0, 3, bitmap.width, bitmap.height,
                0, GL_RGB, GL_UNSIGNED_BYTE, bitmap.rgb_data);
 
   //set up texture filtering
   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
 
   //free the bitmap
   glbmp_FreeBitmap(&bitmap);
 
   return texture;
}
 


void skybox::Init() {

	OFFSET = 1/512.0; //set offset value for skybox

	rot_x = 0.0; rot_y = 0.0;

    GLuint tex1;
	GLuint tex2;
	GLuint tex3;
	GLuint tex4;
	GLuint tex5;
	GLuint tex6;

	tex1 = LoadTexture("images/left1.bmp");
	tex2 = LoadTexture("images/front1.bmp");
	tex3 = LoadTexture("images/right1.bmp");
	tex4 = LoadTexture("images/back1.bmp");
	tex5 = LoadTexture("images/down1.bmp");
	tex6 = LoadTexture("images/up1.bmp");

}


//This is where the magic happens
void skybox::draw() {

		glPushMatrix();
	glRotated(rot_x, 1.0, 0.0, 0.0);	//Rotate around the x axis
	glRotated(rot_y, 0.0, 1.0, 0.0);	//Rotate around the y axis

	glColor3f(1.0f,1.0f,1.0f);			//Set colour to White
	glEnable(GL_TEXTURE_2D);			//Enable texture mapping
	glDisable (GL_DEPTH_TEST);			//Disable depth testing

		//before you can use a texture you have to bind it
		glBindTexture(GL_TEXTURE_2D, texture[0 + text_offset]);

		glBegin (GL_QUADS);		//before you can draw you have to tell OpenGL
								//what you want to draw.  With GL_QUADS you have to
								//specify 4 verticies.  If you are using a texture
								//you also need to specify texture co-ordinates


				//glTexCoord2d allows you to specify the x and y values (range of 0.0 to 1.0)
				//the OFFSET value compensates for a seam that appears at the edges of the
				//skybox.  Try setting OFFSET to 0.0 to see what I mean.

				//glVertex3d allows you to specify the x,y, and z locations of that vertex
		
				glNormal3d (0.0,0.0,1.0); glTexCoord2d (0.0 + OFFSET,0.0 + OFFSET);	glVertex3d (-10.0,-10.0,10.0);
				glNormal3d (0.0,0.0,1.0); glTexCoord2d (1.0 - OFFSET,0.0 + OFFSET);	glVertex3d (-10.0,-10.0,-10.0);
				glNormal3d (0.0,0.0,1.0); glTexCoord2d (1.0 - OFFSET,1.0 - OFFSET);	glVertex3d (-10.0,10.0,-10.0);
				glNormal3d (0.0,0.0,1.0); glTexCoord2d (0.0 + OFFSET,1.0 - OFFSET);	glVertex3d (-10.0,10.0,10.0);

		glEnd ();				//Make sure that after you are finished call the glEnd() or
								//the program will crash really fast.

		glBindTexture(GL_TEXTURE_2D, texture[1 + text_offset]);
		glBegin (GL_QUADS);
		
				glNormal3d (0.0,0.0,1.0); glTexCoord2d (0.0 + OFFSET,0.0 + OFFSET);	glVertex3d (-10.0,-10.0,-10.0);
				glNormal3d (0.0,0.0,1.0); glTexCoord2d (1.0 - OFFSET,0.0 + OFFSET);	glVertex3d (10.0,-10.0,-10.0);
				glNormal3d (0.0,0.0,1.0); glTexCoord2d (1.0 - OFFSET,1.0 - OFFSET);	glVertex3d (10.0,10.0,-10.0);
				glNormal3d (0.0,0.0,1.0); glTexCoord2d (0.0 + OFFSET,1.0 - OFFSET);	glVertex3d (-10.0,10.0,-10.0);
		glEnd ();

		glBindTexture(GL_TEXTURE_2D, texture[2 + text_offset]);
		glBegin (GL_QUADS);
		
				glNormal3d (0.0,0.0,1.0); glTexCoord2d (0.0 + OFFSET ,0.0 + OFFSET); glVertex3d (10.0,-10.0,-10.0);
				glNormal3d (0.0,0.0,1.0); glTexCoord2d (1.0 - OFFSET ,0.0 + OFFSET); glVertex3d (10.0,-10.0,10.0);
				glNormal3d (0.0,0.0,1.0); glTexCoord2d (1.0 - OFFSET ,1.0 - OFFSET); glVertex3d (10.0,10.0,10.0);
				glNormal3d (0.0,0.0,10.0); glTexCoord2d (0.0 + OFFSET ,1.0 - OFFSET); glVertex3d (10.0,10.0,-10.0);

		glEnd ();

		glBindTexture(GL_TEXTURE_2D, texture[3 + text_offset]);	
		glBegin (GL_QUADS);
			
			glNormal3d (0.0,0.0,1.0); glTexCoord2d (0.0 + OFFSET ,0.0 + OFFSET); glVertex3d (10.0,-10.0,10.0);
			glNormal3d (0.0,0.0,1.0); glTexCoord2d (1.0 - OFFSET ,0.0 + OFFSET); glVertex3d (-10.0,-10.0,10.0);
			glNormal3d (0.0,0.0,1.0); glTexCoord2d (1.0 - OFFSET ,1.0 - OFFSET); glVertex3d (-10.0,10.0,10.0);
			glNormal3d (0.0,0.0,1.0); glTexCoord2d (0.0 + OFFSET ,1.0 - OFFSET); glVertex3d (10.0,10.0,10.0);
		
		glEnd ();

		glBindTexture(GL_TEXTURE_2D, texture[4 + text_offset]);	
		glBegin (GL_QUADS);
			
			glNormal3d (0.0,0.0,1.0); glTexCoord2d (0.0 + OFFSET ,0.0 + OFFSET); glVertex3d (-10.0,-10.0,10.0);
			glNormal3d (0.0,0.0,1.0); glTexCoord2d (1.0 - OFFSET ,0.0 + OFFSET); glVertex3d (10.0,-10.0,10.0);
			glNormal3d (0.0,0.0,1.0); glTexCoord2d (1.0 - OFFSET ,1.0 - OFFSET); glVertex3d (10.0,-10.0,-10.0);
			glNormal3d (0.0,0.0,1.0); glTexCoord2d (0.0 + OFFSET ,1.0 - OFFSET); glVertex3d (-10.0,-10.0,-10.0);
		
		glEnd ();

		glBindTexture(GL_TEXTURE_2D, texture[5 + text_offset]);
		glBegin (GL_QUADS);
		
				glNormal3d (0.0,0.0,1.0); glTexCoord2d (0.0 + OFFSET ,0.0 + OFFSET); glVertex3d (-10.0,10.0,-10.0);
				glNormal3d (0.0,0.0,1.0); glTexCoord2d (1.0 - OFFSET ,0.0 + OFFSET); glVertex3d (10.0,10.0,-10.0);
				glNormal3d (0.0,0.0,1.0); glTexCoord2d (1.0 - OFFSET ,1.0 - OFFSET); glVertex3d (10.0,10.0,10.0);
				glNormal3d (0.0,0.0,1.0); glTexCoord2d (0.0 + OFFSET ,1.0 - OFFSET); glVertex3d (-10.0,10.0,10.0);
				
		glEnd ();

	//Re-Enable the depth test
	glEnable(GL_DEPTH_TEST);
	//disable texture mapping
	glDisable(GL_TEXTURE_2D);
	glPopMatrix();

}


Any help in helping me fix this problem would be great. cheers Sorry, the .h file is

#define MAX_TEXTURES 24

class skybox {
public:  //just make everything public than you don't have to worry about access

	skybox() { } //constructor

	GLuint LoadTexture(const char * bitmap_file);
	void Init();
	void draw();


	GLuint	texture[MAX_TEXTURES];

	//used to correct the edges of the skybox overlap
	//try setting this to 0.0 in the Init() and you will see the seams of the textures
	double	OFFSET,	rot_x, rot_y;
	long	text_offset;
};
Advertisement
change 'GLuint LoadTexture(const char * bitmap_file)' to 'GLuint skybox::LoadTexture(const char * bitmap_file)'
sigh, such a simple mistake causes a nervous breakdown! If only i understood this as well as java! Anyways, thank you very much for your help.

This topic is closed to new replies.

Advertisement