Add more SDL_HAVE_YUV defines

This commit is contained in:
Sylvain Becker 2021-01-05 17:39:48 +01:00
parent dc0e5de974
commit c0df40e003
5 changed files with 52 additions and 3 deletions

View File

@ -131,6 +131,7 @@ struct SDL_Renderer
int (*UpdateTexture) (SDL_Renderer * renderer, SDL_Texture * texture, int (*UpdateTexture) (SDL_Renderer * renderer, SDL_Texture * texture,
const SDL_Rect * rect, const void *pixels, const SDL_Rect * rect, const void *pixels,
int pitch); int pitch);
#if SDL_HAVE_YUV
int (*UpdateTextureYUV) (SDL_Renderer * renderer, SDL_Texture * texture, int (*UpdateTextureYUV) (SDL_Renderer * renderer, SDL_Texture * texture,
const SDL_Rect * rect, const SDL_Rect * rect,
const Uint8 *Yplane, int Ypitch, const Uint8 *Yplane, int Ypitch,
@ -140,6 +141,7 @@ struct SDL_Renderer
const SDL_Rect * rect, const SDL_Rect * rect,
const Uint8 *Yplane, int Ypitch, const Uint8 *Yplane, int Ypitch,
const Uint8 *UVplane, int UVpitch); const Uint8 *UVplane, int UVpitch);
#endif
int (*LockTexture) (SDL_Renderer * renderer, SDL_Texture * texture, int (*LockTexture) (SDL_Renderer * renderer, SDL_Texture * texture,
const SDL_Rect * rect, void **pixels, int *pitch); const SDL_Rect * rect, void **pixels, int *pitch);
void (*UnlockTexture) (SDL_Renderer * renderer, SDL_Texture * texture); void (*UnlockTexture) (SDL_Renderer * renderer, SDL_Texture * texture);

View File

@ -1376,6 +1376,7 @@ D3D11_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
return 0; return 0;
} }
#if SDL_HAVE_YUV
static int static int
D3D11_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture, D3D11_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture,
const SDL_Rect * rect, const SDL_Rect * rect,
@ -1426,6 +1427,7 @@ D3D11_UpdateTextureNV(SDL_Renderer * renderer, SDL_Texture * texture,
} }
return 0; return 0;
} }
#endif
static int static int
D3D11_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, D3D11_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
@ -2539,8 +2541,10 @@ D3D11_CreateRenderer(SDL_Window * window, Uint32 flags)
renderer->SupportsBlendMode = D3D11_SupportsBlendMode; renderer->SupportsBlendMode = D3D11_SupportsBlendMode;
renderer->CreateTexture = D3D11_CreateTexture; renderer->CreateTexture = D3D11_CreateTexture;
renderer->UpdateTexture = D3D11_UpdateTexture; renderer->UpdateTexture = D3D11_UpdateTexture;
#if SDL_HAVE_YUV
renderer->UpdateTextureYUV = D3D11_UpdateTextureYUV; renderer->UpdateTextureYUV = D3D11_UpdateTextureYUV;
renderer->UpdateTextureNV = D3D11_UpdateTextureNV; renderer->UpdateTextureNV = D3D11_UpdateTextureNV;
#endif
renderer->LockTexture = D3D11_LockTexture; renderer->LockTexture = D3D11_LockTexture;
renderer->UnlockTexture = D3D11_UnlockTexture; renderer->UnlockTexture = D3D11_UnlockTexture;
renderer->SetTextureScaleMode = D3D11_SetTextureScaleMode; renderer->SetTextureScaleMode = D3D11_SetTextureScaleMode;

View File

