1
0
mirror of https://github.com/blawar/GLideN64.git synced 2024-07-04 10:03:36 +00:00

CombinerProgramBuilder WIP

This commit is contained in:
Sergey Lipskiy 2017-01-08 17:49:05 +07:00
parent 60813209f7
commit 659bd807f5
21 changed files with 2301 additions and 63 deletions

View File

@ -304,9 +304,12 @@
<ClCompile Include="..\..\src\Graphics\OpenGLContext\GLFunctions.cpp" />
<ClCompile Include="..\..\src\Graphics\OpenGLContext\GLSL\glsl_CombinerProgramBuilder.cpp" />
<ClCompile Include="..\..\src\Graphics\OpenGLContext\GLSL\glsl_CombinerProgramImpl.cpp" />
<ClCompile Include="..\..\src\Graphics\OpenGLContext\GLSL\glsl_Utils.cpp" />
<ClCompile Include="..\..\src\Graphics\OpenGLContext\opengl_Attributes.cpp" />
<ClCompile Include="..\..\src\Graphics\OpenGLContext\opengl_BufferManipulationObjectFactory.cpp" />
<ClCompile Include="..\..\src\Graphics\OpenGLContext\opengl_CachedFunctions.cpp" />
<ClCompile Include="..\..\src\Graphics\OpenGLContext\opengl_ContextImpl.cpp" />
<ClCompile Include="..\..\src\Graphics\OpenGLContext\opengl_GLInfo.cpp" />
<ClCompile Include="..\..\src\Graphics\OpenGLContext\opengl_Parameters.cpp" />
<ClCompile Include="..\..\src\Graphics\OpenGLContext\opengl_TextureManipulationObjectFactory.cpp" />
<ClCompile Include="..\..\src\Graphics\OpenGLContext\opengl_Utilis.cpp" />
@ -438,10 +441,12 @@
<ClInclude Include="..\..\src\Graphics\OpenGLContext\GLFunctions.h" />
<ClInclude Include="..\..\src\Graphics\OpenGLContext\GLSL\glsl_CombinerProgramBuilder.h" />
<ClInclude Include="..\..\src\Graphics\OpenGLContext\GLSL\glsl_CombinerProgramImpl.h" />
<ClInclude Include="..\..\src\Graphics\OpenGLContext\GLSL\glsl_Utils.h" />
<ClInclude Include="..\..\src\Graphics\OpenGLContext\opengl_Attributes.h" />
<ClInclude Include="..\..\src\Graphics\OpenGLContext\opengl_BufferManipulationObjectFactory.h" />
<ClInclude Include="..\..\src\Graphics\OpenGLContext\opengl_CachedFunctions.h" />
<ClInclude Include="..\..\src\Graphics\OpenGLContext\opengl_ContextImpl.h" />
<ClInclude Include="..\..\src\Graphics\OpenGLContext\opengl_GLVersion.h" />
<ClInclude Include="..\..\src\Graphics\OpenGLContext\opengl_GLInfo.h" />
<ClInclude Include="..\..\src\Graphics\OpenGLContext\opengl_TextureManipulationObjectFactory.h" />
<ClInclude Include="..\..\src\Graphics\OpenGLContext\opengl_Utilis.h" />
<ClInclude Include="..\..\src\Graphics\Parameter.h" />

View File

