Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[V4.1.x] Fix GL_INVALID_ENUM error in CopyTexture #826

Merged
merged 2 commits into from
Aug 4, 2024

Conversation

kblaschke
Copy link
Member

Bumped libprojectM to v4.1.2 as well. Will create a bugfix release as this issue can break integrations checking for GL errors, e.g. GStreamer.

@kblaschke kblaschke added this to the 4.1.2 milestone Jul 12, 2024
@kblaschke kblaschke self-assigned this Jul 12, 2024
Before rendering the first frame, there is no output texture present in a preset, so we can't copy anything and should just skip that step.
void Texture::CreateEmptyTexture()
auto Texture::Empty() const -> bool
{
return m_textureId == 0;
Copy link

@hack-s hack-s Jul 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was considering checking the texture id instead of the target. I ended up checking the target, because that was the value that directly triggered the GL_INVALID_ENUM. Would it be worth it to check both values ?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disregard, just noticed, this is the backport. We should not do anything different here anyways.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

m_target is, except for the volume noise textures, always set to GL_TEXTURE_2D, even if the texture is empty. I think "target" is a misleading name for the texture's dimensionality, but it's how OpenGL calls it.

What triggered the error was actually m_textureId being zero because the actual texture wasn't initialized at the point when it was first used (copying the previous frame texture into the new preset - naturally, there's no previous texture right after init).

@hack-s
Copy link

hack-s commented Jul 13, 2024

Works great!

Copy link
Collaborator

@revmischa revmischa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have anything to add here, don't have much of an idea of what's going on. Adding some comments on the changed lines about why we need these checks or why New instead of Empty is preferable would be grand

@kblaschke
Copy link
Member Author

kblaschke commented Aug 4, 2024

why New instead of Empty is preferable

I took this consideration because the previous name would be misleading now.

"Empty", in the new naming context, means there is no actual texture allocated at all, e.g. the texture object is 0 or "empty", like a nullptr. The CreateNewTexture() function creates a (blank) texture with a valid, non-zero GL texture ID, but the actual object is no longer considered empty, as a black texture is a texture, despite not a hugely useful one.

Hope this clears it up a bit. The Doxygen comments in the header file also reflect this.

@kblaschke kblaschke merged commit 9bc89af into v4.1.x Aug 4, 2024
18 checks passed
@kblaschke kblaschke deleted the v4.1.x-fix-invalid-gl-enum-error branch August 4, 2024 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

4 participants