@ -803,6 +803,7 @@ METAL_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
return 0; return 0;
}} }}
#if SDL_HAVE_YUV
static int static int
METAL_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture, METAL_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture,
const SDL_Rect * rect, const SDL_Rect * rect,
@ -861,6 +862,7 @@ METAL_UpdateTextureNV(SDL_Renderer * renderer, SDL_Texture * texture,
return 0; return 0;
}} }}
#endif
static int static int
METAL_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, METAL_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
@ -1877,8 +1879,10 @@ METAL_CreateRenderer(SDL_Window * window, Uint32 flags)
renderer->SupportsBlendMode = METAL_SupportsBlendMode; renderer->SupportsBlendMode = METAL_SupportsBlendMode;
renderer->CreateTexture = METAL_CreateTexture; renderer->CreateTexture = METAL_CreateTexture;
renderer->UpdateTexture = METAL_UpdateTexture; renderer->UpdateTexture = METAL_UpdateTexture;
#if SDL_HAVE_YUV
renderer->UpdateTextureYUV = METAL_UpdateTextureYUV; renderer->UpdateTextureYUV = METAL_UpdateTextureYUV;
renderer->UpdateTextureNV = METAL_UpdateTextureNV; renderer->UpdateTextureNV = METAL_UpdateTextureNV;
#endif
renderer->LockTexture = METAL_LockTexture; renderer->LockTexture = METAL_LockTexture;
renderer->UnlockTexture = METAL_UnlockTexture; renderer->UnlockTexture = METAL_UnlockTexture;
renderer->SetTextureScaleMode = METAL_SetTextureScaleMode; renderer->SetTextureScaleMode = METAL_SetTextureScaleMode;

View File

