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

Author Topic: GL_INVALID_OPERATION messages pop up when loading textures.  (Read 2162 times)

0 Members and 1 Guest are viewing this topic.

Sh3xe

  • Newbie
  • *
  • Posts: 2
    • View Profile
GL_INVALID_OPERATION messages pop up when loading textures.
« on: February 23, 2020, 07:05:44 am »
Hello!

I've been working on a simple map editor, and I have this "loadTexture" function, the problem is that when I call it, I have this that pops up hundreds of times in my console:

(click to show/hide)

Here is my loadTexture function:
(click to show/hide)

and my levelEditor class:
(click to show/hide)

I tried to remove the " this->texture_vector.push_back(texture);" and when I do that, I no longer have the message. I also tried to reproduce in another sfml file the same thing:
a class with a std::vector<sf::Texture> and the same function, and everything works fine.

Thank you in advance for your answer because I really don't know what to do right now.

Mortal

  • Sr. Member
  • ****
  • Posts: 284
    • View Profile
Re: GL_INVALID_OPERATION messages pop up when loading textures.
« Reply #1 on: February 23, 2020, 05:16:47 pm »
what SFML version do you use? i remember that the "glFlush()" were removed!!.

also, there is a potential bug in "loadTextures()", the sf::Texture object has tobe inside the nested for-loops. try to change it and see what gonna happen.

fallahn

  • Hero Member
  • *****
  • Posts: 507
  • Buns.
    • View Profile
    • Trederia
Re: GL_INVALID_OPERATION messages pop up when loading textures.
« Reply #2 on: February 23, 2020, 05:40:38 pm »
It's probably caused when the textures get copied, which happen at the very least when you push back a texture into the vector, and also internally to the vector every time it resizes (which will get worse the bigger the vector gets). Storing a texture in a vector is also very prone to the white square problem. Consider perhaps using a vector of std::unique_ptr or maybe even some sort of resource holder such as this or this.

Sh3xe

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: GL_INVALID_OPERATION messages pop up when loading textures.
« Reply #3 on: February 23, 2020, 05:47:35 pm »
what SFML version do you use? i remember that the "glFlush()" were removed!!.

also, there is a potential bug in "loadTextures()", the sf::Texture object has tobe inside the nested for-loops. try to change it and see what gonna happen.
I am using SFML 2.5.1. I tried and It didn't worked. Also I did the same thing in another sfml program (same function and image) and it worked :/

It's probably caused when the textures get copied, which happen at the very least when you push back a texture into the vector, and also internally to the vector every time it resizes (which will get worse the bigger the vector gets). Storing a texture in a vector is also very prone to the white square problem. Consider perhaps using a vector of std::unique_ptr or maybe even some sort of resource holder such as this or this.
Ok i'll try

 

anything