Jump to content
  • Advertisement
Sign in to follow this  
globalhost

OpenGL OpenGL + FTGL. Falling productivity

This topic is 1024 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Main function

int main()
{
    init();
    while (!glfwWindowShouldClose(window))
    {
        glClear(GL_COLOR_BUFFER_BIT);
        currentTime = glfwGetTime(); ++frames;
        if (currentTime - lastTime >= 1.0) { fps = frames; frames = 0; lastTime += 1.0; }
        glPushAttrib(GL_TEXTURE_BIT);
        glColor3f(1.0f,1.0f,1.0f);
        for (int j = 0; j < 16; ++j)
        for (int i = 0; i < 12; ++i)
            font->Render(std::to_string(fps).c_str(), -1, FTPoint(i*60, height - j*30 - font->LineHeight(), 0));
        glPopAttrib();
        glfwSwapBuffers(window);
        glfwPollEvents();
    }
    glfwDestroyWindow(window);
    glfwTerminate();
}

Create font

FTFont *font;
font = new FTTextureFont("fonts/Linux Biolinum/LinBiolinum_R.otf");
font->FaceSize(20);

The problem

As you can see in the screenshots, with an increase in the number of inscriptions fps drop occurs at times!

Share this post


Link to post
Share on other sites
Advertisement

So...

Inscriptions =   1, Time per frame = 0.42ms, Time per inscription = 420?s
Inscriptions =  15, Time per frame = 0.82ms, Time per inscription = 55?s
Inscriptions =  56, Time per frame = 2.04ms, Time per inscription = 37?s
Inscriptions = 192, Time per frame = 5.81ms, Time per inscription = 30?s

Performance is increasing (i.e. time per inscription is decreasing) as you draw more of them.

Share this post


Link to post
Share on other sites

It's very slow. On my video card Radeon HD 7870 can be 172 frames. How many frames will be on the graphics card released in 2000 yr? Scary to imagine.

Share this post


Link to post
Share on other sites


font->Render(std::to_string(fps).c_str(), -1, FTPoint(i*60, height - j*30 - font->LineHeight(), 0));

 

There is a few parts of that line that you probably only need to do once. (to_string, LineHeight. You could probably make the FTPoint once and add an offset each time rather than recreating it. I honestly wouldn't worry unless it is actually an issue, 172 fps sounds great to me and as has been pointed out it is actually getting more efficient the more you do.

 

I don't know how FTGL works but looking it up and it suggests it can render fonts using a variety of methods, you could make sure it is using the texture map method as that is probably the most efficient method (which it is probably using from your code - glPushAttrib(GL_TEXTURE_BIT)).

Share this post


Link to post
Share on other sites

It's very slow. On my video card Radeon HD 7870 can be 172 frames. How many frames will be on the graphics card released in 2000 yr? Scary to imagine.

It might have nothing to do with the video card.
Maybe your video card draws all that text in 0.1ms, but your CPU is taking 5ms per loop of that code...

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!