@ -128,11 +128,13 @@ typedef struct
int pitch; int pitch;
SDL_Rect locked_rect; SDL_Rect locked_rect;
#if SDL_HAVE_YUV
/* YUV texture support */ /* YUV texture support */
SDL_bool yuv; SDL_bool yuv;
SDL_bool nv12; SDL_bool nv12;
GLuint utexture; GLuint utexture;
GLuint vtexture; GLuint vtexture;
#endif
GL_FBOList *fbo; GL_FBOList *fbo;
} GL_TextureData; } GL_TextureData;
@ -577,6 +579,7 @@ GL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
return -1; return -1;
} }
#if SDL_HAVE_YUV
if (texture->format == SDL_PIXELFORMAT_YV12 || if (texture->format == SDL_PIXELFORMAT_YV12 ||
texture->format == SDL_PIXELFORMAT_IYUV) { texture->format == SDL_PIXELFORMAT_IYUV) {
data->yuv = SDL_TRUE; data->yuv = SDL_TRUE;
@ -626,6 +629,7 @@ GL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
renderdata->glTexImage2D(textype, 0, GL_LUMINANCE_ALPHA, (texture_w+1)/2, renderdata->glTexImage2D(textype, 0, GL_LUMINANCE_ALPHA, (texture_w+1)/2,
(texture_h+1)/2, 0, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, NULL); (texture_h+1)/2, 0, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, NULL);
} }
#endif
return GL_CheckError("", renderer); return GL_CheckError("", renderer);
} }
@ -651,6 +655,7 @@ GL_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
renderdata->glTexSubImage2D(textype, 0, rect->x, rect->y, rect->w, renderdata->glTexSubImage2D(textype, 0, rect->x, rect->y, rect->w,
rect->h, data->format, data->formattype, rect->h, data->format, data->formattype,
pixels); pixels);
#if SDL_HAVE_YUV
if (data->yuv) { if (data->yuv) {
renderdata->glPixelStorei(GL_UNPACK_ROW_LENGTH, ((pitch + 1) / 2)); renderdata->glPixelStorei(GL_UNPACK_ROW_LENGTH, ((pitch + 1) / 2));
@ -687,10 +692,11 @@ GL_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
(rect->w + 1)/2, (rect->h + 1)/2, (rect->w + 1)/2, (rect->h + 1)/2,
GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, pixels); GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, pixels);
} }
#endif
return GL_CheckError("glTexSubImage2D()", renderer); return GL_CheckError("glTexSubImage2D()", renderer);
} }
#if SDL_HAVE_YUV
static int static int
GL_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture, GL_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture,
const SDL_Rect * rect, const SDL_Rect * rect,
@ -758,7 +764,7 @@ GL_UpdateTextureNV(SDL_Renderer * renderer, SDL_Texture * texture,
return GL_CheckError("glTexSubImage2D()", renderer); return GL_CheckError("glTexSubImage2D()", renderer);
} }
#endif
static int static int
GL_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, GL_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
@ -800,6 +806,7 @@ GL_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture, SDL_Scale
renderdata->glTexParameteri(textype, GL_TEXTURE_MIN_FILTER, glScaleMode); renderdata->glTexParameteri(textype, GL_TEXTURE_MIN_FILTER, glScaleMode);
renderdata->glTexParameteri(textype, GL_TEXTURE_MAG_FILTER, glScaleMode); renderdata->glTexParameteri(textype, GL_TEXTURE_MAG_FILTER, glScaleMode);
#if SDL_HAVE_YUV
if (texture->format == SDL_PIXELFORMAT_YV12 || if (texture->format == SDL_PIXELFORMAT_YV12 ||
texture->format == SDL_PIXELFORMAT_IYUV) { texture->format == SDL_PIXELFORMAT_IYUV) {
renderdata->glBindTexture(textype, data->utexture); renderdata->glBindTexture(textype, data->utexture);
@ -817,6 +824,7 @@ GL_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture, SDL_Scale
renderdata->glTexParameteri(textype, GL_TEXTURE_MIN_FILTER, glScaleMode); renderdata->glTexParameteri(textype, GL_TEXTURE_MIN_FILTER, glScaleMode);
renderdata->glTexParameteri(textype, GL_TEXTURE_MAG_FILTER, glScaleMode); renderdata->glTexParameteri(textype, GL_TEXTURE_MAG_FILTER, glScaleMode);
} }
#endif
} }
static int static int
@ -1128,6 +1136,7 @@ SetCopyState(GL_RenderData *data, const SDL_RenderCommand *cmd)
shader = SHADER_RGB; shader = SHADER_RGB;
} }
#if SDL_HAVE_YUV
if (data->shaders) { if (data->shaders) {
if (texturedata->yuv || texturedata->nv12) { if (texturedata->yuv || texturedata->nv12) {
switch (SDL_GetYUVConversionModeForResolution(texture->w, texture->h)) { switch (SDL_GetYUVConversionModeForResolution(texture->w, texture->h)) {
@ -1164,11 +1173,13 @@ SetCopyState(GL_RenderData *data, const SDL_RenderCommand *cmd)
} }
} }
} }
#endif
SetDrawState(data, cmd, shader); SetDrawState(data, cmd, shader);
if (texture != data->drawstate.texture) { if (texture != data->drawstate.texture) {
const GLenum textype = data->textype; const GLenum textype = data->textype;
#if SDL_HAVE_YUV
if (texturedata->yuv) { if (texturedata->yuv) {
data->glActiveTextureARB(GL_TEXTURE2_ARB); data->glActiveTextureARB(GL_TEXTURE2_ARB);
data->glBindTexture(textype, texturedata->vtexture); data->glBindTexture(textype, texturedata->vtexture);
@ -1180,6 +1191,7 @@ SetCopyState(GL_RenderData *data, const SDL_RenderCommand *cmd)
data->glActiveTextureARB(GL_TEXTURE1_ARB); data->glActiveTextureARB(GL_TEXTURE1_ARB);
data->glBindTexture(textype, texturedata->utexture); data->glBindTexture(textype, texturedata->utexture);
} }
#endif
data->glActiveTextureARB(GL_TEXTURE0_ARB); data->glActiveTextureARB(GL_TEXTURE0_ARB);
data->glBindTexture(textype, texturedata->texture); data->glBindTexture(textype, texturedata->texture);
@ -1471,10 +1483,12 @@ GL_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
if (data->texture) { if (data->texture) {
renderdata->glDeleteTextures(1, &data->texture); renderdata->glDeleteTextures(1, &data->texture);
} }
#if SDL_HAVE_YUV
if (data->yuv) { if (data->yuv) {
renderdata->glDeleteTextures(1, &data->utexture); renderdata->glDeleteTextures(1, &data->utexture);
renderdata->glDeleteTextures(1, &data->vtexture); renderdata->glDeleteTextures(1, &data->vtexture);
} }
#endif
SDL_free(data->pixels); SDL_free(data->pixels);
SDL_free(data); SDL_free(data);
texture->driverdata = NULL; texture->driverdata = NULL;
@ -1528,6 +1542,7 @@ GL_BindTexture (SDL_Renderer * renderer, SDL_Texture *texture, float *texw, floa
GL_ActivateRenderer(renderer); GL_ActivateRenderer(renderer);
data->glEnable(textype); data->glEnable(textype);
#if SDL_HAVE_YUV
if (texturedata->yuv) { if (texturedata->yuv) {
data->glActiveTextureARB(GL_TEXTURE2_ARB); data->glActiveTextureARB(GL_TEXTURE2_ARB);
data->glBindTexture(textype, texturedata->vtexture); data->glBindTexture(textype, texturedata->vtexture);
@ -1537,6 +1552,7 @@ GL_BindTexture (SDL_Renderer * renderer, SDL_Texture *texture, float *texw, floa
data->glActiveTextureARB(GL_TEXTURE0_ARB); data->glActiveTextureARB(GL_TEXTURE0_ARB);
} }
#endif
data->glBindTexture(textype, texturedata->texture); data->glBindTexture(textype, texturedata->texture);
data->drawstate.texturing = SDL_TRUE; data->drawstate.texturing = SDL_TRUE;
@ -1557,6 +1573,7 @@ GL_UnbindTexture (SDL_Renderer * renderer, SDL_Texture *texture)
GL_ActivateRenderer(renderer); GL_ActivateRenderer(renderer);
#if SDL_HAVE_YUV
if (texturedata->yuv) { if (texturedata->yuv) {
data->glActiveTextureARB(GL_TEXTURE2_ARB); data->glActiveTextureARB(GL_TEXTURE2_ARB);
data->glDisable(textype); data->glDisable(textype);
@ -1566,6 +1583,7 @@ GL_UnbindTexture (SDL_Renderer * renderer, SDL_Texture *texture)
data->glActiveTextureARB(GL_TEXTURE0_ARB); data->glActiveTextureARB(GL_TEXTURE0_ARB);
} }
#endif
data->glDisable(textype); data->glDisable(textype);
@ -1621,8 +1639,10 @@ GL_CreateRenderer(SDL_Window * window, Uint32 flags)
renderer->SupportsBlendMode = GL_SupportsBlendMode; renderer->SupportsBlendMode = GL_SupportsBlendMode;
renderer->CreateTexture = GL_CreateTexture; renderer->CreateTexture = GL_CreateTexture;
renderer->UpdateTexture = GL_UpdateTexture; renderer->UpdateTexture = GL_UpdateTexture;
#if SDL_HAVE_YUV
renderer->UpdateTextureYUV = GL_UpdateTextureYUV; renderer->UpdateTextureYUV = GL_UpdateTextureYUV;
renderer->UpdateTextureNV = GL_UpdateTextureNV; renderer->UpdateTextureNV = GL_UpdateTextureNV;
#endif
renderer->LockTexture = GL_LockTexture; renderer->LockTexture = GL_LockTexture;
renderer->UnlockTexture = GL_UnlockTexture; renderer->UnlockTexture = GL_UnlockTexture;
renderer->SetTextureScaleMode = GL_SetTextureScaleMode; renderer->SetTextureScaleMode = GL_SetTextureScaleMode;

View File

@ -58,11 +58,13 @@ typedef struct GLES2_TextureData
GLenum pixel_type; GLenum pixel_type;
void *pixel_data; void *pixel_data;
int pitch; int pitch;
#if SDL_HAVE_YUV
/* YUV texture support */ /* YUV texture support */
SDL_bool yuv; SDL_bool yuv;
SDL_bool nv12; SDL_bool nv12;
GLenum texture_v; GLenum texture_v;
GLenum texture_u; GLenum texture_u;
#endif
GLES2_FBOList *fbo; GLES2_FBOList *fbo;
} GLES2_TextureData; } GLES2_TextureData;
@ -1037,6 +1039,7 @@ SetDrawState(GLES2_RenderData *data, const SDL_RenderCommand *cmd, const GLES2_I
if (texture) { if (texture) {
GLES2_TextureData *tdata = (GLES2_TextureData *) texture->driverdata; GLES2_TextureData *tdata = (GLES2_TextureData *) texture->driverdata;
#if SDL_HAVE_YUV
if (tdata->yuv) { if (tdata->yuv) {
data->glActiveTexture(GL_TEXTURE2); data->glActiveTexture(GL_TEXTURE2);
data->glBindTexture(tdata->texture_type, tdata->texture_v); data->glBindTexture(tdata->texture_type, tdata->texture_v);
@ -1051,6 +1054,7 @@ SetDrawState(GLES2_RenderData *data, const SDL_RenderCommand *cmd, const GLES2_I
data->glActiveTexture(GL_TEXTURE0); data->glActiveTexture(GL_TEXTURE0);
} }
#endif
data->glBindTexture(tdata->texture_type, tdata->texture); data->glBindTexture(tdata->texture_type, tdata->texture);
} }
@ -1483,10 +1487,12 @@ GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
#endif #endif
data->pixel_format = format; data->pixel_format = format;
data->pixel_type = type; data->pixel_type = type;
#if SDL_HAVE_YUV
data->yuv = ((texture->format == SDL_PIXELFORMAT_IYUV) || (texture->format == SDL_PIXELFORMAT_YV12)); data->yuv = ((texture->format == SDL_PIXELFORMAT_IYUV) || (texture->format == SDL_PIXELFORMAT_YV12));
data->nv12 = ((texture->format == SDL_PIXELFORMAT_NV12) || (texture->format == SDL_PIXELFORMAT_NV21)); data->nv12 = ((texture->format == SDL_PIXELFORMAT_NV12) || (texture->format == SDL_PIXELFORMAT_NV21));
data->texture_u = 0; data->texture_u = 0;
data->texture_v = 0; data->texture_v = 0;
#endif
scaleMode = (texture->scaleMode == SDL_ScaleModeNearest) ? GL_NEAREST : GL_LINEAR; scaleMode = (texture->scaleMode == SDL_ScaleModeNearest) ? GL_NEAREST : GL_LINEAR;
/* Allocate a blob for image renderdata */ /* Allocate a blob for image renderdata */
@ -1494,6 +1500,7 @@ GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
size_t size; size_t size;
data->pitch = texture->w * SDL_BYTESPERPIXEL(texture->format); data->pitch = texture->w * SDL_BYTESPERPIXEL(texture->format);
size = texture->h * data->pitch; size = texture->h * data->pitch;
#if SDL_HAVE_YUV
if (data->yuv) { if (data->yuv) {
/* Need to add size for the U and V planes */ /* Need to add size for the U and V planes */
size += 2 * ((texture->h + 1) / 2) * ((data->pitch + 1) / 2); size += 2 * ((texture->h + 1) / 2) * ((data->pitch + 1) / 2);
@ -1501,6 +1508,7 @@ GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
/* Need to add size for the U/V plane */ /* Need to add size for the U/V plane */
size += 2 * ((texture->h + 1) / 2) * ((data->pitch + 1) / 2); size += 2 * ((texture->h + 1) / 2) * ((data->pitch + 1) / 2);
} }
#endif
data->pixel_data = SDL_calloc(1, size); data->pixel_data = SDL_calloc(1, size);
if (!data->pixel_data) { if (!data->pixel_data) {
SDL_free(data); SDL_free(data);
@ -1511,6 +1519,7 @@ GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
/* Allocate the texture */ /* Allocate the texture */
GL_CheckError("", renderer); GL_CheckError("", renderer);
#if SDL_HAVE_YUV
if (data->yuv) { if (data->yuv) {
renderdata->glGenTextures(1, &data->texture_v); renderdata->glGenTextures(1, &data->texture_v);
if (GL_CheckError("glGenTexures()", renderer) < 0) { if (GL_CheckError("glGenTexures()", renderer) < 0) {
@ -1554,6 +1563,7 @@ GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
return -1; return -1;
} }
} }
#endif
renderdata->glGenTextures(1, &data->texture); renderdata->glGenTextures(1, &data->texture);
if (GL_CheckError("glGenTexures()", renderer) < 0) { if (GL_CheckError("glGenTexures()", renderer) < 0) {
@ -1646,6 +1656,7 @@ GLES2_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect
tdata->pixel_type, tdata->pixel_type,
pixels, pitch, SDL_BYTESPERPIXEL(texture->format)); pixels, pitch, SDL_BYTESPERPIXEL(texture->format));
#if SDL_HAVE_YUV
if (tdata->yuv) { if (tdata->yuv) {
/* Skip to the correct offset into the next texture */ /* Skip to the correct offset into the next texture */
pixels = (const void*)((const Uint8*)pixels + rect->h * pitch); pixels = (const void*)((const Uint8*)pixels + rect->h * pitch);
@ -1692,10 +1703,12 @@ GLES2_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect
GL_UNSIGNED_BYTE, GL_UNSIGNED_BYTE,
pixels, 2 * ((pitch + 1) / 2), 2); pixels, 2 * ((pitch + 1) / 2), 2);
} }
#endif
return GL_CheckError("glTexSubImage2D()", renderer); return GL_CheckError("glTexSubImage2D()", renderer);
} }
#if SDL_HAVE_YUV
static int static int
GLES2_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture, GLES2_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture,
const SDL_Rect * rect, const SDL_Rect * rect,
@ -1788,7 +1801,7 @@ GLES2_UpdateTextureNV(SDL_Renderer * renderer, SDL_Texture * texture,
return GL_CheckError("glTexSubImage2D()", renderer); return GL_CheckError("glTexSubImage2D()", renderer);
} }
#endif
static int static int
GLES2_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *rect, GLES2_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *rect,
@ -1826,6 +1839,7 @@ GLES2_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture, SDL_Sc
GLES2_TextureData *data = (GLES2_TextureData *) texture->driverdata; GLES2_TextureData *data = (GLES2_TextureData *) texture->driverdata;
GLenum glScaleMode = (scaleMode == SDL_ScaleModeNearest) ? GL_NEAREST : GL_LINEAR; GLenum glScaleMode = (scaleMode == SDL_ScaleModeNearest) ? GL_NEAREST : GL_LINEAR;
#if SDL_HAVE_YUV
if (data->yuv) { if (data->yuv) {
renderdata->glActiveTexture(GL_TEXTURE2); renderdata->glActiveTexture(GL_TEXTURE2);
renderdata->glBindTexture(data->texture_type, data->texture_v); renderdata->glBindTexture(data->texture_type, data->texture_v);
@ -1842,6 +1856,7 @@ GLES2_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture, SDL_Sc
renderdata->glTexParameteri(data->texture_type, GL_TEXTURE_MIN_FILTER, glScaleMode); renderdata->glTexParameteri(data->texture_type, GL_TEXTURE_MIN_FILTER, glScaleMode);
renderdata->glTexParameteri(data->texture_type, GL_TEXTURE_MAG_FILTER, glScaleMode); renderdata->glTexParameteri(data->texture_type, GL_TEXTURE_MAG_FILTER, glScaleMode);
} }
#endif
renderdata->glActiveTexture(GL_TEXTURE0); renderdata->glActiveTexture(GL_TEXTURE0);
renderdata->glBindTexture(data->texture_type, data->texture); renderdata->glBindTexture(data->texture_type, data->texture);
@ -1892,12 +1907,14 @@ GLES2_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture)
/* Destroy the texture */ /* Destroy the texture */
if (tdata) { if (tdata) {
data->glDeleteTextures(1, &tdata->texture); data->glDeleteTextures(1, &tdata->texture);
#if SDL_HAVE_YUV
if (tdata->texture_v) { if (tdata->texture_v) {
data->glDeleteTextures(1, &tdata->texture_v); data->glDeleteTextures(1, &tdata->texture_v);
} }
if (tdata->texture_u) { if (tdata->texture_u) {
data->glDeleteTextures(1, &tdata->texture_u); data->glDeleteTextures(1, &tdata->texture_u);
} }
#endif
SDL_free(tdata->pixel_data); SDL_free(tdata->pixel_data);
SDL_free(tdata); SDL_free(tdata);
texture->driverdata = NULL; texture->driverdata = NULL;
@ -2167,8 +2184,10 @@ GLES2_CreateRenderer(SDL_Window *window, Uint32 flags)
renderer->SupportsBlendMode = GLES2_SupportsBlendMode; renderer->SupportsBlendMode = GLES2_SupportsBlendMode;
renderer->CreateTexture = GLES2_CreateTexture; renderer->CreateTexture = GLES2_CreateTexture;
renderer->UpdateTexture = GLES2_UpdateTexture; renderer->UpdateTexture = GLES2_UpdateTexture;
#if SDL_HAVE_YUV
renderer->UpdateTextureYUV = GLES2_UpdateTextureYUV; renderer->UpdateTextureYUV = GLES2_UpdateTextureYUV;
renderer->UpdateTextureNV = GLES2_UpdateTextureNV; renderer->UpdateTextureNV = GLES2_UpdateTextureNV;
#endif
renderer->LockTexture = GLES2_LockTexture; renderer->LockTexture = GLES2_LockTexture;
renderer->UnlockTexture = GLES2_UnlockTexture; renderer->UnlockTexture = GLES2_UnlockTexture;
renderer->SetTextureScaleMode = GLES2_SetTextureScaleMode; renderer->SetTextureScaleMode = GLES2_SetTextureScaleMode;