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

Author Topic: Massive Graphics Optimization  (Read 1088 times)

0 Members and 1 Guest are viewing this topic.

Andrew

  • Newbie
  • *
  • Posts: 22
    • View Profile
    • Email
Massive Graphics Optimization
« on: May 28, 2013, 04:51:14 am »
Hello,

I am in the "scoping" phase of a project I'm working on which will use SFML graphics heavily. What I am wondering is: how can I make the graphics as fast as possible, generally speaking? After searching through these forums, this is what I have found:

1. Limiting the number of SFML "draw" calls.
2. Using VertexArrays (although I have no idea what you mean by this and why).
3. Using OpenGL directly (although would there be a reason for me to use SFML anyways then?).
4. Using multithreading.

Also, would it be faster to use pre-existing, reusable sf::VertexArray's and other Shapes and such to optimize the speed of drawing things (since their constructors and deconstructors wouldn't be called more than once)?


Obviously the context of what graphics is being drawn is of some relevance here, so I will state it. There will be any number of different sections of graphics ("in-window windows") that can be moved around and stacked on top of each other and such. Inside each section can be any number of lines, shapes, texts, and etc. It is possible for any of these 3 scenarios to happen in each section at any time (and I'll know about it ahead of time):

1. The section could have everything drawn differently every time it's displayed.
2. The section could have everything drawn exactly the same (but possibly being moved? (possibly not as well)) every time it's displayed.
3. A combination of #1 and #2.

From what I can understand, it would be beneficial to use RenderTextures and Views for this sort of thing, but when and where would it be applicable and efficient?

Any help you can provide on this subject would be greatly appreciated, thank you!



EDIT: Okay, after doing more reading of the RenderTexture and View documentation, this is what I have found:

RenderTextures should be used whenever it is possible that something will be drawn more than once. I would then call all of my draw commands from the RenderTexture rather than from the RenderWindow, and when I am ready I would draw the RenderTexture onto the RenderWindow. Why is a Sprite needed to do this transfer, though, and will I need to create a new Sprite every time or can/should I reuse the Sprite for the same (and different?) RenderTextures?

Views should be used whenever something needs to be drawn at a different position, size, and/or rotation than normal. Most of the functions for Views are for setting its source rectangle ("from where on the source am I taking graphics?"), and setViewport is used for setting its destination rectangle ("where at on the destination am I placing graphics?"). Are the first two parameters of the FloatRect in a View the coordinates, or are they percentages as well (just like the last two parameters)? Before drawing things, I would need to set the View on the RenderTexture/RenderWindow, draw stuff, and then potentially set the View back before drawing something else if desired.

Is the above correct? Also, would it be faster to draw e.g. 10 lines on a RenderTexture and then use a View to draw that RenderTexture onto a RenderWindow at a different position, OR would it be faster to draw those 10 lines straight to the RenderWindow and adjust each line's position individually? What about for 1 line or 10000 lines? Do RenderTexture's store data differently than the drawing operations themselves, etc.? That's primarily what I need to understand.

Thanks!
« Last Edit: May 28, 2013, 08:36:34 pm by Andrew »

 

anything