testshader.c
Go to the documentation of this file.
/*
Copyright (C) 1997-2018 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.
*/
/* This is a simple example of using GLSL shaders with SDL */
#include "SDL.h"
#ifdef HAVE_OPENGL
#include "SDL_opengl.h"
static SDL_bool shaders_supported;
static int current_shader = 0;
enum {
SHADER_COLOR,
SHADER_TEXTURE,
SHADER_TEXCOORDS,
NUM_SHADERS
};
typedef struct {
GLhandleARB program;
GLhandleARB vert_shader;
GLhandleARB frag_shader;
const char *vert_source;
const char *frag_source;
} ShaderData;
static ShaderData shaders[NUM_SHADERS] = {
/* SHADER_COLOR */
{ 0, 0, 0,
/* vertex shader */
"varying vec4 v_color;\n"
"\n"
"void main()\n"
"{\n"
" gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n"
" v_color = gl_Color;\n"
"}",
/* fragment shader */
"varying vec4 v_color;\n"
"\n"
"void main()\n"
"{\n"
" gl_FragColor = v_color;\n"
"}"
},
/* SHADER_TEXTURE */
{ 0, 0, 0,
/* 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"
"}",
/* 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"
"}"
},
/* SHADER_TEXCOORDS */
{ 0, 0, 0,
/* vertex shader */
"varying vec2 v_texCoord;\n"
"\n"
"void main()\n"
"{\n"
" gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n"
" v_texCoord = vec2(gl_MultiTexCoord0);\n"
"}",
/* fragment shader */
"varying vec2 v_texCoord;\n"
"\n"
"void main()\n"
"{\n"
" vec4 color;\n"
" vec2 delta;\n"
" float dist;\n"
"\n"
" delta = vec2(0.5, 0.5) - v_texCoord;\n"
" dist = dot(delta, delta);\n"
"\n"
" color.r = v_texCoord.x;\n"
" color.g = v_texCoord.x * v_texCoord.y;\n"
" color.b = v_texCoord.y;\n"
" color.a = 1.0 - (dist * 4.0);\n"
" gl_FragColor = color;\n"
"}"
},
};
static PFNGLATTACHOBJECTARBPROC glAttachObjectARB;
static PFNGLCOMPILESHADERARBPROC glCompileShaderARB;
static PFNGLCREATEPROGRAMOBJECTARBPROC glCreateProgramObjectARB;
static PFNGLCREATESHADEROBJECTARBPROC glCreateShaderObjectARB;
static PFNGLDELETEOBJECTARBPROC glDeleteObjectARB;
static PFNGLGETINFOLOGARBPROC glGetInfoLogARB;
static PFNGLGETOBJECTPARAMETERIVARBPROC glGetObjectParameterivARB;
static PFNGLGETUNIFORMLOCATIONARBPROC glGetUniformLocationARB;
static PFNGLLINKPROGRAMARBPROC glLinkProgramARB;
static PFNGLSHADERSOURCEARBPROC glShaderSourceARB;
static PFNGLUNIFORM1IARBPROC glUniform1iARB;
static PFNGLUSEPROGRAMOBJECTARBPROC glUseProgramObjectARB;
static SDL_bool CompileShader(GLhandleARB shader, const char *source)
{
GLint status;
glShaderSourceARB(shader, 1, &source, NULL);
glCompileShaderARB(shader);
glGetObjectParameterivARB(shader, GL_OBJECT_COMPILE_STATUS_ARB, &status);
if (status == 0) {
GLint length;
char *info;
glGetObjectParameterivARB(shader, GL_OBJECT_INFO_LOG_LENGTH_ARB, &length);
info = SDL_stack_alloc(char, length+1);
glGetInfoLogARB(shader, length, NULL, info);
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to compile shader:\n%s\n%s", source, info);
SDL_stack_free(info);
return SDL_FALSE;
} else {
return SDL_TRUE;
}
}
static SDL_bool CompileShaderProgram(ShaderData *data)
{
const int num_tmus_bound = 4;
int i;
GLint location;
glGetError();
/* Create one program object to rule them all */
data->program = glCreateProgramObjectARB();
/* Create the vertex shader */
data->vert_shader = glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB);
if (!CompileShader(data->vert_shader, data->vert_source)) {
return SDL_FALSE;
}
/* Create the fragment shader */
data->frag_shader = glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB);
if (!CompileShader(data->frag_shader, data->frag_source)) {
return SDL_FALSE;
}
/* ... and in the darkness bind them */
glAttachObjectARB(data->program, data->vert_shader);
glAttachObjectARB(data->program, data->frag_shader);
glLinkProgramARB(data->program);
/* Set up some uniform variables */
glUseProgramObjectARB(data->program);
for (i = 0; i < num_tmus_bound; ++i) {
char tex_name[5];
SDL_snprintf(tex_name, SDL_arraysize(tex_name), "tex%d", i);
location = glGetUniformLocationARB(data->program, tex_name);
if (location >= 0) {
glUniform1iARB(location, i);
}
}
glUseProgramObjectARB(0);
return (glGetError() == GL_NO_ERROR) ? SDL_TRUE : SDL_FALSE;
}
static void DestroyShaderProgram(ShaderData *data)
{
if (shaders_supported) {
glDeleteObjectARB(data->vert_shader);
glDeleteObjectARB(data->frag_shader);
glDeleteObjectARB(data->program);
}
}
static SDL_bool InitShaders()
{
int i;
/* Check for shader support */
shaders_supported = SDL_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")) {
glAttachObjectARB = (PFNGLATTACHOBJECTARBPROC) SDL_GL_GetProcAddress("glAttachObjectARB");
glCompileShaderARB = (PFNGLCOMPILESHADERARBPROC) SDL_GL_GetProcAddress("glCompileShaderARB");
glCreateProgramObjectARB = (PFNGLCREATEPROGRAMOBJECTARBPROC) SDL_GL_GetProcAddress("glCreateProgramObjectARB");
glCreateShaderObjectARB = (PFNGLCREATESHADEROBJECTARBPROC) SDL_GL_GetProcAddress("glCreateShaderObjectARB");
glDeleteObjectARB = (PFNGLDELETEOBJECTARBPROC) SDL_GL_GetProcAddress("glDeleteObjectARB");
glGetInfoLogARB = (PFNGLGETINFOLOGARBPROC) SDL_GL_GetProcAddress("glGetInfoLogARB");
glGetObjectParameterivARB = (PFNGLGETOBJECTPARAMETERIVARBPROC) SDL_GL_GetProcAddress("glGetObjectParameterivARB");
glGetUniformLocationARB = (PFNGLGETUNIFORMLOCATIONARBPROC) SDL_GL_GetProcAddress("glGetUniformLocationARB");
glLinkProgramARB = (PFNGLLINKPROGRAMARBPROC) SDL_GL_GetProcAddress("glLinkProgramARB");
glShaderSourceARB = (PFNGLSHADERSOURCEARBPROC) SDL_GL_GetProcAddress("glShaderSourceARB");
glUniform1iARB = (PFNGLUNIFORM1IARBPROC) SDL_GL_GetProcAddress("glUniform1iARB");
glUseProgramObjectARB = (PFNGLUSEPROGRAMOBJECTARBPROC) SDL_GL_GetProcAddress("glUseProgramObjectARB");
if (glAttachObjectARB &&
glCompileShaderARB &&
glCreateProgramObjectARB &&
glCreateShaderObjectARB &&
glDeleteObjectARB &&
glGetInfoLogARB &&
glGetObjectParameterivARB &&
glGetUniformLocationARB &&
glLinkProgramARB &&
glShaderSourceARB &&
glUniform1iARB &&
glUseProgramObjectARB) {
shaders_supported = SDL_TRUE;
}
}
if (!shaders_supported) {
return SDL_FALSE;
}
/* Compile all the shaders */
for (i = 0; i < NUM_SHADERS; ++i) {
if (!CompileShaderProgram(&shaders[i])) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to compile shader!\n");
return SDL_FALSE;
}
}
/* We're done! */
return SDL_TRUE;
}
static void QuitShaders()
{
int i;
for (i = 0; i < NUM_SHADERS; ++i) {
DestroyShaderProgram(&shaders[i]);
}
}
/* Quick utility function for texture creation */
static int
power_of_two(int input)
{
int value = 1;
while (value < input) {
value <<= 1;
}
return value;
}
GLuint
SDL_GL_LoadTexture(SDL_Surface * surface, GLfloat * texcoord)
{
GLuint texture;
int w, h;
SDL_Surface *image;
SDL_Rect area;
SDL_BlendMode saved_mode;
/* Use the surface width and height expanded to powers of 2 */
w = power_of_two(surface->w);
h = power_of_two(surface->h);
texcoord[0] = 0.0f; /* Min X */
texcoord[1] = 0.0f; /* Min Y */
texcoord[2] = (GLfloat) surface->w / w; /* Max X */
texcoord[3] = (GLfloat) surface->h / h; /* Max Y */
image = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, 32,
#if SDL_BYTEORDER == SDL_LIL_ENDIAN /* OpenGL RGBA masks */
0x000000FF,
0x0000FF00, 0x00FF0000, 0xFF000000
#else
0xFF000000,
0x00FF0000, 0x0000FF00, 0x000000FF
#endif
);
if (image == NULL) {
return 0;
}
/* Save the alpha blending attributes */
SDL_GetSurfaceBlendMode(surface, &saved_mode);
SDL_SetSurfaceBlendMode(surface, SDL_BLENDMODE_NONE);
/* Copy the surface into the GL texture image */
area.x = 0;
area.y = 0;
area.w = surface->w;
area.h = surface->h;
SDL_BlitSurface(surface, &area, image, &area);
/* Restore the alpha blending attributes */
SDL_SetSurfaceBlendMode(surface, saved_mode);
/* Create an OpenGL texture for the image */
glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_2D, texture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D,
0,
GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, image->pixels);
SDL_FreeSurface(image); /* No longer needed */
return texture;
}
/* A general OpenGL initialization function. Sets all of the initial parameters. */
void InitGL(int Width, int Height) /* We call this right after our OpenGL window is created. */
{
GLdouble aspect;
glViewport(0, 0, Width, Height);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f); /* This Will Clear The Background Color To Black */
glClearDepth(1.0); /* Enables Clearing Of The Depth Buffer */
glDepthFunc(GL_LESS); /* The Type Of Depth Test To Do */
glEnable(GL_DEPTH_TEST); /* Enables Depth Testing */
glShadeModel(GL_SMOOTH); /* Enables Smooth Color Shading */
glMatrixMode(GL_PROJECTION);
glLoadIdentity(); /* Reset The Projection Matrix */
aspect = (GLdouble)Width / Height;
glOrtho(-3.0, 3.0, -3.0 / aspect, 3.0 / aspect, 0.0, 1.0);
glMatrixMode(GL_MODELVIEW);
}
/* The main drawing function. */
void DrawGLScene(SDL_Window *window, GLuint texture, GLfloat * texcoord)
{
/* Texture coordinate lookup, to make it simple */
enum {
MINX,
MINY,
MAXX,
MAXY
};
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); /* Clear The Screen And The Depth Buffer */
glLoadIdentity(); /* Reset The View */
glTranslatef(-1.5f,0.0f,0.0f); /* Move Left 1.5 Units */
/* draw a triangle (in smooth coloring mode) */
glBegin(GL_POLYGON); /* start drawing a polygon */
glColor3f(1.0f,0.0f,0.0f); /* Set The Color To Red */
glVertex3f( 0.0f, 1.0f, 0.0f); /* Top */
glColor3f(0.0f,1.0f,0.0f); /* Set The Color To Green */
glVertex3f( 1.0f,-1.0f, 0.0f); /* Bottom Right */
glColor3f(0.0f,0.0f,1.0f); /* Set The Color To Blue */
glVertex3f(-1.0f,-1.0f, 0.0f); /* Bottom Left */
glEnd(); /* we're done with the polygon (smooth color interpolation) */
glTranslatef(3.0f,0.0f,0.0f); /* Move Right 3 Units */
/* Enable blending */
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
/* draw a textured square (quadrilateral) */
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, texture);
glColor3f(1.0f,1.0f,1.0f);
if (shaders_supported) {
glUseProgramObjectARB(shaders[current_shader].program);
}
glBegin(GL_QUADS); /* start drawing a polygon (4 sided) */
glTexCoord2f(texcoord[MINX], texcoord[MINY]);
glVertex3f(-1.0f, 1.0f, 0.0f); /* Top Left */
glTexCoord2f(texcoord[MAXX], texcoord[MINY]);
glVertex3f( 1.0f, 1.0f, 0.0f); /* Top Right */
glTexCoord2f(texcoord[MAXX], texcoord[MAXY]);
glVertex3f( 1.0f,-1.0f, 0.0f); /* Bottom Right */
glTexCoord2f(texcoord[MINX], texcoord[MAXY]);
glVertex3f(-1.0f,-1.0f, 0.0f); /* Bottom Left */
glEnd(); /* done with the polygon */
if (shaders_supported) {
glUseProgramObjectARB(0);
}
glDisable(GL_TEXTURE_2D);
/* swap buffers to display, since we're double buffered. */
SDL_GL_SwapWindow(window);
}
int main(int argc, char **argv)
{
int done;
SDL_Window *window;
SDL_Surface *surface;
GLuint texture;
GLfloat texcoords[4];
/* Enable standard application logging */
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
/* Initialize SDL for video output */
if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to initialize SDL: %s\n", SDL_GetError());
exit(1);
}
/* Create a 640x480 OpenGL screen */
window = SDL_CreateWindow( "Shader Demo", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 640, 480, SDL_WINDOW_OPENGL );
if ( !window ) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to create OpenGL window: %s\n", SDL_GetError());
SDL_Quit();
exit(2);
}
if ( !SDL_GL_CreateContext(window)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to create OpenGL context: %s\n", SDL_GetError());
SDL_Quit();
exit(2);
}
surface = SDL_LoadBMP("icon.bmp");
if ( ! surface ) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to load icon.bmp: %s\n", SDL_GetError());
SDL_Quit();
exit(3);
}
texture = SDL_GL_LoadTexture(surface, texcoords);
SDL_FreeSurface(surface);
/* Loop, drawing and checking events */
InitGL(640, 480);
if (InitShaders()) {
SDL_Log("Shaders supported, press SPACE to cycle them.\n");
} else {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Shaders not supported!\n");
}
done = 0;
while ( ! done ) {
DrawGLScene(window, texture, texcoords);
/* This could go in a separate function */
{ SDL_Event event;
while ( SDL_PollEvent(&event) ) {
if ( event.type == SDL_QUIT ) {
done = 1;
}
if ( event.type == SDL_KEYDOWN ) {
if ( event.key.keysym.sym == SDLK_SPACE ) {
current_shader = (current_shader + 1) % NUM_SHADERS;
}
if ( event.key.keysym.sym == SDLK_ESCAPE ) {
done = 1;
}
}
}
}
}
QuitShaders();
SDL_Quit();
return 1;
}
#else /* HAVE_OPENGL */
int
main(int argc, char *argv[])
{
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "No OpenGL support on this system\n");
return 1;
}
#endif /* HAVE_OPENGL */
/* vi: set ts=4 sw=4 expandtab: */
glViewport
GLAPI void GLAPIENTRY glViewport(GLint x, GLint y, GLsizei width, GLsizei height)
glShadeModel
GLAPI void GLAPIENTRY glShadeModel(GLenum mode)
SDL_GL_ExtensionSupported
#define SDL_GL_ExtensionSupported
Definition: SDL_dynapi_overrides.h:556
SDL_WINDOWPOS_CENTERED
#define SDL_WINDOWPOS_CENTERED
Definition: SDL_video.h:139
SDL_PollEvent
#define SDL_PollEvent
Definition: SDL_dynapi_overrides.h:122
SDL_KEYDOWN
Definition: SDL_events.h:93
SDL_GetError
#define SDL_GetError
Definition: SDL_dynapi_overrides.h:113
SDL_TRUE
Definition: SDL_stdinc.h:142
SDL_GL_CreateContext
#define SDL_GL_CreateContext
Definition: SDL_dynapi_overrides.h:559
glVertex3f
GLAPI void GLAPIENTRY glVertex3f(GLfloat x, GLfloat y, GLfloat z)
image
GLeglImageOES image
Definition: SDL_opengl.h:2148
GL_POLYGON
#define GL_POLYGON
Definition: SDL_opengl.h:225
SDL_Surface::h
int h
Definition: SDL_surface.h:73
SDL_LoadBMP
#define SDL_LoadBMP(file)
Definition: SDL_surface.h:200
SDL_BLENDMODE_NONE
Definition: SDL_blendmode.h:42
SDL_SWSURFACE
#define SDL_SWSURFACE
Definition: SDL_surface.h:52
GL_PROJECTION
#define GL_PROJECTION
Definition: SDL_opengl.h:272
glDisable
GLAPI void GLAPIENTRY glDisable(GLenum cap)
SDL_BlendMode
SDL_BlendMode
The blend mode used in SDL_RenderCopy() and drawing operations.
Definition: SDL_blendmode.h:40
SDL_FALSE
Definition: SDL_stdinc.h:141
glBlendFunc
GLAPI void GLAPIENTRY glBlendFunc(GLenum sfactor, GLenum dfactor)
h
GLfloat GLfloat GLfloat GLfloat h
Definition: SDL_opengl_glext.h:1946
surface
EGLSurface surface
Definition: eglext.h:248
GLint
int GLint
Definition: SDL_opengl.h:182
SDL_Surface
A collection of pixels used in software blitting.
Definition: SDL_surface.h:69
SDL_QUIT
Definition: SDL_events.h:60
GL_RGBA
#define GL_RGBA
Definition: SDL_opengl.h:529
SDL_BlitSurface
#define SDL_BlitSurface
Definition: SDL_surface.h:476
GL_DEPTH_BUFFER_BIT
#define GL_DEPTH_BUFFER_BIT
Definition: SDL_opengl.h:736
f
GLfloat f
Definition: SDL_opengl_glext.h:1870
glTexParameteri
GLAPI void GLAPIENTRY glTexParameteri(GLenum target, GLenum pname, GLint param)
SDL_LIL_ENDIAN
#define SDL_LIL_ENDIAN
Definition: SDL_endian.h:37
data
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: SDL_opengl.h:1974
GL_TEXTURE_MAG_FILTER
#define GL_TEXTURE_MAG_FILTER
Definition: SDL_opengl.h:674
GL_VERTEX_SHADER_ARB
#define GL_VERTEX_SHADER_ARB
Definition: SDL_opengl_glext.h:4322
SDL_CreateWindow
#define SDL_CreateWindow
Definition: SDL_dynapi_overrides.h:514
shaders
GLsizei GLsizei GLuint * shaders
Definition: SDL_opengl_glext.h:671
GLhandleARB
unsigned int GLhandleARB
Definition: SDL_opengl_glext.h:3575
GLfloat
float GLfloat
Definition: SDL_opengl.h:187
SDL_Surface::w
int w
Definition: SDL_surface.h:73
GL_ONE_MINUS_SRC_ALPHA
#define GL_ONE_MINUS_SRC_ALPHA
Definition: SDL_opengl.h:405
glEnable
GLAPI void GLAPIENTRY glEnable(GLenum cap)
glTexCoord2f
GLAPI void GLAPIENTRY glTexCoord2f(GLfloat s, GLfloat t)
GL_MODULATE
#define GL_MODULATE
Definition: SDL_opengl.h:703
SDL_GetSurfaceBlendMode
#define SDL_GetSurfaceBlendMode
Definition: SDL_dynapi_overrides.h:460
SDL_LogError
#define SDL_LogError
Definition: SDL_dynapi_overrides.h:36
GL_NO_ERROR
#define GL_NO_ERROR
Definition: SDL_opengl.h:719
SDL_opengl.h
GL_BLEND
#define GL_BLEND
Definition: SDL_opengl.h:397
glBindTexture
GLAPI void GLAPIENTRY glBindTexture(GLenum target, GLuint texture)
SDL_Log
#define SDL_Log
Definition: SDL_dynapi_overrides.h:31
texture
GLenum GLenum GLuint texture
Definition: SDL_opengl_glext.h:1178
input
GLenum GLenum GLenum input
Definition: SDL_opengl_glext.h:9374
SDL_Surface::pixels
void * pixels
Definition: SDL_surface.h:75
SDL_FreeSurface
#define SDL_FreeSurface
Definition: SDL_dynapi_overrides.h:446
glDepthFunc
GLAPI void GLAPIENTRY glDepthFunc(GLenum func)
SDL_stack_alloc
#define SDL_stack_alloc(type, count)
Definition: SDL_stdinc.h:354
event
struct _cl_event * event
Definition: SDL_opengl_glext.h:2649
SDL_GL_GetProcAddress
#define SDL_GL_GetProcAddress
Definition: SDL_dynapi_overrides.h:554
location
GLint location
Definition: SDL_opengl_glext.h:679
GL_OBJECT_INFO_LOG_LENGTH_ARB
#define GL_OBJECT_INFO_LOG_LENGTH_ARB
Definition: SDL_opengl_glext.h:3607
SDL_Quit
#define SDL_Quit
Definition: SDL_dynapi_overrides.h:58
done
int done
Definition: checkkeys.c:28
glGenTextures
GLAPI void GLAPIENTRY glGenTextures(GLsizei n, GLuint *textures)
GL_OBJECT_COMPILE_STATUS_ARB
#define GL_OBJECT_COMPILE_STATUS_ARB
Definition: SDL_opengl_glext.h:3604
GL_TEXTURE_2D
#define GL_TEXTURE_2D
Definition: SDL_opengl.h:671
w
GLubyte GLubyte GLubyte GLubyte w
Definition: SDL_opengl_glext.h:731
value
GLsizei const GLfloat * value
Definition: SDL_opengl_glext.h:698
GL_UNSIGNED_BYTE
#define GL_UNSIGNED_BYTE
Definition: SDL_opengl.h:204
glClear
GLAPI void GLAPIENTRY glClear(GLbitfield mask)
source
GLsizei GLsizei GLchar * source
Definition: SDL_opengl_glext.h:677
GL_LESS
#define GL_LESS
Definition: SDL_opengl.h:320
glTranslatef
GLAPI void GLAPIENTRY glTranslatef(GLfloat x, GLfloat y, GLfloat z)
SDL_LOG_PRIORITY_INFO
Definition: SDL_log.h:106
SDL_Rect::x
int x
Definition: SDL_rect.h:66
SDL_KeyboardEvent::keysym
SDL_Keysym keysym
Definition: SDL_events.h:199
GL_COLOR_BUFFER_BIT
#define GL_COLOR_BUFFER_BIT
Definition: SDL_opengl.h:742
SDL_Rect::w
int w
Definition: SDL_rect.h:67
GL_FRAGMENT_SHADER_ARB
#define GL_FRAGMENT_SHADER_ARB
Definition: SDL_opengl_glext.h:2974
i
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:50
glBegin
GLAPI void GLAPIENTRY glBegin(GLenum mode)
glTexEnvf
GLAPI void GLAPIENTRY glTexEnvf(GLenum target, GLenum pname, GLfloat param)
SDL_LogSetPriority
#define SDL_LogSetPriority
Definition: SDL_dynapi_overrides.h:236
NULL
#define NULL
Definition: begin_code.h:164
SDL_bool
SDL_bool
Definition: SDL_stdinc.h:139
GL_MODELVIEW
#define GL_MODELVIEW
Definition: SDL_opengl.h:271
main
int main(int argc, char *argv[])
Definition: testshader.c:492
GLuint
unsigned int GLuint
Definition: SDL_opengl.h:185
glLoadIdentity
GLAPI void GLAPIENTRY glLoadIdentity(void)
SDL_CreateRGBSurface
#define SDL_CreateRGBSurface
Definition: SDL_dynapi_overrides.h:444
window
EGLSurface EGLNativeWindowType * window
Definition: eglext.h:1025
glMatrixMode
GLAPI void GLAPIENTRY glMatrixMode(GLenum mode)
SDL_Event::key
SDL_KeyboardEvent key
Definition: SDL_events.h:530
SDL_Rect::h
int h
Definition: SDL_rect.h:67
glClearDepth
GLAPI void GLAPIENTRY glClearDepth(GLclampd depth)
SDL_SetSurfaceBlendMode
#define SDL_SetSurfaceBlendMode
Definition: SDL_dynapi_overrides.h:459
SDL_Window
The type used to identify a window.
Definition: SDL_sysvideo.h:73
GL_SRC_ALPHA
#define GL_SRC_ALPHA
Definition: SDL_opengl.h:404
GL_NEAREST
#define GL_NEAREST
Definition: SDL_opengl.h:704
GL_TEXTURE_ENV_MODE
#define GL_TEXTURE_ENV_MODE
Definition: SDL_opengl.h:669
SDL_Keysym::sym
SDL_Keycode sym
Definition: SDL_keyboard.h:50
glGetError
GLAPI GLenum GLAPIENTRY glGetError(void)
SDL_snprintf
#define SDL_snprintf
Definition: SDL_dynapi_overrides.h:40
SDL_Init
#define SDL_Init
Definition: SDL_dynapi_overrides.h:54
SDL_arraysize
#define SDL_arraysize(array)
Definition: SDL_stdinc.h:93
SDL_Event
General event structure.
Definition: SDL_events.h:525
GL_DEPTH_TEST
#define GL_DEPTH_TEST
Definition: SDL_opengl.h:327
SDL_WINDOW_OPENGL
Definition: SDL_video.h:101
GL_SMOOTH
#define GL_SMOOTH
Definition: SDL_opengl.h:365
program
GLbitfield GLuint program
Definition: SDL_opengl_glext.h:1875
glClearColor
GLAPI void GLAPIENTRY glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
GLdouble
double GLdouble
Definition: SDL_opengl.h:189
glColor3f
GLAPI void GLAPIENTRY glColor3f(GLfloat red, GLfloat green, GLfloat blue)
SDL_stack_free
#define SDL_stack_free(data)
Definition: SDL_stdinc.h:355
length
GLuint GLsizei GLsizei * length
Definition: SDL_opengl_glext.h:669
GL_TEXTURE_MIN_FILTER
#define GL_TEXTURE_MIN_FILTER
Definition: SDL_opengl.h:675
SDLK_ESCAPE
Definition: SDL_keycode.h:55
SDL.h
glEnd
GLAPI void GLAPIENTRY glEnd(void)
SDL_BYTEORDER
#define SDL_BYTEORDER
Definition: SDL_config_pandora.h:37
SDL_LOG_CATEGORY_APPLICATION
Definition: SDL_log.h:66
SDL_Rect::y
int y
Definition: SDL_rect.h:66
SDL_GL_SwapWindow
#define SDL_GL_SwapWindow
Definition: SDL_dynapi_overrides.h:566
SDLK_SPACE
Definition: SDL_keycode.h:58
SDL_INIT_VIDEO
#define SDL_INIT_VIDEO
Definition: SDL.h:78
SDL_Rect
A rectangle, with the origin at the upper left.
Definition: SDL_rect.h:64
shader
GLuint shader
Definition: SDL_opengl_glext.h:659
glTexImage2D
const GLubyte GLuint GLuint GLuint GLuint alpha GLboolean GLboolean GLboolean GLboolean alpha GLint GLint GLsizei GLsizei GLenum type GLenum GLint GLenum GLint GLint GLsizei GLsizei GLint border GLenum GLint GLint GLint GLint GLint GLsizei GLsizei height GLsizei GLsizei GLenum GLenum const GLvoid *pixels GLenum GLint GLint GLint GLint j2 GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble zFar GLenum GLenum GLint *params GLenum GLenum GLint *params GLenum GLenum GLint *params GLenum GLenum GLfloat *params GLenum GLint GLenum GLenum GLvoid *pixels GLenum GLint GLenum GLint *params GLenum GLenum GLint *params GLenum GLsizei const GLvoid *pointer GLenum GLenum const GLint *params GLenum GLfloat GLfloat GLint GLint const GLfloat *points GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat *points GLint GLfloat GLfloat GLint GLfloat GLfloat v2 GLenum GLenum const GLint *params GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble zFar GLenum GLsizei const GLuint *values GLsizei const GLuint const GLclampf *priorities GLfloat GLfloat GLfloat GLfloat w GLint GLint GLsizei GLsizei GLenum GLenum GLvoid *pixels GLfloat GLfloat GLfloat GLfloat y2 GLdouble GLdouble GLdouble GLdouble z GLdouble GLdouble GLdouble GLdouble q GLshort GLshort GLshort GLshort q GLenum GLenum const GLfloat *params GLenum GLenum const GLdouble *params GLenum GLenum const GLint *params glTexImage2D
Definition: SDL_glfuncs.h:426
NUM_SHADERS
Definition: SDL_shaders_d3d.h:29
GL_QUADS
#define GL_QUADS
Definition: SDL_opengl.h:223
SDL_Event::type
Uint32 type
Definition: SDL_events.h:527
glOrtho
const GLubyte GLuint GLuint GLuint GLuint alpha GLboolean GLboolean GLboolean GLboolean alpha GLint GLint GLsizei GLsizei GLenum type GLenum GLint GLenum GLint GLint GLsizei GLsizei GLint border GLenum GLint GLint GLint GLint GLint GLsizei GLsizei height GLsizei GLsizei GLenum GLenum const GLvoid *pixels GLenum GLint GLint GLint GLint j2 GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble zFar GLenum GLenum GLint *params GLenum GLenum GLint *params GLenum GLenum GLint *params GLenum GLenum GLfloat *params GLenum GLint GLenum GLenum GLvoid *pixels GLenum GLint GLenum GLint *params GLenum GLenum GLint *params GLenum GLsizei const GLvoid *pointer GLenum GLenum const GLint *params GLenum GLfloat GLfloat GLint GLint const GLfloat *points GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat *points GLint GLfloat GLfloat GLint GLfloat GLfloat v2 GLenum GLenum const GLint *params glOrtho
Definition: SDL_glfuncs.h:284
GL_TEXTURE_ENV
#define GL_TEXTURE_ENV
Definition: SDL_opengl.h:668