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

Author Topic: sf::RenderWindow and resetGLStates()  (Read 2774 times)

0 Members and 1 Guest are viewing this topic.

Sajmon

  • Newbie
  • *
  • Posts: 16
    • View Profile
sf::RenderWindow and resetGLStates()
« on: April 19, 2018, 06:32:13 pm »
When I call the function resetGLStates() from the sf::RenderWindow after rendering my stuff (First SFML and then my OpenGL stuff.)

I get this error:

An internal OpenGL call failed in RenderTarget.cpp(369).
Expression:
   GLEXT_glClientActiveTexture(GLEXT_GL_TEXTURE0)
Error description:
   GL_INVALID_OPERATION
   The specified operation is not allowed in the current state.

The visuals are correct, so there's nothing visually wrong at least.
But the error constantly pops up in the console. It's bugging me.

Here's the link to the actual line of the error in SFML's code.

https://github.com/SFML/SFML/blob/2cd479755732fc048322f9759aa4af0c7ea76e7a/src/SFML/Graphics/RenderTarget.cpp#L502

The error doesn't make any sense at all.

And according to the OpenGL docs; https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/glClientActiveTexture.xml, the function can't even give the INVALID_OPERATION error. So what's up with that?

I'm not even using multiple textures.

Gahhhhhh.

Help?  :'(

 - S



« Last Edit: April 19, 2018, 06:36:53 pm by Sajmon »

Sajmon

  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: sf::RenderWindow and resetGLStates()
« Reply #1 on: April 19, 2018, 06:42:38 pm »
Oh. It got nothing to do with that line specificly. It's the first row that calls glCheck..

Hmm.

I'll be back.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: sf::RenderWindow and resetGLStates()
« Reply #2 on: April 19, 2018, 07:11:37 pm »
What SFML version do you use? master?
Do you reset your states yourself? SFML only knows OpenGL 2.1 states.
What's your code?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Sajmon

  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: sf::RenderWindow and resetGLStates()
« Reply #3 on: April 19, 2018, 07:39:44 pm »
Nah, I'm using 2.4.2.

I can't really show the specific code, because It's a pretty large project, and I don't know the real cause of it.
But it might have something to do with the shader, it might not get reset correctly.

This is the code for when I end my OpenGL shader execution and I'm resetting the things as they were before using the shader.

    void End()
    {
        // Closing up vertex attributes channels
        for (unsigned int i = 0; i < AttributeChannels; i++)
            glDisableVertexAttribArray(i);

        // Setting previous values
        glUseProgram(PrevValues.ProgramID);
        glBindVertexArray(PrevValues.VertexArray);
        glBindBuffer(GL_ARRAY_BUFFER, PrevValues.VertexBuffer);
        glClientActiveTexture(PrevValues.ClientTexture);

        // Setting previous blending
        if (PrevValues.BlendUsed)
        {
            if (PrevValues.BlendOn) glEnable(GL_BLEND);
            else                    glDisable(GL_BLEND);
            glBlendFunc(PrevValues.SRC_Alpha | PrevValues.SRC_RGB,
                        PrevValues.DST_Alpha | PrevValues.DST_RGB);
            PrevValues.BlendUsed = false;
        }
    }

After this, some time later.
I call ImGui::SFML::Render();
Which inside calls the resetGLStates();
Which gives the error on the first glCheck() execution. (Not connected to the multitexture thing)

So is the problem that the first actual glGetError() function produces the error?
Or I'm just getting it wrong?

So are any of these states not compatible with SFML?
« Last Edit: April 19, 2018, 09:36:16 pm by eXpl0it3r »

binary1248

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1405
  • I am awesome.
    • View Profile
    • The server that really shouldn't be running
Re: sf::RenderWindow and resetGLStates()
« Reply #4 on: April 20, 2018, 08:47:05 pm »
Why aren't you checking for errors after every OpenGL function you call?
SFGUI # SFNUL # GLS # Wyrm <- Why do I waste my time on such a useless project? Because I am awesome (first meaning).