|
-
October 29th, 2011, 10:26 AM
#1
Need opengl help.
I made a program with opengl and I keep getting this error:
Code:
1>------ Build started: Project: Aiedoo, Configuration: Debug Win32 ------
1> RenderShape.cpp
1> Main.cpp
1> Generating Code...
1>RenderShape.obj : error LNK2005: "void __cdecl Render2dBox(float,float,float,float)" (?Render2dBox@@YAXMMMM@Z) already defined in Main.obj
1>RenderShape.obj : error LNK2005: "void __cdecl Render2dfilledbox(float,float,float,float)" (?Render2dfilledbox@@YAXMMMM@Z) already defined in Main.obj
1>RenderShape.obj : error LNK2005: "void __cdecl RenderTriStrip(float,float,float,float)" (?RenderTriStrip@@YAXMMMM@Z) already defined in Main.obj
1>C:\Program Files\Aiedoo\Debug\Aiedoo.exe : fatal error LNK1169: one or more multiply defined symbols found
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Main.cpp:
Code:
#include <RenderShape.cpp>
#include <GL/glew.h>
#include <GL/glut.h>
bool* keyStates = new bool[256]; // Create an array of boolean values of length 256 (0-255)
bool* keySpecialStates = new bool[246]; // Create an array of boolean values of length 256 (0-255)
void keyOperations (void)
{
}
void keySpecialOperations (void)
{
}
void keyPressed (unsigned char key, int x, int y)
{
keyStates[key] = true; // Set the state of the current key to pressed
}
void keyUp (unsigned char key, int x, int y)
{
keyStates[key] = false; // Set the state of the current key to not pressed
}
void keySpecial (int key, int x, int y)
{
keyStates[key] = true; // Set the state of the current key to pressed
}
void keySpecialUp (int key, int x, int y)
{
keyStates[key] = false; // Set the state of the current key to not pressed
}
void display (void)
{
keyOperations();
keySpecialOperations();
glClearColor(1.0f, 1.0f, 1.0f, 1.0f); // Clear the background of our window to red
glClear(GL_COLOR_BUFFER_BIT); //Clear the colour buffer (more buffers later on)
glLoadIdentity(); // Load the Identity Matrix to reset our drawing locations
glTranslatef(0.0f, 0.0f, -5.0f);
Render2dBox(1.0, 2.0, 0.0, 1.0);
glFlush(); // Flush the OpenGL buffers to the window
}
void reshape (int width, int height)
{
glViewport(0, 0, (GLsizei)width, (GLsizei)height); // Set our viewport to the size of our window
glMatrixMode(GL_PROJECTION); // Switch to the projection matrix so that we can manipulate how our scene is viewed
glLoadIdentity(); // Reset the projection matrix to the identity matrix so that we don't get any artifacts (cleaning up)
gluPerspective(60, (GLfloat)width / (GLfloat)height, 1.0, 100.0); // Set the Field of view angle (in degrees), the aspect ratio of our window, and the new and far planes
glMatrixMode(GL_MODELVIEW); // Switch back to the model view matrix, so that we can start drawing shapes correctly
}
int main (int argc, char **argv)
{
glutInit(&argc, argv); // Initialize GLUT
glutSpecialFunc(keySpecial); // Tell GLUT to use the method "keySpecial" for special key presses
glutSpecialUpFunc(keySpecialUp); // Tell GLUT to use the method "keySpecialUp" for special up key events
glutKeyboardFunc(keyPressed); // Tell GLUT to use the method "keyPressed" for key presses
glutKeyboardUpFunc(keyUp); // Tell GLUT to use the method "keyUp" for key up events
glutInitDisplayMode (GLUT_SINGLE); // Set up a basic display buffer (only single buffered for now)
glutInitWindowSize (800, 600); // Set the width and height of the window
glutInitWindowPosition (100, 100); // Set the position of the window
glutCreateWindow ("Biolife"); // Set the title for the window
glutDisplayFunc(display); // Tell GLUT to use the method "display" for rendering
glutReshapeFunc(reshape); // Tell GLUT to use the method "reshape" for rendering
glutMainLoop(); // Enter GLUT's main loop
}
RenderShape.cpp:
Code:
#include <GL/glew.h>
#include <GL/glut.h>
void Render2dBox(float r, float g, float b, float a)
{
glColor4f (r, g, b, a);
glBegin(GL_QUADS);
glVertex3f(-1.0f, -1.0f, 0.0f); // The bottom left corner
glVertex3f(-1.0f, 1.0f, 0.0f); // The top left corner
glVertex3f(1.0f, 1.0f, 0.0f); // The top right corner
glVertex3f(1.0f, -1.0f, 0.0f); // The bottom right corner
glEnd();
}
void Render2dfilledbox(float r, float g, float b, float a)
{
glColor4f (r, g, b, a);
glPointSize(20.0f);
glBegin(GL_POINTS); // Start drawing a point primitive
glVertex3f(-1.0f, -1.0f, 0.0f); // The bottom left corner
glVertex3f(-1.0f, 1.0f, 0.0f); // The top left corner
glVertex3f(1.0f, 1.0f, 0.0f); // The top right corner
glVertex3f(1.0f, -1.0f, 0.0f); // The bottom right corner
glEnd();
}
void RenderTriStrip(float r, float g, float b, float a)
{
glColor4f (r, g, b, a);
glBegin(GL_TRIANGLE_STRIP);
glVertex3f(-1.0f, -1.0f, 0.0f);
glVertex3f(-1.0f, 1.0f, 0.0f);
glVertex3f(1.0f, 1.0f, 0.0f);
glVertex3f(1.0f, -1.0f, 0.0f);
glVertex3f(-1.0f, -1.0f, 0.0f);
glEnd();
}
Does anyone know whats wrong with this? All it was meant to do is draw something by calling the function in Display() , Render2dBox specificly. I am building a game engine so this is part of the testing.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|