wx_BGI_Graphics
Classic BGI-compatible graphics API with modern OpenGL extension API
Loading...
Searching...
No Matches
wx_bgi_canvas.h
Go to the documentation of this file.
1#pragma once
2// wx_bgi_canvas.h — WxBgiCanvas: BGI drawing surface embedded in a wxWidgets panel.
3// Include this header in your application AFTER the wxWidgets headers.
4//
5// WxBgiCanvas is compiled into the wx_bgi_wx static library (not the DLL),
6// so it uses your application''s copy of wxWidgets — no DLL-boundary issues.
7
8#include <wx/glcanvas.h>
9#include "wx_bgi.h"
10#include "wx_bgi_ext.h"
11
12namespace wxbgi {
13
31class WxBgiCanvas : public wxGLCanvas
32{
33public:
34 explicit WxBgiCanvas(wxWindow* parent,
35 wxWindowID id = wxID_ANY,
36 const wxPoint& pos = wxDefaultPosition,
37 const wxSize& size = wxDefaultSize,
38 long style = 0,
39 const wxString& name = wxASCII_STR("WxBgiCanvas"));
40
41 ~WxBgiCanvas() override;
42
44 void Render();
45
50 void SetAutoRefreshHz(int hz);
51
52protected:
65 virtual void PreBlit(int w, int h) { (void)w; (void)h; }
66
80 virtual void PostBlit(int pageW, int pageH, int vpW, int vpH)
81 {
82 (void)pageW; (void)pageH; (void)vpW; (void)vpH;
83 }
84
85private:
86 wxGLContext* m_glContext{nullptr};
87 bool m_ownsGLCtx{false};
88 bool m_glewInited{false};
89 bool m_bgiInited{false};
90 int m_autoRefreshHz{0};
91 wxLongLong_t m_lastRenderMs{0};
92
93 void OnPaint(wxPaintEvent& evt);
94 void OnSize(wxSizeEvent& evt);
95 void OnIdle(wxIdleEvent& evt);
96 void OnKeyDown(wxKeyEvent& evt);
97 void OnKeyUp(wxKeyEvent& evt);
98 void OnChar(wxKeyEvent& evt);
99 void OnMouseMove(wxMouseEvent& evt);
100 void OnMouseDown(wxMouseEvent& evt);
101 void OnMouseUp(wxMouseEvent& evt);
102 void OnMouseWheel(wxMouseEvent& evt);
103
104 static int WxKeyToGlfw(int wxKey);
105 void RouteKeyEvent(wxKeyEvent& evt, int action);
106};
107
108} // namespace wxbgi
A wxGLCanvas that hosts the wx_bgi BGI drawing surface.
Definition wx_bgi_canvas.h:32
~WxBgiCanvas() override
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().
Definition wx_bgi_canvas.h:80
virtual void PreBlit(int w, int h)
Called inside Render() after the GL context is current and BGI is initialised, but before the BGI pix...
Definition wx_bgi_canvas.h:65
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"))
void Render()
Render the BGI buffer immediately.
Definition wx_bgi_canvas.h:12
Public classic BGI-compatible C API exported by the library.
Advanced non-BGI extension API for modern OpenGL workflows.