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

Author Topic: Can't construct a Texture object from another Texture object?  (Read 2025 times)

0 Members and 1 Guest are viewing this topic.

Grime

  • Newbie
  • *
  • Posts: 13
    • View Profile
Can't construct a Texture object from another Texture object?
« 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) };
 

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Can't construct a Texture object from another Texture object?
« Reply #1 on: August 15, 2019, 07:25:59 pm »
Is this done at global scope?
Laurent Gomila - SFML developer

binary1248

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1405
  • I am awesome.
    • View Profile
    • The server that really shouldn't be running
Re: Can't construct a Texture object from another Texture object?
« Reply #2 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.
SFGUI # SFNUL # GLS # Wyrm <- Why do I waste my time on such a useless project? Because I am awesome (first meaning).

Grime

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Can't construct a Texture object from another Texture object?
« Reply #3 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 . . .

binary1248

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1405
  • I am awesome.
    • View Profile
    • The server that really shouldn't be running
Re: Can't construct a Texture object from another Texture object?
« Reply #4 on: August 30, 2019, 11:12:47 pm »
This should be fixed with PR #1609

Thanks for reporting this.
SFGUI # SFNUL # GLS # Wyrm <- Why do I waste my time on such a useless project? Because I am awesome (first meaning).

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10801
    • View Profile
    • development blog
    • Email
Re: Can't construct a Texture object from another Texture object?
« Reply #5 on: September 04, 2019, 03:27:09 pm »
Pull request has been merged :)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything