25 #ifndef __GLCHARTCANVAS_H__
26 #define __GLCHARTCANVAS_H__
28 #include <wx/glcanvas.h>
32 #include "model/ocpn_types.h"
33 #include "OCPNRegion.h"
41 #include <unordered_map>
43 #define FORMAT_BITS GL_RGB
45 #ifdef __OCPN__ANDROID__
46 #include <wx/qt/private/wxQtGesture.h>
52 #define GESTURE_EVENT_TIMER 78334
53 #define ZOOM_TIMER 78335
54 #define GESTURE_FINISH_TIMER 78336
60 std::string GLSL_Version;
63 GLenum TextureRectangleFormat;
72 GLboolean QueryExtension(
const char *extName);
76 bool m_bUseAcceleratedPanning;
77 bool m_bUseCanvasPanning;
79 bool m_bTextureCompression;
80 bool m_bTextureCompressionCaching;
82 int m_iTextureDimension;
83 int m_iTextureMemorySize;
85 bool m_GLPolygonSmoothing;
86 bool m_GLLineSmoothing;
102 static bool CanClipViewport(
const ViewPort &vp);
103 static ViewPort ClippedViewport(
const ViewPort &vp,
const LLRegion ®ion);
105 static bool HasNormalizedViewPort(
const ViewPort &vp);
106 static void MultMatrixViewPort(
ViewPort &vp,
float lat = 0,
float lon = 0);
110 static void DrawRegion(
ViewPort &vp,
const LLRegion ®ion);
111 static void SetClipRegion(
ViewPort &vp,
const LLRegion ®ion);
112 static void SetClipRect(
const ViewPort &vp,
const wxRect &rect,
113 bool g_clear =
false);
114 static void DisableClipRegion();
115 void SetColorScheme(ColorScheme cs);
116 void RenderTextures(
ocpnDC &dc,
float *coords,
float *uvCoords,
int nVertex,
118 static void RenderSingleTexture(
ocpnDC &dc,
float *coords,
float *uvCoords,
ViewPort *vp,
119 float dx,
float dy,
float angle);
120 void RenderColorRect(wxRect r, wxColor &color);
122 static bool s_b_useScissorTest;
123 static bool s_b_useStencil;
124 static bool s_b_useStencilAP;
125 static bool s_b_useFBO;
126 static std::unordered_map<wxPenStyle, std::array<wxDash, 2>> dash_map;
128 void SendJSONConfigMessage();
135 void SetContext(wxGLContext *pcontext) { m_pcontext = pcontext; }
136 int GetCanvasIndex() {
return m_pParentCanvas->m_canvasIndex; }
138 int GetGLCanvasWidth() {
return m_glcanvas_width; }
139 int GetGLCanvasHeight() {
return m_glcanvas_height; }
141 void OnPaint(wxPaintEvent &event);
142 void OnEraseBG(wxEraseEvent &evt);
144 void OnActivate(wxActivateEvent &event);
145 void OnSize(wxSizeEvent &event);
146 void MouseEvent(wxMouseEvent &event);
147 void FastPan(
int dx,
int dy);
148 void FastZoom(
float factor,
float cp_x,
float cp_y,
float post_x,
154 #ifdef __OCPN__ANDROID__
155 void OnEvtPanGesture(wxQT_PanGestureEvent &event);
156 void OnEvtPinchGesture(wxQT_PinchGestureEvent &event);
157 void onGestureTimerEvent(wxTimerEvent &event);
158 void onGestureFinishTimerEvent(wxTimerEvent &event);
161 void onZoomTimerEvent(wxTimerEvent &event);
163 wxString GetRendererString() {
return m_renderer; }
164 wxString GetVersionString() {
return m_version; }
165 wxString GetGLSLVersionString() {
return m_GLSLversion; }
166 void EnablePaint(
bool b_enable) { m_b_paint_enable = b_enable; }
172 void DrawGLOverLayObjects(
void);
176 void DrawDynamicRoutesTracksAndWaypoints(
ViewPort &vp);
177 void DrawStaticRoutesTracksAndWaypoints(
ViewPort &vp);
183 void ShipDraw(
ocpnDC &dc);
185 void SetupCompression();
186 bool CanAcceleratePanning() {
return m_b_BuiltFBO; }
187 bool UsingFBO() {
return m_b_BuiltFBO; }
189 bool isInGesture() {
return m_binGesture; }
190 void ResetGridFont() { m_gridfont.Delete(); }
191 time_t m_last_render_time;
194 double mvmatrix[16], projmatrix[16];
201 void RenderS57TextOverlay(
ViewPort &VPoint);
202 void RenderMBTilesOverlay(
ViewPort &VPoint);
203 void RenderScene(
bool bRenderCharts =
true,
bool bRenderOverlays =
true);
205 void RenderGLAlertMessage();
211 bool buildFBOSize(
int fboSize);
213 void configureShaders(
ViewPort &vp);
217 void RenderNoDTA(
ViewPort &vp,
const LLRegion ®ion,
218 int transparency = 255);
223 void DrawFloatingOverlayObjects(
ocpnDC &dc);
226 void DrawChartBar(
ocpnDC &dc);
228 void DrawCloseMessage(wxString msg);
230 void DrawGLTidesInBBox(
ocpnDC &dc, LLBBox &BBox);
231 void DrawGLCurrentsInBBox(
ocpnDC &dc, LLBBox &BBox);
233 void ZoomProject(
float offset_x,
float offset_y,
float swidth,
float sheight);
235 void RendertoTexture(GLint tex);
237 wxGLContext *m_pcontext;
239 int max_texture_dimension;
244 wxString m_version, m_GLSLversion;
245 wxString m_extensions;
250 bool m_b_paint_enable;
256 bool m_b_useFBOStencil;
258 GLuint m_renderbuffer;
260 GLuint m_cache_tex[2];
267 wxSize ownship_size, ownship_tex_size;
276 float m_lastfbo_offsetx;
277 float m_lastfbo_offsety;
278 float m_lastfbo_swidth;
279 float m_lastfbo_sheight;
281 float m_offsetxStep, m_offsetyStep, m_swidthStep, m_sheightStep;
282 float m_runoffsetx, m_runoffsety, m_runswidth, m_runsheight;
283 float m_nStep, m_nTotal, m_nRun;
285 double m_zoomFinalZoom;
286 int m_zoomFinaldx, m_zoomFinaldy;
291 double m_fbo_lat, m_fbo_lon;
293 wxPoint m_lpinchPoint;
299 wxTimer m_gestureEeventTimer;
300 wxTimer m_gestureFinishTimer;
301 bool m_bgestureGuard;
303 wxPoint m_pinchStart;
304 double m_pinchlat, m_pinchlon;
315 int m_currentTexWidth;
316 int m_currentTexHeight;
319 int m_glcanvas_width;
320 int m_glcanvas_height;
324 DECLARE_EVENT_TABLE()
327 extern void BuildCompressedCache();
329 #include "glTextureManager.h"