From a79d59c06c2292fdd2dc749d51efda400fe57b24 Mon Sep 17 00:00:00 2001 From: dsr Date: Wed, 15 Apr 2020 13:51:42 -0400 Subject: [PATCH] Correct MSW build --- src/ocpn_plugin.h | 72 ++----------- src/pi_DepthFont.cpp | 237 ++----------------------------------------- src/s52plib.cpp | 19 ++-- 3 files changed, 26 insertions(+), 302 deletions(-) diff --git a/src/ocpn_plugin.h b/src/ocpn_plugin.h index fe4deb89..f84a54af 100644 --- a/src/ocpn_plugin.h +++ b/src/ocpn_plugin.h @@ -27,14 +27,12 @@ #define _PLUGIN_H_ #ifndef DECL_EXP -#if defined(__WXMSW__) || defined(__CYGWIN__) +#ifdef __WXMSW__ # define DECL_EXP __declspec(dllexport) -#elif defined __GNUC__ && __GNUC__ >= 4 -# define DECL_EXP __attribute__((visibility("default"))) -#elif defined __WXOSX__ -# define DECL_EXP __attribute__((visibility("default"))) #else -# define DECL_EXP +# ifdef __GNUC__ +# define DECL_EXP __attribute__((visibility("default"))) +# endif #endif #endif @@ -45,15 +43,9 @@ #endif #include -#include -#include -#include -#include -#include - #ifdef ocpnUSE_SVG -#include +#include "wxSVG/svg.h" #endif // ocpnUSE_SVG #include @@ -66,7 +58,7 @@ class wxGLContext; // PlugIns conforming to API Version less then the most modern will also // be correctly supported. #define API_VERSION_MAJOR 1 -#define API_VERSION_MINOR 17 +#define API_VERSION_MINOR 16 // Fwd Definitions class wxFileConfig; @@ -164,16 +156,6 @@ class PlugIn_Position_Fix_Ex int nSats; }; -class Plugin_Active_Leg_Info -{ -public: - double Xte; // Left side of the track -> negative XTE - double Btw; - double Dtw; - wxString wp_name; // Name of destination waypoint for active leg - bool arrival; // True when within arrival circle -}; - // Describe AIS Alarm state enum plugin_ais_alarm_type { @@ -554,6 +536,7 @@ class DECL_EXP opencpn_plugin_115 : public opencpn_plugin_114 public: opencpn_plugin_115(void *pmgr); virtual ~opencpn_plugin_115(); + }; class DECL_EXP opencpn_plugin_116 : public opencpn_plugin_115 @@ -567,28 +550,6 @@ class DECL_EXP opencpn_plugin_116 : public opencpn_plugin_115 }; -class DECL_EXP opencpn_plugin_117 : public opencpn_plugin_116 -{ -public: - opencpn_plugin_117(void *pmgr); - /* - * Forms a semantic version together with GetPlugInVersionMajor() and - * GetPlugInVersionMinor(), see https://semver.org/ - */ - virtual int GetPlugInVersionPatch(); - - /** Post-release version part, extends the semver spec. */ - virtual int GetPlugInVersionPost(); - - /** Pre-release tag version part, see GetPlugInVersionPatch() */ - virtual const char* GetPlugInVersionPre(); - - /** Build version part see GetPlugInVersionPatch(). */ - virtual const char* GetPlugInVersionBuild(); - - /*Provide active leg data to plugins*/ - virtual void SetActiveLegInfo(Plugin_Active_Leg_Info &leg_info); -}; //------------------------------------------------------------------ // Route and Waypoint PlugIn support // @@ -1136,7 +1097,6 @@ extern DECL_EXP void SetCanvasTilt(double tilt); extern DECL_EXP bool PlugInPlaySoundEx( wxString &sound_file, int deviceIndex=-1 ); extern DECL_EXP void AddChartDirectory( wxString &path ); extern DECL_EXP void ForceChartDBUpdate(); -extern DECL_EXP void ForceChartDBRebuild(); extern DECL_EXP wxString GetWritableDocumentsDir( void ); extern DECL_EXP wxDialog *GetActiveOptionsDialog(); @@ -1212,7 +1172,7 @@ enum OCPN_DLDialogStyle /* Synchronous (Blocking) download of a single file */ -extern DECL_EXP _OCPN_DLStatus OCPN_downloadFile( const wxString& url, const wxString &outputFile, +extern DECL_EXP _OCPN_DLStatus OCPN_downloadFile( const wxString& url, const wxString &outputFile, const wxString &title, const wxString &message, const wxBitmap& bitmap, wxWindow *parent, long style, int timeout_secs); @@ -1290,13 +1250,6 @@ extern DECL_IMP wxEventType wxEVT_DOWNLOAD_EVENT; extern DECL_EXP wxEventType wxEVT_DOWNLOAD_EVENT; #endif - -/* API 1.14 */ -/* API 1.14 adds some more common functions to avoid unnecessary code duplication */ - -bool LaunchDefaultBrowser_Plugin( wxString url ); - - // API 1.14 Extra canvas Support /* Allow drawing of objects onto other OpenGL canvases */ @@ -1307,7 +1260,7 @@ extern DECL_EXP bool PlugInSetFontColor(const wxString TextElement, const wxColo extern DECL_EXP double PlugInGetDisplaySizeMM(); // -extern DECL_EXP wxFont* FindOrCreateFont_PlugIn( int point_size, wxFontFamily family, +extern DECL_EXP wxFont* FindOrCreateFont_PlugIn( int point_size, wxFontFamily family, wxFontStyle style, wxFontWeight weight, bool underline = false, const wxString &facename = wxEmptyString, wxFontEncoding encoding = wxFONTENCODING_DEFAULT ); @@ -1366,10 +1319,6 @@ extern DECL_EXP int GetCanvasCount( ); extern DECL_EXP bool CheckMUIEdgePan_PlugIn( int x, int y, bool dragging, int margin, int delta, int canvasIndex ); extern DECL_EXP void SetMUICursor_PlugIn( wxCursor *pCursor, int canvasIndex ); -// API 1.17 -// -extern DECL_EXP wxRect GetMasterToolbarRect(); - enum SDDMFORMAT { DEGREES_DECIMAL_MINUTES = 0, @@ -1380,7 +1329,4 @@ enum SDDMFORMAT extern DECL_EXP int GetLatLonFormat(void); -// API 1.17 -extern "C" DECL_EXP void ZeroXTE(); - #endif //_PLUGIN_H_ diff --git a/src/pi_DepthFont.cpp b/src/pi_DepthFont.cpp index e82e75ab..e342dadb 100644 --- a/src/pi_DepthFont.cpp +++ b/src/pi_DepthFont.cpp @@ -36,31 +36,6 @@ #include #endif -#if 0 -#define TXF_CACHE 8 -static TexFontCache s_txf[TXF_CACHE]; - -TexFont *GetTexFont(wxFont *pFont) -{ - // rebuild font if needed - TexFont *f_cache; - unsigned int i; - for (i = 0; i < TXF_CACHE && s_txf[i].key != nullptr; i++) - { - if (s_txf[i].key == pFont) { - return &s_txf[i].cache; - } - } - if (i == TXF_CACHE) { - i = rand() & (TXF_CACHE -1); - } - s_txf[i].key = pFont; - f_cache = &s_txf[i].cache; - f_cache->Build(*pFont); - return f_cache; -} -#endif - DepthFont::DepthFont( ) { texobj = 0; @@ -73,6 +48,15 @@ DepthFont::~DepthFont( ) Delete( ); } +void DepthFont::Delete( ) +{ + if (texobj) { + glDeleteTextures(1, &texobj); + texobj = 0; + } + m_built = false; + m_scaleFactor = 0; +} void DepthFont::Build( wxFont *font, double scale ) { @@ -183,15 +167,6 @@ void DepthFont::Build( wxFont *font, double scale ) m_built = true; } -void DepthFont::Delete( ) -{ - if (texobj) { - glDeleteTextures(1, &texobj); - texobj = 0; - } - m_built = false; - m_scaleFactor = 0; -} bool DepthFont::GetGLTextureRect(wxRect &texrect, int symIndex) { @@ -211,197 +186,3 @@ bool DepthFont::GetGLTextureRect(wxRect &texrect, int symIndex) } } -#if 0 -void DepthFont::RenderGlyph( int c ) -{ - - SoundTexGlyphInfo &tgic = tgi[c]; - - int x = tgic.x, y = tgic.y; - float w = m_maxglyphw, h = m_maxglyphh; - float tx1 = (float)x / (float)tex_w; - float tx2 = (float)(x + w) / (float)tex_w; - float ty1 = (float)y / (float)tex_h; - float ty2 = (float)(y + h) / (float)tex_h; - -#ifndef USE_ANDROID_GLES2 - - glBegin( GL_QUADS ); - - glTexCoord2f( tx1, ty1 ); glVertex2i( 0, 0 ); - glTexCoord2f( tx2, ty1 ); glVertex2i( w, 0 ); - glTexCoord2f( tx2, ty2 ); glVertex2i( w, h ); - glTexCoord2f( tx1, ty2 ); glVertex2i( 0, h ); - - glEnd(); - glTranslatef( tgic.advance, 0.0, 0.0 ); -#else - - float uv[8]; - float coords[8]; - - //normal uv - uv[0] = tx1; uv[1] = ty1; uv[2] = tx2; uv[3] = ty1; - uv[4] = tx2; uv[5] = ty2; uv[6] = tx1; uv[7] = ty2; - - // pixels - coords[0] = 0; coords[1] = 0; coords[2] = w; coords[3] = 0; - coords[4] = w; coords[5] = h; coords[6] = 0; coords[7] = h; - - glUseProgram( texture_2DA_shader_program ); - - // Get pointers to the attributes in the program. - GLint mPosAttrib = glGetAttribLocation( texture_2DA_shader_program, "aPos" ); - GLint mUvAttrib = glGetAttribLocation( texture_2DA_shader_program, "aUV" ); - - // Set up the texture sampler to texture unit 0 - GLint texUni = glGetUniformLocation( texture_2DA_shader_program, "uTex" ); - glUniform1i( texUni, 0 ); - - // Disable VBO's (vertex buffer objects) for attributes. - glBindBuffer( GL_ARRAY_BUFFER, 0 ); - glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, 0 ); - - // Set the attribute mPosAttrib with the vertices in the screen coordinates... - glVertexAttribPointer( mPosAttrib, 2, GL_FLOAT, GL_FALSE, 0, coords ); - // ... and enable it. - glEnableVertexAttribArray( mPosAttrib ); - - // Set the attribute mUvAttrib with the vertices in the GL coordinates... - glVertexAttribPointer( mUvAttrib, 2, GL_FLOAT, GL_FALSE, 0, uv ); - // ... and enable it. - glEnableVertexAttribArray( mUvAttrib ); - - float colorv[4]; - colorv[0] = m_color.Red() / float(256); - colorv[1] = m_color.Green() / float(256); - colorv[2] = m_color.Blue() / float(256); - colorv[3] = 0; - - GLint colloc = glGetUniformLocation(texture_2DA_shader_program,"color"); - glUniform4fv(colloc, 1, colorv); - - // Rotate - float angle = 0; - mat4x4 I, Q; - mat4x4_identity(I); - mat4x4_rotate_Z(Q, I, angle); - - // Translate - Q[3][0] = m_dx; - Q[3][1] = m_dy; - - - //mat4x4 X; - //mat4x4_mul(X, (float (*)[4])vp->vp_transform, Q); - - GLint matloc = glGetUniformLocation(texture_2DA_shader_program,"TransformMatrix"); - glUniformMatrix4fv( matloc, 1, GL_FALSE, (const GLfloat*)Q); - - // Select the active texture unit. - glActiveTexture( GL_TEXTURE0 ); - - // For some reason, glDrawElements is busted on Android - // So we do this a hard ugly way, drawing two triangles... - #if 0 - GLushort indices1[] = {0,1,3,2}; - glDrawElements(GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_SHORT, indices1); - #else - - float co1[8]; - co1[0] = coords[0]; - co1[1] = coords[1]; - co1[2] = coords[2]; - co1[3] = coords[3]; - co1[4] = coords[6]; - co1[5] = coords[7]; - co1[6] = coords[4]; - co1[7] = coords[5]; - - float tco1[8]; - tco1[0] = uv[0]; - tco1[1] = uv[1]; - tco1[2] = uv[2]; - tco1[3] = uv[3]; - tco1[4] = uv[6]; - tco1[5] = uv[7]; - tco1[6] = uv[4]; - tco1[7] = uv[5]; - - glVertexAttribPointer( mPosAttrib, 2, GL_FLOAT, GL_FALSE, 0, co1 ); - glVertexAttribPointer( mUvAttrib, 2, GL_FLOAT, GL_FALSE, 0, tco1 ); - - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); - - #endif - - - - - m_dx += tgic.advance; - -#endif -} -#endif - -#if 0 -void DepthFont::RenderString( const char *string, int x, int y ) -{ - -#ifndef USE_ANDROID_GLES2 - - glPushMatrix(); - glTranslatef(x, y, 0); - - glPushMatrix(); - glBindTexture( GL_TEXTURE_2D, texobj); - - for( int i = 0; string[i]; i++ ) { - if(string[i] == '\n') { - glPopMatrix(); - glTranslatef(0, tgi[(int)'A'].height, 0); - glPushMatrix(); - continue; - } - /* degree symbol */ - if((unsigned char)string[i] == 0xc2 && - (unsigned char)string[i+1] == 0xb0) { - RenderGlyph( DEGREE_GLYPH ); - i++; - continue; - } - RenderGlyph( string[i] ); - } - - glPopMatrix(); - glPopMatrix(); -#else - m_dx = x; - m_dy = y; - - glBindTexture( GL_TEXTURE_2D, texobj); - - for( int i = 0; string[i]; i++ ) { - if(string[i] == '\n') { - m_dy += tgi[(int)'A'].height; - continue; - } - /* degree symbol */ - if((unsigned char)string[i] == 0xc2 && - (unsigned char)string[i+1] == 0xb0) { - RenderGlyph( DEGREE_GLYPH ); - i++; - continue; - } - RenderGlyph( string[i] ); - } - -#endif -} - -void DepthFont::RenderString( const wxString &string, int x, int y ) -{ - RenderString((const char*)string.ToUTF8(), x, y); -} -#endif -//#endif //#ifdef ocpnUSE_GL diff --git a/src/s52plib.cpp b/src/s52plib.cpp index 72059b9e..1e59005d 100644 --- a/src/s52plib.cpp +++ b/src/s52plib.cpp @@ -67,6 +67,7 @@ extern double g_overzoom_emphasis_base; extern bool g_oz_vector_scale; extern float g_ChartScaleFactorExp; extern int g_chart_zoom_modifier_vector; +extern GLenum g_oe_texture_rectangle_format; float g_scaminScale; @@ -3571,7 +3572,6 @@ int s52plib::RenderSY( ObjRazRules *rzRules, Rules *rules, ViewPort *vp ) return 0; } - bool s52plib::RenderSoundingSymbol( ObjRazRules *rzRules, Rule *prule, wxPoint &r, ViewPort *vp, wxColor symColor, float rot_angle ) { @@ -3614,7 +3614,8 @@ bool s52plib::RenderSoundingSymbol( ObjRazRules *rzRules, Rule *prule, wxPoint & wxScreenDC sdc; int charWidth, charHeight, charDescent; while((point_size < 20) && not_done){ - wxFont *tentativeFont = FindOrCreateFont_PlugIn( point_size, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL ); + //wxFont *tentativeFont = FindOrCreateFont_PlugIn( point_size, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL ); + wxFont *tentativeFont = wxTheFontList->FindOrCreateFont( point_size, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL ); sdc.GetTextExtent( _T("0"), &charWidth, &charHeight, &charDescent, NULL, tentativeFont ); // measure the text double font_size_mm = (double)(charHeight- charDescent) / GetPPMM(); @@ -3630,12 +3631,12 @@ bool s52plib::RenderSoundingSymbol( ObjRazRules *rzRules, Rule *prule, wxPoint & if(!m_texSoundings.IsBuilt() || (fabs(m_texSoundings.GetScale() - scale_factor) > 0.1)){ m_texSoundings.Delete(); - m_soundFont = FindOrCreateFont_PlugIn( point_size, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL ); + m_soundFont = wxTheFontList->FindOrCreateFont( point_size, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL ); m_texSoundings.Build(m_soundFont, scale_factor); //texSounding owns the font } } else{ - m_soundFont = FindOrCreateFont_PlugIn( point_size, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL ); + m_soundFont = wxTheFontList->FindOrCreateFont( point_size, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL ); m_pdc->SetFont(*m_soundFont); charHeight -= charDescent; } @@ -3742,7 +3743,6 @@ bool s52plib::RenderSoundingSymbol( ObjRazRules *rzRules, Rule *prule, wxPoint & glEnable( GL_BLEND ); if(texture) { - extern GLenum g_texture_rectangle_format; glEnable(GL_TEXTURE_2D); glEnable( GL_BLEND ); @@ -3757,7 +3757,7 @@ bool s52plib::RenderSoundingSymbol( ObjRazRules *rzRules, Rule *prule, wxPoint & // glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE ); glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE ); - if(g_texture_rectangle_format == GL_TEXTURE_2D) { + if(g_oe_texture_rectangle_format == GL_TEXTURE_2D) { wxSize size = m_texSoundings.GLTextureSize(); tx1 /= size.x, tx2 /= size.x; ty1 /= size.y, ty2 /= size.y; @@ -3786,7 +3786,7 @@ bool s52plib::RenderSoundingSymbol( ObjRazRules *rzRules, Rule *prule, wxPoint & #else - if(g_texture_rectangle_format == GL_TEXTURE_2D) { + if(g_oe_texture_rectangle_format == GL_TEXTURE_2D) { // Normalize the sybmol texture coordinates against the next higher POT size wxSize size = ChartSymbols::GLTextureSize(); @@ -3865,7 +3865,7 @@ bool s52plib::RenderSoundingSymbol( ObjRazRules *rzRules, Rule *prule, wxPoint & #endif // GLES2 - glDisable(g_texture_rectangle_format); + glDisable(g_oe_texture_rectangle_format); } else { /* this is only for legacy mode, or systems without NPOT textures */ float cr = cosf( vp->rotation ); float sr = sinf( vp->rotation ); @@ -3909,7 +3909,6 @@ bool s52plib::RenderSoundingSymbol( ObjRazRules *rzRules, Rule *prule, wxPoint & return true; } - // Line Simple Style, OpenGL int s52plib::RenderGLLS( ObjRazRules *rzRules, Rules *rules, ViewPort *vp ) { @@ -6241,7 +6240,6 @@ int s52plib::RenderMPS( ObjRazRules *rzRules, Rules *rules, ViewPort *vp ) wxPoint cr0 = vp_local.GetPixFromLL( vp_local.GetBBox().GetMaxLat(), vp_local.GetBBox().GetMinLon()); wxPoint cr1 = vp_local.GetPixFromLL( vp_local.GetBBox().GetMinLat(), vp_local.GetBBox().GetMaxLon()); wxRect clip_rect(cr0, cr1); - for( int ip = 0; ip < npt; ip++ ) { double lon = *pdl++; @@ -6288,7 +6286,6 @@ int s52plib::RenderMPS( ObjRazRules *rzRules, Rules *rules, ViewPort *vp ) rules = rules->next; } } - return 1; }