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

Author Topic: Explanation on SFML textures  (Read 1996 times)

0 Members and 1 Guest are viewing this topic.

Grimshaw

  • Hero Member
  • *****
  • Posts: 631
  • Nephilim SDK
    • View Profile
Explanation on SFML textures
« on: February 21, 2011, 01:26:49 am »
I've ran into this problem:

I have a regular sprite, to which i changed alpha with SetColor()

I have some other drawing code which binds another texture in opengl, which screws up the sfml rendering of the sprite.

To prevent this, i used glGet to save the current texture before the custom drawing code. And restored that texture with glBindTexture after it.

This worked, and both drawing code and sfml are rendering correctly, except the texture has full alpha again( color 255,255,255,255 ).

What happened to my custom color, and how to restore it?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Explanation on SFML textures
« Reply #1 on: February 21, 2011, 07:51:18 am »
You should rather use the dedicated SFML functions:
- PreserveOpenGLStates (1.6)
- SaveGLStates / RestoreGLStates (2.0)
Laurent Gomila - SFML developer

Grimshaw

  • Hero Member
  • *****
  • Posts: 631
  • Nephilim SDK
    • View Profile
Explanation on SFML textures
« Reply #2 on: February 21, 2011, 03:48:23 pm »
Okay, i will only be calling that once per frame, but still, i don't win performance with my way? : )

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Explanation on SFML textures
« Reply #3 on: February 21, 2011, 04:15:04 pm »
You do, but it's probably not worth the effort.
Laurent Gomila - SFML developer