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

Author Topic: Texture Update memory wierdness  (Read 2461 times)

0 Members and 1 Guest are viewing this topic.

slotdev

  • Sr. Member
  • ****
  • Posts: 385
    • View Profile
Texture Update memory wierdness
« on: April 02, 2014, 01:20:33 pm »
Hi

I've got a strange bug where when I call "update" on a texture, with a pointer to my pixel buffer, then draw the texture, it displays correctly on the target window but *also* displays in stretched & smeared form on another window, positioned directly below the main (target) window.

It seems like a memory problem, or as if the update function is just running over the end of something....

Does anyone have any ideas??

Thanks
Ed
SFML 2.1

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: Texture Update memory wierdness
« Reply #1 on: April 02, 2014, 01:23:11 pm »
What is this other window? Might it be that it doesn't correctly clear and display? For example GUI frameworks render upon events, not constantly. But they usually re-render when getting focus again, to avoid such issues.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

slotdev

  • Sr. Member
  • ****
  • Posts: 385
    • View Profile
Re: Texture Update memory wierdness
« Reply #2 on: April 02, 2014, 01:28:00 pm »
Nexus, its just another SFML window, which is cleared & redrawn every frame in time with the main window.


More background: I use Berkelium, an "off screen" web browser which copies pixel data to a buffer, and then posts a callback telling us the buffer is updated. I then copy this buffer to the SFML texture and display on screen. This works 100% OK but I just get this strange memory problem.
SFML 2.1

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Texture Update memory wierdness
« Reply #3 on: April 02, 2014, 01:56:30 pm »
Would you be able to reproduce the problem in a small and complete example? For example, first remove Berkelium and use a hard-coded array of black pixels (for example). Then see if you can simplify further, until you get something that we can test.
Laurent Gomila - SFML developer

slotdev

  • Sr. Member
  • ****
  • Posts: 385
    • View Profile
Re: Texture Update memory wierdness
« Reply #4 on: April 02, 2014, 04:16:21 pm »
I will do - but more testing with a newer version of SFML does not show this problem, so for this (old) project I am working on, I have to check the difference between the two SFML versions.

EDIT: Do you remember why this line was added (Texture::Update line 1252)

// Make sure that the current texture binding will be preserved
        priv::TextureSaver save;

?
« Last Edit: April 02, 2014, 04:31:52 pm by slotdev »
SFML 2.1

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Texture Update memory wierdness
« Reply #5 on: April 02, 2014, 04:59:51 pm »
Yes. It's to preserve the current texture binding in case the user calls Texture::update in the middle of its own OpenGL calls involving another texture.
Laurent Gomila - SFML developer