mirror of https://github.com/PCSX2/pcsx2.git
gsdx-ogl-wnd:
* move GL loading function into its own namespace * Use manual GL loading on linux too and mostly drop glew dependency. (Not 100% clean we are still depends on some glew define, it will be fixed later) Note: shaders still need to be copied manually from GSdx/res to bin/plugins git-svn-id: http://pcsx2.googlecode.com/svn/branches/gsdx-ogl-wnd@5510 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
parent
c09f758602
commit
b65ad2c3e5
|
@ -47,6 +47,7 @@ if(XDG_STD)
|
|||
endif(XDG_STD)
|
||||
|
||||
set(GSdxSources
|
||||
GLLoader.cpp
|
||||
GPU.cpp
|
||||
GPUDrawScanline.cpp
|
||||
GPUDrawScanlineCodeGenerator.cpp
|
||||
|
|
|
@ -0,0 +1,208 @@
|
|||
/*
|
||||
* 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
|
||||
*
|
||||
*/
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "GLLoader.h"
|
||||
|
||||
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;
|
||||
|
||||
namespace GLLoader {
|
||||
|
||||
bool check_gl_version(uint32 major, uint32 minor) {
|
||||
const GLubyte* s;
|
||||
s = glGetString(GL_VERSION);
|
||||
if (s == NULL) return false;
|
||||
fprintf(stderr, "Supported Opengl version: %s on GPU: %s. Vendor: %s\n", s, glGetString(GL_RENDERER), glGetString(GL_VENDOR));
|
||||
// Could be useful to detect the GPU vendor:
|
||||
// if ( strcmp((const char*)glGetString(GL_VENDOR), "ATI Technologies Inc.") == 0 )
|
||||
|
||||
GLuint dot = 0;
|
||||
while (s[dot] != '\0' && s[dot] != '.') dot++;
|
||||
if (dot == 0) return false;
|
||||
|
||||
GLuint major_gl = s[dot-1]-'0';
|
||||
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");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void init_gl_function() {
|
||||
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);
|
||||
}
|
||||
|
||||
bool check_gl_supported_extension() {
|
||||
int max_ext = 0;
|
||||
glGetIntegerv(GL_NUM_EXTENSIONS, &max_ext);
|
||||
|
||||
bool found_GL_ARB_separate_shader_objects = false;
|
||||
bool found_GL_ARB_shading_language_420pack = false;
|
||||
fprintf(stderr, "DEBUG: check_gl_supported_extension\n");
|
||||
|
||||
if (glGetStringi && max_ext) {
|
||||
for (GLint i = 0; i < max_ext; i++) {
|
||||
string ext((const char*)glGetStringi(GL_EXTENSIONS, i));
|
||||
if (ext.compare("GL_ARB_separate_shader_objects") == 0) {
|
||||
found_GL_ARB_separate_shader_objects = true;
|
||||
}
|
||||
if (ext.compare("GL_ARB_shading_language_420pack") == 0) {
|
||||
found_GL_ARB_shading_language_420pack = true;
|
||||
}
|
||||
fprintf(stderr, "EXT: %s\n", ext.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
if ( !found_GL_ARB_separate_shader_objects) {
|
||||
fprintf(stderr, "GL_ARB_separate_shader_objects is not supported\n");
|
||||
return false;
|
||||
}
|
||||
if ( !found_GL_ARB_shading_language_420pack) {
|
||||
fprintf(stderr, "GL_ARB_shading_language_420pack is not supported\n");
|
||||
//return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -21,6 +21,22 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#ifdef _WINDOWS
|
||||
#define GL_LOADFN(name) { \
|
||||
if( (*(void**)&name = (void*)wglGetProcAddress(#name)) == NULL ) { \
|
||||
fprintf(stderr,"Failed to find %s\n", #name); \
|
||||
} \
|
||||
}
|
||||
#else
|
||||
#define GL_LOADFN(name) { \
|
||||
if( (*(void**)&name = (void*)glXGetProcAddress((const GLubyte*)#name)) == NULL ) { \
|
||||
fprintf(stderr,"Failed to find %s\n", #name); \
|
||||
} \
|
||||
}
|
||||
// Use glew
|
||||
//#define GL_LOADFN(name)
|
||||
#endif
|
||||
|
||||
extern PFNGLACTIVETEXTUREPROC glActiveTexture;
|
||||
extern PFNGLATTACHSHADERPROC glAttachShader;
|
||||
extern PFNGLBINDBUFFERPROC glBindBuffer;
|
||||
|
@ -83,12 +99,8 @@ 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); \
|
||||
} \
|
||||
namespace GLLoader {
|
||||
bool check_gl_version(uint32 major, uint32 minor);
|
||||
void init_gl_function();
|
||||
bool check_gl_supported_extension();
|
||||
}
|
||||
#else
|
||||
// Use glew
|
||||
#endif
|
||||
|
|
|
@ -252,8 +252,10 @@ static int _GSopen(void** dsp, char* title, int renderer, int threads = -1)
|
|||
switch(renderer)
|
||||
{
|
||||
default:
|
||||
#ifdef _WINDOWS
|
||||
case 0: s_gs = (GSRenderer*)new GSRendererDX9(); break;
|
||||
case 3: s_gs = (GSRenderer*)new GSRendererDX11(); break;
|
||||
#endif
|
||||
case 12: s_gs = (GSRenderer*)new GSRendererOGL(); break;
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -33,68 +33,6 @@
|
|||
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)
|
||||
, m_window(NULL)
|
||||
|
@ -208,124 +146,11 @@ 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
|
||||
// the function pointers. The solution is for GLEW to use glGetStringi instead.
|
||||
// The current version of GLEW is 1.9.0 but they still haven't corrected it. The only fix is to use glewExperimental for now :
|
||||
//NOTE: I'm not sure experimental work on 1.6 ...
|
||||
glewExperimental=true;
|
||||
const int glew_ok = glewInit();
|
||||
if (glew_ok != GLEW_OK)
|
||||
{
|
||||
// FIXME:proper logging
|
||||
fprintf(stderr, "Error: Failed to init glew :%s\n", glewGetErrorString(glew_ok));
|
||||
return false;
|
||||
}
|
||||
// Note: don't rely on glew to avoid to pull glew1.7
|
||||
// Instead we just copy/adapt the 10 lines of code
|
||||
// if (!GLEW_VERSION_4_2) {
|
||||
// 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;
|
||||
fprintf(stderr, "Supported Opengl version: %s on GPU: %s. Vendor: %s\n", s, glGetString(GL_RENDERER), glGetString(GL_VENDOR));
|
||||
// Could be useful to detect the GPU vendor:
|
||||
// if ( strcmp((const char*)glGetString(GL_VENDOR), "ATI Technologies Inc.") == 0 )
|
||||
|
||||
GLuint dot = 0;
|
||||
while (s[dot] != '\0' && s[dot] != '.') dot++;
|
||||
if (dot == 0) return false;
|
||||
|
||||
GLuint major = s[dot-1]-'0';
|
||||
GLuint minor = s[dot+1]-'0';
|
||||
// Note: 4.2 crash on latest nvidia drivers!
|
||||
// So only check 4.1
|
||||
// if ( (major < 4) || ( major == 4 && minor < 2 ) ) return false;
|
||||
// if ( (major < 4) || ( major == 4 && minor < 1 ) ) return false;
|
||||
if ( (major < 3) || ( major == 3 && minor < 3 ) ) {
|
||||
fprintf(stderr, "OPENGL 3.3 is not supported\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef _LINUX
|
||||
if ( !glewIsSupported("GL_ARB_separate_shader_objects")) {
|
||||
fprintf(stderr, "GL_ARB_separate_shader_objects is not supported\n");
|
||||
return false;
|
||||
}
|
||||
if ( !glewIsSupported("GL_ARB_shading_language_420pack")) {
|
||||
fprintf(stderr, "GL_ARB_shading_language_420pack is not supported\n");
|
||||
//return false;
|
||||
}
|
||||
#endif
|
||||
GLLoader::init_gl_function();
|
||||
|
||||
if (!GLLoader::check_gl_version(3, 3)) return false;
|
||||
|
||||
if (!GLLoader::check_gl_supported_extension()) return false;
|
||||
}
|
||||
|
||||
// FIXME disable it when code is ready
|
||||
|
|
|
@ -438,6 +438,7 @@
|
|||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="GLLoader.cpp" />
|
||||
<ClCompile Include="GPU.cpp" />
|
||||
<ClCompile Include="GPUDrawScanline.cpp" />
|
||||
<ClCompile Include="GPUDrawScanlineCodeGenerator.cpp" />
|
||||
|
|
|
@ -270,6 +270,9 @@
|
|||
<ClCompile Include="baseclasses\wxutil.cpp">
|
||||
<Filter>Baseclasses</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="GLLoader.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="GPU.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
|
|
|
@ -454,6 +454,7 @@
|
|||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="GLLoader.cpp" />
|
||||
<ClCompile Include="GPU.cpp" />
|
||||
<ClCompile Include="GPUDrawScanline.cpp" />
|
||||
<ClCompile Include="GPUDrawScanlineCodeGenerator.cpp" />
|
||||
|
|
|
@ -270,6 +270,9 @@
|
|||
<ClCompile Include="baseclasses\wxutil.cpp">
|
||||
<Filter>Baseclasses</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="GLLoader.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="GPU.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
|
|
|
@ -773,6 +773,10 @@
|
|||
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\GLLoader.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\GPU.cpp"
|
||||
>
|
||||
|
|
Loading…
Reference in New Issue