Mercurial > sdl-ios-xcode
diff src/render/opengl/SDL_render_gl.c @ 5233:811beeb698f9
Beginning of a framework for OpenGL shaders
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Tue, 08 Feb 2011 16:27:52 -0800 |
parents | 9c0c4d767ef6 |
children | c015d3e63631 |
line wrap: on
line diff
--- a/src/render/opengl/SDL_render_gl.c Tue Feb 08 10:38:12 2011 -0800 +++ b/src/render/opengl/SDL_render_gl.c Tue Feb 08 16:27:52 2011 -0800 @@ -25,6 +25,7 @@ #include "SDL_opengl.h" #include "../SDL_sysrender.h" +#include "SDL_shaders_gl.h" #ifdef __MACOSX__ #include <OpenGL/OpenGL.h> @@ -94,6 +95,15 @@ void (*glTextureRangeAPPLE) (GLenum target, GLsizei length, const GLvoid * pointer); + + /* Multitexture support */ + SDL_bool GL_ARB_multitexture_supported; + PFNGLACTIVETEXTUREARBPROC glActiveTextureARB; + int num_texture_units; + + /* Shader support */ + GL_ShaderContext *shaders; + } GL_RenderData; typedef struct @@ -262,6 +272,25 @@ SDL_GL_GetProcAddress("glTextureRangeAPPLE"); } + /* Check for multitexture support */ + if (SDL_GL_ExtensionSupported("GL_ARB_multitexture")) { + data->glActiveTextureARB = (PFNGLACTIVETEXTUREARBPROC) SDL_GL_GetProcAddress("glActiveTextureARB"); + if (data->glActiveTextureARB) { + data->GL_ARB_multitexture_supported = SDL_TRUE; + data->glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &data->num_texture_units); + } + } + + /* Check for shader support */ + //data->shaders = GL_CreateShaderContext(); + +#if 0 + /* We support YV12 textures using 3 textures and a shader */ + if (data->shaders && data->num_texture_units >= 3) { + renderer->info.texture_formats[renderer->info.num_texture_formats++] = SDL_PIXELFORMAT_YV12; + } +#endif + /* Set up parameters for rendering */ data->blendMode = -1; data->glDisable(GL_DEPTH_TEST); @@ -579,6 +608,7 @@ GL_ActivateRenderer(renderer); GL_SetBlendMode(data, renderer->blendMode); + GL_SelectShader(data->shaders, SHADER_SOLID); data->glColor4f((GLfloat) renderer->r * inv255f, (GLfloat) renderer->g * inv255f, @@ -604,6 +634,7 @@ GL_ActivateRenderer(renderer); GL_SetBlendMode(data, renderer->blendMode); + GL_SelectShader(data->shaders, SHADER_SOLID); data->glColor4f((GLfloat) renderer->r * inv255f, (GLfloat) renderer->g * inv255f, @@ -674,6 +705,7 @@ GL_ActivateRenderer(renderer); GL_SetBlendMode(data, renderer->blendMode); + GL_SelectShader(data->shaders, SHADER_SOLID); data->glColor4f((GLfloat) renderer->r * inv255f, (GLfloat) renderer->g * inv255f, @@ -727,6 +759,7 @@ } GL_SetBlendMode(data, texture->blendMode); + GL_SelectShader(data->shaders, SHADER_RGB); data->glBegin(GL_TRIANGLE_STRIP); data->glTexCoord2f(minu, minv);