SFML community forums

Help => Graphics => Topic started by: Gambit on October 14, 2016, 08:19:28 pm

Title: [solved] OpenGL calls in RenderTarget not working
Post by: Gambit on October 14, 2016, 08:19:28 pm
Hey all.. again.

This is somewhat related to my last post (http://en.sfml-dev.org/forums/index.php?topic=20979.0) where I am trying to render lighting in OpenGL and have it work with SFML.

My LightEngine class has it's own RenderTexture which I'm using to contain all the state required for rendering the lights. Each frame the RenderTexture is activated, VAO is bound and for each light, uniforms are set and elements are drawn. At the end of that, the state is cleaned up and the render window (passed to the LightEngine render function) is set to draw a sprite containing the RenderTexture's Texture. Unfortunately this doesnt work. Instead, I'm presented with a black screen (since the sprite is rendered with multiply blending). If I dont use the RenderTexture it works fine.

Code:
(click to show/hide)

Desired effect: http://i.imgur.com/APbsUNE.png
Images can be downloaded here: https://www.dropbox.com/s/lvd8ztlecwvh4w2/lighting.zip?dl=1

Edit:
Well I fixed it by setting:
glViewport(0, 0, 1024, 768)
In the constructor of LightEngine just after making m_oTex active.
Result: http://i.imgur.com/f3lY8KV.gifv