/////
// error code
Error 2 error LNK2019: unresolved external symbol "public: __thiscall Color::Color(void)" (??0Color@@QAE@XZ) referenced in function "public: __thiscall ColorChangeCode::ColorChangeCode(void)" (??0ColorChangeCode@@QAE@XZ) C:\Users\O\Desktop\SloanP1\SloanP1v2\SloanP1v2\ColorChangeCode.obj
//Driver//
// BounceDriver.cpp
#include <windows.h> // Must have for Windows platform builds
#include <gl\gl.h> // Microsoft OpenGL headers (version 1.1 by themselves)
#include <gl\glu.h> // OpenGL Utilities
#include <gl\glut.h> // Glut (Free-Glut on Windows)
#include "Bounce.h"
#include "Color.h" <- keep in mind the program will compile without
color or colorchangecode included
#include "ColorChangeCode.h" <- where the above error reports the problem
seems to be in the constructor()
using namespace std;
GLfloat x = 0.0f;
GLfloat y = 0.0f;
GLfloat rsize = 25;
GLfloat xstep = 1.0f;
GLfloat ystep = 1.0f;
GLfloat windowWidth;
GLfloat windowHeight;
////////
// Main program entry point
int main(int argc, char* argv[])
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA);
glutInitWindowSize(500,500);
glutCreateWindow("Ryan Sloan - SloanP1");
glutDisplayFunc(RenderScene);
glutReshapeFunc(ChangeSize);
glutTimerFunc(33, TimerFunction, 1);
SetupRC();
glutMainLoop();
return 0;
}
/////////
//Bounce.cpp
//windows.h gl glu and glut included
#include "ColorChangeCode.h"
#include "Color.h"
#include "Bounce.h"
void RenderScene(void)
{
glClear(GL_COLOR_BUFFER_BIT);
//Draw Grey rectangle at +/-200
glColor3f(.50, .50, .50);
glRecti(-200, 200, 200, -200);
//Draw white rectangle at +/-100
glColor3f(1.0f, 1.0f, 1.0f);
glRecti(-100, 100, 100, -100);
//Set drawing color
// R G B
glColor3f(1.0f, 0.5f, 0.0f);
//draws a orange teapot
glutWireTeapot(sizeOfTeapot);
//set drawing color
// Set current drawing color to blue
// R G B
glColor3f(0.0f, 0.0f, 1.0f);
// Draw a filled rectangle with current color
glRectf(x, y, x + rsize, y - rsize);
glColor3f(0.5f, 0.5f, 0.5f);
glLineWidth(1.5);
glBegin(GL_LINES);
//x and y axis
glVertex3f(0.0, 200, 0.0);
glVertex3f(0.0, -200, 0.0);
glVertex3f(200, 0.0, 0.0);
glVertex3f(-200, 0.0, 0.0);
glEnd();
glutSwapBuffers();
}
//
void TimerFunction(int value)
{
GLfloat windowWidth = 100, windowHeight = 100;
if(x > windowWidth-rsize || x < -windowWidth)
xstep = -xstep;
if(button == GLUT_LEFT_BUTTON && state == GLUT_DOWN ){
glBegin(GL_POLYGON);
//cycle through the colors;
glColor3f(execute.colors[indeXA].getR(),
execute.colors[indeXA].getG(),
execute.colors[indeXA].getB());
// Draw a filled rectangle with current color
glRecti(x, y, x + rsize, y - rsize);
glEnd();
++indeXA;
if (indeXA == 6){
indeXA = 0;
}
}
}
//ColorChangeCode.h
//windows.h, gl, glu,and glut were all included
#include "Color.h"
using namespace std;
#ifndef _COLORCHANGECODE_H
#define _COLORCHANGECODE_H
class ColorChangeCode : public Color {
public:
Color* colors; <------------------ I think the problem is here.
When I comment out this class and
the color class it will compile.
Otherwise, I get LNK2019
ColorChangeCode();
~ColorChangeCode(){ delete[] colors;}
};
#endif
////
//ColorChangeCode.cpp
//windows.h, gl, glu,and glut were all included
#include "Color.h"
#include "ColorChangeCode.h"