Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - thorr

Pages: [1]
1
General / Re: Direct filling the texture buffer
« on: January 16, 2018, 04:58:22 pm »
Thanx a lot!

bg.create(SCR_WIDTH,SCR_HEIGHT);

Now it's work.

2
General / Direct filling the texture buffer
« on: January 16, 2018, 03:21:39 pm »
I'm trying to fill texture buffer with numeric RGBA-values, but that doesn't work, window remains black.

   RenderWindow window(VideoMode(SCR_WIDTH,SCR_HEIGHT),"test");
   
   Texture bg;

   Uint8* pixels = new Uint8[SCR_WIDTH * SCR_HEIGHT * 4];
   
   for(int j=0;j<SCR_HEIGHT;j++)
      for(int i=0;i<SCR_WIDTH;i++)
      {
         pixels[j*SCR_WIDTH*4+i*4]=50;   //red
         pixels[j*SCR_WIDTH*4+i*4+1]=j%255;   // green
         pixels[j*SCR_WIDTH*4+i*4+2]=j%255;   // blue
         pixels[j*SCR_WIDTH*4+i*4+3]=255;// alpha
      }

   bg.update(pixels);
     
   Sprite sprite_bg;
   sprite_bg.setTexture(bg);

   while(window.isOpen()){
      Event e;
      while (window.pollEvent(e))
         if (e.type==Event::Closed)    window.close();
   
      window.draw(sprite_bg);
      window.display();
     
   }

Win7x64, SFML 2.4.2, MinGW 7.2.0

Pages: [1]