I get error whats wrong?

#include <iostream>
#include <vector>
#include <cstdio>
#include "GL\arcball.h"
#include "GL\GL.H"
#include "GL\GLU.H"
#include "GL\glut.h"


#ifndef MAIN_H
#define MAIN_H



const vec eye( 0.0f, 0.0f, -20.0f );
const vec centre( 0.0f, 0.0f, 0.0f );
const vec up( 0.0f, 1.0f, 0.0f );
const float SPHERE_RADIUS = 5.0f;
const int SPHERE_LAT_SLICES = 12;
const int SPHERE_LONG_SLICES = 24;
static float aspect_ratio = 1.0f;
const float PI = 3.141592654f;
//
bool ctrlbutton = false;

struct TPoint
{
TPoint (double ax, double ay,double az)
{
x=ax;y=ay;z=az;
};

double x; double y; double z;
};

typedef TPoint *PPoint ;

class TObject
{
private:
public:
TObject();
virtual ~TObject();
virtual void Draw() const = 0 ;
};

class TLine : public TObject
{
private:
static double x1,y1,z1,x2,y2,z2;

public:
TLine(const double ax1,const double ay1,const double az1,const double ax2,const double ay2,const double az2) {x1 = ax1;x2 = ax2;y1=ay1;z1=az1;z2=az2;};
~TLine() {};
void Draw() const ;
};

typedef std::vector<TObject*> PObject;


class TBlock
{
private:
static PObject *Elements ;
static int width,height;
static float angle ;
static float lx,lz;
static float x, z;
static float deltaAngle;
static float deltaMove ;
static int xOrigin ;
static double ez;

static void computePos(float deltaMove);
static void computeDir(float deltaAngle);
static void mouseMove(int x, int y);
static void drag_scene(int x, int y);

public:
TBlock(int argc, char* argv[]);
~TBlock();
static void AddElement(TObject *Element);
static void Draw() ;
static void OnResize(int width, int height);
static void OnMouse(int button, int state, int x, int y);
static void OnMotion(int x , int y);
static void OnIdle(void);
static void reset_view(int w, int h);
static void OnDisplay();

};

TPoint ConvertMouseToOGLCoordinate(int mouseX, int mouseY, int mouseZ)
{
GLint viewport[4];
GLdouble modelMatrix[16];
GLdouble projectionMatrix[16];

glGetIntegerv(GL_VIEWPORT, viewport);
glGetDoublev(GL_MODELVIEW_MATRIX, modelMatrix);
glGetDoublev(GL_PROJECTION_MATRIX, projectionMatrix);

//float winZ;
float winY = float(viewport[3] - mouseY);
//glReadPixels(mouseX, (int)winY, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &winZ);

double x, y, z;
gluUnProject((double)mouseX, winY, mouseZ,
modelMatrix, projectionMatrix, viewport,
&x, &y, &z);

return TPoint(x,y,z);

};


double TBlock::ez = 5;
float TBlock::angle = 0.0f;
float TBlock::x = 0.0f;
float TBlock::lz = -1.0f;
float TBlock::lx = 0.0f;
float TBlock::z = 5.0f;
float TBlock::deltaAngle = 0.0f;
float TBlock::deltaMove = 0;
int TBlock::xOrigin = -1;
int TBlock::height = 400;
int TBlock::width = 400;
PObject *TBlock::Elements = new PObject();
double TLine::x1 = 0;
double TLine::y1 = 0;
double TLine::z1 = 0;
double TLine::x2 = 0;
double TLine::y2 = 0;
double TLine::z2 = 0;











extern TPoint ConvertMouseToOGLCoordinate(int mouseX, int mouseY, int mouseZ);



#endif






ERROR ****** Unresolved externals....
Last edited on
Sorry, my friend, isn't it the same code you asked for help about three days ago? :-O
It's a lot of code and very few feedback about its errors.
However, you can see that you declare a function here:
1
2
TPoint ConvertMouseToOGLCoordinate(int mouseX, int mouseY, int mouseZ)
{

and then you claim that it is to be found in another compilation unit (i.e. another file) here:
extern TPoint ConvertMouseToOGLCoordinate(int mouseX, int mouseY, int mouseZ);

You are declaring a big bunch of things together in the same header, like structs and two classes, even derived one from the other, and functions that apparently come out of the blue.
I'm also not used to capitalized method names and I must say I've never seen a class where every single variable and every single method are static (TBlock) - whenever I'm just a C++ beginner and that doesn't mean anything. Btw, isn't it common to see static variables being initialized in the source instead of the header? I think it's not a good strategy to initialize them in the header, since headers are generally conceived to be included by several source files.

I think if you tried to split your declarations into several headers and have them more organized, it would be simpler for you to isolate the errors.

Please post the full text of the "unresolved external" message.

PLEASE USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post.
http://www.cplusplus.com/articles/jEywvCM9/
Hint: You can edit your post, highlight your code and press the <> formatting button.
Topic archived. No new replies allowed.