SFML community forums

Help => Graphics => Topic started by: Grime on August 15, 2019, 02:24:30 pm

Title: Can't construct a Texture object from another Texture object?
Post by: Grime on August 15, 2019, 02:24:30 pm
The documentation doesn't seem to have a mention about this so I'm wondering if this is normal.

I get the error:
An internal OpenGL call failed in Texture.cpp(98).
Expression:
   glFlush()
Error description:
   GL_INVALID_OPERATION
   The specified operation is not allowed in the current state.


When I try to construct a Texture object from another Texture object with loaded texture.
        sf::Texture temp1;
        temp.loadFromFile(image_location);
        sf::Texture player_texture{ temp };

No error if the texture object doesn't have a loaded texture already
        sf::Texture temp1;
        sf::Texture player_texture{ temp };
But of course this serves no purpose.


My original intent was to do this:
sf::Texture texture_initialize(std::string location) {
        sf::Texture texture;
        texture.loadFromFile(location);
        return texture;
}

--> inside a function:
        sf::Texture player_texture{ texture_initialize(image_location) };
 
Title: Re: Can't construct a Texture object from another Texture object?
Post by: Laurent on August 15, 2019, 07:25:59 pm
Is this done at global scope?
Title: Re: Can't construct a Texture object from another Texture object?
Post by: binary1248 on August 15, 2019, 11:34:43 pm
It could be that a TransientContextLock lock; is missing before the line that causes the error. A minimal example to reproduce the issue would help to confirm this theory.
Title: Re: Can't construct a Texture object from another Texture object?
Post by: Grime on August 16, 2019, 01:11:41 pm
Here you go:
#include <SFML/Graphics.hpp>
int main() {

        sf::Texture texture;
        texture.loadFromFile(sprite_location);
        sf::Texture new_texture{ texture }; // <-- causes error

        system("pause");
        return 0;
}

I have no idea what TransientContextLock is supposed to be though..  :P

output on console:
An internal OpenGL call failed in Texture.cpp(98).
Expression:
   glFlush()
Error description:
   GL_INVALID_OPERATION
   The specified operation is not allowed in the current state.

Press any key to continue . . .
Title: Re: Can't construct a Texture object from another Texture object?
Post by: binary1248 on August 30, 2019, 11:12:47 pm
This should be fixed with PR #1609 (https://github.com/SFML/SFML/pull/1609)

Thanks for reporting this.
Title: Re: Can't construct a Texture object from another Texture object?
Post by: eXpl0it3r on September 04, 2019, 03:27:09 pm
Pull request has been merged :)