wxBaseGLCanvas

A class that provides basic OpenGL window management.

Project

GLCore

Include

BaseGLCanvas.h

Summary
A class that provides basic OpenGL window management.
The wxBaseGLCanvas constructor.
The wxBaseGLCanvas destructor.
Resizes the OpenGL viewport the current wxWindow size.
Pure virtual function that derived classes must override to provide the OpenGL commands necessary to draw the scene.
Paints the window.
Resizes the window.
Erases the window.
Prevents the OnPaint message from trying to redraw the scene while it is currently drawing the scene.
The wxWidgets event table declaration.
Initializes the OpenGL context for this window.

Protected

Summary
The wxBaseGLCanvas constructor.
The wxBaseGLCanvas destructor.
Resizes the OpenGL viewport the current wxWindow size.
Pure virtual function that derived classes must override to provide the OpenGL commands necessary to draw the scene.
Paints the window.
Resizes the window.
Erases the window.
Prevents the OnPaint message from trying to redraw the scene while it is currently drawing the scene.
The wxWidgets event table declaration.

Constructors

wxBaseGLCanvas

wxBaseGLCanvas(wxWindow *parent, 
const wxWindowID id = -1,
const wxPoint &pos = wxDefaultPosition,
const wxSize &size = wxDefaultSize,
long style = 0,
const wxString &name = wxT("wxBaseGLCanvas"),
wxInt32 *attrib = NULL)

The wxBaseGLCanvas constructor.

Parameters

parentThe parent window (must not be NULL).
idThe id for message handling.
posThe starting position.
sizeThe starting size.
styleThe window style, using wxWindow parameters.
nameThe name.
attributeStarting OpenGL implementation attributes.

Destructor

~wxBaseGLCanvas

virtual ~wxBaseGLCanvas()=0

The wxBaseGLCanvas destructor.  It is pure virtual because this class cannot be instantiated directly.  It must be derived from.

Functions

ResizeGL

void ResizeGL()

Resizes the OpenGL viewport the current wxWindow size.

Pure Virtual Functions

DrawScene

virtual void DrawScene()=0

Pure virtual function that derived classes must override to provide the OpenGL commands necessary to draw the scene.  All needed context and scene preparation is handled by wxBaseGLCanvas.

Event Message Handling

OnPaint

void OnPaint(wxPaintEvent &event)

Paints the window.

Parameters

eventThe paint event.

OnSize

void OnSize(wxSizeEvent &event)

Resizes the window.

Parameters

eventThe size event.

OnEraseBackground

void OnEraseBackground(wxEraseEvent &event)

Erases the window.  Necessary in order to prevent flickering when redrawing the OpenGL scene.

Parameters

eventThe erase event.

Variables

mMutex

bool mMutex

Prevents the OnPaint message from trying to redraw the scene while it is currently drawing the scene.

DECLARE_EVENT_TABLE

The wxWidgets event table declaration.

Private

Summary
Initializes the OpenGL context for this window.

Functions

InitGL

void InitGL(void)

Initializes the OpenGL context for this window.  Sets the shade model to GL_SMOOTH, sets perspective hints, adds a light, and sets the clear color to black.

wxBaseGLCanvas(wxWindow *parent, 
const wxWindowID id = -1,
const wxPoint &pos = wxDefaultPosition,
const wxSize &size = wxDefaultSize,
long style = 0,
const wxString &name = wxT("wxBaseGLCanvas"),
wxInt32 *attrib = NULL)
The wxBaseGLCanvas constructor.
virtual ~wxBaseGLCanvas()=0
The wxBaseGLCanvas destructor.
void ResizeGL()
Resizes the OpenGL viewport the current wxWindow size.
virtual void DrawScene()=0
Pure virtual function that derived classes must override to provide the OpenGL commands necessary to draw the scene.
void OnPaint(wxPaintEvent &event)
Paints the window.
void OnSize(wxSizeEvent &event)
Resizes the window.
void OnEraseBackground(wxEraseEvent &event)
Erases the window.
bool mMutex
Prevents the OnPaint message from trying to redraw the scene while it is currently drawing the scene.
void InitGL(void)
Initializes the OpenGL context for this window.
GLCore provides the underlying window classes and tools needed to create and use an OpenGL window with a camera, lighting, selection, mouse/keyboard handling, and IDrawObject rendering.