\M_canvas.h|15|error: expected ')' before '*' token|
\M_canvas.h|19|error: 'M_frame' does not name a type|
I don't understand why it does not recognize the class if I have the header included. Can I not use my M_frame class as a wxWindow type in the glCanvas constructor?
M_canvas.h
Code: Select all
#ifndef M_CANVAS_H
#define M_CANVAS_H
#include <wx/glcanvas.h>
#include "M_frame.h"
class M_canvas : public wxGLCanvas
{
public:
M_canvas(M_frame* parent, const wxGLAttributes& attribs);
~M_canvas(){};
private:
M_frame* m_parent;
wxGLContext* m_context;
wxDECLARE_EVENT_TABLE();
};
Code: Select all
#include "M_canvas.h"
#include "M_frame.h"
#include <wx/glcanvas.h>
M_canvas::M_canvas(M_frame* parent, const wxGLAttributes& attribs)
: wxGLCanvas(parent, attribs, wxID_ANY, wxDefaultPosition, wxDefaultSize, NULL, "canvas", wxNullPalette)
{
m_parent = parent;
wxGLContextAttrs ctxAttribs;
};
BEGIN_EVENT_TABLE(M_canvas, wxFrame)
END_EVENT_TABLE()
Code: Select all
#ifndef M_FRAME_H
#define M_FRAME_H
#include <wx/frame.h>
#include <wx/glcanvas.h>
#include "M_canvas.h"
class M_frame : public wxFrame
{
public:
M_frame(const wxString& title);
virtual ~M_frame() {};
void OnQuit(wxCommandEvent& event);
private:
M_canvas* canvas;
DECLARE_EVENT_TABLE();
};
#endif // M_FRAME_H
Code: Select all
#include "wx/wx.h"
#include "m_frame.h"
#include <wx/frame.h>
#include <wx/glcanvas.h>
M_frame::M_frame(const wxString& title)
: wxFrame(NULL, wxID_ANY, title, wxDefaultPosition, wxSize(800, 600))
{
canvas = NULL;
wxGLAttributes attribs;
attribs.PlatformDefaults().Defaults().EndList();
wxMenu *menufile = new wxMenu;
wxMenuBar *menubar = new wxMenuBar;
menubar->Append(menufile, "&File");
menufile->Append(wxID_EXIT);
menufile->AppendSeparator();
SetMenuBar(menubar);
};
void M_frame::OnQuit(wxCommandEvent& event)
{
Close(TRUE);
}
BEGIN_EVENT_TABLE(M_frame, wxFrame)
EVT_MENU(wxID_EXIT, M_frame::OnQuit)
END_EVENT_TABLE()
Code: Select all
#ifndef INIT_H
#define INIT_H
class Init : public wxApp
{
public:
Init(){};
bool OnInit() wxOVERRIDE;
};
#endif // INIT_H
Code: Select all
#include <wx/wx.h>
#include <wx/glcanvas.h>
#include "Init.h"
#include "M_frame.h"
#include "M_canvas.h"
IMPLEMENT_APP(Init);
bool Init::OnInit()
{
if ( !wxApp::OnInit() )
return false;
M_frame* frame = new M_frame("main frame");
frame->Show(true);
return true;
}