***EDIT: oops, ]code[ supposed to be ]source[ tags, I appologize
I am using Eclipse C/C++ on Ubuntu Linux.
When I tried to create this class (an Input class for GLUT), it gives me an "undefined reference to `vtable for soabiro_Input'" error. Does anyone know what this is and how I fix it?
here is my code
Soabiro_Input.h
#ifndef sOABIRO_INPUT_H_
#define sOABIRO_INPUT_H_
class soabiro_Input
{
bool keyUp,keyDown,keyLeft,keyRight;
bool leftClick,rightClick,middleClick;
int key[256];
int windowH,windowW; //height and width of screen window, used to get proper coordinates
double mouseX,mouseY;
int mouseBtn,mouseState;
public:
soabiro_Input();
soabiro_Input(int W, int H);
void keyboard(unsigned char key, int x, int y);
void specialKeyboard(int key, int x, int y);
void mouseMove(int x, int y);
void mouseClick(int btn, int state, int x, int y);
virtual ~soabiro_Input();
};
#endif /*SOABIRO_INPUT_H_*/
Soabiro_Input.cpp
#include <GL/glut.h>
#include <iostream>
#include "soabiro_Input.h"
soabiro_Input::soabiro_Input()
{
std::cout << "WARNING, using default constructor for Input class, mouse coordinates \n";
std::cout << "will be calibrated for a window that is 640 * 480!!! \n";
windowW=640;
windowH=480;
}
soabiro_Input::soabiro_Input(int W, int H)
{
windowW=W;
windowH=H;
}
void soabiro_Input::keyboard(unsigned char key, int x, int y)
{
}
void soabiro_Input::specialKeyboard(int key, int x, int y)
{
//left arrow
if (key == GLUT_KEY_LEFT)
keyLeft=true;
else
keyLeft=false;
//right arrow
if (key == GLUT_KEY_RIGHT)
keyRight=true;
else
keyRight=false;
//up arrow
if (key == GLUT_KEY_UP)
keyUp=true;
else
keyUp=false;
//down arrow
if (key == GLUT_KEY_DOWN)
keyUp=true;
else
keyUp=false;
}
void soabiro_Input::mouseMove(int x, int y)
{
/*gets mouse coordinates and converts them to a num between -1 and 1 for OpenGL*/
mouseX=(float)x;
mouseX=((mouseX / windowW)*2)-1;
mouseY=(float)y;
mouseY=((mouseY / windowH)*2)-1;
}
void soabiro_Input::mouseClick(int btn, int state, int x, int y)
{
//get mouse button and state
mouseBtn=btn;
mouseState=state;
//get coordinates in opengl format (-1 to 1)
mouseX=(float)x;
mouseX=((mouseX / windowW)*2)-1;
mouseY=(float)y;
mouseY=((mouseY / windowH)*2)-1;
}