• GWEN OpenGL font renderer help (C++)
    1 replies, posted
I've been working on a 2D physics sandbox game for a long time now, and ran into a snag a few days ago. I'm using GWEN as an interface, and decide to make my own (windows-only, if need be) truetype font renderer to extend the basic GWEN openGL renderer. I've tried a couple of methods with no success. Since I'm using SDL, I tried using the SDL_TTF library to create an SDL surface of the text, convert that to an openGL texture, then draw it, but issues with the pixel format meant errors everywhere, and various attempts to change the format ended with drawing a solid rectangle (not the "missing texture" rectangle). I then tried FTGL (a library using freeType), but nothing was drawn, with no errors or other indication why. Since I no longer have to SDL_TTF renderer, here is the FTGL renderer code that draws nothing. [CODE] void OpenGL_TTF::LoadFont(Gwen::Font* pFont) { char name[128]; WideToChar(name, pFont->facename, 128); FTGLPixmapFont* font = new FTGLPixmapFont("cour.ttf"); if (!font) { std::cout << "Failed to load font" << std::endl; } font->FaceSize(pFont->size); pFont->data = font; }; void OpenGL_TTF::FreeFont(Gwen::Font* pFont) { FTGLPixmapFont* font = (FTGLPixmapFont*)(pFont->data); delete font; pFont->data = NULL; }; void OpenGL_TTF::RenderText(Gwen::Font* pFont, Gwen::Point pos, const Gwen::UnicodeString& text) { if (pFont->data != NULL) { FTGLPixmapFont* font = (FTGLPixmapFont*)(pFont->data); font->Render("Testing"); } else { std::cout << "Invalid font" << std::endl; } };[/CODE] The font measuring code works and has never been an issue, so I haven't included it. If anyone has any suggestions, help or even a working font renderer I could look at, it would be much appreciated. I've spent days on this seemingly simple issue. Cheers
I can't really help you with your current problem; I have never used SDL or SDL_TTF or FTGL, but I have coded my own font renderer and it works pretty damn well. The documents and code I have created for it is pretty stagnant, but feel free to use the resources I've made and useful information I found here: [url]http://facepunch.com/showthread.php?t=1195600&p=36626273&viewfull=1#post36626273[/url]
Sorry, you need to Log In to post a reply to this thread.