From 161d19c2bf31d80965d7db809274d14211078800 Mon Sep 17 00:00:00 2001 From: Mark Watkins Date: Fri, 17 Jun 2011 07:21:52 +1000 Subject: [PATCH] Fixed wxBitmap assert, plus Changed DrawText to be more compatible --- Projects/CodeBlocks/SleepyHead.depend | 17 ++++--- src/SleepyHeadMain.cpp | 13 +++-- src/graphs/gl_pbuffer.h | 1 + src/graphs/graph.cpp | 67 +++++++++++++++----------- src/graphs/graph.h | 8 +-- src/libs/freetype-gl/texture-atlas.cpp | 2 +- src/libs/freetype-gl/texture-glyph.cpp | 6 ++- src/libs/freetype-gl/vertex-buffer.h | 2 + src/version.h | 12 ++--- 9 files changed, 75 insertions(+), 53 deletions(-) diff --git a/Projects/CodeBlocks/SleepyHead.depend b/Projects/CodeBlocks/SleepyHead.depend index d21bd144..af9aa565 100644 --- a/Projects/CodeBlocks/SleepyHead.depend +++ b/Projects/CodeBlocks/SleepyHead.depend @@ -8300,7 +8300,7 @@ "tinyxml/tinyxml.h" -1308143309 /home/mark/projects/git/sleepyhead/src/graphs/graph.h +1308258943 /home/mark/projects/git/sleepyhead/src/graphs/graph.h "gl_pbuffer.h" @@ -8309,7 +8309,7 @@ 1308026543 D -1308240204 /home/mark/projects/git/sleepyhead/src/version.h +1308259082 /home/mark/projects/git/sleepyhead/src/version.h 1308003040 ent of cb2ab33... Linux wx2.8 & wx2.9 builds fixed @@ -8341,7 +8341,7 @@ "preferences.h" "tinyxml/tinyxml.h" -1308160664 source:/home/mark/projects/git/sleepyhead/src/SleepyHeadMain.cpp +1308258772 source:/home/mark/projects/git/sleepyhead/src/SleepyHeadMain.cpp "wx_pch.h" "version.h" @@ -8362,7 +8362,7 @@ "sleeplib/profiles.h" "sleeplib/machine_loader.h" -1308240152 source:/home/mark/projects/git/sleepyhead/src/graphs/graph.cpp +1308259082 source:/home/mark/projects/git/sleepyhead/src/graphs/graph.cpp "freetype-gl/font-manager.h" "freetype-gl/texture-font.h" "graph.h" @@ -8371,6 +8371,7 @@ + "sleeplib/profiles.h" @@ -10947,7 +10948,7 @@ "text-markup.h" "vertex-buffer.h" -1308040815 /home/mark/projects/git/sleepyhead/src/libs/freetype-gl/vertex-buffer.h +1308243124 /home/mark/projects/git/sleepyhead/src/libs/freetype-gl/vertex-buffer.h @@ -11031,7 +11032,7 @@ "font-manager.h" "text-markup.h" -1308116368 source:/home/mark/projects/git/sleepyhead/src/libs/freetype-gl/texture-atlas.cpp +1308243123 source:/home/mark/projects/git/sleepyhead/src/libs/freetype-gl/texture-atlas.cpp @@ -11043,7 +11044,7 @@ "texture-font.h" -1308044876 source:/home/mark/projects/git/sleepyhead/src/libs/freetype-gl/texture-glyph.cpp +1308243123 source:/home/mark/projects/git/sleepyhead/src/libs/freetype-gl/texture-glyph.cpp "texture-glyph.h" @@ -11061,7 +11062,7 @@ "freetype-gl/vector.h" -1308153347 /home/mark/projects/git/sleepyhead/src/graphs/gl_pbuffer.h +1308243123 /home/mark/projects/git/sleepyhead/src/graphs/gl_pbuffer.h diff --git a/src/SleepyHeadMain.cpp b/src/SleepyHeadMain.cpp index 3de9e644..27005738 100644 --- a/src/SleepyHeadMain.cpp +++ b/src/SleepyHeadMain.cpp @@ -151,7 +151,10 @@ void SleepyHeadFrame::UpdateProfiles() for (map::iterator p=Profiles::profiles.begin();p!=Profiles::profiles.end();p++) { Profile &pro=*(Profiles::profiles[p->first]); - wxMenuItem *item=ProfileMenu->AppendRadioItem(i,pro["Realname"],wxEmptyString); + wxString name=pro["Realname"]; + if (name.IsEmpty()) name=pref["Profile"].GetString(); + + wxMenuItem *item=ProfileMenu->AppendRadioItem(i,name,wxEmptyString); if (p->first==pref["Profile"].GetString()) { item->Check(true); @@ -776,19 +779,19 @@ Daily::Daily(wxWindow *win,Profile *p) TAP=new gGraphWindow(GraphWindow,-1,wxT(""),wxPoint(0,0), wxSize(600,30), wxNO_BORDER); //Time@Pressure //TAP->SetMargins(20,15,5,50); - TAP->SetMargins(0,1,0,1); + TAP->SetMargins(0,0,0,0); TAP->AddLayer(new gCandleStick(tap)); TAP_EAP=new gGraphWindow(GraphWindow,-1,wxT(""),wxPoint(0,0), wxSize(600,30), wxNO_BORDER); //Time@EPAP - TAP_EAP->SetMargins(0,1,0,1); + TAP_EAP->SetMargins(0,0,0,0); TAP_EAP->AddLayer(new gCandleStick(tap_eap)); TAP_IAP=new gGraphWindow(GraphWindow,-1,wxT(""),wxPoint(0,0), wxSize(600,30), wxNO_BORDER); //Time@IPAP - TAP_IAP->SetMargins(0,1,0,1); + TAP_IAP->SetMargins(0,0,0,0); TAP_IAP->AddLayer(new gCandleStick(tap_iap)); G_AHI=new gGraphWindow(GraphWindow,-1,wxT(""),wxPoint(0,0), wxSize(600,30), wxNO_BORDER); //Event Breakdown") - G_AHI->SetMargins(0,1,0,1); + G_AHI->SetMargins(0,0,0,0); AddCPAPData(g_ahi=new AHIData()); gCandleStick *l=new gCandleStick(g_ahi); l->AddName(wxT("H")); diff --git a/src/graphs/gl_pbuffer.h b/src/graphs/gl_pbuffer.h index 47a51e09..f2b06315 100644 --- a/src/graphs/gl_pbuffer.h +++ b/src/graphs/gl_pbuffer.h @@ -11,6 +11,7 @@ #define GLEW_STATIC #define WGL_WGLEXT_PROTOTYPES + #include #include //#include diff --git a/src/graphs/graph.cpp b/src/graphs/graph.cpp index 0baccb1a..01cda879 100644 --- a/src/graphs/graph.cpp +++ b/src/graphs/graph.cpp @@ -17,7 +17,7 @@ License: LGPL #include #include #include - +#include #include #include @@ -81,13 +81,13 @@ void GraphInit() wxLogDebug(wxT("GLInfo: ")+glvendor+wxT(" ")+glrenderer+wxT(" ")+glversion); // Despite the stupid warning, this does NOT always evaluate as true. Too lazy to put it in #ifdefs - if (!glGenBuffers) { - wxLogError(wxT("Sorry, your computers graphics card drivers are too old to run this program.\n")+glvendor+wxT(" may have an update.")); - abort(); - } + /*if (!glGenBuffers) { + wxMessageBox(wxT("Sorry, your computers graphics card drivers are too old to run this program.\n")+glvendor+wxT(" may have an update.\n")+glrenderer+wxT("\n")+glversion,_("Welcome to..."),wxOK,NULL); + exit(-1); + } */ font_manager=new FontManager(); - vbuffer=new VertexBuffer((char *)"v3i:t2f:c4f"); + //vbuffer=new VertexBuffer((char *)"v3i:t2f:c4f"); zfont=font_manager->GetFromFilename(pref.Get("{home}{sep}FreeSans.ttf"),12); bigfont=font_manager->GetFromFilename(pref.Get("{home}{sep}FreeSans.ttf"),32); markup=new TextMarkup(); @@ -112,7 +112,7 @@ void GraphDone() { if (gfont_init) { delete font_manager; - delete vbuffer; + // delete vbuffer; delete markup; gfont_init=false; } @@ -147,21 +147,26 @@ void DrawText2(wxString text, float x, float y,TextureFont *font=zfont) // The a TextureGlyph *glyph; glyph=font->GetGlyph((wchar_t)text[0]); if (!glyph) return; - assert(vbuffer!=NULL); + //assert(vbuffer!=NULL); + + //vbuffer->Clear(); - vbuffer->Clear(); - glyph->AddToVertexBuffer(vbuffer, markup, &pen); - for (unsigned j=1; jGetGlyph(text[j]); - pen.x += glyph->GetKerning(text[j-1]); - glyph->AddToVertexBuffer(vbuffer, markup, &pen); - } - //glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); glEnable( GL_BLEND ); glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); glEnable( GL_TEXTURE_2D ); - glColor4f(1,1,1,1); - vbuffer->Render(GL_TRIANGLES, (char *)"vtc" ); + glColor4f(0,0,0,1); + + glyph->Render(markup,&pen); +// glyph->AddToVertexBuffer(vbuffer, markup, &pen); + for (unsigned j=1; jGetGlyph(text[j]); + pen.x += glyph->GetKerning(text[j-1]); + glyph->Render(markup,&pen); + + // glyph->AddToVertexBuffer(vbuffer, markup, &pen); + } + //glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); + //vbuffer->Render(GL_TRIANGLES, (char *)"vtc" ); glDisable(GL_TEXTURE_2D); glDisable(GL_BLEND); @@ -196,6 +201,7 @@ void DrawText(wxString text, float x, float y, float angle=0, const wxColor & co void RoundedRectangle(int x,int y,int w,int h,int radius,const wxColor & color) { //glDisable(GL_TEXTURE_2D); + glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); glColor4ub(color.Red(),color.Green(),color.Blue(),color.Alpha()); @@ -371,7 +377,7 @@ gGraphWindow::gGraphWindow(wxWindow *parent, wxWindowID id,const wxString & titl m_bgColour = *wxWHITE; m_fgColour = *wxBLACK; SetMargins(5, 15, 0, 0); - m_block_move=false; + //m_block_move=false; m_block_zoom=false; m_drag_foobar=false; m_foobar_pos=0; @@ -409,6 +415,7 @@ gGraphWindow::gGraphWindow(wxWindow *parent, wxWindowID id,const wxString & titl if (!title.IsEmpty()) { AddLayer(new gGraphTitle(title,wxVERTICAL)); } + SetBackgroundStyle(wxBG_STYLE_CUSTOM); } gGraphWindow::~gGraphWindow() @@ -1814,15 +1821,23 @@ void gCandleStick::Plot(gGraphWindow & w,float scrx,float scry) glBegin(GL_QUADS); glColor4ub(col1.Red(),col1.Green(),col1.Blue(),col1.Alpha()); - glVertex2f(rect.x, rect.y+height); + glVertex2f(rect.x+1, rect.y+height); glVertex2f(rect.x+rect.width, rect.y+height); glColor4ub(col2.Red(),col2.Green(),col2.Blue(),col2.Alpha()); - glVertex2f(rect.x+rect.width, rect.y); - glVertex2f(rect.x, rect.y); + glVertex2f(rect.x+rect.width, rect.y+1); + glVertex2f(rect.x+1, rect.y+1); glEnd(); - LinedRoundedRectangle(rect.x,rect.y,rect.width,rect.height,0,1,c); + glColor4ub(0,0,0,255); + glBegin(GL_LINE_LOOP); + glVertex2f(rect.x+1, rect.y+height); + glVertex2f(rect.x+rect.width, rect.y+height); + + glVertex2f(rect.x+rect.width, rect.y+1); + glVertex2f(rect.x+1, rect.y+1); + glEnd(); + //LinedRoundedRectangle(rect.x,rect.y,rect.width,rect.height,0,1,c); str=wxT(""); if ((int)m_names.size()>i) { @@ -2100,10 +2115,6 @@ void gLineChart::Plot(gGraphWindow & w,float scrx,float scry) accel=false; } } - //} - wxString a; - a << sam; - DrawText(a,3,scry-w.GetTopMargin()-10); // Prepare the min max y values if we still are accelerating this plot if (accel) { @@ -2261,8 +2272,10 @@ void gLineChart::Plot(gGraphWindow & w,float scrx,float scry) bool antialias=pref["UseAntiAliasing"]; if (antialias) { glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); //_MINUS_SRC_ALPHA); glEnable(GL_LINE_SMOOTH); glHint(GL_LINE_SMOOTH_HINT, GL_NICEST); + } glEnableClientState(GL_VERTEX_ARRAY); diff --git a/src/graphs/graph.h b/src/graphs/graph.h index 3cd453bc..4bd96d10 100644 --- a/src/graphs/graph.h +++ b/src/graphs/graph.h @@ -170,7 +170,7 @@ class gGraphWindow:public wxGLCanvas //Window // rename to gGraphWindow inline int Height() { return m_scrY-m_marginTop-m_marginBottom; }; // Height of ""... void LinkZoom(gGraphWindow *g) { link_zoom.push_back(g); }; // Linking graphs changes zoom behaviour.. - void LinkMove(gGraphWindow *g) { link_move.push_back(g); }; // Linking graphs changes zoom behaviour.. + //void LinkMove(gGraphWindow *g) { link_move.push_back(g); }; // Linking graphs changes zoom behaviour.. virtual double MinX(); virtual double MaxX(); @@ -232,16 +232,16 @@ class gGraphWindow:public wxGLCanvas //Window // rename to gGraphWindow double rmax_x,rmin_x,rmax_y,rmin_y; void SetBlockZoom(bool b) { m_block_zoom=b; }; - void SetBlockMove(bool b) { m_block_move=b; }; + //void SetBlockMove(bool b) { m_block_move=b; }; bool BlockZoom() { return m_block_zoom; }; wxGLContext *gl_context; //FTFont *texfont; protected: listlink_zoom; - listlink_move; + //listlink_move; - bool m_block_move; + //bool m_block_move; bool m_block_zoom; bool m_drag_foobar; double m_foobar_pos,m_foobar_moved; diff --git a/src/libs/freetype-gl/texture-atlas.cpp b/src/libs/freetype-gl/texture-atlas.cpp index bc78783d..491be153 100644 --- a/src/libs/freetype-gl/texture-atlas.cpp +++ b/src/libs/freetype-gl/texture-atlas.cpp @@ -24,7 +24,7 @@ #include #elif defined(__WINDOWS__) #define GL_GLEXT_PROTOTYPES - + #define GLEW_STATIC #include #else #include diff --git a/src/libs/freetype-gl/texture-glyph.cpp b/src/libs/freetype-gl/texture-glyph.cpp index 927aaed2..566e395d 100644 --- a/src/libs/freetype-gl/texture-glyph.cpp +++ b/src/libs/freetype-gl/texture-glyph.cpp @@ -20,11 +20,13 @@ * You should have received a copy of the GNU General Public License along * with this program. If not, see . * ========================================================================= */ + +#define GL_GLEXT_PROTOTYPES + #if defined(__APPLE__) #include #elif defined(__WXMSW__) - -#define GL_GLEXT_PROTOTYPES +#define WGL_WGLEXT_PROTOTYPES #define GLEW_STATIC #define _UNICODE 1 #include diff --git a/src/libs/freetype-gl/vertex-buffer.h b/src/libs/freetype-gl/vertex-buffer.h index 9da5bce4..6f452ae6 100644 --- a/src/libs/freetype-gl/vertex-buffer.h +++ b/src/libs/freetype-gl/vertex-buffer.h @@ -31,6 +31,8 @@ #include #elif defined(__WXMSW__) #define GLEW_STATIC +#define WGL_WGLEXT_PROTOTYPES + //#include #include #include diff --git a/src/version.h b/src/version.h index c8e2a8c4..83ed32dc 100644 --- a/src/version.h +++ b/src/version.h @@ -16,14 +16,14 @@ namespace AutoVersion{ //Standard Version Type static const long _MAJOR = 0; static const long _MINOR = 7; - static const long _BUILD = 6402; - static const long _REVISION = 18233; + static const long _BUILD = 6456; + static const long _REVISION = 18527; //Miscellaneous Version Types - static const long _BUILDS_COUNT = 7475; - #define _RC_FILEVERSION 0,7,6402,18233 - #define _RC_FILEVERSION_STRING "0, 7, 6402, 18233\0" - static const char _FULLVERSION_STRING[] = "0.7.6402.18233"; + static const long _BUILDS_COUNT = 7594; + #define _RC_FILEVERSION 0,7,6456,18527 + #define _RC_FILEVERSION_STRING "0, 7, 6456, 18527\0" + static const char _FULLVERSION_STRING[] = "0.7.6456.18527"; //These values are to keep track of your versioning state, don't modify them. static const long _BUILD_HISTORY = 0;