SFML community forums

Help => Graphics => Topic started by: phoekz on December 02, 2011, 11:18:06 pm

Title: Partially drawing/hiding a sf::Shape::Line
Post by: phoekz on December 02, 2011, 11:18:06 pm
Hey

In short, how would I go about partially hiding sf::Shape::Line objects like sprites (setsubrect). The picture below explains my intents.

The map screen is scroll-able so the elements inside this frame are moving and obviously when they reach border of the frame, they will be hidden and not drawn at all.

(http://i40.tinypic.com/25ib60h.png)
Title: Partially drawing/hiding a sf::Shape::Line
Post by: Naufr4g0 on December 02, 2011, 11:40:16 pm
I think best solution is to calculate the intersection between the lines and the edge of the map display. :)
Title: Partially drawing/hiding a sf::Shape::Line
Post by: Walker on December 03, 2011, 02:07:07 am
(SFML2) Draw the map to a rendertexture and draw that with a sprite onto your HUD/UI.
Title: Partially drawing/hiding a sf::Shape::Line
Post by: phoekz on December 03, 2011, 11:22:49 am
Quote from: "Walker"
(SFML2) Draw the map to a rendertexture and draw that with a sprite onto your HUD/UI.


Wow that was genius, didn't even know you could do that :D.
Title: Partially drawing/hiding a sf::Shape::Line
Post by: Haze on December 03, 2011, 03:22:54 pm
You could use glScissor: it will only draw objects which are within a rectangle area.
It's really easy to use:

Code: [Select]
glEnable(GL_SCISSOR_TEST);
glScissor(right_x, bottom_y, width, height);

// draw your stuff

glDisable(GL_SCISSOR_TEST);


documentation: http://www.opengl.org/sdk/docs/man/xhtml/glScissor.xml