Hi, it's me again.
My previous problem was solved, but I continued my project, I found another problem and I can't find any solution.
The question is, I want to draw my pixel matrix and then over this drawing I want to draw some objects (sprites). But that doens't seem to work.
I made another minimal example to show what I mean:
int main() {
const int H = 500;
const int W = 1000;
sf::RenderTexture RT;
RT.create(W, H);
sf::RenderWindow window(sf::VideoMode(W, H, 32), "Test");
//Creates the sf::Vertex matrix
sf::Vertex **pixMat = new sf::Vertex*[H];
for (int i=0;i<H;++i)
pixMat[i] = new sf::Vertex[W];
//Fills the matrix with blue pixels
for (int i=0;i<H;++i) {
for (int j=0;j<W;++j)
pixMat[i][j] = sf::Vertex(sf::Vector2f(j+.5f, i+.5f), sf::Color::Blue);
}
//Loads the texture and creates the sf::Sprite we want to draw
sf::Texture tex;
tex.loadFromFile("pleasedosomequickdrawonpaint.png");
sf::Sprite whatever(tex);
whatever.setPosition(W/2, H/2);
while (window.isOpen()) {
sf::Event event;
while (window.pollEvent(event)) {
if (event.type == sf::Event::Closed)
window.close();
}
//Draws the pixel matrix
for (int i=0;i<H;++i)
RT.draw(pixMat[i], W, sf::Points);
//THIS IS WHAT DOESNT WORK
RT.draw(whatever);
//And finally draws the RenderTexture to the RenderWindow
RT.display();
window.draw(sf::Sprite(RT.getTexture()));
window.display();
}
}
The drawn sprite is not shown correctly. But I tried to change the sf::Sprite for something else, like a sf::RectangleShape, and it works. The problem seems to be the Sprite.
Thank you very much.