wx_BGI_Graphics
Classic BGI-compatible graphics API with modern OpenGL extension API
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions
wxbgi::WxBgiCanvas Class Reference

A wxGLCanvas that hosts the wx_bgi BGI drawing surface. More...

#include <wx_bgi_canvas.h>

Inheritance diagram for wxbgi::WxBgiCanvas:
Inheritance graph
[legend]
Collaboration diagram for wxbgi::WxBgiCanvas:
Collaboration graph
[legend]

Public Member Functions

void Render ()
 Render the BGI buffer immediately.
 
void SetAutoRefreshHz (int hz)
 Enable idle-driven auto-refresh at the requested frame rate.
 
 WxBgiCanvas (wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=0, const wxString &name=wxASCII_STR("WxBgiCanvas"))
 
 ~WxBgiCanvas () override
 

Protected Member Functions

virtual void PostBlit (int pageW, int pageH, int vpW, int vpH)
 Called AFTER wxbgi_wx_render_page_gl_vp() and all 3-D solid GL passes, but BEFORE SwapBuffers().
 
virtual void PreBlit (int w, int h)
 Called inside Render() after the GL context is current and BGI is initialised, but before the BGI pixel buffer is blitted to this canvas's OpenGL surface.
 

Detailed Description

A wxGLCanvas that hosts the wx_bgi BGI drawing surface.

Drop this panel into any wxFrame or wxPanel. After the first paint the BGI state is initialised and you can call any BGI drawing function.

Typical usage:

// In wxFrame constructor — no GL work here:
m_canvas = new wxbgi::WxBgiCanvas(this, wxID_ANY,
wxDefaultPosition, wxSize(800, 600));
// After first paint fires (e.g. via wxEVT_PAINT or wxCallAfter):
setbkcolor(BLACK);
circle(200, 200, 80);
m_canvas->SetAutoRefreshHz(60);
A wxGLCanvas that hosts the wx_bgi BGI drawing surface.
Definition wx_bgi_canvas.h:32
BGI_API void BGI_CALL circle(int x, int y, int radius)
Draws a circle outline.
BGI_API void BGI_CALL setbkcolor(int color)
Sets background color index used by clear operations.

Constructor & Destructor Documentation

◆ WxBgiCanvas()

wxbgi::WxBgiCanvas::WxBgiCanvas ( wxWindow *  parent,
wxWindowID  id = wxID_ANY,
const wxPoint &  pos = wxDefaultPosition,
const wxSize &  size = wxDefaultSize,
long  style = 0,
const wxString &  name = wxASCII_STR("WxBgiCanvas") 
)
explicit

◆ ~WxBgiCanvas()

wxbgi::WxBgiCanvas::~WxBgiCanvas ( )
override

Member Function Documentation

◆ PostBlit()

virtual void wxbgi::WxBgiCanvas::PostBlit ( int  pageW,
int  pageH,
int  vpW,
int  vpH 
)
inlineprotectedvirtual

Called AFTER wxbgi_wx_render_page_gl_vp() and all 3-D solid GL passes, but BEFORE SwapBuffers().

Override in subclasses to composite overlays (concentric circles, grid, UCS axes) on top of 3-D solid geometry. Typically implemented by calling wxbgi_wx_render_overlays_for_camera() for this panel's camera.

Parameters
pageWLogical BGI page width.
pageHLogical BGI page height.
vpWPhysical framebuffer width (may differ on HiDPI).
vpHPhysical framebuffer height (may differ on HiDPI).

◆ PreBlit()

virtual void wxbgi::WxBgiCanvas::PreBlit ( int  w,
int  h 
)
inlineprotectedvirtual

Called inside Render() after the GL context is current and BGI is initialised, but before the BGI pixel buffer is blitted to this canvas's OpenGL surface.

Override in subclasses to render a specific camera's scene into the shared BGI scratch buffer. Because wx paint events are sequential on the main thread, the scratch buffer is safe to reuse across panels.

Parameters
wLogical pixel width of this canvas.
hLogical pixel height of this canvas.

◆ Render()

void wxbgi::WxBgiCanvas::Render ( )

Render the BGI buffer immediately.

◆ SetAutoRefreshHz()

void wxbgi::WxBgiCanvas::SetAutoRefreshHz ( int  hz)

Enable idle-driven auto-refresh at the requested frame rate.

Parameters
hzTarget refresh rate. Pass 0 to disable.

The documentation for this class was generated from the following file: