Sign in to follow this  
laura1316

Help Errors with Variables

Recommended Posts

Hi All: I am working on the following program. I put my variables into my source. My program is a precompiled code that is going to be in both C++ and OpenGL. Does anyone have any insight to my errors?
#pragma comment(lib, "opengl32.lib")
#pragma comment(lib, "glu32.lib")
#pragma comment(lib, "glut32.lib")
#pragma comment(lib, "glaux.lib")

#include "windows.h"
#include "stdio.h"
#include "GL/gl.h"
#include "GL/glu.h"
#include "GL/glaux.h"

// Tilt.cpp : implementation file
//

#include "stdafx.h"
#include "TRIAX.h"
#include "Tilt.h"
#include ".\tilt.h"
#include "AnalogMeter.h"
#include "SCI.h"
#include "math.h"

CAnalogMeter meterxaxis,meteryaxis,meterzaxis;
unsigned char TiltX,TiltY,TiltZ,Xoff,Yoff,Zoff,Xmax,Ymax,Zmax,BadHandShakeTilt;
double rx,ry,rz;

#define CDS_FULLSCREEN4

HDC hDC = NULL;
HGLRC hRC = NULL;
HWND hWnd = NULL;
HINSTANCE hInstance;

bool keys[256];
bool active = TRUE;
bool fullscreen = TRUE;

//X Rotation
GLfloat xrot;
//Y Rotation
GLfloat yrot;
//Z Rotation
GLfloat zrot;
//X Rotation Speed
GLfloat xspeed;
//Y Rotation Speed
GLfloat yspeed;
// Depth into the screen
GLfloat z = -5.0f;

//Which filter to use
GLuint filter;
//Storage for 3 textures
GLuint texture[3];

// CTilt dialog

IMPLEMENT_DYNAMIC(CTilt, CDialog)
CTilt::CTilt(CWnd* pParent /*=NULL*/)
	: CDialog(CTilt::IDD, pParent)
{
}

CTilt::~CTilt()
{
}


void CTilt::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
}


BEGIN_MESSAGE_MAP(CTilt, CDialog)
	ON_WM_PAINT()
	ON_WM_TIMER()
END_MESSAGE_MAP()


// CTilt message handlers

BOOL CTilt::OnInitDialog()
{
	CDialog::OnInitDialog();
	meterxaxis.SetRange(-90.0, +90.0);
    meterxaxis.SetTitle((CString)"X-axis Tilt");
    meterxaxis.SetUnit((CString)"degrees");
	meterxaxis.SetValueDecimals(1);

    meteryaxis.SetRange(-90.0, +90.0);
    meteryaxis.SetTitle((CString)"Y-axis Tilt");
    meteryaxis.SetUnit((CString)"degrees");
	meteryaxis.SetValueDecimals(1);
  
	meterzaxis.SetRange(-90.0, +90.0);
    meterzaxis.SetTitle((CString)"Z-axis Tilt");
    meterzaxis.SetUnit((CString)"degrees");
	meterzaxis.SetValueDecimals(1);

bool bSCI=SCIgetCal(Xoff,Xmax,Yoff,Ymax,Zoff,Zmax); if (!bSCI) {Xoff=Yoff=Zoff=128; Xmax=Ymax=Zmax=189;}
BadHandShakeTilt=0;
UINT_PTR rodtimer=SetTimer(1,50,0);
InvalidateRect(NULL);
return TRUE;
}

void CTilt::OnPaint()
{
/*CPaintDC dc(this); // device context for painting
CRect r;
GetDlgItem(IDC_TILTX)->GetWindowRect(&r);
ScreenToClient(&r);
meterxaxis.ShowMeter(&dc,r);
GetDlgItem(IDC_TILTY)->GetWindowRect(&r);
ScreenToClient(&r);
meteryaxis.ShowMeter(&dc,r);
GetDlgItem(IDC_TILTZ)->GetWindowRect(&r);
ScreenToClient(&r);
meterzaxis.ShowMeter(&dc,r);*/
}

