Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8845965
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:51:40+00:00 2026-06-14T11:51:40+00:00

I wanted to display some text in my OpenGL application and was already using

  • 0

I wanted to display some text in my OpenGL application and was already using SFML for window & context creation. I didn’t want to add another library and tried using the text rendering provided by SFML (2.0).

The text that is rendered is consisting out of white rectangles (the rectangles match the height of the char they should display roughly).

Everything else is rendered correctly after I added some methods to keep the OpenGL states the same as they were before using the SFML text. Without those methods nothing gets rendered, but the right color buffer clearing color is used.

I use GLSL for texturing and lighting(can provide source&screenshots if needed).

The code I use:

glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glLoadIdentity();

//rotations for looking around & moving the camera
glRotatef(camera.rotation[0], 1.0f, 0.0f, 0.0f);
glRotatef(camera.rotation[1], 0.0f, 1.0f, 0.0f);
glRotatef(camera.rotation[2], 0.0f, 0.0f, 1.0f);
glTranslatef( -5.0f+camera.translation[0], 
                    camera.translation[1], -7.5f+camera.translation[2]);

//set OpenGL light attributes
passPosition(GL_LIGHT0, spotLight);
passSpotDirection(GL_LIGHT0, spotLight);
passPosition(GL_LIGHT1, greenLight);
passPosition(GL_LIGHT2, redLight);
passPosition(GL_LIGHT3, blueLight);

glUseProgram( shaderProg.getId() );
renderMap();
glUseProgram(0);

window.pushGLStates();//supposed to prevent OpenGL & SFML conflicts 
window.draw(testText);
window.popGLStates();

err = glGetError();//doesn't report any errors
if(err != GL_NO_ERROR)
{
    std::cout << "ERROR: " << err << std::endl;
}

window.display();

The text instance is created like this:

sf::Font fontVera;

std::cout << fontVera.loadFromFile("./res/Vera.ttf") << std::endl;
//the font is existing, output for debugging purposes(and shows no error)

sf::Text testText("hasdfas", fontVera, 32);
testText.setPosition(10,10);

I’am using a 3.3 Compatibilty Profile Context, 3.3 GLSL and 2.0 SFML(compiled from source).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T11:51:41+00:00Added an answer on June 14, 2026 at 11:51 am

    I’ve switched my font-rendering to ftgl, since I didn’t find any way to fix the rendering bug from SFML.

    I doubt that i will switch back, because SFML-OpenGL state conflicts seem to be quite widespread:

    StackOverflow: SFML OpenGL Drawing Text

    SFML-Forums: Crazy bug using OpenGL lighting and RenderWindow

    SFML-Forums: glCullFace makes SFML blind

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my application I want to display some pictures (I need to have them
I want to display an image and some text on the URL bar of
What would I do if I wanted my PHP script to show some text
I want to build a website that display changing text-messages. The server gets the
In my app I have a screen where I display some text and then
I wanted to display 9 images one after the other. I have included the
Let's say I wanted to display a Button and a few RadioButtons . Based
I'm having about 200 icons ,which I wanted to display in a treeview on
I am sourcing a large mapping/widget javascript file (1.3 MB) and wanted to display
I have an object of type IMAGE which holds image. I wanted to display

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.