@ -311,6 +311,15 @@
<ClCompile Include="..\..\src\Graphics\OpenGLContext\GLSL\glsl_CombinerProgramImpl.cpp">
<Filter>Source Files\Graphics\OpenGL\GLSL</Filter>
</ClCompile>
<ClCompile Include="..\..\src\Graphics\OpenGLContext\GLSL\glsl_Utils.cpp">
<Filter>Source Files\Graphics\OpenGL\GLSL</Filter>
</ClCompile>
<ClCompile Include="..\..\src\Graphics\OpenGLContext\opengl_Attributes.cpp">
<Filter>Source Files\Graphics\OpenGL</Filter>
</ClCompile>
<ClCompile Include="..\..\src\Graphics\OpenGLContext\opengl_GLInfo.cpp">
<Filter>Source Files\Graphics\OpenGL</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\src\3DMath.h">
@ -544,9 +553,6 @@
<ClInclude Include="..\..\src\Graphics\OpenGLContext\opengl_TextureManipulationObjectFactory.h">
<Filter>Header Files\Graphics\OpenGL</Filter>
</ClInclude>
<ClInclude Include="..\..\src\Graphics\OpenGLContext\opengl_GLVersion.h">
<Filter>Header Files\Graphics\OpenGL</Filter>
</ClInclude>
<ClInclude Include="..\..\src\Graphics\OpenGLContext\opengl_CachedFunctions.h">
<Filter>Header Files\Graphics\OpenGL</Filter>
</ClInclude>
@ -568,5 +574,14 @@
<ClInclude Include="..\..\src\Graphics\OpenGLContext\GLSL\glsl_CombinerProgramImpl.h">
<Filter>Header Files\Graphics\OpenGL\GLSL</Filter>
</ClInclude>
<ClInclude Include="..\..\src\Graphics\OpenGLContext\GLSL\glsl_Utils.h">
<Filter>Header Files\Graphics\OpenGL\GLSL</Filter>
</ClInclude>
<ClInclude Include="..\..\src\Graphics\OpenGLContext\opengl_Attributes.h">
<Filter>Header Files\Graphics\OpenGL</Filter>
</ClInclude>
<ClInclude Include="..\..\src\Graphics\OpenGLContext\opengl_GLInfo.h">
<Filter>Header Files\Graphics\OpenGL</Filter>
</ClInclude>
</ItemGroup>
</Project>

File diff suppressed because it is too large Load Diff

View File

@ -1,17 +1,86 @@
#pragma once
#include <memory>
#include <string>
#include <sstream>
#include <Combiner.h>
#include <Graphics/OpenGLContext/opengl_GLInfo.h>
#include <Graphics/CombinerProgram.h>
namespace opengl {
namespace glsl {
class ShaderPart
{
public:
void write(std::stringstream & shader)
{
shader << m_part;
}
protected:
std::string m_part;
};
class CombinerProgramBuilder
{
public:
CombinerProgramBuilder();
CombinerProgramBuilder(const opengl::GLInfo & _version);
~CombinerProgramBuilder();
graphics::CombinerProgram * buildCombinerProgram(Combiner & _color, Combiner & _alpha, const CombinerKey & _key);
private:
int compileCombiner(const CombinerKey & _key, Combiner & _color, Combiner & _alpha, std::string & _strShader);
typedef std::unique_ptr<ShaderPart> ShaderPartPtr;
ShaderPartPtr m_blender1;
ShaderPartPtr m_blender2;
ShaderPartPtr m_legacyBlender;
ShaderPartPtr m_clamp;
ShaderPartPtr m_signExtendColorC;
ShaderPartPtr m_signExtendAlphaC;
ShaderPartPtr m_signExtendColorABD;
ShaderPartPtr m_signExtendAlphaABD;
ShaderPartPtr m_alphaTest;
ShaderPartPtr m_callDither;
ShaderPartPtr m_vertexHeader;
ShaderPartPtr m_vertexRect;
ShaderPartPtr m_vertexTexturedRect;
ShaderPartPtr m_vertexTriangle;
ShaderPartPtr m_vertexTexturedTriangle;
ShaderPartPtr m_fragmentHeader;
ShaderPartPtr m_fragmentGlobalVariablesTex;
ShaderPartPtr m_fragmentGlobalVariablesNotex;
ShaderPartPtr m_fragmentHeaderNoise;
ShaderPartPtr m_fragmentHeaderWriteDepth;
ShaderPartPtr m_fragmentHeaderCalcLight;
ShaderPartPtr m_fragmentHeaderMipMap;
ShaderPartPtr m_fragmentHeaderReadMSTex;
ShaderPartPtr m_fragmentHeaderDither;
ShaderPartPtr m_fragmentHeaderDepthCompare;
ShaderPartPtr m_fragmentHeaderReadTex;
ShaderPartPtr m_fragmentMain;
ShaderPartPtr m_fragmentMain2Cycle;
ShaderPartPtr m_fragmentBlendMux;
ShaderPartPtr m_fragmentReadTex0;
ShaderPartPtr m_fragmentReadTex1;
ShaderPartPtr m_fragmentReadTexMipmap;
ShaderPartPtr m_fragmentCallN64Depth;
ShaderPartPtr m_fragmentRenderTarget;
ShaderPartPtr m_shaderNoise;
ShaderPartPtr m_shaderDither;
ShaderPartPtr m_shaderWriteDepth;
ShaderPartPtr m_shaderMipmap;
ShaderPartPtr m_shaderCalcLight;
ShaderPartPtr m_shaderReadtex;
ShaderPartPtr m_shaderN64DepthCompare;
ShaderPartPtr m_shaderN64DepthRender;
GLuint m_vertexShaderRect;
GLuint m_vertexShaderTriangle;
GLuint m_vertexShaderTexturedRect;
GLuint m_vertexShaderTexturedTriangle;
};
}
}

