1

I'm building a rendering engine using OpenGL and I'd like to add a minecraft-like debug overlay.

For those of you that don't know what I'm talking about:

Minecraft debug overlay

I'm using FTGL to do the font rendering, and I'm using this code (I'm also rendering a few other things (using GL_TRIANGLE as a primitive) and they all do what they are supposed to do

Initial setup:

FTGLPixmapFont debugFont (debugFontStr.c_str());

if (debugFont.Error())
{
    std::cerr << "[GameScreen::renderLoop()]\tFailed to load debugging font" << std::endl;
}
else
{
    if(!debugFont.FaceSize(static_cast<unsigned int> (debugFontSize)))
    {
        std::cerr << "[GameScreen::renderLoop()]\tCouldn't set fontSize" << std::endl;
    }
}

Main renderloop (The relevant part atleast):

glPushAttrib(GL_ALL_ATTRIB_BITS);
glDisable(GL_DEPTH_TEST);

glColor4d(1.0f, 0.0f, 0.0f, 1.0f);
debugFont.Render(this->generateDebugOutput().c_str());

glEnable(GL_DEPTH_TEST);
glPopAttrib();

SDL_GL_SwapWindow(this->sdlWindow);

Unfortunately, the FTGL text is not visible on my screen. I am using multiple texture units througout my program, if that's a relevant factor.

I've checked the result of this->generateDebugOutput() and it generates a normal C++ string. I'm not using GL_LIGHTING, I've checked the effect of disabling it before I render and re-enabling it when I'm done, no effect.

Could any of you maybe give me some pointers about what might be causing this behaviour?

I'm using SDL2 to create my window, this is my initialization code for SDL, OpenGL and GLEW:

if (SDL_Init(SDL_INIT_EVERYTHING) >= 0)
{
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, GameScreen::OPENGL_MAJOR_VERSION);
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, GameScreen::OPENGL_MINOR_VERSION);
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);

    SDL_DisplayMode dm;
    SDL_GetCurrentDisplayMode(0, &dm);
    this->screenWidth = dm.w;
    this->screenHeight = dm.h;
    this->frameCap = dm.refresh_rate;

    this->sdlWindow = SDL_CreateWindow(GameScreen::DEFAULT_TITLE.c_str(), SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, this->screenWidth, this->screenHeight, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN);
    if (this->sdlWindow != NULL)
    {
        this->openGLContext = SDL_GL_CreateContext(this->sdlWindow);
        if (this->openGLContext != NULL)
        {
            glewExperimental = GL_TRUE;
            GLenum glewError = glewInit();
            if (glewError == GLEW_OK)
            {
                if (SDL_GL_SetSwapInterval(1) < 0)
                {
                    std::cout << "[GameScreen::GameScreen()]\tWARNING: Unable to use VSync: " << SDL_GetError() << std::endl;
                }
            }
            else
            {
                std::cerr << "[GameScreen::GameScreen()]\tFailed to intialize GLEW: " << glewGetErrorString(glewError) << std::endl;
            }
        }
        else
        {
            std::cerr << "[GameScreen::GameScreen()]\tFailed to create OpenGL Context from SDL2 Window: " << SDL_GetError() << std::endl;
        }
    }
    else
    {
        std::cerr << "[GameScreen::GameScreen()]\tFailed to create SDL2 Window: " << SDL_GetError() << std::endl;
    }
}
else
{
    std::cerr << "[GameScreen::GameScreen()]\tFailed to intialize SDL2: " << SDL_GetError() << std::endl;
}

1 Answer 1

0

To everyone that's interested, I was unfortunately unable to solve this, but the nice folks over at /r/opengl were able to recommend me some other libraries:

The reddit thread can be found here: https://www.reddit.com/r/opengl/comments/6taul5/text_rendered_using_ftgl_not_visible/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.