void CTilt::OnTimer(UINT nIDEvent)
{
bool bSCI=SCIgetXYZ(TiltX,TiltY,TiltZ); if (!bSCI) {TiltX=TiltY=TiltZ=0; BadHandShakeTilt++;}
if (BadHandShakeTilt>10) {BadHandShakeTilt=0; SCIHandShake();}
rx=(TiltX-Xoff*1.0)/(Xmax-Xoff*1.0); if (rx<-1.0) rx=-1.0; else if (rx>1.0) rx=1.0; rx=asin(rx)*180.0/3.1416;
ry=(TiltY-Yoff*1.0)/(Ymax-Yoff*1.0); if (ry<-1.0) ry=-1.0; else if (ry>1.0) ry=1.0; ry=asin(ry)*180.0/3.1416;
rz=(TiltZ-Zoff*1.0)/(Zmax-Zoff*1.0); if (rz<-1.0) rz=-1.0; else if (rz>1.0) rz=1.0; rz=asin(rz)*180.0/3.1416;
CDC* dc1=GetDC();
meterxaxis.UpdateNeedle(dc1,rx);
meteryaxis.UpdateNeedle(dc1,ry);
meterzaxis.UpdateNeedle(dc1,rz);
ReleaseDC(dc1);
CDialog::OnTimer(nIDEvent);
}

The following are my errors: d:\Profiles\r65136\My Documents\Visual Studio Projects\miniTRIAX_v1\Tilt.cpp(39): error C2146: syntax error : missing ';' before identifier 'xrot' d:\Profiles\r65136\My Documents\Visual Studio Projects\miniTRIAX_v1\Tilt.cpp(39): error C2501: 'GLfloat' : missing storage-class or type specifiers d:\Profiles\r65136\My Documents\Visual Studio Projects\miniTRIAX_v1\Tilt.cpp(39): error C2501: 'xrot' : missing storage-class or type specifiers d:\Profiles\r65136\My Documents\Visual Studio Projects\miniTRIAX_v1\Tilt.cpp(41): error C2146: syntax error : missing ';' before identifier 'yrot' d:\Profiles\r65136\My Documents\Visual Studio Projects\miniTRIAX_v1\Tilt.cpp(41): error C2501: 'GLfloat' : missing storage-class or type specifiers d:\Profiles\r65136\My Documents\Visual Studio Projects\miniTRIAX_v1\Tilt.cpp(41): error C2086: 'int GLfloat' : redefinition d:\Profiles\r65136\My Documents\Visual Studio Projects\miniTRIAX_v1\Tilt.cpp(41): error C2501: 'yrot' : missing storage-class or type specifiers d:\Profiles\r65136\My Documents\Visual Studio Projects\miniTRIAX_v1\Tilt.cpp(43): error C2146: syntax error : missing ';' before identifier 'zrot' d:\Profiles\r65136\My Documents\Visual Studio Projects\miniTRIAX_v1\Tilt.cpp(43): error C2501: 'GLfloat' : missing storage-class or type specifiers d:\Profiles\r65136\My Documents\Visual Studio Projects\miniTRIAX_v1\Tilt.cpp(43): error C2086: 'int GLfloat' : redefinition d:\Profiles\r65136\My Documents\Visual Studio Projects\miniTRIAX_v1\Tilt.cpp(43): error C2501: 'zrot' : missing storage-class or type specifiers d:\Profiles\r65136\My Documents\Visual Studio Projects\miniTRIAX_v1\Tilt.cpp(45): error C2146: syntax error : missing ';' before identifier 'xspeed' d:\Profiles\r65136\My Documents\Visual Studio Projects\miniTRIAX_v1\Tilt.cpp(45): error C2501: 'GLfloat' : missing storage-class or type specifiers d:\Profiles\r65136\My Documents\Visual Studio Projects\miniTRIAX_v1\Tilt.cpp(45): error C2086: 'int GLfloat' : redefinition d:\Profiles\r65136\My Documents\Visual Studio Projects\miniTRIAX_v1\Tilt.cpp(45): error C2501: 'xspeed' : missing storage-class or type specifiers d:\Profiles\r65136\My Documents\Visual Studio Projects\miniTRIAX_v1\Tilt.cpp(47): error C2146: syntax error : missing ';' before identifier 'yspeed' d:\Profiles\r65136\My Documents\Visual Studio Projects\miniTRIAX_v1\Tilt.cpp(47): error C2501: 'GLfloat' : missing storage-class or type specifiers d:\Profiles\r65136\My Documents\Visual Studio Projects\miniTRIAX_v1\Tilt.cpp(47): error C2086: 'int GLfloat' : redefinition d:\Profiles\r65136\My Documents\Visual Studio Projects\miniTRIAX_v1\Tilt.cpp(47): error C2501: 'yspeed' : missing storage-class or type specifiers d:\Profiles\r65136\My Documents\Visual Studio Projects\miniTRIAX_v1\Tilt.cpp(49): error C2146: syntax error : missing ';' before identifier 'z' d:\Profiles\r65136\My Documents\Visual Studio Projects\miniTRIAX_v1\Tilt.cpp(49): error C2501: 'GLfloat' : missing storage-class or type specifiers d:\Profiles\r65136\My Documents\Visual Studio Projects\miniTRIAX_v1\Tilt.cpp(49): error C2086: 'int GLfloat' : redefinition d:\Profiles\r65136\My Documents\Visual Studio Projects\miniTRIAX_v1\Tilt.cpp(49): error C2501: 'z' : missing storage-class or type specifiers d:\Profiles\r65136\My Documents\Visual Studio Projects\miniTRIAX_v1\Tilt.cpp(49): warning C4244: 'initializing' : conversion from 'float' to 'int', possible loss of data d:\Profiles\r65136\My Documents\Visual Studio Projects\miniTRIAX_v1\Tilt.cpp(52): error C2146: syntax error : missing ';' before identifier 'filter' d:\Profiles\r65136\My Documents\Visual Studio Projects\miniTRIAX_v1\Tilt.cpp(52): error C2501: 'GLuint' : missing storage-class or type specifiers d:\Profiles\r65136\My Documents\Visual Studio Projects\miniTRIAX_v1\Tilt.cpp(52): error C2501: 'filter' : missing storage-class or type specifiers d:\Profiles\r65136\My Documents\Visual Studio Projects\miniTRIAX_v1\Tilt.cpp(54): error C2146: syntax error : missing ';' before identifier 'texture' d:\Profiles\r65136\My Documents\Visual Studio Projects\miniTRIAX_v1\Tilt.cpp(54): error C2501: 'GLuint' : missing storage-class or type specifiers d:\Profiles\r65136\My Documents\Visual Studio Projects\miniTRIAX_v1\Tilt.cpp(54): error C2086: 'int GLuint' : redefinition d:\Profiles\r65136\My Documents\Visual Studio Projects\miniTRIAX_v1\Tilt.cpp(54): error C2501: 'texture' : missing storage-class or type specifiers Thanks.