View File

@ -1,6 +1,50 @@
#include <Combiner.h>
#include "glsl_CombinerProgramImpl.h"
using namespace opengl::glsl;
using namespace glsl;
/*---------------CombinerInputs-------------*/
bool CombinerInputs::usesTile(u32 _t) const
{
if (_t == 0)
return (m_inputs & ((1 << TEXEL0) | (1 << TEXEL0_ALPHA))) != 0;
return (m_inputs & ((1 << TEXEL1) | (1 << TEXEL1_ALPHA))) != 0;
}
bool CombinerInputs::usesTexture() const
{
return (m_inputs & ((1 << TEXEL1) | (1 << TEXEL1_ALPHA) | (1 << TEXEL0) | (1 << TEXEL0_ALPHA))) != 0;
}
bool CombinerInputs::usesLOD() const
{
return (m_inputs & (1 << LOD_FRACTION)) != 0;
}
bool CombinerInputs::usesShade() const
{
return (m_inputs & ((1 << SHADE) | (1 << SHADE_ALPHA))) != 0;
}
bool CombinerInputs::usesShadeColor() const
{
return (m_inputs & (1 << SHADE)) != 0;
}
bool CombinerInputs::usesHwLighting() const
{
return (m_inputs & (1 << HW_LIGHT)) != 0;
}
void CombinerInputs::addInput(int _input)
{
m_inputs |= 1 << _input;
}
/*---------------CombinerProgramImpl-------------*/
CombinerProgramImpl::CombinerProgramImpl()
{

View File

@ -1,9 +1,31 @@
#pragma once
#include <Graphics/CombinerProgram.h>
namespace opengl {
namespace glsl {
class CombinerInputs
{
public:
explicit CombinerInputs(int _inputs) : m_inputs(_inputs) {}
bool usesTile(u32 _t) const;
bool usesTexture() const;
bool usesLOD() const;
bool usesShade() const;
bool usesShadeColor() const;
bool usesHwLighting() const;
void addInput(int _input);
private:
int m_inputs;
};
class CombinerProgramImpl : public graphics::CombinerProgram
{
public:
@ -16,4 +38,3 @@ namespace glsl {
};
}
}

View File

@ -0,0 +1,76 @@
#include <Log.h>
#include <Graphics/OpenGLContext/opengl_Attributes.h>
#include "glsl_Utils.h"
using namespace glsl;
void Utils::locateAttributes(GLuint _program, bool _rect, bool _textures)
{
if (_rect) {
glBindAttribLocation(_program, opengl::rectAttrib::position, "aRectPosition");
glBindAttribLocation(_program, opengl::rectAttrib::color, "aRectColor");
if (_textures) {
glBindAttribLocation(_program, opengl::rectAttrib::texcoord0, "aTexCoord0");
glBindAttribLocation(_program, opengl::rectAttrib::texcoord1, "aTexCoord1");
}
return;
}
glBindAttribLocation(_program, opengl::triangleAttrib::position, "aPosition");
glBindAttribLocation(_program, opengl::triangleAttrib::color, "aColor");
glBindAttribLocation(_program, opengl::triangleAttrib::numlights, "aNumLights");
glBindAttribLocation(_program, opengl::triangleAttrib::modify, "aModify");
if (_textures)
glBindAttribLocation(_program, opengl::triangleAttrib::texcoord, "aTexCoord");
}
static const GLsizei nShaderLogSize = 1024;
bool Utils::checkShaderCompileStatus(GLuint obj)
{
GLint status;
glGetShaderiv(obj, GL_COMPILE_STATUS, &status);
if (status == GL_FALSE) {
GLchar shader_log[nShaderLogSize];
GLsizei nLogSize = nShaderLogSize;
glGetShaderInfoLog(obj, nShaderLogSize, &nLogSize, shader_log);
shader_log[nLogSize] = 0;
LOG(LOG_ERROR, "shader_compile error: %s\n", shader_log);
return false;
}
return true;
}
bool Utils::checkProgramLinkStatus(GLuint obj)
{
GLint status;
glGetProgramiv(obj, GL_LINK_STATUS, &status);
if (status == GL_FALSE) {
GLsizei nLogSize = nShaderLogSize;
GLchar shader_log[nShaderLogSize];
glGetProgramInfoLog(obj, nShaderLogSize, &nLogSize, shader_log);
LOG(LOG_ERROR, "shader_link error: %s\n", shader_log);
return false;
}
return true;
}
void Utils::logErrorShader(GLenum _shaderType, const std::string & _strShader)
{
LOG(LOG_ERROR, "Error in %s shader", _shaderType == GL_VERTEX_SHADER ? "vertex" : "fragment");
const int max = 800;
int pos = 0;
while (pos < _strShader.length()) {
if (_strShader.length() - pos < max) {
LOG(LOG_ERROR, "%s", _strShader.substr(pos).data());
}
else {
LOG(LOG_ERROR, "%s", _strShader.substr(pos, max).data());
}
pos += max;
}
}

View File

@ -0,0 +1,13 @@
#pragma once
#include <string>
#include <Graphics/OpenGLContext/GLFunctions.h>
namespace glsl {
struct Utils {
static void locateAttributes(GLuint _program, bool _rect, bool _textures);
static bool checkShaderCompileStatus(GLuint obj);
static bool checkProgramLinkStatus(GLuint obj);
static void logErrorShader(GLenum _shaderType, const std::string & _strShader);
};
}

View File

@ -0,0 +1,21 @@
#include "opengl_Attributes.h"
namespace opengl {
namespace triangleAttrib {
const GLuint position = 1U;
const GLuint color = 2U;
const GLuint texcoord = 3U;
const GLuint numlights = 4U;
const GLuint modify = 5U;
}
// Rect attributes
namespace rectAttrib {
const GLuint position = 6U;
const GLuint color = 7U;
const GLuint texcoord0 = 8U;
const GLuint texcoord1 = 9U;
}
}

View File

@ -0,0 +1,23 @@
#pragma once
#include "GLFunctions.h"
namespace opengl {
// Triangle attributes
namespace triangleAttrib {
extern const GLuint position;
extern const GLuint color;
extern const GLuint texcoord;
extern const GLuint numlights;
extern const GLuint modify;
}
// Rect attributes
namespace rectAttrib {
extern const GLuint position;
extern const GLuint color;
extern const GLuint texcoord0;
extern const GLuint texcoord1;
}
}

View File

@ -1,5 +1,5 @@
#include <Graphics/Parameters.h>
#include "opengl_GLVersion.h"
#include "opengl_GLInfo.h"
#include "opengl_CachedFunctions.h"
#include "opengl_BufferManipulationObjectFactory.h"
@ -23,9 +23,9 @@ public:
class CreateFramebuffer : public CreateFramebufferObject
{
public:
static bool Check(const GLVersion & _version) {
static bool Check(const GLInfo & _glinfo) {
#ifdef ENABLE_GL_4_5
return (_version.majorVersion > 4) || (_version.majorVersion == 4 && _version.minorVersion >= 5);
return (_glinfo.majorVersion > 4) || (_glinfo.majorVersion == 4 && _glinfo.minorVersion >= 5);
#else
return false;
#endif
@ -101,9 +101,9 @@ private:
class AddNamedFramebufferTexture : public AddFramebufferRenderTarget
{
public:
static bool Check(const GLVersion & _version) {
static bool Check(const GLInfo & _glinfo) {
#ifdef ENABLE_GL_4_5
return (_version.majorVersion > 4) || (_version.majorVersion == 4 && _version.minorVersion >= 5);
return (_glinfo.majorVersion > 4) || (_glinfo.majorVersion == 4 && _glinfo.minorVersion >= 5);
#else
return false;
#endif
@ -120,9 +120,9 @@ public:
/*---------------BufferManipulationObjectFactory-------------*/
BufferManipulationObjectFactory::BufferManipulationObjectFactory(const GLVersion & _version,
BufferManipulationObjectFactory::BufferManipulationObjectFactory(const GLInfo & _info,
CachedFunctions & _cachedFunctions)
: m_version(_version)
: m_glInfo(_info)
, m_cachedFunctions(_cachedFunctions)
{
}
@ -134,7 +134,7 @@ BufferManipulationObjectFactory::~BufferManipulationObjectFactory()
CreateFramebufferObject * BufferManipulationObjectFactory::getCreateFramebufferObject() const
{
if (CreateFramebuffer::Check(m_version))
if (CreateFramebuffer::Check(m_glInfo))
return new CreateFramebuffer;
return new GenFramebuffer;
@ -152,7 +152,7 @@ InitRenderbuffer * BufferManipulationObjectFactory::getInitRenderbuffer() const
AddFramebufferRenderTarget * BufferManipulationObjectFactory::getAddFramebufferRenderTarget() const
{
if (AddNamedFramebufferTexture::Check(m_version))
if (AddNamedFramebufferTexture::Check(m_glInfo))
return new AddNamedFramebufferTexture;
return new AddFramebufferTexture2D(m_cachedFunctions.geCachedBindFramebuffer());

View File

@ -2,10 +2,11 @@
#include <Graphics/ObjectHandle.h>
#include <Graphics/Parameter.h>
#include <Graphics/Context.h>
#include "opengl_GLInfo.h"
namespace opengl {
struct GLVersion;
struct GLInfo;
class CachedFunctions;
class CreateFramebufferObject
@ -40,7 +41,7 @@ namespace opengl {
class BufferManipulationObjectFactory
{
public:
BufferManipulationObjectFactory(const GLVersion & _version, CachedFunctions & _cachedFunctions);
BufferManipulationObjectFactory(const GLInfo & _info, CachedFunctions & _cachedFunctions);
~BufferManipulationObjectFactory();
CreateFramebufferObject * getCreateFramebufferObject() const;
@ -52,7 +53,7 @@ namespace opengl {
AddFramebufferRenderTarget * getAddFramebufferRenderTarget() const;
private:
const GLVersion & m_version;
const GLInfo & m_glInfo;
CachedFunctions & m_cachedFunctions;
};

View File

@ -16,24 +16,20 @@ ContextImpl::~ContextImpl()
void ContextImpl::init()
{
glGetIntegerv(GL_MAJOR_VERSION, &m_version.majorVersion);
LOG(LOG_VERBOSE, "OpenGL major version: %d\n", m_version.majorVersion);
assert(m_version.majorVersion >= 3 && "Plugin requires GL version 3 or higher.");
glGetIntegerv(GL_MINOR_VERSION, &m_version.minorVersion);
LOG(LOG_VERBOSE, "OpenGL minor version: %d\n", m_version.minorVersion);
m_glInfo.init();
if (!m_cachedFunctions)
m_cachedFunctions.reset(new CachedFunctions);
{
TextureManipulationObjectFactory textureObjectsFactory(m_version, *m_cachedFunctions.get());
TextureManipulationObjectFactory textureObjectsFactory(m_glInfo, *m_cachedFunctions.get());
m_createTexture.reset(textureObjectsFactory.getCreate2DTexture());
m_init2DTexture.reset(textureObjectsFactory.getInit2DTexture());
m_set2DTextureParameters.reset(textureObjectsFactory.getSet2DTextureParameters());
}
{
BufferManipulationObjectFactory bufferObjectFactory(m_version, *m_cachedFunctions.get());
BufferManipulationObjectFactory bufferObjectFactory(m_glInfo, *m_cachedFunctions.get());
m_createFramebuffer.reset(bufferObjectFactory.getCreateFramebufferObject());
m_createRenderbuffer.reset(bufferObjectFactory.getCreateRenderbuffer());
m_initRenderbuffer.reset(bufferObjectFactory.getInitRenderbuffer());

View File

@ -3,7 +3,7 @@
#include <Graphics/ContextImpl.h>
#include "opengl_TextureManipulationObjectFactory.h"
#include "opengl_BufferManipulationObjectFactory.h"
#include "opengl_GLVersion.h"
#include "opengl_GLInfo.h"
#include "opengl_CachedFunctions.h"
namespace opengl {
@ -49,7 +49,7 @@ namespace opengl {
std::unique_ptr<InitRenderbuffer> m_initRenderbuffer;
std::unique_ptr<AddFramebufferRenderTarget> m_addFramebufferRenderTarget;
GLVersion m_version;
GLInfo m_glInfo;
};
}

View File

@ -0,0 +1,36 @@
#pragma once
#include <Log.h>
#include <Config.h>
#include "opengl_Utilis.h"
#include "opengl_GLInfo.h"
using namespace opengl;
void GLInfo::init() {
const char * strVersion = reinterpret_cast<const char *>(glGetString(GL_VERSION));
isGLESX = strstr(strVersion, "OpenGL ES") != nullptr;
isGLES2 = strstr(strVersion, "OpenGL ES 2") != nullptr;
if (isGLES2) {
majorVersion = 2;
minorVersion = 0;
}
else {
glGetIntegerv(GL_MAJOR_VERSION, &majorVersion);
glGetIntegerv(GL_MINOR_VERSION, &minorVersion);
}
LOG(LOG_VERBOSE, "%s major version: %d\n", isGLESX ? "OpenGL ES" : "OpenGL", majorVersion);
LOG(LOG_VERBOSE, "%s minor version: %d\n", isGLESX ? "OpenGL ES" : "OpenGL", minorVersion);
#ifdef GL_NUM_PROGRAM_BINARY_FORMATS
GLint numBinaryFormats = 0;
glGetIntegerv(GL_NUM_PROGRAM_BINARY_FORMATS, &numBinaryFormats);
const char * strGetProgramBinary = isGLESX
? "GL_OES_get_program_binary"
: "GL_ARB_get_program_binary";
shaderStorage = numBinaryFormats > 0 &&
config.generalEmulation.enableShadersStorage != 0 &&
Utils::isExtensionSupported(strGetProgramBinary);
#else
shaderStorage =false;
#endif
}

View File

@ -0,0 +1,16 @@
#pragma once
#include "GLFunctions.h"
namespace opengl {
struct GLInfo {
GLint majorVersion = 0;
GLint minorVersion = 0;
bool isGLES2 = false;
bool isGLESX = false;
bool imageTextures = false;
bool shaderStorage = false;
void init();
};
}

View File

@ -1,10 +0,0 @@
#pragma once
#include "GLFunctions.h"
namespace opengl {
struct GLVersion {
GLint majorVersion = 0;
GLint minorVersion = 0;
};
}

View File

@ -1,6 +1,6 @@
#include <unordered_map>
#include <Graphics/Parameters.h>
#include "opengl_GLVersion.h"
#include "opengl_GLInfo.h"
#include "opengl_CachedFunctions.h"
#include "opengl_TextureManipulationObjectFactory.h"
@ -25,9 +25,9 @@ namespace opengl {
class CreateTexture : public Create2DTexture
{
public:
static bool Check(const GLVersion & _version) {
static bool Check(const GLInfo & _glinfo) {
#ifdef ENABLE_GL_4_5
return (_version.majorVersion > 4) || (_version.majorVersion == 4 && _version.minorVersion >= 5);
return (_glinfo.majorVersion > 4) || (_glinfo.majorVersion == 4 && _glinfo.minorVersion >= 5);
#else
return false;
#endif
@ -84,9 +84,9 @@ namespace opengl {
class Init2DTexStorage : public Init2DTexture
{
public:
static bool Check(const GLVersion & _version) {
static bool Check(const GLInfo & _glinfo) {
#ifdef ENABLE_GL_4_2
return (_version.majorVersion > 4) || (_version.majorVersion == 4 && _version.minorVersion >= 2);
return (_glinfo.majorVersion > 4) || (_glinfo.majorVersion == 4 && _glinfo.minorVersion >= 2);
#else
return false;
#endif
@ -142,9 +142,9 @@ namespace opengl {
class Init2DTextureStorage : public Init2DTexture
{
public:
static bool Check(const GLVersion & _version) {
static bool Check(const GLInfo & _glinfo) {
#ifdef ENABLE_GL_4_5
return (_version.majorVersion > 4) || (_version.majorVersion == 4 && _version.minorVersion >= 5);
return (_glinfo.majorVersion > 4) || (_glinfo.majorVersion == 4 && _glinfo.minorVersion >= 5);
#else
return false;
#endif
@ -230,9 +230,9 @@ namespace opengl {
class SetTextureParameters : public Set2DTextureParameters
{
public:
static bool Check(const GLVersion & _version) {
static bool Check(const GLInfo & _glinfo) {
#ifdef ENABLE_GL_4_5
return (_version.majorVersion > 4) || (_version.majorVersion == 4 && _version.minorVersion >= 5);
return (_glinfo.majorVersion > 4) || (_glinfo.majorVersion == 4 && _glinfo.minorVersion >= 5);
#else
return false;
#endif
@ -272,9 +272,9 @@ namespace opengl {
/*---------------TextureManipulationObjectFactory-------------*/
TextureManipulationObjectFactory::TextureManipulationObjectFactory(const GLVersion & _version,
TextureManipulationObjectFactory::TextureManipulationObjectFactory(const GLInfo & _glinfo,
CachedFunctions & _cachedFunctions)
: m_version(_version)
: m_glInfo(_glinfo)
, m_cachedFunctions(_cachedFunctions)
{
}
@ -285,7 +285,7 @@ namespace opengl {
Create2DTexture * TextureManipulationObjectFactory::getCreate2DTexture() const
{
if (CreateTexture::Check(m_version))
if (CreateTexture::Check(m_glInfo))
return new CreateTexture;
return new GenTexture;
@ -293,10 +293,10 @@ namespace opengl {
Init2DTexture * TextureManipulationObjectFactory::getInit2DTexture() const
{
if (Init2DTextureStorage::Check(m_version))
if (Init2DTextureStorage::Check(m_glInfo))
return new Init2DTextureStorage;
if (Init2DTexStorage::Check(m_version))
if (Init2DTexStorage::Check(m_glInfo))
return new Init2DTexStorage(m_cachedFunctions.getCachedBindTexture());
return new Init2DTexImage(m_cachedFunctions.getCachedBindTexture());
@ -304,7 +304,7 @@ namespace opengl {
Set2DTextureParameters * TextureManipulationObjectFactory::getSet2DTextureParameters() const
{
if (SetTextureParameters::Check(m_version))
if (SetTextureParameters::Check(m_glInfo))
return new SetTextureParameters;
return new SetTexParameters(m_cachedFunctions.geCachedActiveTexture(),

View File

@ -5,7 +5,7 @@
namespace opengl {
struct GLVersion;
struct GLInfo;
class CachedFunctions;
class Create2DTexture
@ -33,7 +33,7 @@ namespace opengl {
class TextureManipulationObjectFactory
{
public:
TextureManipulationObjectFactory(const GLVersion & _version, CachedFunctions & _cachedFunctions);
TextureManipulationObjectFactory(const GLInfo & _glinfo, CachedFunctions & _cachedFunctions);
~TextureManipulationObjectFactory();
Create2DTexture * getCreate2DTexture() const;
@ -43,7 +43,7 @@ namespace opengl {
Set2DTextureParameters * getSet2DTextureParameters() const;
private:
const GLVersion & m_version;
const GLInfo & m_glInfo;
CachedFunctions & m_cachedFunctions;
};

View File

@ -2,7 +2,9 @@
#include "opengl_Utilis.h"
#include "GLFunctions.h"
bool opengl::isExtensionSupported(const char *extension)
using namespace opengl;
bool Utils::isExtensionSupported(const char *extension)
{
#ifdef GL_NUM_EXTENSIONS
GLint count = 0;

View File

@ -2,6 +2,9 @@
namespace opengl {
bool isExtensionSupported(const char * extension);
struct Utils
{
static bool isExtensionSupported(const char * extension);
};
}