X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Farb_shader_objects.cpp;h=3cb31bc5cd36f4779ccc91d67071dae77480b687;hb=6afbace895a7bbcf216ab8e48280ea0303ab5892;hp=392538102682016febc1274208bcb93d6d43945c;hpb=5318aa4fd553be4ce0bc428e73592b787842cdea;p=libs%2Fgl.git diff --git a/source/arb_shader_objects.cpp b/source/arb_shader_objects.cpp index 39253810..3cb31bc5 100644 --- a/source/arb_shader_objects.cpp +++ b/source/arb_shader_objects.cpp @@ -1,91 +1,143 @@ -#include "extension.h" #include "arb_shader_objects.h" namespace Msp { namespace GL { -PFNGLDELETEOBJECTARBPROC glDeleteObjectARB=0; -PFNGLGETHANDLEARBPROC glGetHandleARB=0; -PFNGLDETACHOBJECTARBPROC glDetachObjectARB=0; -PFNGLCREATESHADEROBJECTARBPROC glCreateShaderObjectARB=0; -PFNGLSHADERSOURCEARBPROC glShaderSourceARB=0; -PFNGLCOMPILESHADERARBPROC glCompileShaderARB=0; -PFNGLCREATEPROGRAMOBJECTARBPROC glCreateProgramObjectARB=0; -PFNGLATTACHOBJECTARBPROC glAttachObjectARB=0; -PFNGLLINKPROGRAMARBPROC glLinkProgramARB=0; -PFNGLUSEPROGRAMOBJECTARBPROC glUseProgramObjectARB=0; -PFNGLVALIDATEPROGRAMARBPROC glValidateProgramARB=0; -PFNGLUNIFORM1FARBPROC glUniform1fARB=0; -PFNGLUNIFORM2FARBPROC glUniform2fARB=0; -PFNGLUNIFORM3FARBPROC glUniform3fARB=0; -PFNGLUNIFORM4FARBPROC glUniform4fARB=0; -PFNGLUNIFORM1IARBPROC glUniform1iARB=0; -PFNGLUNIFORM2IARBPROC glUniform2iARB=0; -PFNGLUNIFORM3IARBPROC glUniform3iARB=0; -PFNGLUNIFORM4IARBPROC glUniform4iARB=0; -PFNGLUNIFORM1FVARBPROC glUniform1fvARB=0; -PFNGLUNIFORM2FVARBPROC glUniform2fvARB=0; -PFNGLUNIFORM3FVARBPROC glUniform3fvARB=0; -PFNGLUNIFORM4FVARBPROC glUniform4fvARB=0; -PFNGLUNIFORM1IVARBPROC glUniform1ivARB=0; -PFNGLUNIFORM2IVARBPROC glUniform2ivARB=0; -PFNGLUNIFORM3IVARBPROC glUniform3ivARB=0; -PFNGLUNIFORM4IVARBPROC glUniform4ivARB=0; -PFNGLUNIFORMMATRIX2FVARBPROC glUniformMatrix2fvARB=0; -PFNGLUNIFORMMATRIX3FVARBPROC glUniformMatrix3fvARB=0; -PFNGLUNIFORMMATRIX4FVARBPROC glUniformMatrix4fvARB=0; -PFNGLGETOBJECTPARAMETERFVARBPROC glGetObjectParameterfvARB=0; -PFNGLGETOBJECTPARAMETERIVARBPROC glGetObjectParameterivARB=0; -PFNGLGETINFOLOGARBPROC glGetInfoLogARB=0; -PFNGLGETATTACHEDOBJECTSARBPROC glGetAttachedObjectsARB=0; -PFNGLGETUNIFORMLOCATIONARBPROC glGetUniformLocationARB=0; -PFNGLGETACTIVEUNIFORMARBPROC glGetActiveUniformARB=0; -PFNGLGETUNIFORMFVARBPROC glGetUniformfvARB=0; -PFNGLGETUNIFORMIVARBPROC glGetUniformivARB=0; -PFNGLGETSHADERSOURCEARBPROC glGetShaderSourceARB=0; +PFNGLATTACHSHADERPROC glAttachShader = 0; +PFNGLCOMPILESHADERPROC glCompileShader = 0; +PFNGLCREATEPROGRAMPROC glCreateProgram = 0; +PFNGLCREATESHADERPROC glCreateShader = 0; +PFNGLDELETEPROGRAMPROC glDeleteProgram = 0; +PFNGLDELETESHADERPROC glDeleteShader = 0; +PFNGLDETACHSHADERPROC glDetachShader = 0; +PFNGLGETACTIVEUNIFORMPROC glGetActiveUniform = 0; +PFNGLGETATTACHEDSHADERSPROC glGetAttachedShaders = 0; +PFNGLGETPROGRAMINFOLOGPROC glGetProgramInfoLog = 0; +PFNGLGETPROGRAMIVPROC glGetProgramiv = 0; +PFNGLGETSHADERINFOLOGPROC glGetShaderInfoLog = 0; +PFNGLGETSHADERSOURCEPROC glGetShaderSource = 0; +PFNGLGETSHADERIVPROC glGetShaderiv = 0; +PFNGLGETUNIFORMLOCATIONPROC glGetUniformLocation = 0; +PFNGLGETUNIFORMFVPROC glGetUniformfv = 0; +PFNGLGETUNIFORMIVPROC glGetUniformiv = 0; +PFNGLLINKPROGRAMPROC glLinkProgram = 0; +PFNGLSHADERSOURCEPROC glShaderSource = 0; +PFNGLUNIFORM1FPROC glUniform1f = 0; +PFNGLUNIFORM1FVPROC glUniform1fv = 0; +PFNGLUNIFORM1IPROC glUniform1i = 0; +PFNGLUNIFORM1IVPROC glUniform1iv = 0; +PFNGLUNIFORM2FPROC glUniform2f = 0; +PFNGLUNIFORM2FVPROC glUniform2fv = 0; +PFNGLUNIFORM2IPROC glUniform2i = 0; +PFNGLUNIFORM2IVPROC glUniform2iv = 0; +PFNGLUNIFORM3FPROC glUniform3f = 0; +PFNGLUNIFORM3FVPROC glUniform3fv = 0; +PFNGLUNIFORM3IPROC glUniform3i = 0; +PFNGLUNIFORM3IVPROC glUniform3iv = 0; +PFNGLUNIFORM4FPROC glUniform4f = 0; +PFNGLUNIFORM4FVPROC glUniform4fv = 0; +PFNGLUNIFORM4IPROC glUniform4i = 0; +PFNGLUNIFORM4IVPROC glUniform4iv = 0; +PFNGLUNIFORMMATRIX2FVPROC glUniformMatrix2fv = 0; +PFNGLUNIFORMMATRIX3FVPROC glUniformMatrix3fv = 0; +PFNGLUNIFORMMATRIX4FVPROC glUniformMatrix4fv = 0; +PFNGLUSEPROGRAMPROC glUseProgram = 0; +PFNGLVALIDATEPROGRAMPROC glValidateProgram = 0; -void init_arb_shader_objects() +Extension::SupportLevel init_arb_shader_objects() { - glDeleteObjectARB=reinterpret_cast(get_proc_address("glDeleteObjectARB")); - glGetHandleARB=reinterpret_cast(get_proc_address("glGetHandleARB")); - glDetachObjectARB=reinterpret_cast(get_proc_address("glDetachObjectARB")); - glCreateShaderObjectARB=reinterpret_cast(get_proc_address("glCreateShaderObjectARB")); - glShaderSourceARB=reinterpret_cast(get_proc_address("glShaderSourceARB")); - glCompileShaderARB=reinterpret_cast(get_proc_address("glCompileShaderARB")); - glCreateProgramObjectARB=reinterpret_cast(get_proc_address("glCreateProgramObjectARB")); - glAttachObjectARB=reinterpret_cast(get_proc_address("glAttachObjectARB")); - glLinkProgramARB=reinterpret_cast(get_proc_address("glLinkProgramARB")); - glUseProgramObjectARB=reinterpret_cast(get_proc_address("glUseProgramObjectARB")); - glValidateProgramARB=reinterpret_cast(get_proc_address("glValidateProgramARB")); - glUniform1fARB=reinterpret_cast(get_proc_address("glUniform1fARB")); - glUniform2fARB=reinterpret_cast(get_proc_address("glUniform2fARB")); - glUniform3fARB=reinterpret_cast(get_proc_address("glUniform3fARB")); - glUniform4fARB=reinterpret_cast(get_proc_address("glUniform4fARB")); - glUniform1iARB=reinterpret_cast(get_proc_address("glUniform1iARB")); - glUniform2iARB=reinterpret_cast(get_proc_address("glUniform2iARB")); - glUniform3iARB=reinterpret_cast(get_proc_address("glUniform3iARB")); - glUniform4iARB=reinterpret_cast(get_proc_address("glUniform4iARB")); - glUniform1fvARB=reinterpret_cast(get_proc_address("glUniform1fvARB")); - glUniform2fvARB=reinterpret_cast(get_proc_address("glUniform2fvARB")); - glUniform3fvARB=reinterpret_cast(get_proc_address("glUniform3fvARB")); - glUniform4fvARB=reinterpret_cast(get_proc_address("glUniform4fvARB")); - glUniform1ivARB=reinterpret_cast(get_proc_address("glUniform1ivARB")); - glUniform2ivARB=reinterpret_cast(get_proc_address("glUniform2ivARB")); - glUniform3ivARB=reinterpret_cast(get_proc_address("glUniform3ivARB")); - glUniform4ivARB=reinterpret_cast(get_proc_address("glUniform4ivARB")); - glUniformMatrix2fvARB=reinterpret_cast(get_proc_address("glUniformMatrix2fvARB")); - glUniformMatrix3fvARB=reinterpret_cast(get_proc_address("glUniformMatrix3fvARB")); - glUniformMatrix4fvARB=reinterpret_cast(get_proc_address("glUniformMatrix4fvARB")); - glGetObjectParameterfvARB=reinterpret_cast(get_proc_address("glGetObjectParameterfvARB")); - glGetObjectParameterivARB=reinterpret_cast(get_proc_address("glGetObjectParameterivARB")); - glGetInfoLogARB=reinterpret_cast(get_proc_address("glGetInfoLogARB")); - glGetAttachedObjectsARB=reinterpret_cast(get_proc_address("glGetAttachedObjectsARB")); - glGetUniformLocationARB=reinterpret_cast(get_proc_address("glGetUniformLocationARB")); - glGetActiveUniformARB=reinterpret_cast(get_proc_address("glGetActiveUniformARB")); - glGetUniformfvARB=reinterpret_cast(get_proc_address("glGetUniformfvARB")); - glGetUniformivARB=reinterpret_cast(get_proc_address("glGetUniformivARB")); - glGetShaderSourceARB=reinterpret_cast(get_proc_address("glGetShaderSourceARB")); + if(is_version_at_least(2, 0)) + { + glAttachShader = reinterpret_cast(get_proc_address("glAttachShader")); + glCompileShader = reinterpret_cast(get_proc_address("glCompileShader")); + glCreateProgram = reinterpret_cast(get_proc_address("glCreateProgram")); + glCreateShader = reinterpret_cast(get_proc_address("glCreateShader")); + glDeleteProgram = reinterpret_cast(get_proc_address("glDeleteProgram")); + glDeleteShader = reinterpret_cast(get_proc_address("glDeleteShader")); + glDetachShader = reinterpret_cast(get_proc_address("glDetachShader")); + glGetActiveUniform = reinterpret_cast(get_proc_address("glGetActiveUniform")); + glGetAttachedShaders = reinterpret_cast(get_proc_address("glGetAttachedShaders")); + glGetProgramInfoLog = reinterpret_cast(get_proc_address("glGetProgramInfoLog")); + glGetProgramiv = reinterpret_cast(get_proc_address("glGetProgramiv")); + glGetShaderInfoLog = reinterpret_cast(get_proc_address("glGetShaderInfoLog")); + glGetShaderSource = reinterpret_cast(get_proc_address("glGetShaderSource")); + glGetShaderiv = reinterpret_cast(get_proc_address("glGetShaderiv")); + glGetUniformLocation = reinterpret_cast(get_proc_address("glGetUniformLocation")); + glGetUniformfv = reinterpret_cast(get_proc_address("glGetUniformfv")); + glGetUniformiv = reinterpret_cast(get_proc_address("glGetUniformiv")); + glLinkProgram = reinterpret_cast(get_proc_address("glLinkProgram")); + glShaderSource = reinterpret_cast(get_proc_address("glShaderSource")); + glUniform1f = reinterpret_cast(get_proc_address("glUniform1f")); + glUniform1fv = reinterpret_cast(get_proc_address("glUniform1fv")); + glUniform1i = reinterpret_cast(get_proc_address("glUniform1i")); + glUniform1iv = reinterpret_cast(get_proc_address("glUniform1iv")); + glUniform2f = reinterpret_cast(get_proc_address("glUniform2f")); + glUniform2fv = reinterpret_cast(get_proc_address("glUniform2fv")); + glUniform2i = reinterpret_cast(get_proc_address("glUniform2i")); + glUniform2iv = reinterpret_cast(get_proc_address("glUniform2iv")); + glUniform3f = reinterpret_cast(get_proc_address("glUniform3f")); + glUniform3fv = reinterpret_cast(get_proc_address("glUniform3fv")); + glUniform3i = reinterpret_cast(get_proc_address("glUniform3i")); + glUniform3iv = reinterpret_cast(get_proc_address("glUniform3iv")); + glUniform4f = reinterpret_cast(get_proc_address("glUniform4f")); + glUniform4fv = reinterpret_cast(get_proc_address("glUniform4fv")); + glUniform4i = reinterpret_cast(get_proc_address("glUniform4i")); + glUniform4iv = reinterpret_cast(get_proc_address("glUniform4iv")); + glUniformMatrix2fv = reinterpret_cast(get_proc_address("glUniformMatrix2fv")); + glUniformMatrix3fv = reinterpret_cast(get_proc_address("glUniformMatrix3fv")); + glUniformMatrix4fv = reinterpret_cast(get_proc_address("glUniformMatrix4fv")); + glUseProgram = reinterpret_cast(get_proc_address("glUseProgram")); + glValidateProgram = reinterpret_cast(get_proc_address("glValidateProgram")); + return Extension::CORE; + } + if(is_supported("GL_ARB_shader_objects")) + { + glAttachShader = reinterpret_cast(get_proc_address("glAttachObjectARB")); + glCompileShader = reinterpret_cast(get_proc_address("glCompileShaderARB")); + glCreateProgram = reinterpret_cast(get_proc_address("glCreateProgramObjectARB")); + glCreateShader = reinterpret_cast(get_proc_address("glCreateShaderObjectARB")); + glDeleteProgram = reinterpret_cast(get_proc_address("glDeleteObjectARB")); + glDeleteShader = reinterpret_cast(get_proc_address("glDeleteObjectARB")); + glDetachShader = reinterpret_cast(get_proc_address("glDetachObjectARB")); + glGetActiveUniform = reinterpret_cast(get_proc_address("glGetActiveUniformARB")); + glGetAttachedShaders = reinterpret_cast(get_proc_address("glGetAttachedObjectsARB")); + glGetProgramInfoLog = reinterpret_cast(get_proc_address("glGetInfoLogARB")); + glGetProgramiv = reinterpret_cast(get_proc_address("glGetObjectParameterivARB")); + glGetShaderInfoLog = reinterpret_cast(get_proc_address("glGetInfoLogARB")); + glGetShaderSource = reinterpret_cast(get_proc_address("glGetShaderSourceARB")); + glGetShaderiv = reinterpret_cast(get_proc_address("glGetObjectParameterivARB")); + glGetUniformLocation = reinterpret_cast(get_proc_address("glGetUniformLocationARB")); + glGetUniformfv = reinterpret_cast(get_proc_address("glGetUniformfvARB")); + glGetUniformiv = reinterpret_cast(get_proc_address("glGetUniformivARB")); + glLinkProgram = reinterpret_cast(get_proc_address("glLinkProgramARB")); + glShaderSource = reinterpret_cast(get_proc_address("glShaderSourceARB")); + glUniform1f = reinterpret_cast(get_proc_address("glUniform1fARB")); + glUniform1fv = reinterpret_cast(get_proc_address("glUniform1fvARB")); + glUniform1i = reinterpret_cast(get_proc_address("glUniform1iARB")); + glUniform1iv = reinterpret_cast(get_proc_address("glUniform1ivARB")); + glUniform2f = reinterpret_cast(get_proc_address("glUniform2fARB")); + glUniform2fv = reinterpret_cast(get_proc_address("glUniform2fvARB")); + glUniform2i = reinterpret_cast(get_proc_address("glUniform2iARB")); + glUniform2iv = reinterpret_cast(get_proc_address("glUniform2ivARB")); + glUniform3f = reinterpret_cast(get_proc_address("glUniform3fARB")); + glUniform3fv = reinterpret_cast(get_proc_address("glUniform3fvARB")); + glUniform3i = reinterpret_cast(get_proc_address("glUniform3iARB")); + glUniform3iv = reinterpret_cast(get_proc_address("glUniform3ivARB")); + glUniform4f = reinterpret_cast(get_proc_address("glUniform4fARB")); + glUniform4fv = reinterpret_cast(get_proc_address("glUniform4fvARB")); + glUniform4i = reinterpret_cast(get_proc_address("glUniform4iARB")); + glUniform4iv = reinterpret_cast(get_proc_address("glUniform4ivARB")); + glUniformMatrix2fv = reinterpret_cast(get_proc_address("glUniformMatrix2fvARB")); + glUniformMatrix3fv = reinterpret_cast(get_proc_address("glUniformMatrix3fvARB")); + glUniformMatrix4fv = reinterpret_cast(get_proc_address("glUniformMatrix4fvARB")); + glUseProgram = reinterpret_cast(get_proc_address("glUseProgramObjectARB")); + glValidateProgram = reinterpret_cast(get_proc_address("glValidateProgramARB")); + return Extension::EXTENSION; + } + return Extension::UNSUPPORTED; } +Extension ARB_shader_objects("GL_ARB_shader_objects", init_arb_shader_objects); + } // namespace GL } // namespace Msp