#include <SFML/Graphics.hpp>
int main()
{
//INITIALIZE WINDOW
int W = 1280; //Screen width
int H = 720; //Screen height
sf::RenderWindow window(sf::VideoMode(W, H), "SFML Project");
//INITIALIZE PIXELS ARRAY
sf::Texture texture;
texture.create(W, H);
sf::Sprite sprite(texture);
sf::Uint8* pixels = new sf::Uint8[W * H * 4]; //Array for the pixels (A,R,G,B)
for (int ir = 0; ir < W * H * 4; ir++) pixels[ir] = 255; //In particular to set Alpha channel to 1.
int color_Red = 0;
int color_Green = 0;
int color_Blue = 0;
///MAIN LOOP
sf::Event Event;
while (window.isOpen())
{
//HARDWARE INPUTS
while (window.pollEvent(Event))
[glow=red,2,300]{[/glow]
//if (Event.type == sf::Event::Closed)
// window.close();
[glow=red,2,300]}[/glow]
//GAME LOGIC
//The game logic also provide the color for the pixels, for this example all the screen will be..
color_Red = 150;
color_Green = 120;
color_Blue = 175;
//FILL PIXELS ARRAY
for (int ic = 0; ic < W; ic++)
for (int ir = 0; ir < H; ir++)
{
pixels[4*(ic + ir * W)] = color_Red; //RED
pixels[4*(ic + ir * W) + 1] = color_Green; //GREEN
pixels[4*(ic + ir * W) + 2] = color_Blue; //BLUE
}
//DISPLAY
texture.update(pixels);
window.draw(sprite);
window.display();
}
}
[/size]