mirror of https://github.com/PCSX2/pcsx2.git
gsdx-ogl-wnd: add GL function loading (done manually). It would be interesting to do the same on linux that would allow to drop glew depency.
git-svn-id: http://pcsx2.googlecode.com/svn/branches/gsdx-ogl-wnd@5506 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
parent
f9ddd639b8
commit
266af77420
|
@ -0,0 +1,94 @@
|
|||
/*
|
||||
* Copyright (C) 2011-2013 Gregory hainaut
|
||||
* Copyright (C) 2007-2009 Gabest
|
||||
*
|
||||
* This Program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This Program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GNU Make; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA USA.
|
||||
* http://www.gnu.org/copyleft/gpl.html
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
extern PFNGLACTIVETEXTUREPROC glActiveTexture;
|
||||
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 PFNGLBLENDCOLORPROC glBlendColor;
|
||||
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;
|
||||
|
||||
#ifdef _WINDOWS
|
||||
#define GL_LOADFN(name) { \
|
||||
if( (*(void**)&name = (void*)wglGetProcAddress(#name)) == NULL ) { \
|
||||
fprintf(stderr,"Failed to find %s\n", #name); \
|
||||
} \
|
||||
}
|
||||
#else
|
||||
// Use glew
|
||||
#endif
|
|
@ -33,6 +33,67 @@
|
|||
static uint32 g_draw_count = 0;
|
||||
static uint32 g_frame_count = 1;
|
||||
|
||||
PFNGLACTIVETEXTUREPROC glActiveTexture = NULL;
|
||||
PFNGLATTACHSHADERPROC glAttachShader = NULL;
|
||||
PFNGLBINDBUFFERPROC glBindBuffer = NULL;
|
||||
PFNGLBINDBUFFERBASEPROC glBindBufferBase = NULL;
|
||||
PFNGLBINDFRAGDATALOCATIONINDEXEDPROC glBindFragDataLocationIndexed = NULL;
|
||||
PFNGLBINDFRAMEBUFFERPROC glBindFramebuffer = NULL;
|
||||
PFNGLBINDPROGRAMPIPELINEPROC glBindProgramPipeline = NULL;
|
||||
PFNGLBINDSAMPLERPROC glBindSampler = NULL;
|
||||
PFNGLBINDVERTEXARRAYPROC glBindVertexArray = NULL;
|
||||
PFNGLBLENDCOLORPROC glBlendColor = 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;
|
||||
|
||||
GSDeviceOGL::GSDeviceOGL()
|
||||
: m_free_window(false)
|
||||
|
@ -147,6 +208,7 @@ GSTexture* GSDeviceOGL::FetchSurface(int type, int w, int h, bool msaa, int form
|
|||
bool GSDeviceOGL::Create(GSWnd* wnd)
|
||||
{
|
||||
if (m_window == NULL) {
|
||||
#ifdef _LINUX
|
||||
// FIXME......
|
||||
// GLEW's problem is that it calls glGetString(GL_EXTENSIONS) which causes GL_INVALID_ENUM
|
||||
// on GL 3.2 forward compatible context as soon as glewInit() is called. It also doesn't fetch
|
||||
|
@ -167,6 +229,69 @@ bool GSDeviceOGL::Create(GSWnd* wnd)
|
|||
// fprintf(stderr, "4.2 is not supported!\n");
|
||||
// return false;
|
||||
// }
|
||||
#else
|
||||
GL_LOADFN(glActiveTexture);
|
||||
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(glBlendColor);
|
||||
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);
|
||||
#endif
|
||||
const GLubyte* s;
|
||||
s = glGetString(GL_VERSION);
|
||||
if (s == NULL) return false;
|
||||
|
@ -189,6 +314,7 @@ bool GSDeviceOGL::Create(GSWnd* wnd)
|
|||
return false;
|
||||
}
|
||||
|
||||
#ifdef _LINUX
|
||||
if ( !glewIsSupported("GL_ARB_separate_shader_objects")) {
|
||||
fprintf(stderr, "GL_ARB_separate_shader_objects is not supported\n");
|
||||
return false;
|
||||
|
@ -197,6 +323,7 @@ bool GSDeviceOGL::Create(GSWnd* wnd)
|
|||
fprintf(stderr, "GL_ARB_shading_language_420pack is not supported\n");
|
||||
//return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1569,6 +1569,7 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="config.h" />
|
||||
<ClInclude Include="GLLoader.h" />
|
||||
<ClInclude Include="GPU.h" />
|
||||
<ClInclude Include="GPUDrawingEnvironment.h" />
|
||||
<ClInclude Include="GPUDrawScanline.h" />
|
||||
|
|
|
@ -335,6 +335,9 @@
|
|||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="GLLoader.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="GS.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
|
|
|
@ -1585,6 +1585,7 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="config.h" />
|
||||
<ClInclude Include="GLLoader.h" />
|
||||
<ClInclude Include="GPU.h" />
|
||||
<ClInclude Include="GPUDrawingEnvironment.h" />
|
||||
<ClInclude Include="GPUDrawScanline.h" />
|
||||
|
|
|
@ -335,6 +335,9 @@
|
|||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="GLLoader.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="GS.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
|
|
|
@ -1387,6 +1387,10 @@
|
|||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\GLLoader.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\GPU.h"
|
||||
>
|
||||
|
|
Loading…
Reference in New Issue