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

Author Topic: Texture ID Accessor  (Read 10573 times)

0 Members and 1 Guest are viewing this topic.

lolz123

  • Sr. Member
  • ****
  • Posts: 260
    • View Profile
Texture ID Accessor
« on: April 29, 2013, 09:44:29 pm »
Hello,

I cannot seem to find the getTextureID function in the latest version of SFML anymore. Not having this function makes it rather difficult to use SFML with OpenGL. Why not have such an accessor?
Have you heard about the new Cray super computer?  It’s so fast, it executes an infinite loop in 6 seconds.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10801
    • View Profile
    • development blog
    • Email
Re: Texture ID Accessor
« Reply #1 on: April 29, 2013, 10:30:03 pm »
I'm not an expert on the whole OpenGL/SFML thingy, but can't you just use the bind() function?
Also you might want to give a clear example, why it's needed. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Texture ID Accessor
« Reply #2 on: April 29, 2013, 10:36:07 pm »
"anymore"? It has never existed.

The texture ID is almost never necessary, you access the texture properties by binding it (which you can do the bind function) and then calling texture-related functions.

There are also a few threads on this subject, you can do a forum search.
Laurent Gomila - SFML developer

lolz123

  • Sr. Member
  • ****
  • Posts: 260
    • View Profile
Re: Texture ID Accessor
« Reply #3 on: April 29, 2013, 11:23:20 pm »
I thought there was one, I wasn't sure anymore though  :P. Sorry about that!

What if I wanted to use SFML textures as attachments for a framebuffer object? It would be nice if I could use SFML textures for that :)

Also, writing generic OpenGL code and then trying to integrate it with SFML can become more difficult, since you can't feed functions textureIDs anymore.

In addition, being able to get the texture ID makes it easier to find the texture in debugging programs such as gDEBugger.

I just don't see why the function shouldn't exist!
Have you heard about the new Cray super computer?  It’s so fast, it executes an infinite loop in 6 seconds.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Texture ID Accessor
« Reply #4 on: April 29, 2013, 11:51:45 pm »
You have valid points.
Laurent Gomila - SFML developer

lolz123

  • Sr. Member
  • ****
  • Posts: 260
    • View Profile
Re: Texture ID Accessor
« Reply #5 on: May 13, 2013, 12:44:16 am »
So, will this feature be available in future versions? It would be much appreciated!
Have you heard about the new Cray super computer?  It’s so fast, it executes an infinite loop in 6 seconds.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Texture ID Accessor
« Reply #6 on: May 13, 2013, 07:58:14 am »
Maybe :P
Laurent Gomila - SFML developer

Tank

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1486
    • View Profile
    • Blog
    • Email
Re: Texture ID Accessor
« Reply #7 on: May 13, 2013, 08:25:21 am »
I'd need it too, so I can remove this workaround:

sf::Texture::bind( &grass_texture );
glGetIntegerv( GL_TEXTURE_BINDING_2D, &grass_texture_id );

;)

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Texture ID Accessor
« Reply #8 on: May 13, 2013, 08:42:04 am »
What do you do with the ID?
Laurent Gomila - SFML developer

Tank

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1486
    • View Profile
    • Blog
    • Email
Re: Texture ID Accessor
« Reply #9 on: May 13, 2013, 09:14:11 am »
I need the ID for a sampler2D uniform variable in a shader. I use sf::Texture for pure convenience, as it would be perfectly possible to generate the texture myself and load it with sf::Image::getPixelsPtr(). However that also means I can't reuse it with SFML's drawables anymore.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Texture ID Accessor
« Reply #10 on: May 13, 2013, 11:45:49 am »
Why don't you use Shader::setParameter(Texture&)?
Laurent Gomila - SFML developer

Tank

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1486
    • View Profile
    • Blog
    • Email
Re: Texture ID Accessor
« Reply #11 on: May 13, 2013, 11:54:08 am »
Because I don't use SFML for shaders. :)

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Texture ID Accessor
« Reply #12 on: May 13, 2013, 04:40:46 pm »
Why? :P
Laurent Gomila - SFML developer

lolz123

  • Sr. Member
  • ****
  • Posts: 260
    • View Profile
Re: Texture ID Accessor
« Reply #13 on: May 13, 2013, 05:12:01 pm »
While we are at it, I will also propose a method to get the ID for a shader program :).

Unfortunately, the lack of these functions is a reason I still use SDL for 3D  :P. I need these functions for shaders as well. IDK about Tank, but I use my own shader system because SFML doesn't allow you to arbitrarily link uniforms to binding ports, it doesn't have near enough uniform types (especially matrices), and you cannot use UBO's with it (since you cannot get the program ID).
Have you heard about the new Cray super computer?  It’s so fast, it executes an infinite loop in 6 seconds.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Texture ID Accessor
« Reply #14 on: May 13, 2013, 05:24:39 pm »
Look at Tank's code, the workaround is just 2 lines of code... so don't say that your completely blocked because of it ;)
Laurent Gomila - SFML developer

 

anything