SFML community forums

Help => General => Topic started by: wierdgreencat on September 16, 2022, 01:49:56 pm

Title: Help to understand why only half of the screen is painted over.
Post by: wierdgreencat on September 16, 2022, 01:49:56 pm
A little more than half the screen is painted over.
but i think it should draw the whole screen.
Windows 10
MINGW W64 9.0
commit/3a3935d00569c5cf3dbd684ab10e54e8480df167

#include <SFML/Graphics.hpp>

int main()
{
  sf::RenderWindow window(sf::VideoMode({64, 32}), "SFML works!");


  sf::Texture texture;
  sf::Sprite sprite;

  if (!texture.create({64,32})) throw "";
  sprite.setTexture(texture);

  while (window.isOpen())
  {
    sf::Event event;
    while (window.pollEvent(event))
    {
      if (event.type == sf::Event::Closed)
        window.close();
    }

    uint32_t sfml_pixel_buffer[32 * 64];
    static int a= 0x00FFAADD;

    for(int i = 0; i < 32*64; ++i){
      sfml_pixel_buffer[i] = a;
    }a+= 0xFFFF;

    texture.update(reinterpret_cast<uint8_t *>(&sfml_pixel_buffer[0]));

    window.clear();
    window.draw(sprite);
    window.display();
  }
Title: Re: Help to understand why only half of the screen is painted over.
Post by: eXpl0it3r on September 19, 2022, 01:06:45 pm
Is the window actually 64 pixel wide?

Lots of OS/Window Manage will have a minimum size for a window.
Title: Re: Help to understand why only half of the screen is painted over.
Post by: wierdgreencat on September 19, 2022, 02:55:27 pm
yes you are right the window was 2 times wider. thanks