Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Drawing without SFML window  (Read 1267 times)

0 Members and 1 Guest are viewing this topic.

Catch_0x16

  • Newbie
  • *
  • Posts: 2
    • View Profile
Drawing without SFML window
« on: October 27, 2019, 04:50:07 pm »
Hello,

I'm writing a plugin for a flight simulator, that is written in OpenGL. The simulator creates and manages the OpenGL context/window etc. and all I do is make draw calls (in immediate mode... please don't hate me) as and when it's my plugins turn to draw.

So far, I have been using the sf::Image class to save me from writing my own implementation of loading in .png/.jpeg files etc. Once I've loaded an image, I glGenTextures and glTexImage2D to push to pixel data from the sf::Image class across to my GPU. At this point I pretty much no longer use the sf::Image class at all, and handle drawing by myself.

Now I need to do the same with sf::Text, but can't work out how to get the pixel data. I want to use the SFML classes again, to save me from having to re implement FreeType.

I suppose I have two questions:
  • How do I get the pixel data from sf::Text?
  • Is there a better way of drawing these elements, without having an SFML window class?

Thanks

Catch_0x16

G.

  • Hero Member
  • *****
  • Posts: 1593
    • View Profile
Re: Drawing without SFML window
« Reply #1 on: October 27, 2019, 10:24:17 pm »
You could draw your texts on an sf::RenderTexture, no window needed.

Catch_0x16

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Drawing without SFML window
« Reply #2 on: October 27, 2019, 11:00:23 pm »
Ah! that sounds like a solution, thanks!

 

anything