25#ifndef __GLCHARTCANVAS_H__
26#define __GLCHARTCANVAS_H__
28#include <wx/glcanvas.h>
32#include "ocpn_types.h"
33#include "OCPNRegion.h"
40#define FORMAT_BITS GL_RGB
42#ifdef __OCPN__ANDROID__
43#include <wx/qt/private/wxQtGesture.h>
49#define GESTURE_EVENT_TIMER 78334
50#define ZOOM_TIMER 78335
51#define GESTURE_FINISH_TIMER 78336
57 std::string GLSL_Version;
60 GLenum TextureRectangleFormat;
69GLboolean QueryExtension(
const char *extName);
73 bool m_bUseAcceleratedPanning;
74 bool m_bUseCanvasPanning;
76 bool m_bTextureCompression;
77 bool m_bTextureCompressionCaching;
79 int m_iTextureDimension;
80 int m_iTextureMemorySize;
82 bool m_GLPolygonSmoothing;
83 bool m_GLLineSmoothing;
99 static bool CanClipViewport(
const ViewPort &vp);
100 static ViewPort ClippedViewport(
const ViewPort &vp,
const LLRegion ®ion);
102 static bool HasNormalizedViewPort(
const ViewPort &vp);
103 static void MultMatrixViewPort(
ViewPort &vp,
float lat = 0,
float lon = 0);
107 static void DrawRegion(
ViewPort &vp,
const LLRegion ®ion);
108 static void SetClipRegion(
ViewPort &vp,
const LLRegion ®ion);
109 static void SetClipRect(
const ViewPort &vp,
const wxRect &rect,
110 bool g_clear =
false);
111 static void DisableClipRegion();
112 void SetColorScheme(ColorScheme cs);
113 void RenderTextures(
ocpnDC &dc,
float *coords,
float *uvCoords,
int nVertex,
115 static void RenderSingleTexture(
ocpnDC &dc,
float *coords,
float *uvCoords,
ViewPort *vp,
116 float dx,
float dy,
float angle);
117 void RenderColorRect(wxRect r, wxColor &color);
119 static bool s_b_useScissorTest;
120 static bool s_b_useStencil;
121 static bool s_b_useStencilAP;
122 static bool s_b_useFBO;
124 void SendJSONConfigMessage();
131 void SetContext(wxGLContext *pcontext) { m_pcontext = pcontext; }
132 int GetCanvasIndex() {
return m_pParentCanvas->m_canvasIndex; }
134 int GetGLCanvasWidth() {
return m_glcanvas_width; }
135 int GetGLCanvasHeight() {
return m_glcanvas_height; }
137 void OnPaint(wxPaintEvent &event);
138 void OnEraseBG(wxEraseEvent &evt);
140 void OnActivate(wxActivateEvent &event);
141 void OnSize(wxSizeEvent &event);
142 void MouseEvent(wxMouseEvent &event);
143 void FastPan(
int dx,
int dy);
144 void FastZoom(
float factor,
float cp_x,
float cp_y,
float post_x,
150#ifdef __OCPN__ANDROID__
151 void OnEvtPanGesture(wxQT_PanGestureEvent &event);
152 void OnEvtPinchGesture(wxQT_PinchGestureEvent &event);
153 void onGestureTimerEvent(wxTimerEvent &event);
154 void onGestureFinishTimerEvent(wxTimerEvent &event);
157 void onZoomTimerEvent(wxTimerEvent &event);
159 wxString GetRendererString() {
return m_renderer; }
160 wxString GetVersionString() {
return m_version; }
161 wxString GetGLSLVersionString() {
return m_GLSLversion; }
162 void EnablePaint(
bool b_enable) { m_b_paint_enable = b_enable; }
168 void DrawGLOverLayObjects(
void);
172 void DrawDynamicRoutesTracksAndWaypoints(
ViewPort &vp);
173 void DrawStaticRoutesTracksAndWaypoints(
ViewPort &vp);
179 void ShipDraw(
ocpnDC &dc);
181 void SetupCompression();
182 bool CanAcceleratePanning() {
return m_b_BuiltFBO; }
183 bool UsingFBO() {
return m_b_BuiltFBO; }
185 bool isInGesture() {
return m_binGesture; }
186 void ResetGridFont() { m_gridfont.Delete(); }
187 time_t m_last_render_time;
190 double mvmatrix[16], projmatrix[16];
197 void RenderS57TextOverlay(
ViewPort &VPoint);
198 void RenderMBTilesOverlay(
ViewPort &VPoint);
199 void RenderScene(
bool bRenderCharts =
true,
bool bRenderOverlays =
true);
201 void RenderGLAlertMessage();
207 bool buildFBOSize(
int fboSize);
209 void configureShaders(
ViewPort &vp);
213 void RenderNoDTA(
ViewPort &vp,
const LLRegion ®ion,
214 int transparency = 255);
219 void DrawFloatingOverlayObjects(
ocpnDC &dc);
222 void DrawChartBar(
ocpnDC &dc);
224 void DrawCloseMessage(wxString msg);
226 void DrawGLTidesInBBox(
ocpnDC &dc, LLBBox &BBox);
227 void DrawGLCurrentsInBBox(
ocpnDC &dc, LLBBox &BBox);
229 void ZoomProject(
float offset_x,
float offset_y,
float swidth,
float sheight);
231 void RendertoTexture(GLint tex);
233 wxGLContext *m_pcontext;
235 int max_texture_dimension;
240 wxString m_version, m_GLSLversion;
241 wxString m_extensions;
246 bool m_b_paint_enable;
252 bool m_b_useFBOStencil;
254 GLuint m_renderbuffer;
256 GLuint m_cache_tex[2];
263 wxSize ownship_size, ownship_tex_size;
272 float m_lastfbo_offsetx;
273 float m_lastfbo_offsety;
274 float m_lastfbo_swidth;
275 float m_lastfbo_sheight;
277 float m_offsetxStep, m_offsetyStep, m_swidthStep, m_sheightStep;
278 float m_runoffsetx, m_runoffsety, m_runswidth, m_runsheight;
279 float m_nStep, m_nTotal, m_nRun;
281 double m_zoomFinalZoom;
282 int m_zoomFinaldx, m_zoomFinaldy;
287 double m_fbo_lat, m_fbo_lon;
289 wxPoint m_lpinchPoint;
295 wxTimer m_gestureEeventTimer;
296 wxTimer m_gestureFinishTimer;
297 bool m_bgestureGuard;
299 wxPoint m_pinchStart;
300 double m_pinchlat, m_pinchlon;
311 int m_currentTexWidth;
312 int m_currentTexHeight;
315 int m_glcanvas_width;
316 int m_glcanvas_height;
320 DECLARE_EVENT_TABLE()
323extern void BuildCompressedCache();
325#include "glTextureManager.h"