From 9376b265371cc384dc8e38c94be756931f67de39 Mon Sep 17 00:00:00 2001 From: "gregory.hainaut" Date: Sun, 19 May 2013 09:19:20 +0000 Subject: [PATCH] gsdx-ogl-wnd: * load extension as gl_Function instead of glFunction git-svn-id: http://pcsx2.googlecode.com/svn/branches/gsdx-ogl-wnd@5635 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/GSdx/GLLoader.cpp | 262 +++++++++++++++--------------- plugins/GSdx/GLLoader.h | 145 ++++++++--------- plugins/GSdx/GSDeviceOGL.cpp | 166 +++++++++---------- plugins/GSdx/GSDeviceOGL.h | 6 +- plugins/GSdx/GSTextureFXOGL.cpp | 48 +++--- plugins/GSdx/GSTextureOGL.cpp | 68 ++++---- plugins/GSdx/GSUniformBufferOGL.h | 14 +- plugins/GSdx/GSVertexArrayOGL.h | 32 ++-- 8 files changed, 365 insertions(+), 376 deletions(-) diff --git a/plugins/GSdx/GLLoader.cpp b/plugins/GSdx/GLLoader.cpp index 43468c3dde..fa70e2db30 100644 --- a/plugins/GSdx/GLLoader.cpp +++ b/plugins/GSdx/GLLoader.cpp @@ -22,72 +22,68 @@ #include "stdafx.h" #include "GLLoader.h" -// Those are provided on gl.h on linux... -#ifdef _WINDOWS -PFNGLACTIVETEXTUREPROC glActiveTexture = NULL; -PFNGLBLENDCOLORPROC glBlendColor = NULL; -#endif - -PFNGLATTACHSHADERPROC glAttachShader = NULL; -PFNGLBINDBUFFERPROC glBindBuffer = NULL; -PFNGLBINDBUFFERBASEPROC glBindBufferBase = NULL; -PFNGLBINDFRAGDATALOCATIONINDEXEDPROC glBindFragDataLocationIndexed = NULL; -PFNGLBINDFRAMEBUFFERPROC glBindFramebuffer = NULL; -PFNGLBINDPROGRAMPIPELINEPROC glBindProgramPipeline = NULL; -PFNGLBINDSAMPLERPROC glBindSampler = NULL; -PFNGLBINDVERTEXARRAYPROC glBindVertexArray = NULL; -PFNGLBLENDEQUATIONSEPARATEPROC glBlendEquationSeparate = NULL; -PFNGLBLENDFUNCSEPARATEPROC glBlendFuncSeparate = NULL; -PFNGLBLITFRAMEBUFFERPROC glBlitFramebuffer = NULL; -PFNGLBUFFERDATAPROC glBufferData = NULL; -PFNGLCHECKFRAMEBUFFERSTATUSPROC glCheckFramebufferStatus = NULL; -PFNGLCLEARBUFFERFVPROC glClearBufferfv = NULL; -PFNGLCLEARBUFFERIVPROC glClearBufferiv = NULL; -PFNGLCOMPILESHADERPROC glCompileShader = NULL; -PFNGLCOPYIMAGESUBDATANVPROC glCopyImageSubDataNV = NULL; -PFNGLCREATEPROGRAMPROC glCreateProgram = NULL; -PFNGLCREATESHADERPROC glCreateShader = NULL; -PFNGLCREATESHADERPROGRAMVPROC glCreateShaderProgramv = NULL; -PFNGLDELETEBUFFERSPROC glDeleteBuffers = NULL; -PFNGLDELETEFRAMEBUFFERSPROC glDeleteFramebuffers = NULL; -PFNGLDELETEPROGRAMPROC glDeleteProgram = NULL; -PFNGLDELETEPROGRAMPIPELINESPROC glDeleteProgramPipelines = NULL; -PFNGLDELETESAMPLERSPROC glDeleteSamplers = NULL; -PFNGLDELETESHADERPROC glDeleteShader = NULL; -PFNGLDELETEVERTEXARRAYSPROC glDeleteVertexArrays = NULL; -PFNGLDETACHSHADERPROC glDetachShader = NULL; -PFNGLDRAWBUFFERSPROC glDrawBuffers = NULL; -PFNGLDRAWELEMENTSBASEVERTEXPROC glDrawElementsBaseVertex = NULL; -PFNGLENABLEVERTEXATTRIBARRAYPROC glEnableVertexAttribArray = NULL; -PFNGLFRAMEBUFFERRENDERBUFFERPROC glFramebufferRenderbuffer = NULL; -PFNGLFRAMEBUFFERTEXTURE2DPROC glFramebufferTexture2D = NULL; -PFNGLGENBUFFERSPROC glGenBuffers = NULL; -PFNGLGENFRAMEBUFFERSPROC glGenFramebuffers = NULL; -PFNGLGENPROGRAMPIPELINESPROC glGenProgramPipelines = NULL; -PFNGLGENSAMPLERSPROC glGenSamplers = NULL; -PFNGLGENVERTEXARRAYSPROC glGenVertexArrays = NULL; -PFNGLGETBUFFERPARAMETERIVPROC glGetBufferParameteriv = NULL; -PFNGLGETDEBUGMESSAGELOGARBPROC glGetDebugMessageLogARB = NULL; -PFNGLGETFRAGDATAINDEXPROC glGetFragDataIndex = NULL; -PFNGLGETFRAGDATALOCATIONPROC glGetFragDataLocation = NULL; -PFNGLGETPROGRAMINFOLOGPROC glGetProgramInfoLog = NULL; -PFNGLGETPROGRAMIVPROC glGetProgramiv = NULL; -PFNGLGETSHADERIVPROC glGetShaderiv = NULL; -PFNGLGETSTRINGIPROC glGetStringi = NULL; -PFNGLISFRAMEBUFFERPROC glIsFramebuffer = NULL; -PFNGLLINKPROGRAMPROC glLinkProgram = NULL; -PFNGLMAPBUFFERPROC glMapBuffer = NULL; -PFNGLMAPBUFFERRANGEPROC glMapBufferRange = NULL; -PFNGLPROGRAMPARAMETERIPROC glProgramParameteri = NULL; -PFNGLSAMPLERPARAMETERFPROC glSamplerParameterf = NULL; -PFNGLSAMPLERPARAMETERIPROC glSamplerParameteri = NULL; -PFNGLSHADERSOURCEPROC glShaderSource = NULL; -PFNGLUNIFORM1IPROC glUniform1i = NULL; -PFNGLUNMAPBUFFERPROC glUnmapBuffer = NULL; -PFNGLUSEPROGRAMSTAGESPROC glUseProgramStages = NULL; -PFNGLVERTEXATTRIBIPOINTERPROC glVertexAttribIPointer = NULL; -PFNGLVERTEXATTRIBPOINTERPROC glVertexAttribPointer = NULL; -PFNGLTEXSTORAGE2DPROC glTexStorage2D = NULL; +PFNGLACTIVETEXTUREPROC gl_ActiveTexture = NULL; +PFNGLBLENDCOLORPROC gl_BlendColor = NULL; +PFNGLATTACHSHADERPROC gl_AttachShader = NULL; +PFNGLBINDBUFFERPROC gl_BindBuffer = NULL; +PFNGLBINDBUFFERBASEPROC gl_BindBufferBase = NULL; +PFNGLBINDFRAGDATALOCATIONINDEXEDPROC gl_BindFragDataLocationIndexed = NULL; +PFNGLBINDFRAMEBUFFERPROC gl_BindFramebuffer = NULL; +PFNGLBINDPROGRAMPIPELINEPROC gl_BindProgramPipeline = NULL; +PFNGLBINDSAMPLERPROC gl_BindSampler = NULL; +PFNGLBINDVERTEXARRAYPROC gl_BindVertexArray = NULL; +PFNGLBLENDEQUATIONSEPARATEPROC gl_BlendEquationSeparate = NULL; +PFNGLBLENDFUNCSEPARATEPROC gl_BlendFuncSeparate = NULL; +PFNGLBLITFRAMEBUFFERPROC gl_BlitFramebuffer = NULL; +PFNGLBUFFERDATAPROC gl_BufferData = NULL; +PFNGLCHECKFRAMEBUFFERSTATUSPROC gl_CheckFramebufferStatus = NULL; +PFNGLCLEARBUFFERFVPROC gl_ClearBufferfv = NULL; +PFNGLCLEARBUFFERIVPROC gl_ClearBufferiv = NULL; +PFNGLCOMPILESHADERPROC gl_CompileShader = NULL; +PFNGLCOPYIMAGESUBDATANVPROC gl_CopyImageSubDataNV = NULL; +PFNGLCREATEPROGRAMPROC gl_CreateProgram = NULL; +PFNGLCREATESHADERPROC gl_CreateShader = NULL; +PFNGLCREATESHADERPROGRAMVPROC gl_CreateShaderProgramv = NULL; +PFNGLDELETEBUFFERSPROC gl_DeleteBuffers = NULL; +PFNGLDELETEFRAMEBUFFERSPROC gl_DeleteFramebuffers = NULL; +PFNGLDELETEPROGRAMPROC gl_DeleteProgram = NULL; +PFNGLDELETEPROGRAMPIPELINESPROC gl_DeleteProgramPipelines = NULL; +PFNGLDELETESAMPLERSPROC gl_DeleteSamplers = NULL; +PFNGLDELETESHADERPROC gl_DeleteShader = NULL; +PFNGLDELETEVERTEXARRAYSPROC gl_DeleteVertexArrays = NULL; +PFNGLDETACHSHADERPROC gl_DetachShader = NULL; +PFNGLDRAWBUFFERSPROC gl_DrawBuffers = NULL; +PFNGLDRAWELEMENTSBASEVERTEXPROC gl_DrawElementsBaseVertex = NULL; +PFNGLENABLEVERTEXATTRIBARRAYPROC gl_EnableVertexAttribArray = NULL; +PFNGLFRAMEBUFFERRENDERBUFFERPROC gl_FramebufferRenderbuffer = NULL; +PFNGLFRAMEBUFFERTEXTURE2DPROC gl_FramebufferTexture2D = NULL; +PFNGLGENBUFFERSPROC gl_GenBuffers = NULL; +PFNGLGENFRAMEBUFFERSPROC gl_GenFramebuffers = NULL; +PFNGLGENPROGRAMPIPELINESPROC gl_GenProgramPipelines = NULL; +PFNGLGENSAMPLERSPROC gl_GenSamplers = NULL; +PFNGLGENVERTEXARRAYSPROC gl_GenVertexArrays = NULL; +PFNGLGETBUFFERPARAMETERIVPROC gl_GetBufferParameteriv = NULL; +PFNGLGETDEBUGMESSAGELOGARBPROC gl_GetDebugMessageLogARB = NULL; +PFNGLGETFRAGDATAINDEXPROC gl_GetFragDataIndex = NULL; +PFNGLGETFRAGDATALOCATIONPROC gl_GetFragDataLocation = NULL; +PFNGLGETPROGRAMINFOLOGPROC gl_GetProgramInfoLog = NULL; +PFNGLGETPROGRAMIVPROC gl_GetProgramiv = NULL; +PFNGLGETSHADERIVPROC gl_GetShaderiv = NULL; +PFNGLGETSTRINGIPROC gl_GetStringi = NULL; +PFNGLISFRAMEBUFFERPROC gl_IsFramebuffer = NULL; +PFNGLLINKPROGRAMPROC gl_LinkProgram = NULL; +PFNGLMAPBUFFERPROC gl_MapBuffer = NULL; +PFNGLMAPBUFFERRANGEPROC gl_MapBufferRange = NULL; +PFNGLPROGRAMPARAMETERIPROC gl_ProgramParameteri = NULL; +PFNGLSAMPLERPARAMETERFPROC gl_SamplerParameterf = NULL; +PFNGLSAMPLERPARAMETERIPROC gl_SamplerParameteri = NULL; +PFNGLSHADERSOURCEPROC gl_ShaderSource = NULL; +PFNGLUNIFORM1IPROC gl_Uniform1i = NULL; +PFNGLUNMAPBUFFERPROC gl_UnmapBuffer = NULL; +PFNGLUSEPROGRAMSTAGESPROC gl_UseProgramStages = NULL; +PFNGLVERTEXATTRIBIPOINTERPROC gl_VertexAttribIPointer = NULL; +PFNGLVERTEXATTRIBPOINTERPROC gl_VertexAttribPointer = NULL; +PFNGLTEXSTORAGE2DPROC gl_TexStorage2D = NULL; namespace GLLoader { @@ -107,7 +103,7 @@ namespace GLLoader { GLuint minor_gl = s[dot+1]-'0'; if ( (major_gl < major) || ( major_gl == major && minor_gl < minor ) ) { - fprintf(stderr, "OPENGL 3.3 is not supported\n"); + fprintf(stderr, "OPENGL %d.%d is not supported\n", major, minor); return false; } @@ -115,72 +111,68 @@ namespace GLLoader { } void init_gl_function() { - // Those are provided on gl.h on linux... -#ifdef _WINDOWS - GL_LOADFN(glActiveTexture); - GL_LOADFN(glBlendColor); -#endif - - GL_LOADFN(glAttachShader); - GL_LOADFN(glBindBuffer); - GL_LOADFN(glBindBufferBase); - GL_LOADFN(glBindFragDataLocationIndexed); - GL_LOADFN(glBindFramebuffer); - GL_LOADFN(glBindProgramPipeline); - GL_LOADFN(glBindSampler); - GL_LOADFN(glBindVertexArray); - GL_LOADFN(glBlendEquationSeparate); - GL_LOADFN(glBlendFuncSeparate); - GL_LOADFN(glBlitFramebuffer); - GL_LOADFN(glBufferData); - GL_LOADFN(glCheckFramebufferStatus); - GL_LOADFN(glClearBufferfv); - GL_LOADFN(glClearBufferiv); - GL_LOADFN(glCompileShader); - GL_LOADFN(glCopyImageSubDataNV); - GL_LOADFN(glCreateProgram); - GL_LOADFN(glCreateShader); - GL_LOADFN(glCreateShaderProgramv); - GL_LOADFN(glDeleteBuffers); - GL_LOADFN(glDeleteFramebuffers); - GL_LOADFN(glDeleteProgram); - GL_LOADFN(glDeleteProgramPipelines); - GL_LOADFN(glDeleteSamplers); - GL_LOADFN(glDeleteShader); - GL_LOADFN(glDeleteVertexArrays); - GL_LOADFN(glDetachShader); - GL_LOADFN(glDrawBuffers); - GL_LOADFN(glDrawElementsBaseVertex); - GL_LOADFN(glEnableVertexAttribArray); - GL_LOADFN(glFramebufferRenderbuffer); - GL_LOADFN(glFramebufferTexture2D); - GL_LOADFN(glGenBuffers); - GL_LOADFN(glGenFramebuffers); - GL_LOADFN(glGenProgramPipelines); - GL_LOADFN(glGenSamplers); - GL_LOADFN(glGenVertexArrays); - GL_LOADFN(glGetBufferParameteriv); - GL_LOADFN(glGetDebugMessageLogARB); - GL_LOADFN(glGetFragDataIndex); - GL_LOADFN(glGetFragDataLocation); - GL_LOADFN(glGetProgramInfoLog); - GL_LOADFN(glGetProgramiv); - GL_LOADFN(glGetShaderiv); - GL_LOADFN(glGetStringi); - GL_LOADFN(glIsFramebuffer); - GL_LOADFN(glLinkProgram); - GL_LOADFN(glMapBuffer); - GL_LOADFN(glMapBufferRange); - GL_LOADFN(glProgramParameteri); - GL_LOADFN(glSamplerParameterf); - GL_LOADFN(glSamplerParameteri); - GL_LOADFN(glShaderSource); - GL_LOADFN(glUniform1i); - GL_LOADFN(glUnmapBuffer); - GL_LOADFN(glUseProgramStages); - GL_LOADFN(glVertexAttribIPointer); - GL_LOADFN(glVertexAttribPointer); - GL_LOADFN(glTexStorage2D); + GL_LOADFN(gl_ActiveTexture, glActiveTexture); + GL_LOADFN(gl_BlendColor, glBlendColor); + GL_LOADFN(gl_AttachShader, glAttachShader); + GL_LOADFN(gl_BindBuffer, glBindBuffer); + GL_LOADFN(gl_BindBufferBase, glBindBufferBase); + GL_LOADFN(gl_BindFragDataLocationIndexed, glBindFragDataLocationIndexed); + GL_LOADFN(gl_BindFramebuffer, glBindFramebuffer); + GL_LOADFN(gl_BindProgramPipeline, glBindProgramPipeline); + GL_LOADFN(gl_BindSampler, glBindSampler); + GL_LOADFN(gl_BindVertexArray, glBindVertexArray); + GL_LOADFN(gl_BlendEquationSeparate, glBlendEquationSeparate); + GL_LOADFN(gl_BlendFuncSeparate, glBlendFuncSeparate); + GL_LOADFN(gl_BlitFramebuffer, glBlitFramebuffer); + GL_LOADFN(gl_BufferData, glBufferData); + GL_LOADFN(gl_CheckFramebufferStatus, glCheckFramebufferStatus); + GL_LOADFN(gl_ClearBufferfv, glClearBufferfv); + GL_LOADFN(gl_ClearBufferiv, glClearBufferiv); + GL_LOADFN(gl_CompileShader, glCompileShader); + GL_LOADFN(gl_CopyImageSubDataNV, glCopyImageSubDataNV); + GL_LOADFN(gl_CreateProgram, glCreateProgram); + GL_LOADFN(gl_CreateShader, glCreateShader); + GL_LOADFN(gl_CreateShaderProgramv, glCreateShaderProgramv); + GL_LOADFN(gl_DeleteBuffers, glDeleteBuffers); + GL_LOADFN(gl_DeleteFramebuffers, glDeleteFramebuffers); + GL_LOADFN(gl_DeleteProgram, glDeleteProgram); + GL_LOADFN(gl_DeleteProgramPipelines, glDeleteProgramPipelines); + GL_LOADFN(gl_DeleteSamplers, glDeleteSamplers); + GL_LOADFN(gl_DeleteShader, glDeleteShader); + GL_LOADFN(gl_DeleteVertexArrays, glDeleteVertexArrays); + GL_LOADFN(gl_DetachShader, glDetachShader); + GL_LOADFN(gl_DrawBuffers, glDrawBuffers); + GL_LOADFN(gl_DrawElementsBaseVertex, glDrawElementsBaseVertex); + GL_LOADFN(gl_EnableVertexAttribArray, glEnableVertexAttribArray); + GL_LOADFN(gl_FramebufferRenderbuffer, glFramebufferRenderbuffer); + GL_LOADFN(gl_FramebufferTexture2D, glFramebufferTexture2D); + GL_LOADFN(gl_GenBuffers, glGenBuffers); + GL_LOADFN(gl_GenFramebuffers, glGenFramebuffers); + GL_LOADFN(gl_GenProgramPipelines, glGenProgramPipelines); + GL_LOADFN(gl_GenSamplers, glGenSamplers); + GL_LOADFN(gl_GenVertexArrays, glGenVertexArrays); + GL_LOADFN(gl_GetBufferParameteriv, glGetBufferParameteriv); + GL_LOADFN(gl_GetDebugMessageLogARB, glGetDebugMessageLogARB); + GL_LOADFN(gl_GetFragDataIndex, glGetFragDataIndex); + GL_LOADFN(gl_GetFragDataLocation, glGetFragDataLocation); + GL_LOADFN(gl_GetProgramInfoLog, glGetProgramInfoLog); + GL_LOADFN(gl_GetProgramiv, glGetProgramiv); + GL_LOADFN(gl_GetShaderiv, glGetShaderiv); + GL_LOADFN(gl_GetStringi, glGetStringi); + GL_LOADFN(gl_IsFramebuffer, glIsFramebuffer); + GL_LOADFN(gl_LinkProgram, glLinkProgram); + GL_LOADFN(gl_MapBuffer, glMapBuffer); + GL_LOADFN(gl_MapBufferRange, glMapBufferRange); + GL_LOADFN(gl_ProgramParameteri, glProgramParameteri); + GL_LOADFN(gl_SamplerParameterf, glSamplerParameterf); + GL_LOADFN(gl_SamplerParameteri, glSamplerParameteri); + GL_LOADFN(gl_ShaderSource, glShaderSource); + GL_LOADFN(gl_Uniform1i, glUniform1i); + GL_LOADFN(gl_UnmapBuffer, glUnmapBuffer); + GL_LOADFN(gl_UseProgramStages, glUseProgramStages); + GL_LOADFN(gl_VertexAttribIPointer, glVertexAttribIPointer); + GL_LOADFN(gl_VertexAttribPointer, glVertexAttribPointer); + GL_LOADFN(gl_TexStorage2D, glTexStorage2D); } bool check_gl_supported_extension() { @@ -192,9 +184,9 @@ namespace GLLoader { bool found_GL_ARB_texture_storage = false; fprintf(stderr, "DEBUG: check_gl_supported_extension\n"); - if (glGetStringi && max_ext) { + if (gl_GetStringi && max_ext) { for (GLint i = 0; i < max_ext; i++) { - string ext((const char*)glGetStringi(GL_EXTENSIONS, i)); + string ext((const char*)gl_GetStringi(GL_EXTENSIONS, i)); if (ext.compare("GL_ARB_separate_shader_objects") == 0) { found_GL_ARB_separate_shader_objects = true; } diff --git a/plugins/GSdx/GLLoader.h b/plugins/GSdx/GLLoader.h index c49fd3f28d..6fe9194aaf 100644 --- a/plugins/GSdx/GLLoader.h +++ b/plugins/GSdx/GLLoader.h @@ -28,92 +28,89 @@ #endif #ifdef _WINDOWS -#define GL_LOADFN(name) { \ - if( (*(void**)&name = (void*)wglGetProcAddress(#name)) == NULL ) { \ - fprintf(stderr,"Failed to find %s\n", #name); \ +#define GL_LOADFN(name, glName) { \ + if( (*(void**)&name = (void*)wglGetProcAddress(#glName)) == NULL ) { \ + fprintf(stderr,"Failed to find %s\n", #glName); \ } \ } #else #ifdef EGL_API -#define GL_LOADFN(name) { \ - if( (*(void**)&name = (void*)eglGetProcAddress(#name)) == NULL ) { \ - fprintf(stderr,"Failed to find %s\n", #name); \ +#define GL_LOADFN(name, glName) { \ + if( (*(void**)&name = (void*)eglGetProcAddress(#glName)) == NULL ) { \ + fprintf(stderr,"Failed to find %s\n", #glName); \ } \ } #else -#define GL_LOADFN(name) { \ - if( (*(void**)&name = (void*)glXGetProcAddress((const GLubyte*)#name)) == NULL ) { \ - fprintf(stderr,"Failed to find %s\n", #name); \ +#define GL_LOADFN(name, glName) { \ + if( (*(void**)&name = (void*)glXGetProcAddress((const GLubyte*)#glName)) == NULL ) { \ + fprintf(stderr,"Failed to find %s\n", #glName); \ } \ } #endif #endif -// Those are provided on gl.h on linux... -#ifdef _WINDOWS -extern PFNGLACTIVETEXTUREPROC glActiveTexture; -extern PFNGLBLENDCOLORPROC glBlendColor; -#endif -extern PFNGLATTACHSHADERPROC glAttachShader; -extern PFNGLBINDBUFFERPROC glBindBuffer; -extern PFNGLBINDBUFFERBASEPROC glBindBufferBase; -extern PFNGLBINDFRAGDATALOCATIONINDEXEDPROC glBindFragDataLocationIndexed; -extern PFNGLBINDFRAMEBUFFERPROC glBindFramebuffer; -extern PFNGLBINDPROGRAMPIPELINEPROC glBindProgramPipeline; -extern PFNGLBINDSAMPLERPROC glBindSampler; -extern PFNGLBINDVERTEXARRAYPROC glBindVertexArray; -extern PFNGLBLENDEQUATIONSEPARATEPROC glBlendEquationSeparate; -extern PFNGLBLENDFUNCSEPARATEPROC glBlendFuncSeparate; -extern PFNGLBLITFRAMEBUFFERPROC glBlitFramebuffer; -extern PFNGLBUFFERDATAPROC glBufferData; -extern PFNGLCHECKFRAMEBUFFERSTATUSPROC glCheckFramebufferStatus; -extern PFNGLCLEARBUFFERFVPROC glClearBufferfv; -extern PFNGLCLEARBUFFERIVPROC glClearBufferiv; -extern PFNGLCOMPILESHADERPROC glCompileShader; -extern PFNGLCOPYIMAGESUBDATANVPROC glCopyImageSubDataNV; -extern PFNGLCREATEPROGRAMPROC glCreateProgram; -extern PFNGLCREATESHADERPROC glCreateShader; -extern PFNGLCREATESHADERPROGRAMVPROC glCreateShaderProgramv; -extern PFNGLDELETEBUFFERSPROC glDeleteBuffers; -extern PFNGLDELETEFRAMEBUFFERSPROC glDeleteFramebuffers; -extern PFNGLDELETEPROGRAMPROC glDeleteProgram; -extern PFNGLDELETEPROGRAMPIPELINESPROC glDeleteProgramPipelines; -extern PFNGLDELETESAMPLERSPROC glDeleteSamplers; -extern PFNGLDELETESHADERPROC glDeleteShader; -extern PFNGLDELETEVERTEXARRAYSPROC glDeleteVertexArrays; -extern PFNGLDETACHSHADERPROC glDetachShader; -extern PFNGLDRAWBUFFERSPROC glDrawBuffers; -extern PFNGLDRAWELEMENTSBASEVERTEXPROC glDrawElementsBaseVertex; -extern PFNGLENABLEVERTEXATTRIBARRAYPROC glEnableVertexAttribArray; -extern PFNGLFRAMEBUFFERRENDERBUFFERPROC glFramebufferRenderbuffer; -extern PFNGLFRAMEBUFFERTEXTURE2DPROC glFramebufferTexture2D; -extern PFNGLGENBUFFERSPROC glGenBuffers; -extern PFNGLGENFRAMEBUFFERSPROC glGenFramebuffers; -extern PFNGLGENPROGRAMPIPELINESPROC glGenProgramPipelines; -extern PFNGLGENSAMPLERSPROC glGenSamplers; -extern PFNGLGENVERTEXARRAYSPROC glGenVertexArrays; -extern PFNGLGETBUFFERPARAMETERIVPROC glGetBufferParameteriv; -extern PFNGLGETDEBUGMESSAGELOGARBPROC glGetDebugMessageLogARB; -extern PFNGLGETFRAGDATAINDEXPROC glGetFragDataIndex; -extern PFNGLGETFRAGDATALOCATIONPROC glGetFragDataLocation; -extern PFNGLGETPROGRAMINFOLOGPROC glGetProgramInfoLog; -extern PFNGLGETPROGRAMIVPROC glGetProgramiv; -extern PFNGLGETSHADERIVPROC glGetShaderiv; -extern PFNGLGETSTRINGIPROC glGetStringi; -extern PFNGLISFRAMEBUFFERPROC glIsFramebuffer; -extern PFNGLLINKPROGRAMPROC glLinkProgram; -extern PFNGLMAPBUFFERPROC glMapBuffer; -extern PFNGLMAPBUFFERRANGEPROC glMapBufferRange; -extern PFNGLPROGRAMPARAMETERIPROC glProgramParameteri; -extern PFNGLSAMPLERPARAMETERFPROC glSamplerParameterf; -extern PFNGLSAMPLERPARAMETERIPROC glSamplerParameteri; -extern PFNGLSHADERSOURCEPROC glShaderSource; -extern PFNGLUNIFORM1IPROC glUniform1i; -extern PFNGLUNMAPBUFFERPROC glUnmapBuffer; -extern PFNGLUSEPROGRAMSTAGESPROC glUseProgramStages; -extern PFNGLVERTEXATTRIBIPOINTERPROC glVertexAttribIPointer; -extern PFNGLVERTEXATTRIBPOINTERPROC glVertexAttribPointer; -extern PFNGLTEXSTORAGE2DPROC glTexStorage2D; +extern PFNGLACTIVETEXTUREPROC gl_ActiveTexture; +extern PFNGLBLENDCOLORPROC gl_BlendColor; +extern PFNGLATTACHSHADERPROC gl_AttachShader; +extern PFNGLBINDBUFFERPROC gl_BindBuffer; +extern PFNGLBINDBUFFERBASEPROC gl_BindBufferBase; +extern PFNGLBINDFRAGDATALOCATIONINDEXEDPROC gl_BindFragDataLocationIndexed; +extern PFNGLBINDFRAMEBUFFERPROC gl_BindFramebuffer; +extern PFNGLBINDPROGRAMPIPELINEPROC gl_BindProgramPipeline; +extern PFNGLBINDSAMPLERPROC gl_BindSampler; +extern PFNGLBINDVERTEXARRAYPROC gl_BindVertexArray; +extern PFNGLBLENDEQUATIONSEPARATEPROC gl_BlendEquationSeparate; +extern PFNGLBLENDFUNCSEPARATEPROC gl_BlendFuncSeparate; +extern PFNGLBLITFRAMEBUFFERPROC gl_BlitFramebuffer; +extern PFNGLBUFFERDATAPROC gl_BufferData; +extern PFNGLCHECKFRAMEBUFFERSTATUSPROC gl_CheckFramebufferStatus; +extern PFNGLCLEARBUFFERFVPROC gl_ClearBufferfv; +extern PFNGLCLEARBUFFERIVPROC gl_ClearBufferiv; +extern PFNGLCOMPILESHADERPROC gl_CompileShader; +extern PFNGLCOPYIMAGESUBDATANVPROC gl_CopyImageSubDataNV; +extern PFNGLCREATEPROGRAMPROC gl_CreateProgram; +extern PFNGLCREATESHADERPROC gl_CreateShader; +extern PFNGLCREATESHADERPROGRAMVPROC gl_CreateShaderProgramv; +extern PFNGLDELETEBUFFERSPROC gl_DeleteBuffers; +extern PFNGLDELETEFRAMEBUFFERSPROC gl_DeleteFramebuffers; +extern PFNGLDELETEPROGRAMPROC gl_DeleteProgram; +extern PFNGLDELETEPROGRAMPIPELINESPROC gl_DeleteProgramPipelines; +extern PFNGLDELETESAMPLERSPROC gl_DeleteSamplers; +extern PFNGLDELETESHADERPROC gl_DeleteShader; +extern PFNGLDELETEVERTEXARRAYSPROC gl_DeleteVertexArrays; +extern PFNGLDETACHSHADERPROC gl_DetachShader; +extern PFNGLDRAWBUFFERSPROC gl_DrawBuffers; +extern PFNGLDRAWELEMENTSBASEVERTEXPROC gl_DrawElementsBaseVertex; +extern PFNGLENABLEVERTEXATTRIBARRAYPROC gl_EnableVertexAttribArray; +extern PFNGLFRAMEBUFFERRENDERBUFFERPROC gl_FramebufferRenderbuffer; +extern PFNGLFRAMEBUFFERTEXTURE2DPROC gl_FramebufferTexture2D; +extern PFNGLGENBUFFERSPROC gl_GenBuffers; +extern PFNGLGENFRAMEBUFFERSPROC gl_GenFramebuffers; +extern PFNGLGENPROGRAMPIPELINESPROC gl_GenProgramPipelines; +extern PFNGLGENSAMPLERSPROC gl_GenSamplers; +extern PFNGLGENVERTEXARRAYSPROC gl_GenVertexArrays; +extern PFNGLGETBUFFERPARAMETERIVPROC gl_GetBufferParameteriv; +extern PFNGLGETDEBUGMESSAGELOGARBPROC gl_GetDebugMessageLogARB; +extern PFNGLGETFRAGDATAINDEXPROC gl_GetFragDataIndex; +extern PFNGLGETFRAGDATALOCATIONPROC gl_GetFragDataLocation; +extern PFNGLGETPROGRAMINFOLOGPROC gl_GetProgramInfoLog; +extern PFNGLGETPROGRAMIVPROC gl_GetProgramiv; +extern PFNGLGETSHADERIVPROC gl_GetShaderiv; +extern PFNGLGETSTRINGIPROC gl_GetStringi; +extern PFNGLISFRAMEBUFFERPROC gl_IsFramebuffer; +extern PFNGLLINKPROGRAMPROC gl_LinkProgram; +extern PFNGLMAPBUFFERPROC gl_MapBuffer; +extern PFNGLMAPBUFFERRANGEPROC gl_MapBufferRange; +extern PFNGLPROGRAMPARAMETERIPROC gl_ProgramParameteri; +extern PFNGLSAMPLERPARAMETERFPROC gl_SamplerParameterf; +extern PFNGLSAMPLERPARAMETERIPROC gl_SamplerParameteri; +extern PFNGLSHADERSOURCEPROC gl_ShaderSource; +extern PFNGLUNIFORM1IPROC gl_Uniform1i; +extern PFNGLUNMAPBUFFERPROC gl_UnmapBuffer; +extern PFNGLUSEPROGRAMSTAGESPROC gl_UseProgramStages; +extern PFNGLVERTEXATTRIBIPOINTERPROC gl_VertexAttribIPointer; +extern PFNGLVERTEXATTRIBPOINTERPROC gl_VertexAttribPointer; +extern PFNGLTEXSTORAGE2DPROC gl_TexStorage2D; namespace GLLoader { bool check_gl_version(uint32 major, uint32 minor); diff --git a/plugins/GSdx/GSDeviceOGL.cpp b/plugins/GSdx/GSDeviceOGL.cpp index 1526a8c361..9214b51e04 100644 --- a/plugins/GSdx/GSDeviceOGL.cpp +++ b/plugins/GSdx/GSDeviceOGL.cpp @@ -76,9 +76,9 @@ GSDeviceOGL::~GSDeviceOGL() // Clean m_merge_obj for (uint32 i = 0; i < 2; i++) #ifndef DISABLE_GL41_SSO - glDeleteProgram(m_merge_obj.ps[i]); + gl_DeleteProgram(m_merge_obj.ps[i]); #else - glDeleteShader(m_merge_obj.ps[i]); + gl_DeleteShader(m_merge_obj.ps[i]); #endif delete (m_merge_obj.cb); delete (m_merge_obj.bs); @@ -86,24 +86,24 @@ GSDeviceOGL::~GSDeviceOGL() // Clean m_interlace for (uint32 i = 0; i < 2; i++) #ifndef DISABLE_GL41_SSO - glDeleteProgram(m_interlace.ps[i]); + gl_DeleteProgram(m_interlace.ps[i]); #else - glDeleteShader(m_interlace.ps[i]); + gl_DeleteShader(m_interlace.ps[i]); #endif delete (m_interlace.cb); // Clean m_convert #ifndef DISABLE_GL41_SSO - glDeleteProgram(m_convert.vs); + gl_DeleteProgram(m_convert.vs); for (uint32 i = 0; i < 2; i++) - glDeleteProgram(m_convert.ps[i]); + gl_DeleteProgram(m_convert.ps[i]); #else - glDeleteShader(m_convert.vs); + gl_DeleteShader(m_convert.vs); for (uint i = 0; i < 2; i++) - glDeleteShader(m_convert.ps[i]); + gl_DeleteShader(m_convert.ps[i]); #endif - glDeleteSamplers(1, &m_convert.ln); - glDeleteSamplers(1, &m_convert.pt); + gl_DeleteSamplers(1, &m_convert.ln); + gl_DeleteSamplers(1, &m_convert.pt); delete m_convert.dss; delete m_convert.bs; @@ -113,30 +113,30 @@ GSDeviceOGL::~GSDeviceOGL() // Clean various opengl allocation #ifndef DISABLE_GL41_SSO - glDeleteProgramPipelines(1, &m_pipeline); + gl_DeleteProgramPipelines(1, &m_pipeline); #endif - glDeleteFramebuffers(1, &m_fbo); - glDeleteFramebuffers(1, &m_fbo_read); + gl_DeleteFramebuffers(1, &m_fbo); + gl_DeleteFramebuffers(1, &m_fbo_read); // Delete HW FX delete m_vs_cb; delete m_ps_cb; - glDeleteSamplers(1, &m_rt_ss); + gl_DeleteSamplers(1, &m_rt_ss); delete m_vb; #ifndef DISABLE_GL41_SSO - for (auto it = m_vs.begin(); it != m_vs.end() ; it++) glDeleteProgram(it->second); - for (auto it = m_gs.begin(); it != m_gs.end() ; it++) glDeleteProgram(it->second); - for (auto it = m_ps.begin(); it != m_ps.end() ; it++) glDeleteProgram(it->second); + for (auto it = m_vs.begin(); it != m_vs.end() ; it++) gl_DeleteProgram(it->second); + for (auto it = m_gs.begin(); it != m_gs.end() ; it++) gl_DeleteProgram(it->second); + for (auto it = m_ps.begin(); it != m_ps.end() ; it++) gl_DeleteProgram(it->second); #else - for (auto it = m_vs.begin(); it != m_vs.end() ; it++) glDeleteShader(it->second); - for (auto it = m_gs.begin(); it != m_gs.end() ; it++) glDeleteShader(it->second); - for (auto it = m_ps.begin(); it != m_ps.end() ; it++) glDeleteShader(it->second); + for (auto it = m_vs.begin(); it != m_vs.end() ; it++) gl_DeleteShader(it->second); + for (auto it = m_gs.begin(); it != m_gs.end() ; it++) gl_DeleteShader(it->second); + for (auto it = m_ps.begin(); it != m_ps.end() ; it++) gl_DeleteShader(it->second); - for (auto it = m_single_prog.begin(); it != m_single_prog.end() ; it++) glDeleteProgram(it->second); + for (auto it = m_single_prog.begin(); it != m_single_prog.end() ; it++) gl_DeleteProgram(it->second); m_single_prog.clear(); #endif - for (auto it = m_ps_ss.begin(); it != m_ps_ss.end() ; it++) glDeleteSamplers(1, &it->second); + for (auto it = m_ps_ss.begin(); it != m_ps_ss.end() ; it++) gl_DeleteSamplers(1, &it->second); m_vs.clear(); m_gs.clear(); m_ps.clear(); @@ -197,12 +197,12 @@ bool GSDeviceOGL::Create(GSWnd* wnd) // Various object // **************************************************************** #ifndef DISABLE_GL41_SSO - glGenProgramPipelines(1, &m_pipeline); - glBindProgramPipeline(m_pipeline); + gl_GenProgramPipelines(1, &m_pipeline); + gl_BindProgramPipeline(m_pipeline); #endif - glGenFramebuffers(1, &m_fbo); - glGenFramebuffers(1, &m_fbo_read); + gl_GenFramebuffers(1, &m_fbo); + gl_GenFramebuffers(1, &m_fbo_read); // **************************************************************** // Vertex buffer state @@ -240,35 +240,35 @@ bool GSDeviceOGL::Create(GSWnd* wnd) hr = m_dev->CreateBlendState(&bsd, &m_convert.bs); #endif - glGenSamplers(1, &m_convert.ln); - glSamplerParameteri(m_convert.ln, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glSamplerParameteri(m_convert.ln, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glSamplerParameteri(m_convert.ln, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); - glSamplerParameteri(m_convert.ln, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glSamplerParameteri(m_convert.ln, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + gl_GenSamplers(1, &m_convert.ln); + gl_SamplerParameteri(m_convert.ln, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + gl_SamplerParameteri(m_convert.ln, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + gl_SamplerParameteri(m_convert.ln, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); + gl_SamplerParameteri(m_convert.ln, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + gl_SamplerParameteri(m_convert.ln, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); // FIXME which value for GL_TEXTURE_MIN_LOD - glSamplerParameterf(m_convert.ln, GL_TEXTURE_MAX_LOD, FLT_MAX); + gl_SamplerParameterf(m_convert.ln, GL_TEXTURE_MAX_LOD, FLT_MAX); // FIXME: seems there is 2 possibility in opengl // DX: sd.ComparisonFunc = D3D11_COMPARISON_NEVER; - // glSamplerParameteri(m_convert.ln, GL_TEXTURE_COMPARE_MODE, GL_NONE); - glSamplerParameteri(m_convert.ln, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE); - glSamplerParameteri(m_convert.ln, GL_TEXTURE_COMPARE_FUNC, GL_NEVER); + // gl_SamplerParameteri(m_convert.ln, GL_TEXTURE_COMPARE_MODE, GL_NONE); + gl_SamplerParameteri(m_convert.ln, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE); + gl_SamplerParameteri(m_convert.ln, GL_TEXTURE_COMPARE_FUNC, GL_NEVER); // FIXME: need ogl extension sd.MaxAnisotropy = 16; - glGenSamplers(1, &m_convert.pt); - glSamplerParameteri(m_convert.pt, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glSamplerParameteri(m_convert.pt, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glSamplerParameteri(m_convert.pt, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); - glSamplerParameteri(m_convert.pt, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glSamplerParameteri(m_convert.pt, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + gl_GenSamplers(1, &m_convert.pt); + gl_SamplerParameteri(m_convert.pt, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + gl_SamplerParameteri(m_convert.pt, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + gl_SamplerParameteri(m_convert.pt, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); + gl_SamplerParameteri(m_convert.pt, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + gl_SamplerParameteri(m_convert.pt, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); // FIXME which value for GL_TEXTURE_MIN_LOD - glSamplerParameterf(m_convert.pt, GL_TEXTURE_MAX_LOD, FLT_MAX); + gl_SamplerParameterf(m_convert.pt, GL_TEXTURE_MAX_LOD, FLT_MAX); // FIXME: seems there is 2 possibility in opengl // DX: sd.ComparisonFunc = D3D11_COMPARISON_NEVER; - // glSamplerParameteri(m_convert.pt, GL_TEXTURE_COMPARE_MODE, GL_NONE); - glSamplerParameteri(m_convert.pt, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE); - glSamplerParameteri(m_convert.pt, GL_TEXTURE_COMPARE_FUNC, GL_NEVER); + // gl_SamplerParameteri(m_convert.pt, GL_TEXTURE_COMPARE_MODE, GL_NONE); + gl_SamplerParameteri(m_convert.pt, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE); + gl_SamplerParameteri(m_convert.pt, GL_TEXTURE_COMPARE_FUNC, GL_NEVER); // FIXME: need ogl extension sd.MaxAnisotropy = 16; m_convert.dss = new GSDepthStencilOGL(); @@ -530,7 +530,7 @@ void GSDeviceOGL::DebugBB() static_cast(rt)->Attach(GL_COLOR_ATTACHMENT0); - glBlitFramebuffer(0, 0, size.x, size.y, + gl_BlitFramebuffer(0, 0, size.x, size.y, 0, 0, size.x, size.y, GL_COLOR_BUFFER_BIT, GL_NEAREST); @@ -599,21 +599,21 @@ static void set_uniform_buffer_binding(GLuint prog, GLchar* name, GLuint binding #ifdef DISABLE_GL41_SSO GLuint GSDeviceOGL::link_prog() { - GLuint single_prog = glCreateProgram(); - if (m_state.vs) glAttachShader(single_prog, m_state.vs); - if (m_state.ps) glAttachShader(single_prog, m_state.ps); - if (m_state.gs) glAttachShader(single_prog, m_state.gs); + GLuint single_prog = gl_CreateProgram(); + if (m_state.vs) gl_AttachShader(single_prog, m_state.vs); + if (m_state.ps) gl_AttachShader(single_prog, m_state.ps); + if (m_state.gs) gl_AttachShader(single_prog, m_state.gs); - glLinkProgram(single_prog); + gl_LinkProgram(single_prog); GLint status; - glGetProgramiv(single_prog, GL_LINK_STATUS, &status); + gl_GetProgramiv(single_prog, GL_LINK_STATUS, &status); if (!status) { GLint log_length = 0; - glGetProgramiv(single_prog, GL_INFO_LOG_LENGTH, &log_length); + gl_GetProgramiv(single_prog, GL_INFO_LOG_LENGTH, &log_length); if (log_length > 0) { char* log = new char[log_length]; - glGetProgramInfoLog(single_prog, log_length, NULL, log); + gl_GetProgramInfoLog(single_prog, log_length, NULL, log); fprintf(stderr, "%s", log); delete[] log; } @@ -621,9 +621,9 @@ GLuint GSDeviceOGL::link_prog() } #if 0 - if (m_state.vs) glDetachShader(single_prog, m_state.vs); - if (m_state.ps) glDetachShader(single_prog, m_state.ps); - if (m_state.gs) glDetachShader(single_prog, m_state.gs); + if (m_state.vs) gl_DetachShader(single_prog, m_state.vs); + if (m_state.ps) gl_DetachShader(single_prog, m_state.ps); + if (m_state.gs) gl_DetachShader(single_prog, m_state.gs); #endif return single_prog; @@ -700,8 +700,8 @@ void GSDeviceOGL::ClearRenderTarget(GSTexture* t, const GSVector4& c) if (static_cast(t)->IsBackbuffer()) { // FIXME I really not sure OMSetFBO(0); - //glClearBufferfv(GL_COLOR, GL_LEFT, c.v); - glClearBufferfv(GL_COLOR, 0, c.v); + //gl_ClearBufferfv(GL_COLOR, GL_LEFT, c.v); + gl_ClearBufferfv(GL_COLOR, 0, c.v); // code for the old interface // glClearColor(c.x, c.y, c.z, c.w); // glClear(GL_COLOR_BUFFER_BIT); @@ -710,7 +710,7 @@ void GSDeviceOGL::ClearRenderTarget(GSTexture* t, const GSVector4& c) // I would like to avoid FBO for a basic clean operation OMSetFBO(m_fbo); static_cast(t)->Attach(GL_COLOR_ATTACHMENT0); - glClearBufferfv(GL_COLOR, 0, c.v); + gl_ClearBufferfv(GL_COLOR, 0, c.v); } OMSetFBO(fbo_old); } @@ -733,10 +733,10 @@ void GSDeviceOGL::ClearDepth(GSTexture* t, float c) // could be smaller than the texture and we really want to clean all pixels. glDisable(GL_SCISSOR_TEST); if (m_state.dss != NULL && m_state.dss->IsMaskEnable()) { - glClearBufferfv(GL_DEPTH, 0, &c); + gl_ClearBufferfv(GL_DEPTH, 0, &c); } else { glDepthMask(true); - glClearBufferfv(GL_DEPTH, 0, &c); + gl_ClearBufferfv(GL_DEPTH, 0, &c); glDepthMask(false); } glEnable(GL_SCISSOR_TEST); @@ -752,7 +752,7 @@ void GSDeviceOGL::ClearStencil(GSTexture* t, uint8 c) static_cast(t)->Attach(GL_DEPTH_STENCIL_ATTACHMENT); GLint color = c; // FIXME can you clean depth and stencil separately - glClearBufferiv(GL_STENCIL, 0, &color); + gl_ClearBufferiv(GL_STENCIL, 0, &color); OMSetFBO(fbo_old); } @@ -841,7 +841,7 @@ void GSDeviceOGL::CopyRect(GSTexture* st, GSTexture* dt, const GSVector4i& r) // uint32 srcName, enum srcTarget, int srcLevel, int srcX, int srcY, int srcZ, // uint32 dstName, enum dstTarget, int dstLevel, int dstX, int dstY, int dstZ, // sizei width, sizei height, sizei depth); - glCopyImageSubDataNV( static_cast(st)->GetID(), static_cast(st)->GetTarget(), + gl_CopyImageSubDataNV( static_cast(st)->GetID(), static_cast(st)->GetTarget(), 0, r.x, r.y, 0, static_cast(dt)->GetID(), static_cast(dt)->GetTarget(), 0, r.x, r.y, 0, @@ -1140,7 +1140,7 @@ void GSDeviceOGL::VSSetShader(GLuint vs) { m_state.vs = vs; #ifndef DISABLE_GL41_SSO - glUseProgramStages(m_pipeline, GL_VERTEX_SHADER_BIT, vs); + gl_UseProgramStages(m_pipeline, GL_VERTEX_SHADER_BIT, vs); #endif } } @@ -1151,7 +1151,7 @@ void GSDeviceOGL::GSSetShader(GLuint gs) { m_state.gs = gs; #ifndef DISABLE_GL41_SSO - glUseProgramStages(m_pipeline, GL_GEOMETRY_SHADER_BIT, gs); + gl_UseProgramStages(m_pipeline, GL_GEOMETRY_SHADER_BIT, gs); #endif } } @@ -1194,24 +1194,24 @@ void GSDeviceOGL::PSSetShader(GLuint ps) { m_state.ps = ps; #ifndef DISABLE_GL41_SSO - glUseProgramStages(m_pipeline, GL_FRAGMENT_SHADER_BIT, ps); + gl_UseProgramStages(m_pipeline, GL_FRAGMENT_SHADER_BIT, ps); #endif } // Sampler and texture must be set at the same time // 1/ select the texture unit -// glActiveTexture(GL_TEXTURE0 + 1); +// gl_ActiveTexture(GL_TEXTURE0 + 1); // 2/ bind the texture // glBindTexture(GL_TEXTURE_2D , brickTexture); // 3/ sets the texture sampler in GLSL (could be useless with layout stuff) -// glUniform1i(brickSamplerId , 1); +// gl_Uniform1i(brickSamplerId , 1); // 4/ set the sampler state -// glBindSampler(1 , sampler); +// gl_BindSampler(1 , sampler); if (m_srv_changed || m_ss_changed) { for (uint32 i=0 ; i < 1; i++) { if (m_state.ps_srv[i] != NULL) { m_state.ps_srv[i]->EnableUnit(i); - glBindSampler(i, m_state.ps_ss[i]); + gl_BindSampler(i, m_state.ps_ss[i]); } } } @@ -1221,9 +1221,9 @@ void GSDeviceOGL::OMSetFBO(GLuint fbo, GLenum buffer) { if (m_state.fbo != fbo) { m_state.fbo = fbo; - glBindFramebuffer(GL_FRAMEBUFFER, fbo); + gl_BindFramebuffer(GL_FRAMEBUFFER, fbo); // FIXME DEBUG - //if (fbo) fprintf(stderr, "FB status %x\n", glCheckFramebufferStatus(GL_FRAMEBUFFER)); + //if (fbo) fprintf(stderr, "FB status %x\n", gl_CheckFramebufferStatus(GL_FRAMEBUFFER)); } if (m_state.draw != buffer) { @@ -1396,14 +1396,14 @@ void GSDeviceOGL::CompileShaderFromSource(const std::string& glsl_file, const st // Could be useful one day const GLchar* ShaderSource[1]; ShaderSource[0] = header.append(source).c_str(); - *program = glCreateShaderProgramv(type, 1, &ShaderSource[0]); + *program = gl_CreateShaderProgramv(type, 1, &ShaderSource[0]); #else - *program = glCreateShaderProgramv(type, 2, sources_array); + *program = gl_CreateShaderProgramv(type, 2, sources_array); #endif #else - *program = glCreateShader(type); - glShaderSource(*program, 2, sources_array, NULL); - glCompileShader(*program); + *program = gl_CreateShader(type); + gl_ShaderSource(*program, 2, sources_array, NULL); + gl_CompileShader(*program); #endif free(source_str); @@ -1417,14 +1417,14 @@ void GSDeviceOGL::CompileShaderFromSource(const std::string& glsl_file, const st GLint log_length = 0; #ifndef DISABLE_GL41_SSO - glGetProgramiv(*program, GL_INFO_LOG_LENGTH, &log_length); + gl_GetProgramiv(*program, GL_INFO_LOG_LENGTH, &log_length); #else - glGetShaderiv(*program, GL_INFO_LOG_LENGTH, &log_length); + gl_GetShaderiv(*program, GL_INFO_LOG_LENGTH, &log_length); #endif if (log_length > 0) { char* log = new char[log_length]; #ifndef DISABLE_GL41_SSO - glGetProgramInfoLog(*program, log_length, NULL, log); + gl_GetProgramInfoLog(*program, log_length, NULL, log); #else glGetShaderInfoLog(*program, log_length, NULL, log); #endif @@ -1446,7 +1446,7 @@ void GSDeviceOGL::CheckDebugLog() int* lengths = new int[count]; char* messageLog = new char[bufsize]; - unsigned int retVal = glGetDebugMessageLogARB(count, bufsize, sources, types, ids, severities, lengths, messageLog); + unsigned int retVal = gl_GetDebugMessageLogARB(count, bufsize, sources, types, ids, severities, lengths, messageLog); if(retVal > 0) { diff --git a/plugins/GSdx/GSDeviceOGL.h b/plugins/GSdx/GSDeviceOGL.h index 6856bc032a..7c06319417 100644 --- a/plugins/GSdx/GSDeviceOGL.h +++ b/plugins/GSdx/GSDeviceOGL.h @@ -105,11 +105,11 @@ public: glEnable(GL_BLEND); if (HasConstantFactor()) { debug_factor = factor; - glBlendColor(factor, factor, factor, 0); + gl_BlendColor(factor, factor, factor, 0); } - glBlendEquationSeparate(m_equation_RGB, m_equation_ALPHA); - glBlendFuncSeparate(m_func_sRGB, m_func_dRGB, m_func_sALPHA, m_func_dALPHA); + gl_BlendEquationSeparate(m_equation_RGB, m_equation_ALPHA); + gl_BlendFuncSeparate(m_func_sRGB, m_func_dRGB, m_func_sALPHA, m_func_dALPHA); } else { glDisable(GL_BLEND); } diff --git a/plugins/GSdx/GSTextureFXOGL.cpp b/plugins/GSdx/GSTextureFXOGL.cpp index dbf8ae46ed..91b708fcf7 100644 --- a/plugins/GSdx/GSTextureFXOGL.cpp +++ b/plugins/GSdx/GSTextureFXOGL.cpp @@ -33,22 +33,22 @@ void GSDeviceOGL::CreateTextureFX() m_vs_cb = new GSUniformBufferOGL(g_vs_cb_index, sizeof(VSConstantBuffer)); m_ps_cb = new GSUniformBufferOGL(g_ps_cb_index, sizeof(PSConstantBuffer)); - glGenSamplers(1, &m_rt_ss); + gl_GenSamplers(1, &m_rt_ss); // FIXME, seem to have no difference between sampler !!! m_palette_ss = m_rt_ss; - glSamplerParameteri(m_rt_ss, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glSamplerParameteri(m_rt_ss, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glSamplerParameteri(m_rt_ss, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); - glSamplerParameteri(m_rt_ss, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glSamplerParameteri(m_rt_ss, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + gl_SamplerParameteri(m_rt_ss, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + gl_SamplerParameteri(m_rt_ss, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + gl_SamplerParameteri(m_rt_ss, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); + gl_SamplerParameteri(m_rt_ss, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + gl_SamplerParameteri(m_rt_ss, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); // FIXME which value for GL_TEXTURE_MIN_LOD - glSamplerParameterf(m_rt_ss, GL_TEXTURE_MAX_LOD, FLT_MAX); + gl_SamplerParameterf(m_rt_ss, GL_TEXTURE_MAX_LOD, FLT_MAX); // FIXME: seems there is 2 possibility in opengl // DX: sd.ComparisonFunc = D3D11_COMPARISON_NEVER; - // glSamplerParameteri(m_rt_ss, GL_TEXTURE_COMPARE_MODE, GL_NONE); - glSamplerParameteri(m_rt_ss, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE); - glSamplerParameteri(m_rt_ss, GL_TEXTURE_COMPARE_FUNC, GL_NEVER); + // gl_SamplerParameteri(m_rt_ss, GL_TEXTURE_COMPARE_MODE, GL_NONE); + gl_SamplerParameteri(m_rt_ss, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE); + gl_SamplerParameteri(m_rt_ss, GL_TEXTURE_COMPARE_FUNC, GL_NEVER); // FIXME: need ogl extension sd.MaxAnisotropy = 16; GSInputLayoutOGL vert_format[] = @@ -200,35 +200,35 @@ void GSDeviceOGL::SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSamplerS // ************************************************************* // Static // ************************************************************* - glGenSamplers(1, &ss0); + gl_GenSamplers(1, &ss0); if (ssel.ltf) { - glSamplerParameteri(ss0, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glSamplerParameteri(ss0, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + gl_SamplerParameteri(ss0, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + gl_SamplerParameteri(ss0, GL_TEXTURE_MAG_FILTER, GL_LINEAR); } else { - glSamplerParameteri(ss0, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glSamplerParameteri(ss0, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + gl_SamplerParameteri(ss0, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + gl_SamplerParameteri(ss0, GL_TEXTURE_MAG_FILTER, GL_NEAREST); } // FIXME ensure U -> S, V -> T and W->R if (ssel.tau) - glSamplerParameteri(ss0, GL_TEXTURE_WRAP_S, GL_REPEAT); + gl_SamplerParameteri(ss0, GL_TEXTURE_WRAP_S, GL_REPEAT); else - glSamplerParameteri(ss0, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + gl_SamplerParameteri(ss0, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); if (ssel.tav) - glSamplerParameteri(ss0, GL_TEXTURE_WRAP_T, GL_REPEAT); + gl_SamplerParameteri(ss0, GL_TEXTURE_WRAP_T, GL_REPEAT); else - glSamplerParameteri(ss0, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + gl_SamplerParameteri(ss0, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - glSamplerParameteri(ss0, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); + gl_SamplerParameteri(ss0, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); // FIXME which value for GL_TEXTURE_MIN_LOD - glSamplerParameterf(m_rt_ss, GL_TEXTURE_MAX_LOD, FLT_MAX); + gl_SamplerParameterf(m_rt_ss, GL_TEXTURE_MAX_LOD, FLT_MAX); // FIXME: seems there is 2 possibility in opengl // DX: sd.ComparisonFunc = D3D11_COMPARISON_NEVER; - // glSamplerParameteri(m_rt_ss, GL_TEXTURE_COMPARE_MODE, GL_NONE); - glSamplerParameteri(m_rt_ss, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE); - glSamplerParameteri(m_rt_ss, GL_TEXTURE_COMPARE_FUNC, GL_NEVER); + // gl_SamplerParameteri(m_rt_ss, GL_TEXTURE_COMPARE_MODE, GL_NONE); + gl_SamplerParameteri(m_rt_ss, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE); + gl_SamplerParameteri(m_rt_ss, GL_TEXTURE_COMPARE_FUNC, GL_NEVER); // FIXME: need ogl extension sd.MaxAnisotropy = 16; m_ps_ss[ssel] = ss0; diff --git a/plugins/GSdx/GSTextureOGL.cpp b/plugins/GSdx/GSTextureOGL.cpp index 89a654bd4f..d4f1a0d9f8 100644 --- a/plugins/GSdx/GSTextureOGL.cpp +++ b/plugins/GSdx/GSTextureOGL.cpp @@ -33,19 +33,19 @@ GSTextureOGL::GSTextureOGL(int type, int w, int h, bool msaa, int format, GLuint // Opengl world // Render work in parallal with framebuffer object (FBO) http://www.opengl.org/wiki/Framebuffer_Objects - // render are attached to FBO through : glFramebufferRenderbuffer. You can query the number of colorattachement with GL_MAX_COLOR_ATTACHMENTS - // FBO : constructor -> glGenFramebuffers, glDeleteFramebuffers - // binding -> glBindFramebuffer (target can be read/write/both) - // blit -> glBlitFramebuffer (read FB to draw FB) - // info -> glIsFramebuffer, glGetFramebufferAttachmentParameter, glCheckFramebufferStatus + // render are attached to FBO through : gl_FramebufferRenderbuffer. You can query the number of colorattachement with GL_MAX_COLOR_ATTACHMENTS + // FBO : constructor -> gl_GenFramebuffers, gl_DeleteFramebuffers + // binding -> gl_BindFramebuffer (target can be read/write/both) + // blit -> gl_BlitFramebuffer (read FB to draw FB) + // info -> gl_IsFramebuffer, glGetFramebufferAttachmentParameter, gl_CheckFramebufferStatus // // There are two types of framebuffer-attachable images; texture images and renderbuffer images. // If an image of a texture object is attached to a framebuffer, OpenGL performs "render to texture". // And if an image of a renderbuffer object is attached to a framebuffer, then OpenGL performs "offscreen rendering". // Blitting: - // glDrawBuffers + // gl_DrawBuffers // glReadBuffer - // glBlitFramebuffer + // gl_BlitFramebuffer // ************************************************************* // m_size.x = w; @@ -62,7 +62,7 @@ GSTextureOGL::GSTextureOGL(int type, int w, int h, bool msaa, int format, GLuint switch (m_type) { case GSTexture::Offscreen: //FIXME I not sure we need a pixel buffer object. It seems more a texture - // glGenBuffers(1, &m_texture_id); + // gl_GenBuffers(1, &m_texture_id); // m_texture_target = GL_PIXEL_UNPACK_BUFFER; // ASSERT(0); // Note there is also a buffer texture!!! @@ -84,7 +84,7 @@ GSTextureOGL::GSTextureOGL(int type, int w, int h, bool msaa, int format, GLuint break; } // Extra buffer to handle various pixel transfer - glGenBuffers(1, &m_pbo_id); + gl_GenBuffers(1, &m_pbo_id); uint32 msaa_level; if (m_msaa) { @@ -105,9 +105,9 @@ GSTextureOGL::GSTextureOGL(int type, int w, int h, bool msaa, int format, GLuint ASSERT(0); // TODO Later } - glBindBuffer(GL_PIXEL_PACK_BUFFER, m_pbo_id); - glBufferData(GL_PIXEL_PACK_BUFFER, m_pbo_size, NULL, GL_STREAM_DRAW); - glBindBuffer(GL_PIXEL_PACK_BUFFER, 0); + gl_BindBuffer(GL_PIXEL_PACK_BUFFER, m_pbo_id); + gl_BufferData(GL_PIXEL_PACK_BUFFER, m_pbo_size, NULL, GL_STREAM_DRAW); + gl_BindBuffer(GL_PIXEL_PACK_BUFFER, 0); ASSERT(!m_msaa); case GSTexture::DepthStencil: @@ -121,9 +121,9 @@ GSTextureOGL::GSTextureOGL(int type, int w, int h, bool msaa, int format, GLuint if (m_msaa) { ASSERT(m_texture_target == GL_TEXTURE_2D_MULTISAMPLE); // Require a recent GLEW and GL4.3 - //glTexStorage2DMultisample(m_texture_target, msaa_level, m_format, m_size.x, m_size.y, false); + //gl_TexStorage2DMultisample(m_texture_target, msaa_level, m_format, m_size.x, m_size.y, false); } else { - glTexStorage2D(m_texture_target, 1, m_format, m_size.x, m_size.y); + gl_TexStorage2D(m_texture_target, 1, m_format, m_size.x, m_size.y); } break; default: break; @@ -132,16 +132,16 @@ GSTextureOGL::GSTextureOGL(int type, int w, int h, bool msaa, int format, GLuint GSTextureOGL::~GSTextureOGL() { - glDeleteBuffers(1, &m_pbo_id); + gl_DeleteBuffers(1, &m_pbo_id); glDeleteTextures(1, &m_texture_id); } void GSTextureOGL::Attach(GLenum attachment) { //fprintf(stderr, "format %d,%x\n", m_type, m_format); - glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, attachment, m_texture_target, m_texture_id, 0); + gl_FramebufferTexture2D(GL_DRAW_FRAMEBUFFER, attachment, m_texture_target, m_texture_id, 0); // FIXME DEBUG - //fprintf(stderr, "FB status %x\n", glCheckFramebufferStatus(GL_FRAMEBUFFER)); + //fprintf(stderr, "FB status %x\n", gl_CheckFramebufferStatus(GL_FRAMEBUFFER)); } bool GSTextureOGL::Update(const GSVector4i& r, const void* data, int pitch) @@ -206,7 +206,7 @@ void GSTextureOGL::EnableUnit(uint32 unit) // For the moment SW renderer only use 1 so don't bother if (g_state_texture_unit != unit) { g_state_texture_unit = unit; - glActiveTexture(GL_TEXTURE0 + unit); + gl_ActiveTexture(GL_TEXTURE0 + unit); // When you change the texture unit, texture must be rebinded g_state_texture_id = m_texture_id; glBindTexture(m_texture_target, m_texture_id); @@ -224,18 +224,18 @@ bool GSTextureOGL::Map(GSMap& m, const GSVector4i* r) // Set m.pitch <- size of a row // I think in opengl we need to copy back the data to the RAM: glReadPixels — read a block of pixels from the frame buffer // - // glMapBuffer — map a buffer object's data store + // gl_MapBuffer — map a buffer object's data store // Can be used on GL_PIXEL_UNPACK_BUFFER or GL_TEXTURE_BUFFER if (m_type == GSTexture::Offscreen) { // Bind the texture to the read framebuffer to avoid any disturbance EnableUnit(0); - glBindFramebuffer(GL_READ_FRAMEBUFFER, m_fbo_read); - glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, m_texture_target, m_texture_id, 0); + gl_BindFramebuffer(GL_READ_FRAMEBUFFER, m_fbo_read); + gl_FramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, m_texture_target, m_texture_id, 0); glReadBuffer(GL_COLOR_ATTACHMENT0); // FIXME It might be possible to only read a subrange of the texture based on r object // Load the PBO with the data - glBindBuffer(GL_PIXEL_PACK_BUFFER, m_pbo_id); + gl_BindBuffer(GL_PIXEL_PACK_BUFFER, m_pbo_id); if (m_format == GL_RGBA8) { glPixelStorei(GL_PACK_ALIGNMENT, 4); glReadPixels(0, 0, m_size.x, m_size.y, GL_RGBA, GL_UNSIGNED_BYTE, 0); @@ -249,17 +249,17 @@ bool GSTextureOGL::Map(GSMap& m, const GSVector4i* r) fprintf(stderr, "wrong texture pixel format :%x\n", m_format); ASSERT(0); } - glBindFramebuffer(GL_READ_FRAMEBUFFER, 0); + gl_BindFramebuffer(GL_READ_FRAMEBUFFER, 0); // Give access from the CPU - m.bits = (uint8*) glMapBufferRange(GL_PIXEL_PACK_BUFFER, 0, m_pbo_size, GL_MAP_READ_BIT); + m.bits = (uint8*) gl_MapBufferRange(GL_PIXEL_PACK_BUFFER, 0, m_pbo_size, GL_MAP_READ_BIT); m.pitch = m_size.x; if ( m.bits ) { return true; } else { fprintf(stderr, "bad mapping of the pbo\n"); - glBindBuffer(GL_PIXEL_PACK_BUFFER, 0); + gl_BindBuffer(GL_PIXEL_PACK_BUFFER, 0); return false; } } @@ -286,8 +286,8 @@ bool GSTextureOGL::Map(GSMap& m, const GSVector4i* r) void GSTextureOGL::Unmap() { if (m_type == GSTexture::Offscreen) { - glUnmapBuffer(GL_PIXEL_PACK_BUFFER); - glBindBuffer(GL_PIXEL_PACK_BUFFER, 0); + gl_UnmapBuffer(GL_PIXEL_PACK_BUFFER); + gl_BindBuffer(GL_PIXEL_PACK_BUFFER, 0); } } @@ -405,22 +405,22 @@ bool GSTextureOGL::Save(const string& fn, bool dds) // for us if (IsBackbuffer()) { //glReadBuffer(GL_BACK); - //glBindFramebuffer(GL_READ_FRAMEBUFFER, 0); + //gl_BindFramebuffer(GL_READ_FRAMEBUFFER, 0); glReadPixels(0, 0, m_size.x, m_size.y, GL_RGBA, GL_UNSIGNED_BYTE, image); } else if(IsDss()) { - glBindFramebuffer(GL_READ_FRAMEBUFFER, m_fbo_read); + gl_BindFramebuffer(GL_READ_FRAMEBUFFER, m_fbo_read); //EnableUnit(0); - glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, m_texture_target, m_texture_id, 0); + gl_FramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, m_texture_target, m_texture_id, 0); glReadPixels(0, 0, m_size.x, m_size.y, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, image); - glBindFramebuffer(GL_READ_FRAMEBUFFER, 0); + gl_BindFramebuffer(GL_READ_FRAMEBUFFER, 0); } else { - glBindFramebuffer(GL_READ_FRAMEBUFFER, m_fbo_read); + gl_BindFramebuffer(GL_READ_FRAMEBUFFER, m_fbo_read); EnableUnit(0); - glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, m_texture_target, m_texture_id, 0); + gl_FramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, m_texture_target, m_texture_id, 0); glReadBuffer(GL_COLOR_ATTACHMENT0); if (m_format == GL_RGBA8) @@ -438,7 +438,7 @@ bool GSTextureOGL::Save(const string& fn, bool dds) status = false; } - glBindFramebuffer(GL_READ_FRAMEBUFFER, 0); + gl_BindFramebuffer(GL_READ_FRAMEBUFFER, 0); } if (status) Save(fn, image, pitch); diff --git a/plugins/GSdx/GSUniformBufferOGL.h b/plugins/GSdx/GSUniformBufferOGL.h index 133d775a17..fea75ab946 100644 --- a/plugins/GSdx/GSUniformBufferOGL.h +++ b/plugins/GSdx/GSUniformBufferOGL.h @@ -32,7 +32,7 @@ public: , size(size) ,target(GL_UNIFORM_BUFFER) { - glGenBuffers(1, &buffer); + gl_GenBuffers(1, &buffer); bind(); allocate(); attach(); @@ -40,28 +40,28 @@ public: void bind() { - glBindBuffer(target, buffer); + gl_BindBuffer(target, buffer); } void allocate() { - glBufferData(target, size, NULL, GL_STREAM_DRAW); + gl_BufferData(target, size, NULL, GL_STREAM_DRAW); } void attach() { - glBindBufferBase(target, index, buffer); + gl_BindBufferBase(target, index, buffer); } void upload(const void* src) { uint32 flags = GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT; - uint8* dst = (uint8*) glMapBufferRange(target, 0, size, flags); + uint8* dst = (uint8*) gl_MapBufferRange(target, 0, size, flags); memcpy(dst, src, size); - glUnmapBuffer(target); + gl_UnmapBuffer(target); } ~GSUniformBufferOGL() { - glDeleteBuffers(1, &buffer); + gl_DeleteBuffers(1, &buffer); } }; diff --git a/plugins/GSdx/GSVertexArrayOGL.h b/plugins/GSdx/GSVertexArrayOGL.h index f7d69009e0..8c1f83ad57 100644 --- a/plugins/GSdx/GSVertexArrayOGL.h +++ b/plugins/GSdx/GSVertexArrayOGL.h @@ -47,12 +47,12 @@ class GSBufferOGL { , m_limit(0) , m_target(target) { - glGenBuffers(1, &m_buffer); + gl_GenBuffers(1, &m_buffer); // Opengl works best with 1-4MB buffer. m_default_size = 2 * 1024 * 1024 / m_stride; } - ~GSBufferOGL() { glDeleteBuffers(1, &m_buffer); } + ~GSBufferOGL() { gl_DeleteBuffers(1, &m_buffer); } void allocate() { allocate(m_default_size); } @@ -60,12 +60,12 @@ class GSBufferOGL { { m_start = 0; m_limit = new_limit; - glBufferData(m_target, m_limit * m_stride, NULL, GL_STREAM_DRAW); + gl_BufferData(m_target, m_limit * m_stride, NULL, GL_STREAM_DRAW); } void bind() { - glBindBuffer(m_target, m_buffer); + gl_BindBuffer(m_target, m_buffer); } void upload(const void* src, uint32 count) @@ -83,7 +83,7 @@ class GSBufferOGL { bool Map(void** pointer, uint32 count ) { #ifdef ENABLE_OGL_DEBUG GLint b_size = -1; - glGetBufferParameteriv(m_target, GL_BUFFER_SIZE, &b_size); + gl_GetBufferParameteriv(m_target, GL_BUFFER_SIZE, &b_size); if (b_size <= 0) return false; #endif @@ -112,7 +112,7 @@ class GSBufferOGL { } // Upload the data to the buffer - *pointer = (uint8*) glMapBufferRange(m_target, m_stride*m_start, m_stride*m_count, map_flags); + *pointer = (uint8*) gl_MapBufferRange(m_target, m_stride*m_start, m_stride*m_count, map_flags); //fprintf(stderr, "Map %x from %d to %d\n", *pointer, m_start, m_start+m_count); #ifdef ENABLE_OGL_DEBUG if (*pointer == NULL) { @@ -123,7 +123,7 @@ class GSBufferOGL { return true; } - void Unmap() { glUnmapBuffer(m_target); } + void Unmap() { gl_UnmapBuffer(m_target); } void EndScene() { @@ -138,12 +138,12 @@ class GSBufferOGL { void Draw(GLenum mode, GLint basevertex) { - glDrawElementsBaseVertex(mode, m_count, GL_UNSIGNED_INT, (void*)(m_start * m_stride), basevertex); + gl_DrawElementsBaseVertex(mode, m_count, GL_UNSIGNED_INT, (void*)(m_start * m_stride), basevertex); } void Draw(GLenum mode, GLint basevertex, int offset, int count) { - glDrawElementsBaseVertex(mode, count, GL_UNSIGNED_INT, (void*)((m_start + offset) * m_stride), basevertex); + gl_DrawElementsBaseVertex(mode, count, GL_UNSIGNED_INT, (void*)((m_start + offset) * m_stride), basevertex); } size_t GetStart() { return m_start; } @@ -165,7 +165,7 @@ class GSVertexBufferStateOGL { public: GSVertexBufferStateOGL(size_t stride, GSInputLayoutOGL* layout, uint32 layout_nbr) { - glGenVertexArrays(1, &m_va); + gl_GenVertexArrays(1, &m_va); m_vb = new GSBufferOGL(GL_ARRAY_BUFFER, stride); m_ib = new GSBufferOGL(GL_ELEMENT_ARRAY_BUFFER, sizeof(uint32)); @@ -181,7 +181,7 @@ public: void bind() { - glBindVertexArray(m_va); + gl_BindVertexArray(m_va); m_vb->bind(); } @@ -189,15 +189,15 @@ public: { for (uint32 i = 0; i < layout_nbr; i++) { // Note this function need both a vertex array object and a GL_ARRAY_BUFFER buffer - glEnableVertexAttribArray(layout[i].index); + gl_EnableVertexAttribArray(layout[i].index); switch (layout[i].type) { case GL_UNSIGNED_SHORT: case GL_UNSIGNED_INT: - // Rule: when shader use integral (not normalized) you must use glVertexAttribIPointer (note the extra I) - glVertexAttribIPointer(layout[i].index, layout[i].size, layout[i].type, layout[i].stride, layout[i].offset); + // Rule: when shader use integral (not normalized) you must use gl_VertexAttribIPointer (note the extra I) + gl_VertexAttribIPointer(layout[i].index, layout[i].size, layout[i].type, layout[i].stride, layout[i].offset); break; default: - glVertexAttribPointer(layout[i].index, layout[i].size, layout[i].type, layout[i].normalize, layout[i].stride, layout[i].offset); + gl_VertexAttribPointer(layout[i].index, layout[i].size, layout[i].type, layout[i].normalize, layout[i].stride, layout[i].offset); break; } } @@ -227,7 +227,7 @@ public: ~GSVertexBufferStateOGL() { - glDeleteVertexArrays(1, &m_va); + gl_DeleteVertexArrays(1, &m_va); delete m_vb; delete m_ib; }