Fixed wxBitmap assert, plus Changed DrawText to be more compatible

This commit is contained in:
Mark Watkins 2011-06-17 07:21:52 +10:00
parent 206297da83
commit 161d19c2bf
9 changed files with 75 additions and 53 deletions

View File

@ -8300,7 +8300,7 @@
<map>
"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"
<wx/glcanvas.h>
<wx/geometry.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
<wx/dcbuffer.h>
@ -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"
<wx/app.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 @@
<wx/image.h>
<wx/bitmap.h>
<wx/dcbuffer.h>
<wx/msgdlg.h>
<wx/log.h>
<math.h>
"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
<Glut/glut.h>
<GL/glew.h>
<GL/wglew.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
<Glut/glut.h>
<GL/glew.h>
<GL/gl.h>
@ -11043,7 +11044,7 @@
<math.h>
"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
<Glut/glut.h>
<GL/glew.h>
"texture-glyph.h"
@ -11061,7 +11062,7 @@
<string.h>
"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
<wx/log.h>
<GL/glew.h>
<GL/wglew.h>

View File

@ -151,7 +151,10 @@ void SleepyHeadFrame::UpdateProfiles()
for (map<wxString,Profile *>::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"));

View File

@ -11,6 +11,7 @@
#define GLEW_STATIC
#define WGL_WGLEXT_PROTOTYPES
#include <GL/glew.h>
#include <GL/wglew.h>
//#include <GL/gl.h>

View File

@ -17,7 +17,7 @@ License: LGPL
#include <wx/image.h>
#include <wx/bitmap.h>
#include <wx/dcbuffer.h>
#include <wx/msgdlg.h>
#include <wx/log.h>
#include <math.h>
@ -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; j<text.Length(); ++j) {
glyph=font->GetGlyph(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; j<text.Length(); ++j) {
glyph=font->GetGlyph(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);

View File

@ -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:
list<gGraphWindow *>link_zoom;
list<gGraphWindow *>link_move;
//list<gGraphWindow *>link_move;
bool m_block_move;
//bool m_block_move;
bool m_block_zoom;
bool m_drag_foobar;
double m_foobar_pos,m_foobar_moved;

View File

@ -24,7 +24,7 @@
#include <Glut/glut.h>
#elif defined(__WINDOWS__)
#define GL_GLEXT_PROTOTYPES
#define GLEW_STATIC
#include <GL/glew.h>
#else
#include <GL/gl.h>

View File

@ -20,11 +20,13 @@
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
* ========================================================================= */
#define GL_GLEXT_PROTOTYPES
#if defined(__APPLE__)
#include <Glut/glut.h>
#elif defined(__WXMSW__)
#define GL_GLEXT_PROTOTYPES
#define WGL_WGLEXT_PROTOTYPES
#define GLEW_STATIC
#define _UNICODE 1
#include <GL/glew.h>

View File

@ -31,6 +31,8 @@
#include <Glut/glut.h>
#elif defined(__WXMSW__)
#define GLEW_STATIC
#define WGL_WGLEXT_PROTOTYPES
//#include <GL/freeglut_ext.h>
#include <GL/glew.h>
#include <GL/wglew.h>

View File

@ -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;