1
Graphics / 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 :-/
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?
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);
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.