SFML community forums

General => Feature requests => Topic started by: Lolilolight on March 02, 2014, 07:12:53 pm

Title: Get access to the cache_id in the Texture class and other attributes.
Post by: Lolilolight on March 02, 2014, 07:12:53 pm
Hi,

SFML don't allow us to display 3D objects, so, I've re-create the classes RenderTarget, RenderWindow, Vertex, VertexArray, ..., which can display 3D objects.

And I didn't want to modify SFML. (because if the SFML version change I'll have to modify all again)

It's why I've recreate similar classes for the 3D.

But I had to modify a little thing in the sfml source code, this is the m_cacheId, in the sf::Texture class.

Because the m_cacheId and some other attributes are private, so, I've moved them into the public part of the sf::Texture class otherwise only the friend class sf::RenderTarget can access to them.

Otherwise this is very nice that the SFML classes encapsulate the opengl code.

Shaders and textures becomes very more simple to implement. (This is why I keep using sfml even for the 3D)





Title: Re: Get access to the cache_id in the Texture class and other attributes.
Post by: Nexus on March 02, 2014, 07:48:02 pm
The m_cacheId is an implementation detail used for an internal optimization (the render target cache). This member has no meaning in the public API and therefore won't be exposed.
Title: Re: Get access to the cache_id in the Texture class and other attributes.
Post by: Lolilolight on March 03, 2014, 09:56:10 am
Ok I had to make another change to increment the cacheId of the Texture in my own class RenderTarget : (And put this into the sf namespace)
namespace sf
{
    static sf::Uint64 getUniqueId()
    {
        static sf::Uint64 id = 1; // start at 1, zero is "no texture"
        static sf::Mutex mutex;
        sf::Lock lock(mutex);
        return id++;
    }
 

Otherwise it doesn't increment the m_cacheId.