7
« on: November 12, 2020, 08:15:39 am »
Hi all !
I've started working with the SFML again after years of not touching it...
So i'm working on a small raycasting engine and was wondering what was the correct method for drawing stuff in the window...
Specifically, i need to access and modify the individual pixels of the image to write the correct color in there and then draw that image on the window.
Additionally, i'd like being able to use only a portion of the screen for that view, no matter the actual resolution of the window (bigger than the play screen which will be either 320x240 or 640x480 for the oldschool feel).
Right now here's how i'm doing things:
buffer is a sf::Image
drawBuffer is a sf::Texture
spriteBuffer is a sf::Sprite
For each pixel on the game screen, i'm setting the color (after getting it from the texture) with
buffer.setPixel(x,y, color);
then when it's done
drawBuffer.loadFromImage(buffer);
spriteBuffer.setTexture(drawBuffer);
window->draw(spriteBuffer);
I'm pretty sure that's not ideal (especially since my basic engine isn't very computation heavy and it's too slow right now) so i'd like to know how to improve this.
Thanks!