We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 4998

Summary: OpenGL renderer doesn't always enable GL_TEXTURE_2D
Product: SDL Reporter: Juha Niemimäki <juha.niemimaki>
Component: renderAssignee: Ryan C. Gordon <icculus>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 Keywords: target-2.0.14
Version: HG 2.1   
Hardware: PowerPC   
OS: AmigaOS   

Description Juha Niemimäki 2020-02-21 08:10:59 UTC
It seems that when SDL_UpdateTexture() is called in a draw loop, GL_TEXTURE_2D gets disabled. This issue may only impact platforms without shaders.

A potential workaround is to add glEnable(data->textype) in SetCopyState:

http://hg.libsdl.org/SDL/file/28fcb5ef7ff1/src/render/opengl/SDL_render_gl.c#l1115

Can be reproduced on Linux when shaders are deactivated.
Comment 1 Ryan C. Gordon 2020-03-20 20:47:32 UTC
So this is cached state, so if we're turning it on and off, we need to check/update:

GL_RenderData::drawstate.texturing

It looks like several places (not just SDL_UpdateTexture) enable and disable it. This is likely a holdover from before we were aggressively caching state.

I need to go back and read up on the legacy rules of GL_TEXTURE_2D...I suspect we don't need to enable it every time we bind a texture, but only when drawing with one, which would mean the correct thing to do is remove all these enable/disable calls outside of the one in SetDrawState().

--ryan.
Comment 2 Ryan C. Gordon 2020-03-22 18:34:03 UTC
Ok, this is fixed by https://hg.libsdl.org/SDL/rev/1c73cc1e4a3a ...we don't need to enable GL_TEXTURE_* to change texture state, just to enable texturing during rendering.

--ryan.