diff --git a/source/glest_game/global/core_data.cpp b/source/glest_game/global/core_data.cpp index d9d0c1f8..93268841 100644 --- a/source/glest_game/global/core_data.cpp +++ b/source/glest_game/global/core_data.cpp @@ -324,14 +324,22 @@ void CoreData::load() { } -int CoreData::computeFontSize(int size){ +int CoreData::computeFontSize(int size) { + int rs = size; Config &config= Config::getInstance(); - int screenH= config.getInt("ScreenHeight"); - int rs= size*screenH/1024; + if(Font::forceLegacyFonts == true) { + int screenH = config.getInt("ScreenHeight"); + rs = size * screenH / 1024; + } + else { + rs = ((float)size * 0.86); + } //FontSizeAdjustment - rs=rs+config.getInt("FontSizeAdjustment"); - if(rs<10){ - rs= 10; + rs += config.getInt("FontSizeAdjustment"); + if(Font::forceLegacyFonts == true) { + if(rs < 10) { + rs= 10; + } } if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] fontsize orginal %d calculated:%d \n",__FILE__,__FUNCTION__,__LINE__,size,rs); return rs; diff --git a/source/glest_game/global/metrics.cpp b/source/glest_game/global/metrics.cpp index df612f7c..39b103f3 100644 --- a/source/glest_game/global/metrics.cpp +++ b/source/glest_game/global/metrics.cpp @@ -24,8 +24,8 @@ namespace Glest{ namespace Game{ // class Metrics // ===================================================== -Metrics::Metrics(){ - Config &config= Config::getInstance(); +Metrics::Metrics() { + Config &config = Config::getInstance(); virtualW= 1000; virtualH= 750; diff --git a/source/glest_game/graphics/renderer.cpp b/source/glest_game/graphics/renderer.cpp index 606e5d0e..7e234d18 100644 --- a/source/glest_game/graphics/renderer.cpp +++ b/source/glest_game/graphics/renderer.cpp @@ -1392,13 +1392,14 @@ void Renderer::renderText3D(const string &text, Font3D *font, float alpha, int x glEnable(GL_BLEND); glColor4fv(Vec4f(1.f, 1.f, 1.f, alpha).ptr()); - Vec2i pos= centered? computeCenteredPos(text, font, x, y): Vec2i(x, y); - //Vec2i pos= Vec2i(x, y); + Vec2i pos= Vec2i(x, y); + //Vec2i pos= centered? computeCenteredPos(text, font, x, y): Vec2i(x, y); textRenderer3D->begin(font); - textRenderer3D->render(text, pos.x, pos.y, font->getSize()); + textRenderer3D->render(text, pos.x, pos.y, centered); textRenderer3D->end(); + glDisable(GL_BLEND); glPopAttrib(); } @@ -1416,14 +1417,42 @@ void Renderer::renderText(const string &text, Font2D *font, float alpha, int x, glPopAttrib(); } +void Renderer::renderTextBoundingBox3D(const string &text, Font3D *font, const Vec3f &color, int x, int y, int w, int h, bool centered) { + glPushAttrib(GL_CURRENT_BIT); + glColor3fv(color.ptr()); + + Vec2f pos= Vec2f(x, y); + //Vec2i pos= centered? computeCenteredPos(text, font, x, y): Vec2i(x, y); + + if(centered) { + float lineWidth = font->getTextHandler()->Advance(text.c_str()); + if(lineWidth < w) { + pos.x += ((w / 2.f) - (lineWidth / 2.f)); + } + + float lineHeight = font->getTextHandler()->LineHeight(text.c_str()); + if(lineHeight < h) { + //pos.y -= ((float(h) / 2.f) - (lineHeight / 2.f)); + pos.y += (lineHeight / 2.f); + } + } + + textRenderer3D->begin(font); + textRenderer3D->render(text, pos.x, pos.y); + textRenderer3D->end(); + + glPopAttrib(); +} + void Renderer::renderText3D(const string &text, Font3D *font, const Vec3f &color, int x, int y, bool centered) { glPushAttrib(GL_CURRENT_BIT); glColor3fv(color.ptr()); - Vec2i pos= centered? computeCenteredPos(text, font, x, y): Vec2i(x, y); + Vec2i pos= Vec2i(x, y); + //Vec2i pos= centered? computeCenteredPos(text, font, x, y): Vec2i(x, y); textRenderer3D->begin(font); - textRenderer3D->render(text, pos.x, pos.y); + textRenderer3D->render(text, pos.x, pos.y, centered); textRenderer3D->end(); glPopAttrib(); @@ -1442,17 +1471,48 @@ void Renderer::renderText(const string &text, Font2D *font, const Vec3f &color, glPopAttrib(); } -void Renderer::renderText3D(const string &text, Font3D *font, const Vec4f &color, int x, int y, bool centered) { +void Renderer::renderTextBoundingBox3D(const string &text, Font3D *font, const Vec4f &color, int x, int y, int w, int h, bool centered) { glPushAttrib(GL_ENABLE_BIT | GL_CURRENT_BIT); glEnable(GL_BLEND); glColor4fv(color.ptr()); - Vec2i pos= centered? computeCenteredPos(text, font, x, y): Vec2i(x, y); + Vec2f pos= Vec2f(x, y); + //Vec2i pos= centered? computeCenteredPos(text, font, x, y): Vec2i(x, y); + + if(centered) { + float lineWidth = font->getTextHandler()->Advance(text.c_str()); + if(lineWidth < w) { + pos.x += ((w / 2.f) - (lineWidth / 2.f)); + } + + float lineHeight = font->getTextHandler()->LineHeight(text.c_str()); + if(lineHeight < h) { + //pos.y -= ((float(h) / 2.f) - (lineHeight / 2.f)); + pos.y += (lineHeight / 2.f); + } + } textRenderer3D->begin(font); textRenderer3D->render(text, pos.x, pos.y); textRenderer3D->end(); + glDisable(GL_BLEND); + glPopAttrib(); +} + +void Renderer::renderText3D(const string &text, Font3D *font, const Vec4f &color, int x, int y, bool centered) { + glPushAttrib(GL_ENABLE_BIT | GL_CURRENT_BIT); + glEnable(GL_BLEND); + glColor4fv(color.ptr()); + + Vec2i pos= Vec2i(x, y); + //Vec2i pos= centered? computeCenteredPos(text, font, x, y): Vec2i(x, y); + + textRenderer3D->begin(font); + textRenderer3D->render(text, pos.x, pos.y, centered); + textRenderer3D->end(); + + glDisable(GL_BLEND); glPopAttrib(); } @@ -1692,24 +1752,27 @@ void Renderer::renderButton(GraphicButton *button, const Vec4f *fontColorOverrid glEnd(); } - Vec2i textPos= Vec2i(x + w / 2, y + h / 2); + //Vec2i textPos= Vec2i(x + w / 2, y + h / 2); if(button->getEditable()) { if(renderText3DEnabled == true) { - renderText3D(button->getText(), button->getFont3D(), color,x + w / 2, y + h / 2, true); + //renderText3D(button->getText(), button->getFont3D(), color,x + (w / 2), y + (h / 2), true); + renderTextBoundingBox3D(button->getText(), button->getFont3D(), color, x, y, w, h, true); } else { - renderText(button->getText(), button->getFont(), color,x + w / 2, y + h / 2, true); + renderText(button->getText(), button->getFont(), color,x + (w / 2), y + (h / 2), true); } } else { if(renderText3DEnabled == true) { - renderText3D(button->getText(), button->getFont3D(),disabledTextColor, - x + w / 2, y + h / 2, true); + //renderText3D(button->getText(), button->getFont3D(),disabledTextColor, + // x + (w / 2), y + (h / 2), true); + renderTextBoundingBox3D(button->getText(), button->getFont3D(),disabledTextColor, + x, y, w, h, true); } else { renderText(button->getText(), button->getFont(),disabledTextColor, - x + w / 2, y + h / 2, true); + x + (w / 2), y + (h / 2), true); } } @@ -4984,9 +5047,10 @@ void Renderer::renderArrow(const Vec3f &pos1, const Vec3f &pos2, void Renderer::renderProgressBar3D(int size, int x, int y, Font3D *font, int customWidth, string prefixLabel,bool centeredText) { - int currentSize = size; - int maxSize = maxProgressBar; - string renderText = intToStr(static_cast(size)) + "%"; + int progressbarHeight = 10; + int currentSize = size; + int maxSize = maxProgressBar; + string renderText = intToStr(static_cast(size)) + "%"; if(customWidth > 0) { if(size > 0) { currentSize = (int)((double)customWidth * ((double)size / 100.0)); @@ -5004,9 +5068,9 @@ void Renderer::renderProgressBar3D(int size, int x, int y, Font3D *font, int cus glBegin(GL_QUADS); glColor4fv(progressBarFront2.ptr()); glVertex2i(x, y); - glVertex2i(x, y+10); + glVertex2i(x, y + progressbarHeight); glColor4fv(progressBarFront1.ptr()); - glVertex2i(x + currentSize, y+10); + glVertex2i(x + currentSize, y + progressbarHeight); glVertex2i(x + currentSize, y); glEnd(); @@ -5015,16 +5079,20 @@ void Renderer::renderProgressBar3D(int size, int x, int y, Font3D *font, int cus glBegin(GL_QUADS); glColor4fv(progressBarBack2.ptr()); glVertex2i(x + currentSize, y); - glVertex2i(x + currentSize, y+10); + glVertex2i(x + currentSize, y + progressbarHeight); glColor4fv(progressBarBack1.ptr()); - glVertex2i(x + maxSize, y+10); + glVertex2i(x + maxSize, y + progressbarHeight); glVertex2i(x + maxSize, y); glEnd(); glDisable(GL_BLEND); //text - glColor3fv(defColor.ptr()); + //glColor3fv(defColor.ptr()); + //printf("Render progress bar3d renderText [%s] y = %d, centeredText = %d\n",renderText.c_str(),y, centeredText); + + renderTextBoundingBox3D(renderText, font, defColor, x, y, maxSize, progressbarHeight, true); + /* textRenderer3D->begin(font); if(centeredText == true) { textRenderer3D->render(renderText.c_str(), x + maxSize / 2, y, centeredText); @@ -5033,6 +5101,7 @@ void Renderer::renderProgressBar3D(int size, int x, int y, Font3D *font, int cus textRenderer3D->render(renderText.c_str(), x, y, centeredText); } textRenderer3D->end(); + */ } void Renderer::renderProgressBar(int size, int x, int y, Font2D *font, int customWidth, diff --git a/source/glest_game/graphics/renderer.h b/source/glest_game/graphics/renderer.h index 9ca3e0a4..84e1b622 100644 --- a/source/glest_game/graphics/renderer.h +++ b/source/glest_game/graphics/renderer.h @@ -368,6 +368,9 @@ public: void renderTextShadow3D(const string &text, Font3D *font,const Vec4f &color, int x, int y, bool centered=false); void renderProgressBar3D(int size, int x, int y, Font3D *font, int customWidth=-1, string prefixLabel="", bool centeredText=true); + void renderTextBoundingBox3D(const string &text, Font3D *font, const Vec4f &color, int x, int y, int w, int h, bool centered); + void renderTextBoundingBox3D(const string &text, Font3D *font, const Vec3f &color, int x, int y, int w, int h, bool centered); + //components void renderLabel(GraphicLabel *label); void renderLabel(GraphicLabel *label,const Vec3f *color); diff --git a/source/glest_game/main/main.cpp b/source/glest_game/main/main.cpp index 4e0b42cf..2e215855 100644 --- a/source/glest_game/main/main.cpp +++ b/source/glest_game/main/main.cpp @@ -126,6 +126,7 @@ const char *GAME_ARGS[] = { "--disable-vbo", "--disable-sound", "--enable-legacyfonts", + "--use-video-settings", "--verbose" }; @@ -161,6 +162,7 @@ enum GAME_ARG_TYPE { GAME_ARG_DISABLE_VBO, GAME_ARG_DISABLE_SOUND, GAME_ARG_ENABLE_LEGACYFONTS, + GAME_ARG_USE_VIDEO_SETTINGS, GAME_ARG_VERBOSE_MODE }; @@ -1063,6 +1065,16 @@ void printParameterHelp(const char *argv0, bool foundInvalidArgs) { printf("\n%s\t\t\tenables using the legacy font system.",GAME_ARGS[GAME_ARG_ENABLE_LEGACYFONTS]); + + printf("\n%s=x\t\t\toverride video settings.",GAME_ARGS[GAME_ARG_USE_VIDEO_SETTINGS]); + printf("\n \t\tWhere x is a string with the following format:"); + printf("\n \t\twidthxheightxcolorbitsxdepthbitsxfullscreen"); + printf("\n \t\twhere * indicates not to replace the default value for the parameter"); + printf("\n \t\fullscreen has possible values of true, false, 1 or 0"); + printf("\n \t\tand only the width and height parameters are required (the others are optional)"); + printf("\n \t\texample: %s %s=1024x768x*x*",argv0,GAME_ARGS[GAME_ARG_USE_VIDEO_SETTINGS]); + printf("\n \t\tsame result for: %s %s=1024x768",argv0,GAME_ARGS[GAME_ARG_USE_VIDEO_SETTINGS]); + printf("\n%s\t\t\tdisplays verbose information in the console.",GAME_ARGS[GAME_ARG_VERBOSE_MODE]); printf("\n\n"); @@ -2464,6 +2476,60 @@ int glestMain(int argc, char** argv) { Renderer::renderText3DEnabled = config.getBool("Enable3DFontRendering",intToStr(Renderer::renderText3DEnabled).c_str()); + if(hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_USE_VIDEO_SETTINGS]) == true) { + int foundParamIndIndex = -1; + hasCommandArgument(argc, argv,string(GAME_ARGS[GAME_ARG_USE_VIDEO_SETTINGS]) + string("="),&foundParamIndIndex); + if(foundParamIndIndex < 0) { + hasCommandArgument(argc, argv,string(GAME_ARGS[GAME_ARG_USE_VIDEO_SETTINGS]),&foundParamIndIndex); + } + string paramValue = argv[foundParamIndIndex]; + vector paramPartTokens; + Tokenize(paramValue,paramPartTokens,"="); + if(paramPartTokens.size() >= 2 && paramPartTokens[1].length() > 0) { + string settings = paramPartTokens[1]; + printf("Forcing video settings [%s]\n",settings.c_str()); + + paramPartTokens.clear(); + Tokenize(settings,paramPartTokens,"x"); + if(paramPartTokens.size() >= 2) { + int newScreenWidth = strToInt(paramPartTokens[0]); + config.setInt("ScreenWidth",newScreenWidth); + + int newScreenHeight = strToInt(paramPartTokens[1]); + config.setInt("ScreenHeight",newScreenHeight); + + if(paramPartTokens.size() >= 3) { + if(paramPartTokens[2] != "*") { + int newColorBits = strToInt(paramPartTokens[2]); + config.setInt("ColorBits",newColorBits); + } + } + if(paramPartTokens.size() >= 4) { + if(paramPartTokens[3] != "*") { + int newDepthBits = strToInt(paramPartTokens[3]); + config.setInt("DepthBits",newDepthBits); + } + } + if(paramPartTokens.size() >= 5) { + if(paramPartTokens[4] != "*") { + bool newFullScreenMode = strToBool(paramPartTokens[4]); + config.setBool("Windowed",newFullScreenMode); + } + } + } + else { + printf("\nInvalid missing video settings specified on commandline [%s] value [%s]\n\n",argv[foundParamIndIndex],(paramPartTokens.size() >= 2 ? paramPartTokens[1].c_str() : NULL)); + //printParameterHelp(argv[0],false); + return -1; + } + } + else { + printf("\nInvalid missing video settings specified on commandline [%s] value [%s]\n\n",argv[foundParamIndIndex],(paramPartTokens.size() >= 2 ? paramPartTokens[1].c_str() : NULL)); + //printParameterHelp(argv[0],false); + return -1; + } + } + // Set some statics based on ini entries SystemFlags::ENABLE_THREADED_LOGGING = config.getBool("ThreadedLogging","true"); FontGl::setDefault_fontType(config.getString("DefaultFont",FontGl::getDefault_fontType().c_str())); diff --git a/source/shared_lib/include/graphics/gl/text_renderer_gl.h b/source/shared_lib/include/graphics/gl/text_renderer_gl.h index c07ffa82..021e1466 100644 --- a/source/shared_lib/include/graphics/gl/text_renderer_gl.h +++ b/source/shared_lib/include/graphics/gl/text_renderer_gl.h @@ -50,8 +50,10 @@ class TextRenderer3DGl: public TextRenderer3D { private: Font3DGl *font; bool rendering; + int currentFTGLErrorCount; void internalRender(const string &text, float x, float y, bool centered, Vec3f *color); + void specialFTGLErrorCheckWorkaround(string text); public: TextRenderer3DGl(); diff --git a/source/shared_lib/sources/graphics/gl/font_textFTGL.cpp b/source/shared_lib/sources/graphics/gl/font_textFTGL.cpp index 531afaa5..63581b83 100644 --- a/source/shared_lib/sources/graphics/gl/font_textFTGL.cpp +++ b/source/shared_lib/sources/graphics/gl/font_textFTGL.cpp @@ -185,6 +185,29 @@ void TextFTGL::Render(const char* str, const int len) { float TextFTGL::Advance(const char* str, const int len) { return ftFont->Advance(str, len); + + //FTBBox box = ftFont->BBox(str); + //float urx = box.Upper().X(); + //float llx = box.Lower().X(); + //float llx, lly, llz, urx, ury, urz; + //ftFont->BBox(str, llx, lly, llz, urx, ury, urz); + + //Short_t halign = fTextAlign/10; + //Short_t valign = fTextAlign - 10*halign; + //Float_t dx = 0, dy = 0; +// switch (halign) { +// case 1 : dx = 0 ; break; +// case 2 : dx = -urx/2; break; +// case 3 : dx = -urx ; break; +// } +// switch (valign) { +// case 1 : dy = 0 ; break; +// case 2 : dy = -ury/2; break; +// case 3 : dy = -ury ; break; +// } + + //printf("For str [%s] advance = %f, urx = %f, llx = %f\n",str, ftFont->Advance(str, len),urx,llx); + //return urx; } float TextFTGL::LineHeight(const char* str, const int len) { diff --git a/source/shared_lib/sources/graphics/gl/text_renderer_gl.cpp b/source/shared_lib/sources/graphics/gl/text_renderer_gl.cpp index 11aeab4d..d66bbfd5 100644 --- a/source/shared_lib/sources/graphics/gl/text_renderer_gl.cpp +++ b/source/shared_lib/sources/graphics/gl/text_renderer_gl.cpp @@ -351,6 +351,7 @@ void TextRenderer2DGl::end() { TextRenderer3DGl::TextRenderer3DGl() : TextRenderer3D() { rendering= false; this->font = NULL; + currentFTGLErrorCount = 0; } TextRenderer3DGl::~TextRenderer3DGl() { @@ -367,70 +368,118 @@ void TextRenderer3DGl::begin(Font3D *font) { //load color glPushAttrib(GL_TRANSFORM_BIT); - assertGl(); + //assertGl(); } void TextRenderer3DGl::render(const string &text, float x, float y, bool centered, Vec3f *color) { assert(rendering); - string renderText = text; - if(Font::fontIsMultibyte == true) { - if(font->getTextHandler() != NULL) { - if(Font::fontIsRightToLeft == true) { - //printf("\n\n#A [%s]\n",renderText.c_str()); - //bool isRLM = utf8::starts_with_rlm(text.begin(), text.end() + text.size()); + if(text.empty() == false) { + string renderText = text; + if(Font::fontIsMultibyte == true) { + if(font->getTextHandler() != NULL) { + if(Font::fontIsRightToLeft == true) { + //printf("\n\n#A [%s]\n",renderText.c_str()); + //bool isRLM = utf8::starts_with_rlm(text.begin(), text.end() + text.size()); - //printf("\n\nORIGINAL TEXT [%s] isRLM = %d\n\n",text.c_str(),isRLM); - //for(int i = 0; i < renderText.size(); ++i) { - // printf("i = %d c [%c][%d][%X]\n",i,renderText[i],renderText[i],renderText[i]); - //} - //if(isRLM == true) { - if(is_string_all_ascii(renderText) == false) { - strrev_utf8(renderText); + //printf("\n\nORIGINAL TEXT [%s] isRLM = %d\n\n",text.c_str(),isRLM); + //for(int i = 0; i < renderText.size(); ++i) { + // printf("i = %d c [%c][%d][%X]\n",i,renderText[i],renderText[i],renderText[i]); + //} + //if(isRLM == true) { + if(is_string_all_ascii(renderText) == false) { + strrev_utf8(renderText); + } } } } - } - internalRender(renderText, x, y, centered, color); + internalRender(renderText, x, y, centered, color); + } +} + +void TextRenderer3DGl::specialFTGLErrorCheckWorkaround(string text) { + GLenum error = glGetError(); + if(error) { + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("\n\nIn [%s::%s Line: %d] error = %d for text [%s]\n\n",__FILE__,__FUNCTION__,__LINE__,error,text.c_str()); + + if(currentFTGLErrorCount > 0) { + printf("error = %d for text [%s]\n",error,text.c_str()); + assertGlWithErrorNumber(error); + } + + currentFTGLErrorCount++; + } } void TextRenderer3DGl::internalRender(const string &text, float x, float y, bool centered, Vec3f *color) { //assert(rendering); if(color != NULL) { + //assertGl(); glPushAttrib(GL_CURRENT_BIT); + + //assertGl(); + glColor3fv(color->ptr()); + + //assertGl(); } const unsigned char *utext= NULL; - assertGl(); + //assertGl(); glMatrixMode(GL_MODELVIEW); + + //assertGl(); + glPushMatrix(); + + //assertGl(); + glLoadIdentity(); + + //assertGl(); + //glPushAttrib(GL_POLYGON_BIT); int size = font->getSize(); //float scale= size / 15.f; - float scale= 1.0f; - //float scale= size; Vec3f translatePos; FontMetrics *metrics= font->getMetrics(); if(font->getTextHandler() != NULL) { + //centered = false; if(centered) { - translatePos.x = x - scale * font->getTextHandler()->Advance(text.c_str()) / 2.f; - translatePos.y = y - scale * font->getTextHandler()->LineHeight(text.c_str()) / font->getYOffsetFactor(); + //printf("3d text to center [%s] advance = %f, x = %f\n",text.c_str(),font->getTextHandler()->Advance(text.c_str()), x); + //printf("3d text to center [%s] lineheight = %f, y = %f\n",text.c_str(),font->getTextHandler()->LineHeight(text.c_str()), y); + +// translatePos.x = x - scale * font->getTextHandler()->Advance(text.c_str()) / 2.f; +// translatePos.y = y - scale * font->getTextHandler()->LineHeight(text.c_str()) / font->getYOffsetFactor(); + //assertGl(); + translatePos.x = x - (font->getTextHandler()->Advance(text.c_str()) / 2.f); + //assertGl(); + //translatePos.y = y - (font->getTextHandler()->LineHeight(text.c_str()) / font->getYOffsetFactor()); + translatePos.y = y - (font->getTextHandler()->LineHeight(text.c_str()) / 2.f); + //assertGl(); + translatePos.z = 0; } else { - translatePos.x = x-scale; - translatePos.y = y-scale; + //printf("3d text [%s] advance = %f, x = %f\n",text.c_str(),font->getTextHandler()->Advance(text.c_str()), x); + +// translatePos.x = x-scale; +// translatePos.y = y-scale; + translatePos.x = x; + translatePos.y = y; + translatePos.z = 0; } } else { + float scale= 1.0f; + //float scale= size; + utext= reinterpret_cast(text.c_str()); if(centered) { //glTranslatef(x-scale*metrics->getTextWidth(text)/2.f, y-scale*metrics->getHeight()/2.f, 0); @@ -446,24 +495,35 @@ void TextRenderer3DGl::internalRender(const string &text, float x, float y, boo } } - float scaleX = 0.65; - float scaleY = 0.75; - float scaleZ = 1.0; + //float scaleX = 0.65; + //float scaleY = 0.75; + //float scaleZ = 1.0; + //float scaleX = 1; //float scaleY = 1; //float scaleZ = 1; - float yScaleFactor = (metrics->getHeight() * (1.0 - scaleY)); - translatePos.y += yScaleFactor; + //float yScaleFactor = (metrics->getHeight() * (1.0 - scaleY)); + //translatePos.y += yScaleFactor; + + //assertGl(); glTranslatef(translatePos.x, translatePos.y, translatePos.z); - glScalef(scaleX, scaleY, scaleZ); - //font->getTextHandler()->Render(text.c_str()); + //assertGl(); + + //glScalef(scaleX, scaleY, scaleZ); + + //assertGl(); + + // font->getTextHandler()->Render(text.c_str()); + // specialFTGLErrorCheckWorkaround(text); if(font->getTextHandler() != NULL) { if(text.find("\n") == text.npos && text.find("\t") == text.npos) { + //assertGl(); font->getTextHandler()->Render(text.c_str()); + specialFTGLErrorCheckWorkaround(text); } else { int line=0; @@ -479,18 +539,12 @@ void TextRenderer3DGl::internalRender(const string &text, float x, float y, boo case '\t': parts.push_back(szBuf); lastCharacterWasSpecial = true; - //rasterPos= Vec2f((rasterPos.x / size + 3.f) * size, y-(size + 1.f) * line); - //glRasterPos2f(rasterPos.x, rasterPos.y); break; case '\n': parts.push_back(szBuf); lastCharacterWasSpecial = true; - //line++; - //rasterPos= Vec2f(static_cast(x), y - (fontFTGL->LineHeight(text.c_str()) * 2.f) * line); - //glRasterPos2f(rasterPos.x, rasterPos.y); break; default: - //glCallList(font->getHandle()+utext[i]); if(lastCharacterWasSpecial == true) { parts.push_back(szBuf); } @@ -512,18 +566,30 @@ void TextRenderer3DGl::internalRender(const string &text, float x, float y, boo case '\n': { line++; + //assertGl(); float yLineValue = font->getTextHandler()->LineHeight(parts[i].c_str()); + //assertGl(); translatePos= Vec3f(translatePos.x, translatePos.y - yLineValue, translatePos.z); needsRecursiveRender = true; } break; default: if(needsRecursiveRender == true) { - internalRender(parts[i], translatePos.x, translatePos.y, false, color); + //internalRender(parts[i], translatePos.x, translatePos.y, false, color); + glPushMatrix(); + glLoadIdentity(); + glTranslatef(translatePos.x, translatePos.y, translatePos.z); + font->getTextHandler()->Render(parts[i].c_str()); + specialFTGLErrorCheckWorkaround(parts[i]); + glPopMatrix(); + needsRecursiveRender = false; } else { + //assertGl(); + font->getTextHandler()->Render(parts[i].c_str()); + specialFTGLErrorCheckWorkaround(parts[i]); } } } @@ -560,8 +626,12 @@ void TextRenderer3DGl::internalRender(const string &text, float x, float y, boo } } + //assertGl(); + glPopMatrix(); + //assertGl(); + if(color != NULL) { glPopAttrib(); } @@ -573,7 +643,7 @@ void TextRenderer3DGl::end() { assert(rendering); rendering= false; - assertGl(); + //assertGl(); glPopAttrib(); diff --git a/source/shared_lib/sources/graphics/interpolation.cpp b/source/shared_lib/sources/graphics/interpolation.cpp index 24fe6272..753b2644 100644 --- a/source/shared_lib/sources/graphics/interpolation.cpp +++ b/source/shared_lib/sources/graphics/interpolation.cpp @@ -17,6 +17,7 @@ #include "model.h" #include "conversion.h" #include "util.h" +#include #include "leak_dumper.h" using namespace std; @@ -76,7 +77,11 @@ void InterpolationData::updateVertices(float t, bool cycle) { if(t <0.0f || t>1.0f) { printf("ERROR t = [%f] for cycle [%d] f [%d] v [%d]\n",t,cycle,mesh->getFrameCount(),mesh->getVertexCount()); } - assert(t>=0.0f && t<=1.0f); + //assert(t>=0.0f && t<=1.0f); + if(t < 0.0f || t > 1.0f) { + throw runtime_error("t < 0.0f || t > 1.0f t = [" + floatToStr(t) + "]"); + } + assert(t >= 0.f && t <= 1.f); uint32 frameCount= mesh->getFrameCount(); uint32 vertexCount= mesh->getVertexCount();