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

Author Topic: Partially drawing/hiding a sf::Shape::Line  (Read 3531 times)

0 Members and 1 Guest are viewing this topic.

phoekz

  • Newbie
  • *
  • Posts: 14
    • View Profile
Partially drawing/hiding a sf::Shape::Line
« 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.


Naufr4g0

  • Full Member
  • ***
  • Posts: 112
    • View Profile
Partially drawing/hiding a sf::Shape::Line
« Reply #1 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. :)

Walker

  • Full Member
  • ***
  • Posts: 181
    • View Profile
Partially drawing/hiding a sf::Shape::Line
« Reply #2 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.

phoekz

  • Newbie
  • *
  • Posts: 14
    • View Profile
Partially drawing/hiding a sf::Shape::Line
« Reply #3 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.

Haze

  • Full Member
  • ***
  • Posts: 201
    • View Profile
    • Github Profile
Partially drawing/hiding a sf::Shape::Line
« Reply #4 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