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 - coolnonis

Pages: [1]
1
Graphics / Re: Texture equality operator
« on: February 11, 2014, 03:52:26 pm »
Thanks for the advice everyone.

I've decided to re-implement my sprite batcher to use shared_ptr address comparisons to check the equality of textures. It works well with my current implementation.

I feel that this is a better solution than modifying the SFML source, which would cause issues if the internal structure of the Texture class was changed.

2
Graphics / Re: Texture equality operator
« on: February 10, 2014, 04:38:03 pm »
Quote
About the same issue: I wish SFML would let us get the m_cacheID(not the GL ID, the internal SFML 64 bit ID), now it's private and RenderTexture/Window are friends. Why not let user get the cache ID too?

Sort of related, do you think I should use the SFML cache ID rather than the GL ID?

Looking at the source code, It looks like the use of the assignment operator causes the object to generate a new cacheID for itself.

Texture& Texture::operator =(const Texture& right)
{
    Texture temp(right);

    std::swap(m_size, temp.m_size);
    std::swap(m_actualSize, temp.m_actualSize);
    std::swap(m_texture, temp.m_texture);
    std::swap(m_isSmooth, temp.m_isSmooth);
    std::swap(m_isRepeated, temp.m_isRepeated);
    std::swap(m_pixelsFlipped, temp.m_pixelsFlipped);
    // New cache ID
    m_cacheId = getUniqueId();

    return *this;
}

I assume that would make it difficult to compare texture equality.

Also, i'm not quite sure if you were being sarcastic there...  :P

3
Graphics / Re: Texture equality operator
« on: February 10, 2014, 04:27:06 pm »
Quote
Not fully sure why, but an equality operator for sf::Texture could have multiple meanings. For example whether it's the same OpenGL resource, or whether it's the same pixels, or ...

I see. Thank you for the swift reply.

In my case, I want to check the equality between two textures in regards to their OpenGL texture ID.

Maybe this will do:

namespace sf
{

bool Texture::operator==(const Texture& other)
{
return (this->m_texture == other.m_texture);
}

}
 

4
Graphics / Texture equality operator
« on: February 10, 2014, 02:54:14 pm »
Hey guys, I was just wondering if there's a specific reason that an equality operator is not implemented for the sf::Texture class. I'm currently writing an OpenGL sprite batcher using sfml textures, but i'd like to implement automatic texture switching.

Is there a reason I shouldn't re-implement the texture class to support the comparison of 2 objects using the internal m_texture ID?

Pages: [1]