diff --git a/src/projectM-engine/Renderer.cpp b/src/projectM-engine/Renderer.cpp index b66ec2aa2..58faf671c 100644 --- a/src/projectM-engine/Renderer.cpp +++ b/src/projectM-engine/Renderer.cpp @@ -32,7 +32,7 @@ Renderer::Renderer(int width, int height, int gx, int gy, RenderTarget *renderTa this->drawtitle=0; - this->title = NULL; + this->title = "Unknown"; /** Other stuff... */ this->correction = 1; @@ -1200,21 +1200,19 @@ void Renderer::draw_title_to_texture() { { glBlendFunc(GL_ONE_MINUS_DST_COLOR,GL_ZERO); glColor4f(1.0,1.0,1.0,1.0); + glMatrixMode(GL_MODELVIEW); glPushMatrix(); - + glLoadIdentity(); glTranslatef(0,0.5, 0); glScalef(0.0025,-0.0025,30*.0025); - //glTranslatef(0,0, 1.0); + poly_font->FaceSize( 22); glRasterPos2f(0.0, 0.0); - - if ( this->title != NULL ) { - poly_font->Render(this->title ); - } else { - poly_font->Render("Unknown" ); - } + + poly_font->Render(this->title.c_str() ); + glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); glPopMatrix(); this->drawtitle=0; @@ -1233,28 +1231,24 @@ void Renderer::draw_title_to_screen() { glBlendFunc(GL_ONE_MINUS_DST_COLOR,GL_ZERO); glColor4f(1.0,1.0,1.0,1.0); + + glMatrixMode(GL_MODELVIEW); glPushMatrix(); - - - //glTranslatef(this->vw*.5,this->vh*.5 , -1.0); - glTranslatef(0,0.5 , 0); + glLoadIdentity(); + + glTranslatef(-0.5, 0 , 0); glScalef(easein3,easein3,30*.0025); glRotatef(easein2*360,1,0,0); - - - //glTranslatef(-.5*this->vw,0, 0.0); //poly_font->Depth(1.0); poly_font->FaceSize(22); glRasterPos2f(0.0, 0.0); - if ( this->title != NULL ) { - poly_font->Render(this->title ); - } else { - poly_font->Render("Unknown" ); - } + + poly_font->Render(this->title.c_str() ); + // poly_font->Depth(0.0); glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); glPopMatrix(); @@ -1277,11 +1271,8 @@ void Renderer::draw_title() { glRasterPos2f(0.01, 0.05); title_font->FaceSize( (unsigned)(20*(this->vh/512.0))); - if ( this->title != NULL ) { - title_font->Render(this->title ); - } else { - title_font->Render("Unknown" ); - } + + title_font->Render(this->title.c_str() ); // glPopMatrix(); //glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); diff --git a/src/projectM-engine/Renderer.hpp b/src/projectM-engine/Renderer.hpp index fb9d550ca..92f8b82cb 100644 --- a/src/projectM-engine/Renderer.hpp +++ b/src/projectM-engine/Renderer.hpp @@ -75,7 +75,7 @@ FTGLPolygonFont *poly_font; int totalframes; float realfps; -char *title; +std::string title; int drawtitle; Renderer( int width, int height, int gx, int gy, RenderTarget *renderTarget, TextureManager *textureManager, BeatDetect *beatDetect, std::string fontURL); diff --git a/src/projectM-engine/projectM.cpp b/src/projectM-engine/projectM.cpp index ae26a9884..d92478e43 100755 --- a/src/projectM-engine/projectM.cpp +++ b/src/projectM-engine/projectM.cpp @@ -817,23 +817,13 @@ DLLEXPORT void projectM::projectM_resetGL ( int w, int h ) } /** Sets the title to display */ -DLLEXPORT void projectM::projectM_setTitle ( char *title ) -{ - /* - if (strcmp(this->title, title)!=0) - {printf("new title\n"); - this->drawtitle=1; - - if ( this->title != NULL ) { - free( this->title ); - this->title = NULL; - } - - this->title = (char *)wipemalloc( sizeof( char ) * ( strlen( title ) + 1 ) ); - strcpy( this->title, title ); - - } - */ +DLLEXPORT void projectM::projectM_setTitle ( std::string title ) +{ + if (title != renderer->title) + { + renderer->title=title; + renderer->drawtitle=1; + } } diff --git a/src/projectM-engine/projectM.hpp b/src/projectM-engine/projectM.hpp index 507aa7e37..cf1a58b6e 100755 --- a/src/projectM-engine/projectM.hpp +++ b/src/projectM-engine/projectM.hpp @@ -174,7 +174,7 @@ public: void projectM_init(int gx, int gy, int fps, int texsize, int width, int height); void projectM_reset(); DLLEXPORT void projectM_resetGL( int width, int height ); - DLLEXPORT void projectM_setTitle( char *title ); + DLLEXPORT void projectM_setTitle( std::string title ); DLLEXPORT void renderFrame(); diff --git a/src/projectM-wmp/projectM-wmp/projectM-wmp.cpp b/src/projectM-wmp/projectM-wmp/projectM-wmp.cpp index 5926c70c7..b146cf272 100644 --- a/src/projectM-wmp/projectM-wmp/projectM-wmp.cpp +++ b/src/projectM-wmp/projectM-wmp/projectM-wmp.cpp @@ -9,8 +9,6 @@ #include "stdafx.h" #include "projectM-wmp.h" - - ///////////////////////////////////////////////////////////////////////////// // CProjectMwmp::CProjectMwmp // Constructor @@ -348,6 +346,30 @@ STDMETHODIMP CProjectMwmp::Destroy() return S_OK; } + +char* ConvertBSTRToLPSTR (BSTR bstrIn) + { + LPSTR pszOut = NULL; + + if (bstrIn != NULL) + { + int nInputStrLen = SysStringLen (bstrIn); + + // Double NULL Termination + int nOutputStrLen = WideCharToMultiByte(CP_ACP, 0, bstrIn, nInputStrLen, NULL, 0, 0, 0) + 2; + + pszOut = new char [nOutputStrLen]; + + if (pszOut) + { + memset (pszOut, 0x00, sizeof (char)*nOutputStrLen); + + WideCharToMultiByte (CP_ACP, 0, bstrIn, nInputStrLen, pszOut, nOutputStrLen, 0, 0); + } + } + + return pszOut; + } ////////////////////////////////////////////////////////////////////////////// // CProjectMwmp::NotifyNewMedia // Invoked when a new media stream begins playing. @@ -357,9 +379,23 @@ STDMETHODIMP CProjectMwmp::Destroy() ////////////////////////////////////////////////////////////////////////////// STDMETHODIMP CProjectMwmp::NotifyNewMedia(IWMPMedia *pMedia) { + if (starting == false) + { + CComBSTR name; + pMedia->get_name(&name); + + LPTSTR pszConvertedCharStr = ConvertBSTRToLPSTR (name); + std::string strConverted (pszConvertedCharStr); + + delete [] pszConvertedCharStr; + + globalPM->projectM_setTitle(strConverted); return S_OK; + } } + + ////////////////////////////////////////////////////////////////////////////// // CProjectMwmp::OnWindowMessage // Window messages sent to the parent window.