ok...here it is.....in the camera.h i did:
extern CCamera gl_Camera;
in the mainprog.cpp:
Code:
glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
glClear( GL_COLOR_BUFFER_BIT );
gluLookAt(gl_Camera.C_vPosition.x, gl_Camera.C_vPosition.y, gl_Camera.C_vPosition.z,
gl_Camera.C_vView.x, gl_Camera.C_vView.y, gl_Camera.C_vView.z,
gl_Camera.C_vUpVector.x, gl_Camera.C_vUpVector.y, gl_Camera.C_vUpVector.z);
glPushMatrix();
glBegin( GL_POLYGON );
glColor3f( 1.0f, 1.0f, 0.0f ); glVertex3f( 1.0f, 1.0f, -1.0f );
glColor3f( 0.0f, 1.0f, 0.0f ); glVertex3f( 1.0f, -1.0f, -1.0f );
glColor3f( 0.0f, 0.0f, 1.0f ); glVertex3f( -1.0f, -1.0f, -1.0f );
glColor3f( 1.0f, 0.0f, 0.0f ); glVertex3f( -1.0f, 1.0f, -1.0f );
glEnd();
glPopMatrix();
SwapBuffers( hdc );
theta += 1.0f;
and:
Code:
case WM_KEYDOWN:
float speed;
switch ( wparam ) {
case VK_ESCAPE:
PostQuitMessage( 0 );
break;
case VK_UP:
gl_Camera.MoveCamera(speed); //move camera forward
void RenderScene(); //render the scene after movement
break;
case VK_DOWN:
gl_Camera.MoveCamera(-speed); //move camera backward
void RenderScene(); //render the scene after movement
break;
return 0;
}
those are the areas i get 'unidentified reference to gl_Camera...below is the camera.cpp and camera.h incase it might be important:
camera.cpp
Code:
#include <windows.h>
#include <gl/gl.h>
#include "include.h"
//camera constructor
CCamera :: CCamera()
{
CVector3 vZero = {0.0, 0.0, 0.0};
CVector3 vView = {0.0, 1.0, 0.5};
CVector3 vUp = {0.0, 0.0, 1.0};
C_vPosition = vZero;
C_vView = vView;
C_vUpVector = vUp;
};
//position camera
void CCamera :: PositionCamera(float positionX, float positionY, float positionZ,
float viewX, float viewY, float viewZ,
float upVectorX, float upVectorY, float upVectorZ)
{
CVector3 vPosition = {positionX, positionY, positionZ};
CVector3 vView = {viewX, viewY, viewZ};
CVector3 vUpVector = {upVectorX, upVectorY, upVectorZ};
C_vPosition = vPosition;
C_vView = vView;
C_vUpVector = C_vUpVector;
};
//move camera
void CCamera::MoveCamera(float speed)
{
CVector3 vVector = {0};
vVector.x = C_vView.x - C_vPosition.x;
vVector.y = C_vView.y - C_vPosition.y;
vVector.z = C_vView.z - C_vPosition.z;
C_vPosition.x += vVector.x * speed;
C_vPosition.z += vVector.z * speed;
C_vView.x += vVector.x * speed;
C_vView.z += vVector.z * speed;
};
camera.h
Code:
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <gl\gl.h>
//vector class
class CVector3
{
public:
float x, y, z;
};
//camera class
class CCamera
{
public:
CVector3 C_vPosition; //camera position
CVector3 C_vView; //camera view
CVector3 C_vUpVector; //camera 'up' vector
CCamera(); //camera constructor
//values for camera positioning
void PositionCamera(float PositionX, float PositionY, float PositionZ,
float ViewX, float ViewY, float ViewZ,
float UpVectorX, float UpVectorY, float UpVectorZ);
//camera movement
float speed;
void MoveCamera(float speed);
};
//extern values so they can be accessed globally
extern CCamera gl_Camera;
-psychopath