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

Author Topic: Render to texture  (Read 1098 times)

0 Members and 1 Guest are viewing this topic.

Keeeo

  • Newbie
  • *
  • Posts: 4
    • View Profile
Render to texture
« on: February 06, 2015, 06:49:21 pm »
Hello, i would like to render normals into texture. This texture then use in another render cycle and then show result on screen. But i don't know how to handle it with mix of sfml and opengl.

Prep:
To do this, i will need: sf::RenderWindow to display result, sf::RenderTexture to save normal texture and two sf::shaders (normalShader and renderShader).

First: How should the code look like? I couldn't find any source on this :-/
normalTexture.activate(true);
normalShader.bind();

glBindVertexArray(vertexArrayID);
glDrawElements(GL_TRIANGLES, count, GL_UNSIGNED_INT, 0); // this line will throw exception*
glBindVertexArray(0);

normalTexture.display();
normalTexture.activate(false);

Second: If i would like to render into multiple textures at once, is it possible? Theres no place to select it.

*because this renderTarget was not active when i created VAOs and BOs. So do I have to create these things twice?

As long as everything happens in the same OpenGL context, you shouldn't have to call glFlush. sf::RenderTarget calls it because the target has its own separate context...
Well that explains why i cant use VAOs there.
« Last Edit: February 07, 2015, 06:14:50 pm by Keeeo »

 

anything