I don't know if it's a bug of opengl or of SFML, but, when I draw with opengl on a renderwindow. (I mean by using the functions glVertexAttribPointer and the corresponding attribute location in the shaders) it works but when I want to draw it on a rendertexture, it doesn't draw anything!
Here it's a source code :
int main(void)
{
odfaeg::RenderWindow window(sf::VideoMode(800, 600), "Test odfaeg");
odfaeg::RenderTexture rTex;
rTex.create(800, 600);
odfaeg::Shader shader;
const std::string vertexCode =
"attribute vec3 vertexPosition_modelspace;"
"attribute vec4 vertex_color;"
"void main() {"
"vec4 vertex = vec4(vertexPosition_modelspace.xyz, 1.0f);"
"gl_Position = gl_ModelViewProjectionMatrix * vertex;"
"gl_FrontColor = vertex_color;"
"}";
const std::string fragmentCode =
"void main() {"
"gl_FragColor = gl_Color;"
"}";
shader.loadFromMemory(vertexCode, fragmentCode);
shader.bindAttribute(0, "vertexPosition_modelspace");
shader.bindAttribute(1, "vertex_color");
odfaeg::Texture tex;
tex.loadFromFile("tilesets/herbe.png");
Tile tile(&tex, Vec2f(0, 0), Vec2f(120, 60), IntRect(0, 0, 100, 50));
while (window.isOpen()) {
sf::Event event;
while (window.pollEvent(event)) {
if (event.type == sf::Event::Closed)
window.close();
}
odfaeg::RenderStates states;
states.shader = &shader;
window.clear();
rTex.clear();
rTex.draw(tile, states);
rTex.display();
odfaeg::Texture tex2 = rTex.getTexture();
Tile tile2 (&tex2, Vec2f(0, 0), Vec2f(800, 600), IntRect(0, 0, 800, 600));
window.draw(tile2);
window.display();
}
return 0;
}