mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-05-09 01:14:24 +02:00
Removed SDL_GL_BindTexture() and SDL_GL_UnbindTexture()
Now that we have the OpenGL texture properties, you can directly bind them yourself. Fixes https://github.com/libsdl-org/SDL/issues/2124
This commit is contained in:
@@ -110,7 +110,6 @@ SDL3_0.0.0 {
|
||||
SDL_FlushRenderer;
|
||||
SDL_GDKGetTaskQueue;
|
||||
SDL_GDKSuspendComplete;
|
||||
SDL_GL_BindTexture;
|
||||
SDL_GL_CreateContext;
|
||||
SDL_GL_DeleteContext;
|
||||
SDL_GL_ExtensionSupported;
|
||||
@@ -125,7 +124,6 @@ SDL3_0.0.0 {
|
||||
SDL_GL_SetAttribute;
|
||||
SDL_GL_SetSwapInterval;
|
||||
SDL_GL_SwapWindow;
|
||||
SDL_GL_UnbindTexture;
|
||||
SDL_GL_UnloadLibrary;
|
||||
SDL_GUIDFromString;
|
||||
SDL_GUIDToString;
|
||||
|
||||
@@ -134,7 +134,6 @@
|
||||
#define SDL_FlushRenderer SDL_FlushRenderer_REAL
|
||||
#define SDL_GDKGetTaskQueue SDL_GDKGetTaskQueue_REAL
|
||||
#define SDL_GDKSuspendComplete SDL_GDKSuspendComplete_REAL
|
||||
#define SDL_GL_BindTexture SDL_GL_BindTexture_REAL
|
||||
#define SDL_GL_CreateContext SDL_GL_CreateContext_REAL
|
||||
#define SDL_GL_DeleteContext SDL_GL_DeleteContext_REAL
|
||||
#define SDL_GL_ExtensionSupported SDL_GL_ExtensionSupported_REAL
|
||||
@@ -149,7 +148,6 @@
|
||||
#define SDL_GL_SetAttribute SDL_GL_SetAttribute_REAL
|
||||
#define SDL_GL_SetSwapInterval SDL_GL_SetSwapInterval_REAL
|
||||
#define SDL_GL_SwapWindow SDL_GL_SwapWindow_REAL
|
||||
#define SDL_GL_UnbindTexture SDL_GL_UnbindTexture_REAL
|
||||
#define SDL_GL_UnloadLibrary SDL_GL_UnloadLibrary_REAL
|
||||
#define SDL_GUIDFromString SDL_GUIDFromString_REAL
|
||||
#define SDL_GUIDToString SDL_GUIDToString_REAL
|
||||
|
||||
@@ -194,7 +194,6 @@ SDL_DYNAPI_PROC(int,SDL_FlashWindow,(SDL_Window *a, SDL_FlashOperation b),(a,b),
|
||||
SDL_DYNAPI_PROC(void,SDL_FlushEvent,(Uint32 a),(a),)
|
||||
SDL_DYNAPI_PROC(void,SDL_FlushEvents,(Uint32 a, Uint32 b),(a,b),)
|
||||
SDL_DYNAPI_PROC(int,SDL_FlushRenderer,(SDL_Renderer *a),(a),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_GL_BindTexture,(SDL_Texture *a, float *b, float *c),(a,b,c),return)
|
||||
SDL_DYNAPI_PROC(SDL_GLContext,SDL_GL_CreateContext,(SDL_Window *a),(a),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_GL_DeleteContext,(SDL_GLContext a),(a),return)
|
||||
SDL_DYNAPI_PROC(SDL_bool,SDL_GL_ExtensionSupported,(const char *a),(a),return)
|
||||
@@ -209,7 +208,6 @@ SDL_DYNAPI_PROC(void,SDL_GL_ResetAttributes,(void),(),)
|
||||
SDL_DYNAPI_PROC(int,SDL_GL_SetAttribute,(SDL_GLattr a, int b),(a,b),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_GL_SetSwapInterval,(int a),(a),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_GL_SwapWindow,(SDL_Window *a),(a),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_GL_UnbindTexture,(SDL_Texture *a),(a),return)
|
||||
SDL_DYNAPI_PROC(void,SDL_GL_UnloadLibrary,(void),(),)
|
||||
SDL_DYNAPI_PROC(SDL_GUID,SDL_GUIDFromString,(const char *a),(a),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_GUIDToString,(SDL_GUID a, char *b, int c),(a,b,c),return)
|
||||
|
||||
@@ -4153,38 +4153,6 @@ void SDL_DestroyRenderer(SDL_Renderer *renderer)
|
||||
renderer->DestroyRenderer(renderer);
|
||||
}
|
||||
|
||||
int SDL_GL_BindTexture(SDL_Texture *texture, float *texw, float *texh)
|
||||
{
|
||||
SDL_Renderer *renderer;
|
||||
|
||||
CHECK_TEXTURE_MAGIC(texture, -1);
|
||||
renderer = texture->renderer;
|
||||
if (texture->native) {
|
||||
return SDL_GL_BindTexture(texture->native, texw, texh);
|
||||
} else if (renderer && renderer->GL_BindTexture) {
|
||||
FlushRenderCommandsIfTextureNeeded(texture); /* in case the app is going to mess with it. */
|
||||
return renderer->GL_BindTexture(renderer, texture, texw, texh);
|
||||
} else {
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
}
|
||||
|
||||
int SDL_GL_UnbindTexture(SDL_Texture *texture)
|
||||
{
|
||||
SDL_Renderer *renderer;
|
||||
|
||||
CHECK_TEXTURE_MAGIC(texture, -1);
|
||||
renderer = texture->renderer;
|
||||
if (texture->native) {
|
||||
return SDL_GL_UnbindTexture(texture->native);
|
||||
} else if (renderer && renderer->GL_UnbindTexture) {
|
||||
FlushRenderCommandsIfTextureNeeded(texture); /* in case the app messed with it. */
|
||||
return renderer->GL_UnbindTexture(renderer, texture);
|
||||
}
|
||||
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
void *SDL_GetRenderMetalLayer(SDL_Renderer *renderer)
|
||||
{
|
||||
CHECK_RENDERER_MAGIC(renderer, NULL);
|
||||
|
||||
@@ -209,9 +209,6 @@ struct SDL_Renderer
|
||||
|
||||
int (*SetVSync)(SDL_Renderer *renderer, int vsync);
|
||||
|
||||
int (*GL_BindTexture)(SDL_Renderer *renderer, SDL_Texture *texture, float *texw, float *texh);
|
||||
int (*GL_UnbindTexture)(SDL_Renderer *renderer, SDL_Texture *texture);
|
||||
|
||||
void *(*GetMetalLayer)(SDL_Renderer *renderer);
|
||||
void *(*GetMetalCommandEncoder)(SDL_Renderer *renderer);
|
||||
|
||||
|
||||
@@ -1145,7 +1145,7 @@ static int SetDrawState(GL_RenderData *data, const SDL_RenderCommand *cmd, const
|
||||
}
|
||||
|
||||
/* This is a little awkward but should avoid texcoord arrays getting into
|
||||
a bad state if SDL_GL_BindTexture/UnbindTexture are called. */
|
||||
a bad state if the application is manually binding textures */
|
||||
if (texture_array != data->drawstate.texture_array) {
|
||||
if (texture_array) {
|
||||
data->glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
@@ -1610,105 +1610,6 @@ static void GL_DestroyRenderer(SDL_Renderer *renderer)
|
||||
SDL_free(renderer);
|
||||
}
|
||||
|
||||
static int GL_BindTexture(SDL_Renderer *renderer, SDL_Texture *texture, float *texw, float *texh)
|
||||
{
|
||||
GL_RenderData *data = (GL_RenderData *)renderer->driverdata;
|
||||
GL_TextureData *texturedata = (GL_TextureData *)texture->driverdata;
|
||||
const GLenum textype = data->textype;
|
||||
|
||||
GL_ActivateRenderer(renderer);
|
||||
|
||||
data->glEnable(textype);
|
||||
#if SDL_HAVE_YUV
|
||||
if (texturedata->yuv) {
|
||||
if (data->GL_ARB_multitexture_supported) {
|
||||
data->glActiveTextureARB(GL_TEXTURE2_ARB);
|
||||
}
|
||||
data->glBindTexture(textype, texturedata->vtexture);
|
||||
|
||||
if (data->GL_ARB_multitexture_supported) {
|
||||
data->glActiveTextureARB(GL_TEXTURE1_ARB);
|
||||
}
|
||||
data->glBindTexture(textype, texturedata->utexture);
|
||||
|
||||
if (data->GL_ARB_multitexture_supported) {
|
||||
data->glActiveTextureARB(GL_TEXTURE0_ARB);
|
||||
}
|
||||
}
|
||||
if (texturedata->nv12) {
|
||||
if (data->GL_ARB_multitexture_supported) {
|
||||
data->glActiveTextureARB(GL_TEXTURE1_ARB);
|
||||
}
|
||||
data->glBindTexture(textype, texturedata->utexture);
|
||||
|
||||
if (data->GL_ARB_multitexture_supported) {
|
||||
data->glActiveTextureARB(GL_TEXTURE0_ARB);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
data->glBindTexture(textype, texturedata->texture);
|
||||
|
||||
data->drawstate.texturing = SDL_TRUE;
|
||||
data->drawstate.texture = texture;
|
||||
|
||||
if (texw) {
|
||||
*texw = (float)texturedata->texw;
|
||||
}
|
||||
if (texh) {
|
||||
*texh = (float)texturedata->texh;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int GL_UnbindTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
{
|
||||
GL_RenderData *data = (GL_RenderData *)renderer->driverdata;
|
||||
const GLenum textype = data->textype;
|
||||
#if SDL_HAVE_YUV
|
||||
GL_TextureData *texturedata = (GL_TextureData *)texture->driverdata;
|
||||
#endif
|
||||
|
||||
GL_ActivateRenderer(renderer);
|
||||
|
||||
#if SDL_HAVE_YUV
|
||||
if (texturedata->yuv) {
|
||||
if (data->GL_ARB_multitexture_supported) {
|
||||
data->glActiveTextureARB(GL_TEXTURE2_ARB);
|
||||
}
|
||||
data->glBindTexture(textype, 0);
|
||||
data->glDisable(textype);
|
||||
|
||||
if (data->GL_ARB_multitexture_supported) {
|
||||
data->glActiveTextureARB(GL_TEXTURE1_ARB);
|
||||
}
|
||||
data->glBindTexture(textype, 0);
|
||||
data->glDisable(textype);
|
||||
|
||||
if (data->GL_ARB_multitexture_supported) {
|
||||
data->glActiveTextureARB(GL_TEXTURE0_ARB);
|
||||
}
|
||||
}
|
||||
if (texturedata->nv12) {
|
||||
if (data->GL_ARB_multitexture_supported) {
|
||||
data->glActiveTextureARB(GL_TEXTURE1_ARB);
|
||||
}
|
||||
data->glBindTexture(textype, 0);
|
||||
data->glDisable(textype);
|
||||
|
||||
if (data->GL_ARB_multitexture_supported) {
|
||||
data->glActiveTextureARB(GL_TEXTURE0_ARB);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
data->glBindTexture(textype, 0);
|
||||
data->glDisable(textype);
|
||||
|
||||
data->drawstate.texturing = SDL_FALSE;
|
||||
data->drawstate.texture = NULL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int GL_SetVSync(SDL_Renderer *renderer, const int vsync)
|
||||
{
|
||||
int retval;
|
||||
@@ -1828,8 +1729,6 @@ static SDL_Renderer *GL_CreateRenderer(SDL_Window *window, SDL_PropertiesID crea
|
||||
renderer->DestroyTexture = GL_DestroyTexture;
|
||||
renderer->DestroyRenderer = GL_DestroyRenderer;
|
||||
renderer->SetVSync = GL_SetVSync;
|
||||
renderer->GL_BindTexture = GL_BindTexture;
|
||||
renderer->GL_UnbindTexture = GL_UnbindTexture;
|
||||
renderer->info = GL_RenderDriver.info;
|
||||
renderer->info.flags = 0; /* will set some flags below. */
|
||||
renderer->driverdata = data;
|
||||
|
||||
@@ -2013,57 +2013,6 @@ static int GLES2_SetVSync(SDL_Renderer *renderer, const int vsync)
|
||||
return retval;
|
||||
}
|
||||
|
||||
/*************************************************************************************************
|
||||
* Bind/unbinding of textures
|
||||
*************************************************************************************************/
|
||||
static int GLES2_BindTexture(SDL_Renderer *renderer, SDL_Texture *texture, float *texw, float *texh)
|
||||
{
|
||||
GLES2_RenderData *data = (GLES2_RenderData *)renderer->driverdata;
|
||||
GLES2_TextureData *texturedata = (GLES2_TextureData *)texture->driverdata;
|
||||
GLES2_ActivateRenderer(renderer);
|
||||
|
||||
#if SDL_HAVE_YUV
|
||||
if (texturedata->yuv) {
|
||||
data->glActiveTexture(GL_TEXTURE2);
|
||||
data->glBindTexture(texturedata->texture_type, texturedata->texture_v);
|
||||
|
||||
data->glActiveTexture(GL_TEXTURE1);
|
||||
data->glBindTexture(texturedata->texture_type, texturedata->texture_u);
|
||||
|
||||
data->glActiveTexture(GL_TEXTURE0);
|
||||
} else if (texturedata->nv12) {
|
||||
data->glActiveTexture(GL_TEXTURE1);
|
||||
data->glBindTexture(texturedata->texture_type, texturedata->texture_u);
|
||||
|
||||
data->glActiveTexture(GL_TEXTURE0);
|
||||
}
|
||||
#endif
|
||||
|
||||
data->glBindTexture(texturedata->texture_type, texturedata->texture);
|
||||
data->drawstate.texture = texture;
|
||||
|
||||
if (texw) {
|
||||
*texw = 1.0;
|
||||
}
|
||||
if (texh) {
|
||||
*texh = 1.0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int GLES2_UnbindTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
{
|
||||
GLES2_RenderData *data = (GLES2_RenderData *)renderer->driverdata;
|
||||
GLES2_TextureData *texturedata = (GLES2_TextureData *)texture->driverdata;
|
||||
GLES2_ActivateRenderer(renderer);
|
||||
|
||||
data->glBindTexture(texturedata->texture_type, 0);
|
||||
data->drawstate.texture = NULL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*************************************************************************************************
|
||||
* Renderer instantiation *
|
||||
*************************************************************************************************/
|
||||
@@ -2220,8 +2169,6 @@ static SDL_Renderer *GLES2_CreateRenderer(SDL_Window *window, SDL_PropertiesID c
|
||||
renderer->DestroyTexture = GLES2_DestroyTexture;
|
||||
renderer->DestroyRenderer = GLES2_DestroyRenderer;
|
||||
renderer->SetVSync = GLES2_SetVSync;
|
||||
renderer->GL_BindTexture = GLES2_BindTexture;
|
||||
renderer->GL_UnbindTexture = GLES2_UnbindTexture;
|
||||
#if SDL_HAVE_YUV
|
||||
renderer->info.texture_formats[renderer->info.num_texture_formats++] = SDL_PIXELFORMAT_YV12;
|
||||
renderer->info.texture_formats[renderer->info.num_texture_formats++] = SDL_PIXELFORMAT_IYUV;
|
||||
|
||||
Reference in New Issue
Block a user