Daily update on 20250721-223448 by Nitload Youmu. Additional Message : Rename StgSHarp.C to StgSharp.Native. Add SDL to repo.

Signed-off-by: Nitload <YoumuLiu_NSI@whv0t.onmicrosoft.com>
This commit is contained in:
Nitload
2025-07-21 22:34:48 +08:00
parent c624a8ca38
commit 28ea5d1d1e
1215 changed files with 628924 additions and 114 deletions
@@ -0,0 +1,476 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
/* list of OpenGL functions sorted alphabetically
If you need to use a GL function from the SDL video subsystem,
change its entry from SDL_PROC_UNUSED to SDL_PROC and rebuild.
*/
#define SDL_PROC_UNUSED(ret, func, params)
SDL_PROC_UNUSED(void, glAccum, (GLenum, GLfloat))
SDL_PROC_UNUSED(void, glAlphaFunc, (GLenum, GLclampf))
SDL_PROC_UNUSED(GLboolean, glAreTexturesResident,
(GLsizei, const GLuint *, GLboolean *))
SDL_PROC_UNUSED(void, glArrayElement, (GLint))
SDL_PROC(void, glBegin, (GLenum))
SDL_PROC(void, glBindTexture, (GLenum, GLuint))
SDL_PROC_UNUSED(void, glBitmap,
(GLsizei, GLsizei, GLfloat, GLfloat, GLfloat, GLfloat,
const GLubyte *))
SDL_PROC(void, glBlendEquation, (GLenum))
SDL_PROC_UNUSED(void, glBlendFunc, (GLenum, GLenum))
SDL_PROC(void, glBlendFuncSeparate, (GLenum, GLenum, GLenum, GLenum))
SDL_PROC_UNUSED(void, glCallList, (GLuint))
SDL_PROC_UNUSED(void, glCallLists, (GLsizei, GLenum, const GLvoid *))
SDL_PROC(void, glClear, (GLbitfield))
SDL_PROC_UNUSED(void, glClearAccum, (GLfloat, GLfloat, GLfloat, GLfloat))
SDL_PROC(void, glClearColor, (GLclampf, GLclampf, GLclampf, GLclampf))
SDL_PROC_UNUSED(void, glClearDepth, (GLclampd))
SDL_PROC_UNUSED(void, glClearIndex, (GLfloat))
SDL_PROC_UNUSED(void, glClearStencil, (GLint))
SDL_PROC_UNUSED(void, glClipPlane, (GLenum, const GLdouble *))
SDL_PROC_UNUSED(void, glColor3b, (GLbyte, GLbyte, GLbyte))
SDL_PROC_UNUSED(void, glColor3bv, (const GLbyte *))
SDL_PROC_UNUSED(void, glColor3d, (GLdouble, GLdouble, GLdouble))
SDL_PROC_UNUSED(void, glColor3dv, (const GLdouble *))
SDL_PROC_UNUSED(void, glColor3f, (GLfloat, GLfloat, GLfloat))
SDL_PROC(void, glColor3fv, (const GLfloat *))
SDL_PROC_UNUSED(void, glColor3i, (GLint, GLint, GLint))
SDL_PROC_UNUSED(void, glColor3iv, (const GLint *))
SDL_PROC_UNUSED(void, glColor3s, (GLshort, GLshort, GLshort))
SDL_PROC_UNUSED(void, glColor3sv, (const GLshort *))
SDL_PROC_UNUSED(void, glColor3ub, (GLubyte, GLubyte, GLubyte))
SDL_PROC_UNUSED(void, glColor3ubv, (const GLubyte *))
SDL_PROC_UNUSED(void, glColor3ui, (GLuint, GLuint, GLuint))
SDL_PROC_UNUSED(void, glColor3uiv, (const GLuint *))
SDL_PROC_UNUSED(void, glColor3us, (GLushort, GLushort, GLushort))
SDL_PROC_UNUSED(void, glColor3usv, (const GLushort *))
SDL_PROC_UNUSED(void, glColor4b, (GLbyte, GLbyte, GLbyte, GLbyte))
SDL_PROC_UNUSED(void, glColor4bv, (const GLbyte *))
SDL_PROC_UNUSED(void, glColor4d, (GLdouble, GLdouble, GLdouble, GLdouble))
SDL_PROC_UNUSED(void, glColor4dv, (const GLdouble *))
SDL_PROC(void, glColor4f, (GLfloat, GLfloat, GLfloat, GLfloat))
SDL_PROC_UNUSED(void, glColor4fv, (const GLfloat *))
SDL_PROC_UNUSED(void, glColor4i, (GLint, GLint, GLint, GLint))
SDL_PROC_UNUSED(void, glColor4iv, (const GLint *))
SDL_PROC_UNUSED(void, glColor4s, (GLshort, GLshort, GLshort, GLshort))
SDL_PROC_UNUSED(void, glColor4sv, (const GLshort *))
SDL_PROC(void, glColor4ub,
(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha))
SDL_PROC_UNUSED(void, glColor4ubv, (const GLubyte *v))
SDL_PROC_UNUSED(void, glColor4ui,
(GLuint red, GLuint green, GLuint blue, GLuint alpha))
SDL_PROC_UNUSED(void, glColor4uiv, (const GLuint *v))
SDL_PROC_UNUSED(void, glColor4us,
(GLushort red, GLushort green, GLushort blue, GLushort alpha))
SDL_PROC_UNUSED(void, glColor4usv, (const GLushort *v))
SDL_PROC_UNUSED(void, glColorMask,
(GLboolean red, GLboolean green, GLboolean blue,
GLboolean alpha))
SDL_PROC_UNUSED(void, glColorMaterial, (GLenum face, GLenum mode))
SDL_PROC(void, glColorPointer,
(GLint size, GLenum type, GLsizei stride,
const GLvoid *pointer))
SDL_PROC_UNUSED(void, glCopyPixels,
(GLint x, GLint y, GLsizei width, GLsizei height,
GLenum type))
SDL_PROC_UNUSED(void, glCopyTexImage1D,
(GLenum target, GLint level, GLenum internalFormat, GLint x,
GLint y, GLsizei width, GLint border))
SDL_PROC_UNUSED(void, glCopyTexImage2D,
(GLenum target, GLint level, GLenum internalFormat, GLint x,
GLint y, GLsizei width, GLsizei height, GLint border))
SDL_PROC_UNUSED(void, glCopyTexSubImage1D,
(GLenum target, GLint level, GLint xoffset, GLint x, GLint y,
GLsizei width))
SDL_PROC_UNUSED(void, glCopyTexSubImage2D,
(GLenum target, GLint level, GLint xoffset, GLint yoffset,
GLint x, GLint y, GLsizei width, GLsizei height))
SDL_PROC_UNUSED(void, glCullFace, (GLenum mode))
SDL_PROC_UNUSED(void, glDeleteLists, (GLuint list, GLsizei range))
SDL_PROC(void, glDeleteTextures, (GLsizei n, const GLuint *textures))
SDL_PROC(void, glDepthFunc, (GLenum func))
SDL_PROC_UNUSED(void, glDepthMask, (GLboolean flag))
SDL_PROC_UNUSED(void, glDepthRange, (GLclampd zNear, GLclampd zFar))
SDL_PROC(void, glDisable, (GLenum cap))
SDL_PROC(void, glDisableClientState, (GLenum array))
SDL_PROC(void, glDrawArrays, (GLenum mode, GLint first, GLsizei count))
SDL_PROC_UNUSED(void, glDrawBuffer, (GLenum mode))
SDL_PROC_UNUSED(void, glDrawElements,
(GLenum mode, GLsizei count, GLenum type,
const GLvoid *indices))
SDL_PROC(void, glDrawPixels,
(GLsizei width, GLsizei height, GLenum format, GLenum type,
const GLvoid *pixels))
SDL_PROC_UNUSED(void, glEdgeFlag, (GLboolean flag))
SDL_PROC_UNUSED(void, glEdgeFlagPointer,
(GLsizei stride, const GLvoid *pointer))
SDL_PROC_UNUSED(void, glEdgeFlagv, (const GLboolean *flag))
SDL_PROC(void, glEnable, (GLenum cap))
SDL_PROC(void, glEnableClientState, (GLenum array))
SDL_PROC(void, glEnd, (void))
SDL_PROC_UNUSED(void, glEndList, (void))
SDL_PROC_UNUSED(void, glEvalCoord1d, (GLdouble u))
SDL_PROC_UNUSED(void, glEvalCoord1dv, (const GLdouble *u))
SDL_PROC_UNUSED(void, glEvalCoord1f, (GLfloat u))
SDL_PROC_UNUSED(void, glEvalCoord1fv, (const GLfloat *u))
SDL_PROC_UNUSED(void, glEvalCoord2d, (GLdouble u, GLdouble v))
SDL_PROC_UNUSED(void, glEvalCoord2dv, (const GLdouble *u))
SDL_PROC_UNUSED(void, glEvalCoord2f, (GLfloat u, GLfloat v))
SDL_PROC_UNUSED(void, glEvalCoord2fv, (const GLfloat *u))
SDL_PROC_UNUSED(void, glEvalMesh1, (GLenum mode, GLint i1, GLint i2))
SDL_PROC_UNUSED(void, glEvalMesh2,
(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2))
SDL_PROC_UNUSED(void, glEvalPoint1, (GLint i))
SDL_PROC_UNUSED(void, glEvalPoint2, (GLint i, GLint j))
SDL_PROC_UNUSED(void, glFeedbackBuffer,
(GLsizei size, GLenum type, GLfloat *buffer))
SDL_PROC_UNUSED(void, glFinish, (void))
SDL_PROC_UNUSED(void, glFlush, (void))
SDL_PROC_UNUSED(void, glFogf, (GLenum pname, GLfloat param))
SDL_PROC_UNUSED(void, glFogfv, (GLenum pname, const GLfloat *params))
SDL_PROC_UNUSED(void, glFogi, (GLenum pname, GLint param))
SDL_PROC_UNUSED(void, glFogiv, (GLenum pname, const GLint *params))
SDL_PROC_UNUSED(void, glFrontFace, (GLenum mode))
SDL_PROC_UNUSED(void, glFrustum,
(GLdouble left, GLdouble right, GLdouble bottom,
GLdouble top, GLdouble zNear, GLdouble zFar))
SDL_PROC_UNUSED(GLuint, glGenLists, (GLsizei range))
SDL_PROC(void, glGenTextures, (GLsizei n, GLuint *textures))
SDL_PROC_UNUSED(void, glGetBooleanv, (GLenum pname, GLboolean *params))
SDL_PROC_UNUSED(void, glGetClipPlane, (GLenum plane, GLdouble *equation))
SDL_PROC_UNUSED(void, glGetDoublev, (GLenum pname, GLdouble *params))
SDL_PROC(GLenum, glGetError, (void))
SDL_PROC(void, glGetFloatv, (GLenum pname, GLfloat *params))
SDL_PROC(void, glGetIntegerv, (GLenum pname, GLint *params))
SDL_PROC_UNUSED(void, glGetLightfv,
(GLenum light, GLenum pname, GLfloat *params))
SDL_PROC_UNUSED(void, glGetLightiv,
(GLenum light, GLenum pname, GLint *params))
SDL_PROC_UNUSED(void, glGetMapdv, (GLenum target, GLenum query, GLdouble *v))
SDL_PROC_UNUSED(void, glGetMapfv, (GLenum target, GLenum query, GLfloat *v))
SDL_PROC_UNUSED(void, glGetMapiv, (GLenum target, GLenum query, GLint *v))
SDL_PROC_UNUSED(void, glGetMaterialfv,
(GLenum face, GLenum pname, GLfloat *params))
SDL_PROC_UNUSED(void, glGetMaterialiv,
(GLenum face, GLenum pname, GLint *params))
SDL_PROC_UNUSED(void, glGetPixelMapfv, (GLenum map, GLfloat *values))
SDL_PROC_UNUSED(void, glGetPixelMapuiv, (GLenum map, GLuint *values))
SDL_PROC_UNUSED(void, glGetPixelMapusv, (GLenum map, GLushort *values))
SDL_PROC(void, glGetPointerv, (GLenum pname, GLvoid **params))
SDL_PROC_UNUSED(void, glGetPolygonStipple, (GLubyte * mask))
SDL_PROC(const GLubyte *, glGetString, (GLenum name))
SDL_PROC_UNUSED(void, glGetTexEnvfv,
(GLenum target, GLenum pname, GLfloat *params))
SDL_PROC_UNUSED(void, glGetTexEnviv,
(GLenum target, GLenum pname, GLint *params))
SDL_PROC_UNUSED(void, glGetTexGendv,
(GLenum coord, GLenum pname, GLdouble *params))
SDL_PROC_UNUSED(void, glGetTexGenfv,
(GLenum coord, GLenum pname, GLfloat *params))
SDL_PROC_UNUSED(void, glGetTexGeniv,
(GLenum coord, GLenum pname, GLint *params))
SDL_PROC_UNUSED(void, glGetTexImage,
(GLenum target, GLint level, GLenum format, GLenum type,
GLvoid *pixels))
SDL_PROC_UNUSED(void, glGetTexLevelParameterfv,
(GLenum target, GLint level, GLenum pname, GLfloat *params))
SDL_PROC_UNUSED(void, glGetTexLevelParameteriv,
(GLenum target, GLint level, GLenum pname, GLint *params))
SDL_PROC_UNUSED(void, glGetTexParameterfv,
(GLenum target, GLenum pname, GLfloat *params))
SDL_PROC_UNUSED(void, glGetTexParameteriv,
(GLenum target, GLenum pname, GLint *params))
SDL_PROC_UNUSED(void, glHint, (GLenum target, GLenum mode))
SDL_PROC_UNUSED(void, glIndexMask, (GLuint mask))
SDL_PROC_UNUSED(void, glIndexPointer,
(GLenum type, GLsizei stride, const GLvoid *pointer))
SDL_PROC_UNUSED(void, glIndexd, (GLdouble c))
SDL_PROC_UNUSED(void, glIndexdv, (const GLdouble *c))
SDL_PROC_UNUSED(void, glIndexf, (GLfloat c))
SDL_PROC_UNUSED(void, glIndexfv, (const GLfloat *c))
SDL_PROC_UNUSED(void, glIndexi, (GLint c))
SDL_PROC_UNUSED(void, glIndexiv, (const GLint *c))
SDL_PROC_UNUSED(void, glIndexs, (GLshort c))
SDL_PROC_UNUSED(void, glIndexsv, (const GLshort *c))
SDL_PROC_UNUSED(void, glIndexub, (GLubyte c))
SDL_PROC_UNUSED(void, glIndexubv, (const GLubyte *c))
SDL_PROC_UNUSED(void, glInitNames, (void))
SDL_PROC_UNUSED(void, glInterleavedArrays,
(GLenum format, GLsizei stride, const GLvoid *pointer))
SDL_PROC_UNUSED(GLboolean, glIsEnabled, (GLenum cap))
SDL_PROC_UNUSED(GLboolean, glIsList, (GLuint list))
SDL_PROC_UNUSED(GLboolean, glIsTexture, (GLuint texture))
SDL_PROC_UNUSED(void, glLightModelf, (GLenum pname, GLfloat param))
SDL_PROC_UNUSED(void, glLightModelfv, (GLenum pname, const GLfloat *params))
SDL_PROC_UNUSED(void, glLightModeli, (GLenum pname, GLint param))
SDL_PROC_UNUSED(void, glLightModeliv, (GLenum pname, const GLint *params))
SDL_PROC_UNUSED(void, glLightf, (GLenum light, GLenum pname, GLfloat param))
SDL_PROC_UNUSED(void, glLightfv,
(GLenum light, GLenum pname, const GLfloat *params))
SDL_PROC_UNUSED(void, glLighti, (GLenum light, GLenum pname, GLint param))
SDL_PROC_UNUSED(void, glLightiv,
(GLenum light, GLenum pname, const GLint *params))
SDL_PROC_UNUSED(void, glLineStipple, (GLint factor, GLushort pattern))
SDL_PROC(void, glLineWidth, (GLfloat width))
SDL_PROC_UNUSED(void, glListBase, (GLuint base))
SDL_PROC(void, glLoadIdentity, (void))
SDL_PROC_UNUSED(void, glLoadMatrixd, (const GLdouble *m))
SDL_PROC_UNUSED(void, glLoadMatrixf, (const GLfloat *m))
SDL_PROC_UNUSED(void, glLoadName, (GLuint name))
SDL_PROC_UNUSED(void, glLogicOp, (GLenum opcode))
SDL_PROC_UNUSED(void, glMap1d,
(GLenum target, GLdouble u1, GLdouble u2, GLint stride,
GLint order, const GLdouble *points))
SDL_PROC_UNUSED(void, glMap1f,
(GLenum target, GLfloat u1, GLfloat u2, GLint stride,
GLint order, const GLfloat *points))
SDL_PROC_UNUSED(void, glMap2d,
(GLenum target, GLdouble u1, GLdouble u2, GLint ustride,
GLint uorder, GLdouble v1, GLdouble v2, GLint vstride,
GLint vorder, const GLdouble *points))
SDL_PROC_UNUSED(void, glMap2f,
(GLenum target, GLfloat u1, GLfloat u2, GLint ustride,
GLint uorder, GLfloat v1, GLfloat v2, GLint vstride,
GLint vorder, const GLfloat *points))
SDL_PROC_UNUSED(void, glMapGrid1d, (GLint un, GLdouble u1, GLdouble u2))
SDL_PROC_UNUSED(void, glMapGrid1f, (GLint un, GLfloat u1, GLfloat u2))
SDL_PROC_UNUSED(void, glMapGrid2d,
(GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1,
GLdouble v2))
SDL_PROC_UNUSED(void, glMapGrid2f,
(GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1,
GLfloat v2))
SDL_PROC_UNUSED(void, glMaterialf, (GLenum face, GLenum pname, GLfloat param))
SDL_PROC_UNUSED(void, glMaterialfv,
(GLenum face, GLenum pname, const GLfloat *params))
SDL_PROC_UNUSED(void, glMateriali, (GLenum face, GLenum pname, GLint param))
SDL_PROC_UNUSED(void, glMaterialiv,
(GLenum face, GLenum pname, const GLint *params))
SDL_PROC(void, glMatrixMode, (GLenum mode))
SDL_PROC_UNUSED(void, glMultMatrixd, (const GLdouble *m))
SDL_PROC_UNUSED(void, glMultMatrixf, (const GLfloat *m))
SDL_PROC_UNUSED(void, glNewList, (GLuint list, GLenum mode))
SDL_PROC_UNUSED(void, glNormal3b, (GLbyte nx, GLbyte ny, GLbyte nz))
SDL_PROC_UNUSED(void, glNormal3bv, (const GLbyte *v))
SDL_PROC_UNUSED(void, glNormal3d, (GLdouble nx, GLdouble ny, GLdouble nz))
SDL_PROC_UNUSED(void, glNormal3dv, (const GLdouble *v))
SDL_PROC_UNUSED(void, glNormal3f, (GLfloat nx, GLfloat ny, GLfloat nz))
SDL_PROC_UNUSED(void, glNormal3fv, (const GLfloat *v))
SDL_PROC_UNUSED(void, glNormal3i, (GLint nx, GLint ny, GLint nz))
SDL_PROC_UNUSED(void, glNormal3iv, (const GLint *v))
SDL_PROC_UNUSED(void, glNormal3s, (GLshort nx, GLshort ny, GLshort nz))
SDL_PROC_UNUSED(void, glNormal3sv, (const GLshort *v))
SDL_PROC_UNUSED(void, glNormalPointer,
(GLenum type, GLsizei stride, const GLvoid *pointer))
SDL_PROC(void, glOrtho,
(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top,
GLdouble zNear, GLdouble zFar))
SDL_PROC_UNUSED(void, glPassThrough, (GLfloat token))
SDL_PROC_UNUSED(void, glPixelMapfv,
(GLenum map, GLsizei mapsize, const GLfloat *values))
SDL_PROC_UNUSED(void, glPixelMapuiv,
(GLenum map, GLsizei mapsize, const GLuint *values))
SDL_PROC_UNUSED(void, glPixelMapusv,
(GLenum map, GLsizei mapsize, const GLushort *values))
SDL_PROC_UNUSED(void, glPixelStoref, (GLenum pname, GLfloat param))
SDL_PROC(void, glPixelStorei, (GLenum pname, GLint param))
SDL_PROC_UNUSED(void, glPixelTransferf, (GLenum pname, GLfloat param))
SDL_PROC_UNUSED(void, glPixelTransferi, (GLenum pname, GLint param))
SDL_PROC_UNUSED(void, glPixelZoom, (GLfloat xfactor, GLfloat yfactor))
SDL_PROC(void, glPointSize, (GLfloat size))
SDL_PROC_UNUSED(void, glPolygonMode, (GLenum face, GLenum mode))
SDL_PROC_UNUSED(void, glPolygonOffset, (GLfloat factor, GLfloat units))
SDL_PROC_UNUSED(void, glPolygonStipple, (const GLubyte *mask))
SDL_PROC_UNUSED(void, glPopAttrib, (void))
SDL_PROC_UNUSED(void, glPopClientAttrib, (void))
SDL_PROC_UNUSED(void, glPopMatrix, (void))
SDL_PROC_UNUSED(void, glPopName, (void))
SDL_PROC_UNUSED(void, glPrioritizeTextures,
(GLsizei n, const GLuint *textures,
const GLclampf *priorities))
SDL_PROC_UNUSED(void, glPushAttrib, (GLbitfield mask))
SDL_PROC_UNUSED(void, glPushClientAttrib, (GLbitfield mask))
SDL_PROC_UNUSED(void, glPushMatrix, (void))
SDL_PROC_UNUSED(void, glPushName, (GLuint name))
SDL_PROC_UNUSED(void, glRasterPos2d, (GLdouble x, GLdouble y))
SDL_PROC_UNUSED(void, glRasterPos2dv, (const GLdouble *v))
SDL_PROC_UNUSED(void, glRasterPos2f, (GLfloat x, GLfloat y))
SDL_PROC_UNUSED(void, glRasterPos2fv, (const GLfloat *v))
SDL_PROC(void, glRasterPos2i, (GLint x, GLint y))
SDL_PROC_UNUSED(void, glRasterPos2iv, (const GLint *v))
SDL_PROC_UNUSED(void, glRasterPos2s, (GLshort x, GLshort y))
SDL_PROC_UNUSED(void, glRasterPos2sv, (const GLshort *v))
SDL_PROC_UNUSED(void, glRasterPos3d, (GLdouble x, GLdouble y, GLdouble z))
SDL_PROC_UNUSED(void, glRasterPos3dv, (const GLdouble *v))
SDL_PROC_UNUSED(void, glRasterPos3f, (GLfloat x, GLfloat y, GLfloat z))
SDL_PROC_UNUSED(void, glRasterPos3fv, (const GLfloat *v))
SDL_PROC_UNUSED(void, glRasterPos3i, (GLint x, GLint y, GLint z))
SDL_PROC_UNUSED(void, glRasterPos3iv, (const GLint *v))
SDL_PROC_UNUSED(void, glRasterPos3s, (GLshort x, GLshort y, GLshort z))
SDL_PROC_UNUSED(void, glRasterPos3sv, (const GLshort *v))
SDL_PROC_UNUSED(void, glRasterPos4d,
(GLdouble x, GLdouble y, GLdouble z, GLdouble w))
SDL_PROC_UNUSED(void, glRasterPos4dv, (const GLdouble *v))
SDL_PROC_UNUSED(void, glRasterPos4f,
(GLfloat x, GLfloat y, GLfloat z, GLfloat w))
SDL_PROC_UNUSED(void, glRasterPos4fv, (const GLfloat *v))
SDL_PROC_UNUSED(void, glRasterPos4i, (GLint x, GLint y, GLint z, GLint w))
SDL_PROC_UNUSED(void, glRasterPos4iv, (const GLint *v))
SDL_PROC_UNUSED(void, glRasterPos4s,
(GLshort x, GLshort y, GLshort z, GLshort w))
SDL_PROC_UNUSED(void, glRasterPos4sv, (const GLshort *v))
SDL_PROC(void, glReadBuffer, (GLenum mode))
SDL_PROC(void, glReadPixels,
(GLint x, GLint y, GLsizei width, GLsizei height,
GLenum format, GLenum type, GLvoid *pixels))
SDL_PROC_UNUSED(void, glRectd,
(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2))
SDL_PROC_UNUSED(void, glRectdv, (const GLdouble *v1, const GLdouble *v2))
SDL_PROC(void, glRectf,
(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2))
SDL_PROC_UNUSED(void, glRectfv, (const GLfloat *v1, const GLfloat *v2))
SDL_PROC_UNUSED(void, glRecti, (GLint x1, GLint y1, GLint x2, GLint y2))
SDL_PROC_UNUSED(void, glRectiv, (const GLint *v1, const GLint *v2))
SDL_PROC_UNUSED(void, glRects,
(GLshort x1, GLshort y1, GLshort x2, GLshort y2))
SDL_PROC_UNUSED(void, glRectsv, (const GLshort *v1, const GLshort *v2))
SDL_PROC_UNUSED(GLint, glRenderMode, (GLenum mode))
SDL_PROC_UNUSED(void, glRotated,
(GLdouble angle, GLdouble x, GLdouble y, GLdouble z))
SDL_PROC(void, glRotatef,
(GLfloat angle, GLfloat x, GLfloat y, GLfloat z))
SDL_PROC_UNUSED(void, glScaled, (GLdouble x, GLdouble y, GLdouble z))
SDL_PROC_UNUSED(void, glScalef, (GLfloat x, GLfloat y, GLfloat z))
SDL_PROC(void, glScissor, (GLint x, GLint y, GLsizei width, GLsizei height))
SDL_PROC_UNUSED(void, glSelectBuffer, (GLsizei size, GLuint *buffer))
SDL_PROC(void, glShadeModel, (GLenum mode))
SDL_PROC_UNUSED(void, glStencilFunc, (GLenum func, GLint ref, GLuint mask))
SDL_PROC_UNUSED(void, glStencilMask, (GLuint mask))
SDL_PROC_UNUSED(void, glStencilOp, (GLenum fail, GLenum zfail, GLenum zpass))
SDL_PROC_UNUSED(void, glTexCoord1d, (GLdouble s))
SDL_PROC_UNUSED(void, glTexCoord1dv, (const GLdouble *v))
SDL_PROC_UNUSED(void, glTexCoord1f, (GLfloat s))
SDL_PROC_UNUSED(void, glTexCoord1fv, (const GLfloat *v))
SDL_PROC_UNUSED(void, glTexCoord1i, (GLint s))
SDL_PROC_UNUSED(void, glTexCoord1iv, (const GLint *v))
SDL_PROC_UNUSED(void, glTexCoord1s, (GLshort s))
SDL_PROC_UNUSED(void, glTexCoord1sv, (const GLshort *v))
SDL_PROC_UNUSED(void, glTexCoord2d, (GLdouble s, GLdouble t))
SDL_PROC_UNUSED(void, glTexCoord2dv, (const GLdouble *v))
SDL_PROC(void, glTexCoord2f, (GLfloat s, GLfloat t))
SDL_PROC_UNUSED(void, glTexCoord2fv, (const GLfloat *v))
SDL_PROC_UNUSED(void, glTexCoord2i, (GLint s, GLint t))
SDL_PROC_UNUSED(void, glTexCoord2iv, (const GLint *v))
SDL_PROC_UNUSED(void, glTexCoord2s, (GLshort s, GLshort t))
SDL_PROC_UNUSED(void, glTexCoord2sv, (const GLshort *v))
SDL_PROC_UNUSED(void, glTexCoord3d, (GLdouble s, GLdouble t, GLdouble r))
SDL_PROC_UNUSED(void, glTexCoord3dv, (const GLdouble *v))
SDL_PROC_UNUSED(void, glTexCoord3f, (GLfloat s, GLfloat t, GLfloat r))
SDL_PROC_UNUSED(void, glTexCoord3fv, (const GLfloat *v))
SDL_PROC_UNUSED(void, glTexCoord3i, (GLint s, GLint t, GLint r))
SDL_PROC_UNUSED(void, glTexCoord3iv, (const GLint *v))
SDL_PROC_UNUSED(void, glTexCoord3s, (GLshort s, GLshort t, GLshort r))
SDL_PROC_UNUSED(void, glTexCoord3sv, (const GLshort *v))
SDL_PROC_UNUSED(void, glTexCoord4d,
(GLdouble s, GLdouble t, GLdouble r, GLdouble q))
SDL_PROC_UNUSED(void, glTexCoord4dv, (const GLdouble *v))
SDL_PROC_UNUSED(void, glTexCoord4f,
(GLfloat s, GLfloat t, GLfloat r, GLfloat q))
SDL_PROC_UNUSED(void, glTexCoord4fv, (const GLfloat *v))
SDL_PROC_UNUSED(void, glTexCoord4i, (GLint s, GLint t, GLint r, GLint q))
SDL_PROC_UNUSED(void, glTexCoord4iv, (const GLint *v))
SDL_PROC_UNUSED(void, glTexCoord4s,
(GLshort s, GLshort t, GLshort r, GLshort q))
SDL_PROC_UNUSED(void, glTexCoord4sv, (const GLshort *v))
SDL_PROC(void, glTexCoordPointer,
(GLint size, GLenum type, GLsizei stride,
const GLvoid *pointer))
SDL_PROC(void, glTexEnvf, (GLenum target, GLenum pname, GLfloat param))
SDL_PROC_UNUSED(void, glTexEnvfv,
(GLenum target, GLenum pname, const GLfloat *params))
SDL_PROC_UNUSED(void, glTexEnvi, (GLenum target, GLenum pname, GLint param))
SDL_PROC_UNUSED(void, glTexEnviv,
(GLenum target, GLenum pname, const GLint *params))
SDL_PROC_UNUSED(void, glTexGend, (GLenum coord, GLenum pname, GLdouble param))
SDL_PROC_UNUSED(void, glTexGendv,
(GLenum coord, GLenum pname, const GLdouble *params))
SDL_PROC_UNUSED(void, glTexGenf, (GLenum coord, GLenum pname, GLfloat param))
SDL_PROC_UNUSED(void, glTexGenfv,
(GLenum coord, GLenum pname, const GLfloat *params))
SDL_PROC_UNUSED(void, glTexGeni, (GLenum coord, GLenum pname, GLint param))
SDL_PROC_UNUSED(void, glTexGeniv,
(GLenum coord, GLenum pname, const GLint *params))
SDL_PROC_UNUSED(void, glTexImage1D,
(GLenum target, GLint level, GLint internalformat,
GLsizei width, GLint border, GLenum format, GLenum type,
const GLvoid *pixels))
SDL_PROC(void, glTexImage2D,
(GLenum target, GLint level, GLint internalformat, GLsizei width,
GLsizei height, GLint border, GLenum format, GLenum type,
const GLvoid *pixels))
SDL_PROC_UNUSED(void, glTexParameterf,
(GLenum target, GLenum pname, GLfloat param))
SDL_PROC_UNUSED(void, glTexParameterfv,
(GLenum target, GLenum pname, const GLfloat *params))
SDL_PROC(void, glTexParameteri, (GLenum target, GLenum pname, GLint param))
SDL_PROC_UNUSED(void, glTexParameteriv,
(GLenum target, GLenum pname, const GLint *params))
SDL_PROC_UNUSED(void, glTexSubImage1D,
(GLenum target, GLint level, GLint xoffset, GLsizei width,
GLenum format, GLenum type, const GLvoid *pixels))
SDL_PROC(void, glTexSubImage2D,
(GLenum target, GLint level, GLint xoffset, GLint yoffset,
GLsizei width, GLsizei height, GLenum format, GLenum type,
const GLvoid *pixels))
SDL_PROC_UNUSED(void, glTranslated, (GLdouble x, GLdouble y, GLdouble z))
SDL_PROC_UNUSED(void, glTranslatef, (GLfloat x, GLfloat y, GLfloat z))
SDL_PROC_UNUSED(void, glVertex2d, (GLdouble x, GLdouble y))
SDL_PROC_UNUSED(void, glVertex2dv, (const GLdouble *v))
SDL_PROC(void, glVertex2f, (GLfloat x, GLfloat y))
SDL_PROC_UNUSED(void, glVertex2fv, (const GLfloat *v))
SDL_PROC_UNUSED(void, glVertex2i, (GLint x, GLint y))
SDL_PROC_UNUSED(void, glVertex2iv, (const GLint *v))
SDL_PROC_UNUSED(void, glVertex2s, (GLshort x, GLshort y))
SDL_PROC_UNUSED(void, glVertex2sv, (const GLshort *v))
SDL_PROC_UNUSED(void, glVertex3d, (GLdouble x, GLdouble y, GLdouble z))
SDL_PROC_UNUSED(void, glVertex3dv, (const GLdouble *v))
SDL_PROC_UNUSED(void, glVertex3f, (GLfloat x, GLfloat y, GLfloat z))
SDL_PROC(void, glVertex3fv, (const GLfloat *v))
SDL_PROC_UNUSED(void, glVertex3i, (GLint x, GLint y, GLint z))
SDL_PROC_UNUSED(void, glVertex3iv, (const GLint *v))
SDL_PROC_UNUSED(void, glVertex3s, (GLshort x, GLshort y, GLshort z))
SDL_PROC_UNUSED(void, glVertex3sv, (const GLshort *v))
SDL_PROC_UNUSED(void, glVertex4d,
(GLdouble x, GLdouble y, GLdouble z, GLdouble w))
SDL_PROC_UNUSED(void, glVertex4dv, (const GLdouble *v))
SDL_PROC_UNUSED(void, glVertex4f,
(GLfloat x, GLfloat y, GLfloat z, GLfloat w))
SDL_PROC_UNUSED(void, glVertex4fv, (const GLfloat *v))
SDL_PROC_UNUSED(void, glVertex4i, (GLint x, GLint y, GLint z, GLint w))
SDL_PROC_UNUSED(void, glVertex4iv, (const GLint *v))
SDL_PROC_UNUSED(void, glVertex4s,
(GLshort x, GLshort y, GLshort z, GLshort w))
SDL_PROC_UNUSED(void, glVertex4sv, (const GLshort *v))
SDL_PROC(void, glVertexPointer,
(GLint size, GLenum type, GLsizei stride,
const GLvoid *pointer))
SDL_PROC(void, glViewport, (GLint x, GLint y, GLsizei width, GLsizei height))
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,634 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "SDL_internal.h"
#ifdef SDL_VIDEO_RENDER_OGL
#include <SDL3/SDL_opengl.h>
#include "SDL_shaders_gl.h"
// OpenGL shader implementation
// #define DEBUG_SHADERS
typedef struct
{
GLhandleARB program;
GLhandleARB vert_shader;
GLhandleARB frag_shader;
} GL_ShaderData;
struct GL_ShaderContext
{
GLenum (*glGetError)(void);
PFNGLATTACHOBJECTARBPROC glAttachObjectARB;
PFNGLCOMPILESHADERARBPROC glCompileShaderARB;
PFNGLCREATEPROGRAMOBJECTARBPROC glCreateProgramObjectARB;
PFNGLCREATESHADEROBJECTARBPROC glCreateShaderObjectARB;
PFNGLDELETEOBJECTARBPROC glDeleteObjectARB;
PFNGLGETINFOLOGARBPROC glGetInfoLogARB;
PFNGLGETOBJECTPARAMETERIVARBPROC glGetObjectParameterivARB;
PFNGLGETUNIFORMLOCATIONARBPROC glGetUniformLocationARB;
PFNGLLINKPROGRAMARBPROC glLinkProgramARB;
PFNGLSHADERSOURCEARBPROC glShaderSourceARB;
PFNGLUNIFORM1IARBPROC glUniform1iARB;
PFNGLUNIFORM1FARBPROC glUniform1fARB;
PFNGLUNIFORM3FARBPROC glUniform3fARB;
PFNGLUNIFORM4FARBPROC glUniform4fARB;
PFNGLUSEPROGRAMOBJECTARBPROC glUseProgramObjectARB;
bool GL_ARB_texture_rectangle_supported;
GL_ShaderData shaders[NUM_SHADERS];
const float *shader_params[NUM_SHADERS];
};
/* *INDENT-OFF* */ // clang-format off
#define COLOR_VERTEX_SHADER \
"varying vec4 v_color;\n" \
"\n" \
"void main()\n" \
"{\n" \
" gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n" \
" v_color = gl_Color;\n" \
"}" \
#define TEXTURE_VERTEX_SHADER \
"varying vec4 v_color;\n" \
"varying vec2 v_texCoord;\n" \
"\n" \
"void main()\n" \
"{\n" \
" gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n" \
" v_color = gl_Color;\n" \
" v_texCoord = vec2(gl_MultiTexCoord0);\n" \
"}" \
#define YUV_SHADER_PROLOGUE \
"varying vec4 v_color;\n" \
"varying vec2 v_texCoord;\n" \
"uniform sampler2D tex0; // Y \n" \
"uniform sampler2D tex1; // U \n" \
"uniform sampler2D tex2; // V \n" \
"uniform vec3 Yoffset;\n" \
"uniform vec3 Rcoeff;\n" \
"uniform vec3 Gcoeff;\n" \
"uniform vec3 Bcoeff;\n" \
"\n" \
#define YUV_SHADER_BODY \
"\n" \
"void main()\n" \
"{\n" \
" vec2 tcoord;\n" \
" vec3 yuv, rgb;\n" \
"\n" \
" // Get the Y value \n" \
" tcoord = v_texCoord;\n" \
" yuv.x = texture2D(tex0, tcoord).r;\n" \
"\n" \
" // Get the U and V values \n" \
" tcoord *= UVCoordScale;\n" \
" yuv.y = texture2D(tex1, tcoord).r;\n" \
" yuv.z = texture2D(tex2, tcoord).r;\n" \
"\n" \
" // Do the color transform \n" \
" yuv += Yoffset;\n" \
" rgb.r = dot(yuv, Rcoeff);\n" \
" rgb.g = dot(yuv, Gcoeff);\n" \
" rgb.b = dot(yuv, Bcoeff);\n" \
"\n" \
" // That was easy. :) \n" \
" gl_FragColor = vec4(rgb, 1.0) * v_color;\n" \
"}" \
#define NV12_SHADER_PROLOGUE \
"varying vec4 v_color;\n" \
"varying vec2 v_texCoord;\n" \
"uniform sampler2D tex0; // Y \n" \
"uniform sampler2D tex1; // U/V \n" \
"uniform vec3 Yoffset;\n" \
"uniform vec3 Rcoeff;\n" \
"uniform vec3 Gcoeff;\n" \
"uniform vec3 Bcoeff;\n" \
"\n" \
#define NV12_RA_SHADER_BODY \
"\n" \
"void main()\n" \
"{\n" \
" vec2 tcoord;\n" \
" vec3 yuv, rgb;\n" \
"\n" \
" // Get the Y value \n" \
" tcoord = v_texCoord;\n" \
" yuv.x = texture2D(tex0, tcoord).r;\n" \
"\n" \
" // Get the U and V values \n" \
" tcoord *= UVCoordScale;\n" \
" yuv.yz = texture2D(tex1, tcoord).ra;\n" \
"\n" \
" // Do the color transform \n" \
" yuv += Yoffset;\n" \
" rgb.r = dot(yuv, Rcoeff);\n" \
" rgb.g = dot(yuv, Gcoeff);\n" \
" rgb.b = dot(yuv, Bcoeff);\n" \
"\n" \
" // That was easy. :) \n" \
" gl_FragColor = vec4(rgb, 1.0) * v_color;\n" \
"}" \
#define NV12_RG_SHADER_BODY \
"\n" \
"void main()\n" \
"{\n" \
" vec2 tcoord;\n" \
" vec3 yuv, rgb;\n" \
"\n" \
" // Get the Y value \n" \
" tcoord = v_texCoord;\n" \
" yuv.x = texture2D(tex0, tcoord).r;\n" \
"\n" \
" // Get the U and V values \n" \
" tcoord *= UVCoordScale;\n" \
" yuv.yz = texture2D(tex1, tcoord).rg;\n" \
"\n" \
" // Do the color transform \n" \
" yuv += Yoffset;\n" \
" rgb.r = dot(yuv, Rcoeff);\n" \
" rgb.g = dot(yuv, Gcoeff);\n" \
" rgb.b = dot(yuv, Bcoeff);\n" \
"\n" \
" // That was easy. :) \n" \
" gl_FragColor = vec4(rgb, 1.0) * v_color;\n" \
"}" \
#define NV21_RA_SHADER_BODY \
"\n" \
"void main()\n" \
"{\n" \
" vec2 tcoord;\n" \
" vec3 yuv, rgb;\n" \
"\n" \
" // Get the Y value \n" \
" tcoord = v_texCoord;\n" \
" yuv.x = texture2D(tex0, tcoord).r;\n" \
"\n" \
" // Get the U and V values \n" \
" tcoord *= UVCoordScale;\n" \
" yuv.yz = texture2D(tex1, tcoord).ar;\n" \
"\n" \
" // Do the color transform \n" \
" yuv += Yoffset;\n" \
" rgb.r = dot(yuv, Rcoeff);\n" \
" rgb.g = dot(yuv, Gcoeff);\n" \
" rgb.b = dot(yuv, Bcoeff);\n" \
"\n" \
" // That was easy. :) \n" \
" gl_FragColor = vec4(rgb, 1.0) * v_color;\n" \
"}" \
#define NV21_RG_SHADER_BODY \
"\n" \
"void main()\n" \
"{\n" \
" vec2 tcoord;\n" \
" vec3 yuv, rgb;\n" \
"\n" \
" // Get the Y value \n" \
" tcoord = v_texCoord;\n" \
" yuv.x = texture2D(tex0, tcoord).r;\n" \
"\n" \
" // Get the U and V values \n" \
" tcoord *= UVCoordScale;\n" \
" yuv.yz = texture2D(tex1, tcoord).gr;\n" \
"\n" \
" // Do the color transform \n" \
" yuv += Yoffset;\n" \
" rgb.r = dot(yuv, Rcoeff);\n" \
" rgb.g = dot(yuv, Gcoeff);\n" \
" rgb.b = dot(yuv, Bcoeff);\n" \
"\n" \
" // That was easy. :) \n" \
" gl_FragColor = vec4(rgb, 1.0) * v_color;\n" \
"}" \
/*
* NOTE: Always use sampler2D, etc here. We'll #define them to the
* texture_rectangle versions if we choose to use that extension.
*/
static struct {
const char *vertex_shader;
const char *fragment_shader;
const char *fragment_version;
} shader_source[NUM_SHADERS] = {
// SHADER_NONE
{ NULL, NULL, NULL },
// SHADER_SOLID
{
// vertex shader
COLOR_VERTEX_SHADER,
// fragment shader
"varying vec4 v_color;\n"
"\n"
"void main()\n"
"{\n"
" gl_FragColor = v_color;\n"
"}",
// fragment version
NULL
},
// SHADER_RGB
{
// vertex shader
TEXTURE_VERTEX_SHADER,
// fragment shader
"varying vec4 v_color;\n"
"varying vec2 v_texCoord;\n"
"uniform sampler2D tex0;\n"
"uniform vec4 texel_size; // texel size (xy: texel size, zw: texture dimensions)\n"
"\n"
"void main()\n"
"{\n"
" gl_FragColor = texture2D(tex0, v_texCoord);\n"
" gl_FragColor.a = 1.0;\n"
" gl_FragColor *= v_color;\n"
"}",
// fragment version
NULL
},
// SHADER_RGBA
{
// vertex shader
TEXTURE_VERTEX_SHADER,
// fragment shader
"varying vec4 v_color;\n"
"varying vec2 v_texCoord;\n"
"uniform sampler2D tex0;\n"
"\n"
"void main()\n"
"{\n"
" gl_FragColor = texture2D(tex0, v_texCoord) * v_color;\n"
"}",
// fragment version
NULL
},
// SHADER_RGB_PIXELART
{
// vertex shader
TEXTURE_VERTEX_SHADER,
// fragment shader
"varying vec4 v_color;\n"
"varying vec2 v_texCoord;\n"
"uniform sampler2D tex0;\n"
"uniform vec4 texel_size;\n"
"\n"
"void main()\n"
"{\n"
" vec2 boxSize = clamp(fwidth(v_texCoord) * texel_size.zw, 1e-5, 1.0);\n"
" vec2 tx = v_texCoord * texel_size.zw - 0.5 * boxSize;\n"
" vec2 txOffset = smoothstep(vec2(1.0) - boxSize, vec2(1.0), fract(tx));\n"
" vec2 uv = (floor(tx) + 0.5 + txOffset) * texel_size.xy;\n"
" gl_FragColor = textureGrad(tex0, uv, dFdx(v_texCoord), dFdy(v_texCoord));\n"
" gl_FragColor.a = 1.0;\n"
" gl_FragColor *= v_color;\n"
"}",
// fragment version
"#version 130\n"
},
// SHADER_RGBA_PIXELART
{
// vertex shader
TEXTURE_VERTEX_SHADER,
// fragment shader
"varying vec4 v_color;\n"
"varying vec2 v_texCoord;\n"
"uniform sampler2D tex0;\n"
"uniform vec4 texel_size;\n"
"\n"
"void main()\n"
"{\n"
" vec2 boxSize = clamp(fwidth(v_texCoord) * texel_size.zw, 1e-5, 1.0);\n"
" vec2 tx = v_texCoord * texel_size.zw - 0.5 * boxSize;\n"
" vec2 txOffset = smoothstep(vec2(1.0) - boxSize, vec2(1.0), fract(tx));\n"
" vec2 uv = (floor(tx) + 0.5 + txOffset) * texel_size.xy;\n"
" gl_FragColor = textureGrad(tex0, uv, dFdx(v_texCoord), dFdy(v_texCoord));\n"
" gl_FragColor *= v_color;\n"
"}",
// fragment version
"#version 130\n"
},
#ifdef SDL_HAVE_YUV
// SHADER_YUV
{
// vertex shader
TEXTURE_VERTEX_SHADER,
// fragment shader
YUV_SHADER_PROLOGUE
YUV_SHADER_BODY,
// fragment version
NULL
},
// SHADER_NV12_RA
{
// vertex shader
TEXTURE_VERTEX_SHADER,
// fragment shader
NV12_SHADER_PROLOGUE
NV12_RA_SHADER_BODY,
// fragment version
NULL
},
// SHADER_NV12_RG
{
// vertex shader
TEXTURE_VERTEX_SHADER,
// fragment shader
NV12_SHADER_PROLOGUE
NV12_RG_SHADER_BODY,
// fragment version
NULL
},
// SHADER_NV21_RA
{
// vertex shader
TEXTURE_VERTEX_SHADER,
// fragment shader
NV12_SHADER_PROLOGUE
NV21_RA_SHADER_BODY,
// fragment version
NULL
},
// SHADER_NV21_RG
{
// vertex shader
TEXTURE_VERTEX_SHADER,
// fragment shader
NV12_SHADER_PROLOGUE
NV21_RG_SHADER_BODY,
// fragment version
NULL
},
#endif // SDL_HAVE_YUV
};
/* *INDENT-ON* */ // clang-format on
static bool CompileShader(GL_ShaderContext *ctx, GLhandleARB shader, const char *version, const char *defines, const char *source)
{
GLint status;
const char *sources[3];
sources[0] = version;
sources[1] = defines;
sources[2] = source;
ctx->glShaderSourceARB(shader, SDL_arraysize(sources), sources, NULL);
ctx->glCompileShaderARB(shader);
ctx->glGetObjectParameterivARB(shader, GL_OBJECT_COMPILE_STATUS_ARB, &status);
if (status == 0) {
bool isstack;
GLint length;
char *info;
ctx->glGetObjectParameterivARB(shader, GL_OBJECT_INFO_LOG_LENGTH_ARB, &length);
info = SDL_small_alloc(char, length + 1, &isstack);
if (info) {
ctx->glGetInfoLogARB(shader, length, NULL, info);
SDL_LogError(SDL_LOG_CATEGORY_RENDER, "Failed to compile shader:");
SDL_LogError(SDL_LOG_CATEGORY_RENDER, "%s", defines);
SDL_LogError(SDL_LOG_CATEGORY_RENDER, "%s", source);
SDL_LogError(SDL_LOG_CATEGORY_RENDER, "%s", info);
SDL_small_free(info, isstack);
}
return false;
} else {
return true;
}
}
static bool CompileShaderProgram(GL_ShaderContext *ctx, int index, GL_ShaderData *data)
{
const int num_tmus_bound = 4;
const char *vert_defines = "";
const char *frag_defines = "";
const char *frag_version = "";
int i;
GLint location;
if (index == SHADER_NONE) {
return true;
}
ctx->glGetError();
// Make sure we use the correct sampler type for our texture type
if (ctx->GL_ARB_texture_rectangle_supported) {
frag_defines =
"#define sampler2D sampler2DRect\n"
"#define texture2D texture2DRect\n"
"#define UVCoordScale 0.5\n";
} else {
frag_defines =
"#define UVCoordScale 1.0\n";
}
if (shader_source[index].fragment_version) {
frag_version = shader_source[index].fragment_version;
}
// Create one program object to rule them all
data->program = ctx->glCreateProgramObjectARB();
// Create the vertex shader
data->vert_shader = ctx->glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB);
if (!CompileShader(ctx, data->vert_shader, "", vert_defines, shader_source[index].vertex_shader)) {
return false;
}
// Create the fragment shader
data->frag_shader = ctx->glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB);
if (!CompileShader(ctx, data->frag_shader, frag_version, frag_defines, shader_source[index].fragment_shader)) {
return false;
}
// ... and in the darkness bind them
ctx->glAttachObjectARB(data->program, data->vert_shader);
ctx->glAttachObjectARB(data->program, data->frag_shader);
ctx->glLinkProgramARB(data->program);
// Set up some uniform variables
ctx->glUseProgramObjectARB(data->program);
for (i = 0; i < num_tmus_bound; ++i) {
char tex_name[10];
(void)SDL_snprintf(tex_name, SDL_arraysize(tex_name), "tex%d", i);
location = ctx->glGetUniformLocationARB(data->program, tex_name);
if (location >= 0) {
ctx->glUniform1iARB(location, i);
}
}
ctx->glUseProgramObjectARB(0);
return ctx->glGetError() == GL_NO_ERROR;
}
static void DestroyShaderProgram(GL_ShaderContext *ctx, GL_ShaderData *data)
{
ctx->glDeleteObjectARB(data->vert_shader);
ctx->glDeleteObjectARB(data->frag_shader);
ctx->glDeleteObjectARB(data->program);
}
GL_ShaderContext *GL_CreateShaderContext(void)
{
GL_ShaderContext *ctx;
bool shaders_supported;
int i;
ctx = (GL_ShaderContext *)SDL_calloc(1, sizeof(*ctx));
if (!ctx) {
return NULL;
}
if (!SDL_GL_ExtensionSupported("GL_ARB_texture_non_power_of_two") &&
(SDL_GL_ExtensionSupported("GL_ARB_texture_rectangle") ||
SDL_GL_ExtensionSupported("GL_EXT_texture_rectangle"))) {
ctx->GL_ARB_texture_rectangle_supported = true;
}
// Check for shader support
shaders_supported = false;
if (SDL_GL_ExtensionSupported("GL_ARB_shader_objects") &&
SDL_GL_ExtensionSupported("GL_ARB_shading_language_100") &&
SDL_GL_ExtensionSupported("GL_ARB_vertex_shader") &&
SDL_GL_ExtensionSupported("GL_ARB_fragment_shader")) {
ctx->glGetError = (GLenum(*)(void))SDL_GL_GetProcAddress("glGetError");
ctx->glAttachObjectARB = (PFNGLATTACHOBJECTARBPROC)SDL_GL_GetProcAddress("glAttachObjectARB");
ctx->glCompileShaderARB = (PFNGLCOMPILESHADERARBPROC)SDL_GL_GetProcAddress("glCompileShaderARB");
ctx->glCreateProgramObjectARB = (PFNGLCREATEPROGRAMOBJECTARBPROC)SDL_GL_GetProcAddress("glCreateProgramObjectARB");
ctx->glCreateShaderObjectARB = (PFNGLCREATESHADEROBJECTARBPROC)SDL_GL_GetProcAddress("glCreateShaderObjectARB");
ctx->glDeleteObjectARB = (PFNGLDELETEOBJECTARBPROC)SDL_GL_GetProcAddress("glDeleteObjectARB");
ctx->glGetInfoLogARB = (PFNGLGETINFOLOGARBPROC)SDL_GL_GetProcAddress("glGetInfoLogARB");
ctx->glGetObjectParameterivARB = (PFNGLGETOBJECTPARAMETERIVARBPROC)SDL_GL_GetProcAddress("glGetObjectParameterivARB");
ctx->glGetUniformLocationARB = (PFNGLGETUNIFORMLOCATIONARBPROC)SDL_GL_GetProcAddress("glGetUniformLocationARB");
ctx->glLinkProgramARB = (PFNGLLINKPROGRAMARBPROC)SDL_GL_GetProcAddress("glLinkProgramARB");
ctx->glShaderSourceARB = (PFNGLSHADERSOURCEARBPROC)SDL_GL_GetProcAddress("glShaderSourceARB");
ctx->glUniform1iARB = (PFNGLUNIFORM1IARBPROC)SDL_GL_GetProcAddress("glUniform1iARB");
ctx->glUniform1fARB = (PFNGLUNIFORM1FARBPROC)SDL_GL_GetProcAddress("glUniform1fARB");
ctx->glUniform3fARB = (PFNGLUNIFORM3FARBPROC)SDL_GL_GetProcAddress("glUniform3fARB");
ctx->glUniform4fARB = (PFNGLUNIFORM4FARBPROC)SDL_GL_GetProcAddress("glUniform4fARB");
ctx->glUseProgramObjectARB = (PFNGLUSEPROGRAMOBJECTARBPROC)SDL_GL_GetProcAddress("glUseProgramObjectARB");
if (ctx->glGetError &&
ctx->glAttachObjectARB &&
ctx->glCompileShaderARB &&
ctx->glCreateProgramObjectARB &&
ctx->glCreateShaderObjectARB &&
ctx->glDeleteObjectARB &&
ctx->glGetInfoLogARB &&
ctx->glGetObjectParameterivARB &&
ctx->glGetUniformLocationARB &&
ctx->glLinkProgramARB &&
ctx->glShaderSourceARB &&
ctx->glUniform1iARB &&
ctx->glUniform1fARB &&
ctx->glUniform3fARB &&
ctx->glUseProgramObjectARB) {
shaders_supported = true;
}
}
if (!shaders_supported) {
SDL_free(ctx);
return NULL;
}
// Compile all the shaders
for (i = 0; i < NUM_SHADERS; ++i) {
if (!CompileShaderProgram(ctx, i, &ctx->shaders[i])) {
GL_DestroyShaderContext(ctx);
return NULL;
}
}
// We're done!
return ctx;
}
void GL_SelectShader(GL_ShaderContext *ctx, GL_Shader shader, const float *shader_params)
{
GLint location;
GLhandleARB program = ctx->shaders[shader].program;
ctx->glUseProgramObjectARB(program);
if (shader_params && shader_params != ctx->shader_params[shader]) {
if (shader == SHADER_RGB_PIXELART ||
shader == SHADER_RGBA_PIXELART) {
location = ctx->glGetUniformLocationARB(program, "texel_size");
if (location >= 0) {
ctx->glUniform4fARB(location, shader_params[0], shader_params[1], shader_params[2], shader_params[3]);
}
}
#ifdef SDL_HAVE_YUV
if (shader >= SHADER_YUV) {
// YUV shader params are Yoffset, 0, Rcoeff, 0, Gcoeff, 0, Bcoeff, 0
location = ctx->glGetUniformLocationARB(program, "Yoffset");
if (location >= 0) {
ctx->glUniform3fARB(location, shader_params[0], shader_params[1], shader_params[2]);
}
location = ctx->glGetUniformLocationARB(program, "Rcoeff");
if (location >= 0) {
ctx->glUniform3fARB(location, shader_params[4], shader_params[5], shader_params[6]);
}
location = ctx->glGetUniformLocationARB(program, "Gcoeff");
if (location >= 0) {
ctx->glUniform3fARB(location, shader_params[8], shader_params[9], shader_params[10]);
}
location = ctx->glGetUniformLocationARB(program, "Bcoeff");
if (location >= 0) {
ctx->glUniform3fARB(location, shader_params[12], shader_params[13], shader_params[14]);
}
}
#endif // SDL_HAVE_YUV
ctx->shader_params[shader] = shader_params;
}
}
void GL_DestroyShaderContext(GL_ShaderContext *ctx)
{
int i;
for (i = 0; i < NUM_SHADERS; ++i) {
DestroyShaderProgram(ctx, &ctx->shaders[i]);
}
SDL_free(ctx);
}
#endif // SDL_VIDEO_RENDER_OGL
@@ -0,0 +1,54 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef SDL_shaders_gl_h_
#define SDL_shaders_gl_h_
#include "SDL_internal.h"
// OpenGL shader implementation
typedef enum
{
SHADER_INVALID = -1,
SHADER_NONE,
SHADER_SOLID,
SHADER_RGB,
SHADER_RGBA,
SHADER_RGB_PIXELART,
SHADER_RGBA_PIXELART,
#ifdef SDL_HAVE_YUV
SHADER_YUV,
SHADER_NV12_RA,
SHADER_NV12_RG,
SHADER_NV21_RA,
SHADER_NV21_RG,
#endif
NUM_SHADERS
} GL_Shader;
typedef struct GL_ShaderContext GL_ShaderContext;
extern GL_ShaderContext *GL_CreateShaderContext(void);
extern void GL_SelectShader(GL_ShaderContext *ctx, GL_Shader shader, const float *shader_params);
extern void GL_DestroyShaderContext(GL_ShaderContext *ctx);
#endif // SDL_shaders_gl_h_