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 1718

Summary: SDL_GL_BindTexture() doesn't allow selection of active texture unit
Product: SDL Reporter: Denis Washington <denisw>
Component: videoAssignee: Sam Lantinga <slouken>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: gabomdq
Version: HG 2.0   
Hardware: x86_64   
OS: Linux   

Description Denis Washington 2013-02-13 05:27:35 UTC
SDL_GL_BindTexture() unconditionally calls glActiveTexture(GL_TEXTURE0), so it is not possible to bind multiple textures at once (e.g. for shaders with multiple texture inputs). It would be nice if there were an SDL_GL_BindTextureEx() function where a texture unit constant could be passed, or if that would be added to SDL_GL_BindTexture() itself.
Comment 1 Gabriel Jacobo 2013-02-13 06:32:20 UTC
I agree that SDL_GL_BindTexture functionality can be expanded...minimal as it is now, I barely got it through Sam's "no bloat" filter :)

But if more people start using this functionality (you are the third person besides me I've seen interested in these functions), we can certainly expand it (and add something to reset SDL to a known rendering state externally as well, something which currently is not possible)
Comment 2 Denis Washington 2013-02-14 01:15:03 UTC
It would be really useful. In my application I am rendering by using OpenGL ES 2.0 directly, but I rely on SDL_CreateTextureFromSurface() so that I don't have to do the conversion of an SDL_Surface to a GLES2 texture myself. For this use case, it would be handy if I could do anything with an SDL_Texture that I can do with a GL texture handle.

A simple alternative solution that minimizes bloat would be to have something like SDL_GL_GetTextureHandle() that directly returns the native GL texture ID, so that you can pass it to glBindTexture() etc. yourself.
Comment 3 Sam Lantinga 2013-03-04 00:57:39 UTC
This was just a bug with the OpenGL ES 2.0 renderer.  The other OpenGL renderers don't bind a texture unit, for this reason.

Fixed, thanks!
http://hg.libsdl.org/SDL/rev/a3ebd92ff0b2