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

Author Topic: sf::Shape + sf::Shader = Nothing ?  (Read 1816 times)

0 Members and 1 Guest are viewing this topic.

Haikarainen

  • Guest
sf::Shape + sf::Shader = Nothing ?
« on: October 14, 2011, 02:02:24 am »
So I noticed you can't draw shapes using shaders, or they just wont draw. Why is this? This is a huge drawback for me, aesthetically speaking.

If I missed something; I try to render them on a RenderTexture (since I also have fullscreen shaders), wich I then draw on the RenderWindow. This works perfectly using Textures and Sprites, but not Shapes unless I decide to draw those perticular Shapes without shaders.

Also I'm drawing Circles and Lines

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
sf::Shape + sf::Shader = Nothing ?
« Reply #1 on: October 14, 2011, 07:50:36 am »
It should work, as long as you remember that shapes have no texture.

Can you show the shader that you use?
Laurent Gomila - SFML developer

Haikarainen

  • Guest
sf::Shape + sf::Shader = Nothing ?
« Reply #2 on: October 14, 2011, 09:56:07 am »
Well that's kinda obvious heh, I should've known since i use gl_TexCoord and such. Full shader is below. I guess it would be possible to cache the shapes into textures by rendering them on a rendertexture?

That'll just leaves the problem with the lines. (I'm actually drawing a path with pathnodes represented as circles, and lines between them)

Code: [Select]
uniform sampler2D screen;
uniform float time;

uniform float divider;


void main(){
   vec2 offset = vec2(cos(time/500+gl_TexCoord[0].x*10)/divider, sin(time/500+gl_TexCoord[0].y*10)/divider);
   gl_FragColor = vec4(texture2D(screen, gl_TexCoord[0].xy+offset));
}