Hello,
I have the following files:
------------------------------------------------- Contents of constants.h -------------------------------------------------
#ifndef CONSTANTS_H
#define CONSTANTS_H
#include "wx/wx.h"
#endif
------------------------------------------------- Contents of myglcanvas.h -------------------------------------------------
#ifndef MYGLCANVAS_H
#define MYGLCANVAS_H
#include "wx/glcanvas.h"
class MyGLCanvas : public wxGLCanvas
{
public:
MyGLCanvas(wxWindow*, const wxString& title);
void OnSize(wxSizeEvent&);
void OnPaint( wxPaintEvent&);
void OnEraseBackground(wxEraseEvent&);
void OnMouse(wxMouseEvent&);
~MyGLCanvas();
private:
DECLARE_EVENT_TABLE()
};
#endif
------------------------------------------------- Contents of myglcanvas.cpp -------------------------------------------------
#include "MyGLCanvas.h"
BEGIN_EVENT_TABLE(MyGLCanvas, wxGLCanvas)
EVT_SIZE(MyGLCanvas::OnSize)
EVT_PAINT(MyGLCanvas::OnPaint)
EVT_ERASE_BACKGROUND(MyGLCanvas::OnEraseBackground)
EVT_MOUSE_EVENTS(MyGLCanvas::OnMouse)
END_EVENT_TABLE()
MyGLCanvas::MyGLCanvas(wxWindow* parent, const wxString& title)
: wxGLCanvas(parent, -1, wxDefaultPosition, wxSize(300,
300), wxDEFAULT_FRAME_STYLE)
{
Centre(wxBOTH);
}
void MyGLCanvas::OnPaint( wxPaintEvent& event )
{
wxPaintDC dc(this);
}
void MyGLCanvas::OnSize(wxSizeEvent& event)
{
}
void MyGLCanvas::OnEraseBackground(wxEraseEvent& event)
{
}
void MyGLCanvas::OnMouse( wxMouseEvent& event )
{
}
MyGLCanvas::~MyGLCanvas() {
}
------------------------------------------------- Contents of winmain.h -------------------------------------------------
#ifndef WINMAIN_H
#define WINMAIN_H
#include "Constants.h"
const int WIN_MAIN_WIDTH = 400;
const int WIN_MAIN_HEIGHT = 400;
class WinMain : public wxFrame
{
public:
WinMain();
WinMain(wxFrame*, const wxString& title);
private:
};
#endif
------------------------------------------------- Contents of winmain.cpp -------------------------------------------------
#include "WinMain.h"
WinMain::WinMain(wxFrame* parent, const wxString& title)
: wxFrame(parent, -1, title, wxDefaultPosition, wxSize(WIN_MAIN_WIDTH,
WIN_MAIN_HEIGHT), wxDEFAULT_FRAME_STYLE)
{
Centre(wxBOTH);
}
-------------------------------------------------
Contents of main.cpp
-------------------------------------------------
[code]
#include "WinMain.h"
#include "MyGLCanvas.h"
class MyApp : public wxApp
{
public:
virtual bool OnInit();
};
bool MyApp::OnInit()
{
WinMain* myWin = new WinMain(NULL, "test");
return true;
}
IMPLEMENT_APP(MyApp);
-------------------------------------------------
When I compile, I get the following errors on Windows XP using VS Studio 6, SP 5
--------------------Configuration: CDGL - Win32 Debug-------------------- Compiling... main.cpp main.cpp(31) : error C2065: 'myWin' : undeclared identifier main.cpp(31) : error C2296: '*' : illegal, left operand has type 'int (__stdcall *)(struct HINSTANCE__ *,struct HINSTANCE__ *,char *,int)' main.cpp(31) : error C2061: syntax error : identifier 'WinMain' main.cpp(38) : error C2227: left of '->Show' must point to class/struct/union CDGL\main.cpp(44) : error C2143: syntax error : missing ';' before '}'
The last line error C2143 repeats on about 90 times.
It's acting as if it doesn't recogonize my WinMain class. If I comment out the line "#include "MyGLCanvas.h"" in main.cpp, it compiles fine. Also, I can compile and run the OpenGL wxWindow examples, so it is not a matter of setting up my setup.h under wx or anything like that I can think of. Does anyone know what I'm doing wrong? |