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

Author Topic: Creating a interface maker using sfml  (Read 5121 times)

0 Members and 1 Guest are viewing this topic.

andariel97

  • Newbie
  • *
  • Posts: 14
    • View Profile
    • Email
Creating a interface maker using sfml
« on: November 26, 2016, 05:59:35 am »
Hi. Im currently working on a program that uses sfml to create interfaces for my future projects,kinda like how visual studio lets you create interfaces. Lets say for exemple that my program supports buttons and the ability to split the screen into regions. In order to split the screen i read that i should use sfml views and in order to draw faster i should put all of my sprites into a vertexrray. My question is: Is it possible to combine those 2? (to draw a lot of sprites using vertexarray but to draw them in different views?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Creating a interface maker using sfml
« Reply #1 on: November 26, 2016, 09:25:48 am »
Why not?
Laurent Gomila - SFML developer

andariel97

  • Newbie
  • *
  • Posts: 14
    • View Profile
    • Email
Re: Creating a interface maker using sfml
« Reply #2 on: November 26, 2016, 02:16:55 pm »
Because i dont know how you can do that. Could you please show me a small example that draws 2 sprites in 2 views using vertexarrays?

andariel97

  • Newbie
  • *
  • Posts: 14
    • View Profile
    • Email
Re: Creating a interface maker using sfml
« Reply #3 on: November 26, 2016, 04:53:48 pm »
Oh, sorry, i understand your confusion now. I should had wrote the question better. What i want from my program is to create one vertexarray that contains 2 sprites but each sprite to be drawn in a different view. So can you show me a small exemple that does that?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Creating a interface maker using sfml
« Reply #4 on: November 26, 2016, 04:56:08 pm »
You can't do this in a way that really makes sense. If you want to draw to different views you need different draw calls and with a vertexarray you just need one draw call. You could however for example have the game objects in one vertexarray and draw it with the game view and then one vertexarray with all the UI elements and draw it with the ui view.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

andariel97

  • Newbie
  • *
  • Posts: 14
    • View Profile
    • Email
Re: Creating a interface maker using sfml
« Reply #5 on: November 26, 2016, 05:10:53 pm »
Thank you for your answer but i doesnt really help me because my program creates interfaces. Think of a complex program like photoshop. For every button in photoshop i plan to create a sfml view in which a draw a sprite. So in order to draw a interface i'd have to make a draw call for every button which is awfull. The solution would be to not use sfml views. Instead i should do precalculations before the draw call in which i decide if a sprite should apear in the draw call or not(or to be drawn partially) then call the draw function. This should take me a while to figure it out. Too bad. I hoped i would a simple task.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Creating a interface maker using sfml
« Reply #6 on: November 26, 2016, 05:36:55 pm »
Well a normal PC can easily handle a few hundred or thousand draw calls.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

andariel97

  • Newbie
  • *
  • Posts: 14
    • View Profile
    • Email
Re: Creating a interface maker using sfml
« Reply #7 on: November 26, 2016, 05:56:47 pm »
It can but if do that ill just waste gpu power to draw the interface instead of using it for the actual rendering of models (i plan to work on a game engine in the future)

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Creating a interface maker using sfml
« Reply #8 on: November 26, 2016, 06:05:29 pm »
Quote
For every button in photoshop i plan to create a sfml view in which a draw a sprite
And why would you do that? The only reason I can think of, is to use these views for clipping. But:
- there's no need to activate clipping for buttons
- if you intend to enable custom clipping for every single element of your UI, then you'll have to make a separate draw call for each one anyway, whatever implementation you use for clipping
« Last Edit: November 26, 2016, 06:10:42 pm by Laurent »
Laurent Gomila - SFML developer

andariel97

  • Newbie
  • *
  • Posts: 14
    • View Profile
    • Email
Re: Creating a interface maker using sfml
« Reply #9 on: November 26, 2016, 06:36:16 pm »
Yes. I want to use view for clipping. And i need to use it for buttons. Look for exemple at this webpage. It has a "HOME" button. If i scroll down the button might not appear on the screen anymore.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Creating a interface maker using sfml
« Reply #10 on: November 26, 2016, 07:02:16 pm »
But you're not scolling the button itself, instead you're scrolling the whole site. So the view that does the clipping is site-based and not button-based. As such it makes sense to have something like a scroll window or panel, which then has its own view, but a view per button doesn't really make much sense.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/