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 4757

Summary: SDL_GL_BindTexture behaves differently on GL3 and GLES
Product: SDL Reporter: Malte Kießling <mkalte>
Component: renderAssignee: Sam Lantinga <slouken>
Status: NEW --- QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2    
Version: HG 2.1   
Hardware: x86_64   
OS: Linux   
Attachments: patch idea

Description Malte Kießling 2019-08-08 18:17:44 UTC
The Implementations of SDL_GL_BindTexture have different behaviour depending on the selected renderer. 

For the GL renderer, depending on the type (yuv or not), either 3 or one texture is bound. The different texture units are also only selected when it is a yuv texture. Otherwise, i assume, the caller is responsible for that. 

Both GLES1 and GLES2 only bind a single texture target. This is interesting, as the GLES2 renderer has support for yuv textures, but does not bind them when using GLES2_BindTexture. It does bind them on a yuv render. 

As pointed out in bug 3286, this is quite inconsistent. 

For the future i would suggest functions that return information (gl texture id?) of the texture type and number of hardware textures used. 

Maybe something akin to 

    int SDL_GL_GetTextureIDs(SDL_Texture* texture, int* count, Uint32** dst); 

would help, and let the user bind it. Or seperate it, like for the update functions. 
    int SDL_GL_BindTexture(SDL_Texture* texture, float* w, float* h);
    int SDL_GL_BindTextureYUV(SDL_Texture* texture, float* w, float* h);
    int SDL_GL_GetTextureID(SDL_Texture* texture, int* dst);
    int SDL_GL_GetTextureIDYUV(SDL_Texture* texture, Uint32* y, Uint32* u, Uint32* v);
    

These are just ideas. Id be willing to try my hand at implementing something akin to this, if its generally wanted. 

Having access to the underlying driver data for textures in general is nice when interacting with 3rd party libraries. Im not at home in direct x, but i would think that it would help there, too. 
(In my case, the current implementation of imgui expects a texture id for drawing images, and integrating imgui with renderer things in general is a tad messy right now). 

Have a nice week!
~mkalte
Comment 1 Malte Kießling 2019-08-09 20:46:14 UTC
Created attachment 3924 [details]
patch idea

I have written some stuff to show what kind of functionality i thought of when writing this report. 

This isn't tested and there likely is more to add and improve.