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

Author Topic: How to reduce two draw calls into one  (Read 2035 times)

0 Members and 1 Guest are viewing this topic.

Folling

  • Newbie
  • *
  • Posts: 1
    • View Profile
How to reduce two draw calls into one
« on: May 10, 2017, 06:56:34 pm »
Hello everyone,

I have created my own class called SFMLButton which is supposed to, as the name implies function as a button.
Now an SFMLButton contains both a RectangleShape and a Text for the respective purposes.
The issue is, to draw this Button now I would have to call two separate draw calls.
window.draw(SFMLButton.shape) and window.draw(SFMLButton.text)
now I could override the draw function as SFMLButton is derived from Drawable.
Though I would still perform two draw calls per Button.
Is there a way to maybe create a texture which will contain both the shape and the text?

thanks in Advance
Folling

Turbine

  • Full Member
  • ***
  • Posts: 102
    • View Profile
Re: How to reduce two draw calls into one
« Reply #1 on: May 10, 2017, 07:55:34 pm »
Yeah sure, use a sf:RenderTexture: https://www.sfml-dev.org/documentation/2.4.2/classsf_1_1RenderTexture.php

As it's a sf:RenderTarget you may draw to the texture before drawing the texture to the window. You could draw a texture to another texture if you wanted even.