Code: Select all
#include "wx/wx.h";
#include "wx/notebook.h";
#include <GL/glew.h>;
#include "wx/glcanvas.h";
#include <GL/GL.h>;
#include <GL/glu.h>;
// Declare the application class
class MyApp : public wxApp
{
public:
// Called on application startup
virtual bool OnInit();
};
// Declare our main frame class
class MyFrame : public wxFrame
{
public:
wxNotebook* nbHierarchy = new wxNotebook(this, wxID_ANY, wxDefaultPosition, wxSize(200, 300));
wxNotebook* nbScene = new wxNotebook(this, wxID_ANY, wxDefaultPosition , wxSize(800, 600));
wxNotebook* nbInspector = new wxNotebook(this, wxID_ANY, wxDefaultPosition, wxSize(200, 300));
wxGLCanvas* myCanvas;
wxGLContext* myContext;
// Constructor
MyFrame(const wxString& title);
// Event handlers
void OnQuit(wxCommandEvent& event);
void OnAbout(wxCommandEvent& event);
private:
// This class handles events
DECLARE_EVENT_TABLE()
};
// Implements MyApp& GetApp()
DECLARE_APP(MyApp)
// Give wxWidgets the means to create a MyApp object
IMPLEMENT_APP(MyApp)
// Initialize the application
bool MyApp::OnInit()
{
// Create the main application window
MyFrame *frame = new MyFrame(wxT("War Engine Version 0"));
// Show it
frame->Show(true);
// Start the event loop
return true;
}
// Event table for MyFrame
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_MENU(wxID_ABOUT, MyFrame::OnAbout)
EVT_MENU(wxID_EXIT, MyFrame::OnQuit)
END_EVENT_TABLE()
void MyFrame::OnAbout(wxCommandEvent& event)
{
wxString msg;
msg.Printf(wxT("Hello and welcome to %s."),
"War Engine Version 0");
wxMessageBox(msg, wxT("About War Engine"),
wxOK | wxICON_INFORMATION, this);
}
void MyFrame::OnQuit(wxCommandEvent& event)
{
// Destroy the frame
Close();
}
MyFrame::MyFrame(const wxString& title)
: wxFrame(NULL, wxID_ANY, title)
{
// Create a menu bar
wxMenu *fileMenu = new wxMenu;
// The “About” item should be in the help menu
wxMenu *helpMenu = new wxMenu;
helpMenu->Append(wxID_ABOUT, wxT("&About...\tF1"),
wxT("ABout this program."));
fileMenu->Append(wxID_EXIT, wxT("E&xit\tAlt - X"),
wxT("Quit this program"));
// Now append the freshly created menu to the menu bar...
wxMenuBar *menuBar = new wxMenuBar();
menuBar->Append(fileMenu, wxT("&File"));
menuBar->Append(helpMenu, wxT("&Help"));
// ... and attach this menu bar to the frame
SetMenuBar(menuBar);
// Create a status bar just for fun
CreateStatusBar(2);
SetStatusText(wxT("Welcome to War Engine!"));
wxPanel* hierarchyWindow = new wxPanel(nbHierarchy, wxID_ANY);
nbHierarchy->AddPage(hierarchyWindow, "Hierarchy", false);
wxPanel* sceneWindow = new wxPanel(nbScene, wxID_ANY);
wxGLAttributes canvasAttrib;
canvasAttrib.PlatformDefaults().Defaults().EndList();
bool accepted = wxGLCanvas::IsDisplaySupported(canvasAttrib);
if (accepted)
{
myCanvas = new wxGLCanvas(this, canvasAttrib);
}
else
{
wxMessageBox(wxT("Visual attributes not supported."), wxT("Error"));
}
wxGLContextAttrs contextAttr;
contextAttr.PlatformDefaults().OGLVersion(4, 0).EndList();
myContext = new wxGLContext(myCanvas, NULL, &contextAttr);
if(!myContext->IsOK() )
{
wxMessageBox(wxT("Failed to set OpenGL 4.0"), wxT("Error"));
}
myCanvas = new wxGLCanvas(nbScene, canvasAttrib, wxID_ANY, wxDefaultPosition, wxSize(800, 600));
myContext = new wxGLContext(myCanvas);
myCanvas->SetCurrent(*myContext);
nbScene->AddPage(myCanvas, "Scene", false);
nbScene->AddPage(sceneWindow, "Game", false);
//glClearColor(1.0f, 0.0f, 0.0f, 1.0f);
//glClear(GL_COLOR_BUFFER_BIT);
wxPanel* inspectorWindow = new wxPanel(nbInspector, wxID_ANY);
nbInspector->AddPage(inspectorWindow, "Inspector", false);
wxBoxSizer* sizer = new wxBoxSizer(wxHORIZONTAL);
sizer->Add(nbHierarchy, 0, wxEXPAND, 0);
sizer->Add(nbScene, 1, wxEXPAND, 0);
sizer->Add(nbInspector, 0, wxEXPAND, 0);
sizer->SetSizeHints(this);
SetSizer(sizer);
if (glewInit() != GLEW_OK)
{
wxMessageBox(wxT("GLEW cant initialize."), wxT("Error"));
}
}
What I have so far I got from openGL/notebook samples and the wxwidgets book. I don't wanna deal with shaders yet but I just want to get a blank red window to show then I'll move onto a triangle, then 3d models, etc. IS anyone familiar enough with this to provide some basic code to show the red window? I think I pulled all I can from the sample...I don't know what else to do.