Share this post


Link to post
Share on other sites
I'm having a little hard time figuring out your files. For example:


#pragma comment(lib, "opengl32.lib")
#pragma comment(lib, "glu32.lib")
#pragma comment(lib, "glut32.lib")
#pragma comment(lib, "glaux.lib")

#include "windows.h"
#include "stdio.h"
#include "GL/gl.h"
#include "GL/glu.h"
#include "GL/glaux.h"

// Tilt.cpp : implementation file



Ok, so this means that Tilt.cpp is what you have posted after the last comment? Where are the lines above(#pragma comment...etc) located? In stdafx.h?

Share this post


Link to post
Share on other sites
Yes this is part of a larger program. It a large application with a lot of different applications. For example there is the main GUI that has a menu to select from and depending on the selection there is different applications that are ran. Does that make sense? So the code that I have posted is just a snippet of the overall program. All the other applications are written in C++ but I wanted to make a 3D graphic so I have chosen to incorporate OpenGL. So I wrote the OpenGL application, which is a 3D cube. I took that code and am trying to put it into my other app, and it doesn't recognize any of the OpenGL Variable types.

Share this post


Link to post
Share on other sites
The problem is likely to be this: all code before the inclusion of the precompiled header file is ignored. You include a bunch of files before you include stdafx.h. If you are using PCH, then all those lines are ignored.

It is likely that the pragmas are ignored too, but I don't know for sure.

BTW, you probably want to move the lines that include windows and GL headers to stdafx.h.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this