Commit 20d7ecbc authored by Matthias Möller's avatar Matthias Möller
Browse files

using gl extension defines instead of apple macro to disable/enable features

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@17900 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 60a7759d
......@@ -98,11 +98,11 @@ void FBO::attachTexture2D( GLenum _attachment, GLsizei _width, GLsizei _height,
GLuint texID;
glGenTextures(1, &texID);
#ifdef __APPLE__
GLenum target = GL_TEXTURE_2D;
#else
#ifdef GL_ARB_texture_multisample
GLenum target = samples_ ? GL_TEXTURE_2D_MULTISAMPLE : GL_TEXTURE_2D;
#endif // __APPLE__
#else
GLenum target = GL_TEXTURE_2D;
#endif // GL_ARB_texture_multisample
// store texture id in internal array
......@@ -121,11 +121,7 @@ void FBO::attachTexture2D( GLenum _attachment, GLsizei _width, GLsizei _height,
glTexParameteri(target, GL_TEXTURE_WRAP_T, _wrapMode);
#ifdef __APPLE__
glTexParameteri(target, GL_TEXTURE_MIN_FILTER, _minFilter);
glTexParameteri(target, GL_TEXTURE_MAG_FILTER, _magFilter);
glTexImage2D(target, 0, _internalFmt, _width, _height, 0, _format, GL_FLOAT, 0);
#else
#ifdef GL_ARB_texture_multisample
if (!samples_)
{
glTexParameteri(target, GL_TEXTURE_MIN_FILTER, _minFilter);
......@@ -134,7 +130,11 @@ void FBO::attachTexture2D( GLenum _attachment, GLsizei _width, GLsizei _height,
}
else
glTexImage2DMultisample(target, samples_, _internalFmt, _width, _height, fixedsamplelocation_);
#endif // __APPLE__
#else
glTexParameteri(target, GL_TEXTURE_MIN_FILTER, _minFilter);
glTexParameteri(target, GL_TEXTURE_MAG_FILTER, _magFilter);
glTexImage2D(target, 0, _internalFmt, _width, _height, 0, _format, GL_FLOAT, 0);
#endif // GL_ARB_texture_multisample
checkGLError();
......@@ -156,11 +156,11 @@ void FBO::attachTexture2DDepth( GLsizei _width, GLsizei _height, GLuint _interna
GLuint texID;
glGenTextures(1, &texID);
#ifdef __APPLE__
#ifdef GL_ARB_texture_multisample
GLenum target = GL_TEXTURE_2D;
#else
GLenum target = samples_ ? GL_TEXTURE_2D_MULTISAMPLE : GL_TEXTURE_2D;
#endif // __APPLE__
#endif // GL_ARB_texture_multisample
// store texture id in internal array
RenderTexture intID;
......@@ -177,11 +177,7 @@ void FBO::attachTexture2DDepth( GLsizei _width, GLsizei _height, GLuint _interna
glTexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
#ifdef __APPLE__
glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexImage2D(target, 0, _internalFmt, _width, _height, 0, _format, _format == GL_DEPTH_STENCIL ? GL_UNSIGNED_INT_24_8 : GL_FLOAT, 0);
#else
#ifdef GL_ARB_texture_multisample
if (!samples_)
{
glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
......@@ -190,7 +186,12 @@ void FBO::attachTexture2DDepth( GLsizei _width, GLsizei _height, GLuint _interna
}
else
glTexImage2DMultisample(target, samples_, _internalFmt, _width, _height, fixedsamplelocation_);
#endif // __APPLE__
#else
glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexImage2D(target, 0, _internalFmt, _width, _height, 0, _format, _format == GL_DEPTH_STENCIL ? GL_UNSIGNED_INT_24_8 : GL_FLOAT, 0);
#endif // GL_ARB_texture_multisample
checkGLError();
......@@ -349,26 +350,27 @@ void FBO::resize( GLsizei _width, GLsizei _height, bool _forceResize )
{
RenderTexture* rt = &internalTextures_[i];
#ifndef __APPLE__
#ifdef GL_ARB_texture_multisample
// check if we have to convert to multisampling
if (rt->target != GL_TEXTURE_2D_MULTISAMPLE && samples_ > 0)
{
rt->target = GL_TEXTURE_2D_MULTISAMPLE;
reattachTextures = true;
}
#endif // __APPLE__
#endif // GL_ARB_texture_multisample
glBindTexture(rt->target, rt->id);
#ifdef __APPLE__
glTexImage2D(rt->target, 0, rt->internalFormat, _width, _height, 0, rt->format, rt->format == GL_DEPTH_STENCIL ? GL_UNSIGNED_INT_24_8 : GL_FLOAT, 0);
#else
#ifdef GL_ARB_texture_multisample
if (!samples_)
glTexImage2D(rt->target, 0, rt->internalFormat, _width, _height, 0, rt->format, rt->format == GL_DEPTH_STENCIL ? GL_UNSIGNED_INT_24_8 : GL_FLOAT, 0);
else
glTexImage2DMultisample(rt->target, samples_, rt->internalFormat, _width, _height, fixedsamplelocation_);
#endif // __APPLE__
#else
glTexImage2D(rt->target, 0, rt->internalFormat, _width, _height, 0, rt->format, rt->format == GL_DEPTH_STENCIL ? GL_UNSIGNED_INT_24_8 : GL_FLOAT, 0);
#endif // GL_ARB_texture_multisample
}
......
......@@ -807,16 +807,23 @@ void ShaderProgGenerator::buildFragmentShader()
case GL_TEXTURE_2D: type = "sampler2D"; break;
case GL_TEXTURE_3D: type = "sampler3D"; break;
case GL_TEXTURE_CUBE_MAP: type = "samplerCube​"; break;
#if !defined(ARCH_DARWIN)
case GL_TEXTURE_RECTANGLE: type = "sampler2DRect"; break;
case GL_TEXTURE_BUFFER: type = "samplerBuffer​"; break;
case GL_TEXTURE_1D_ARRAY: type = "sampler1DArray"; break;
case GL_TEXTURE_2D_ARRAY: type = "sampler2DArray"; break;
case GL_TEXTURE_CUBE_MAP_ARRAY: type = "samplerCubeArray"; break;
#ifdef GL_ARB_texture_rectangle //ARCH_DARWIN doesn't support all texture defines with all xcode version (xcode 5.0 seems to support all)
case GL_TEXTURE_RECTANGLE_ARB: type = "sampler2DRect"; break;
#endif
#ifdef GL_ARB_texture_buffer_object
case GL_TEXTURE_BUFFER_ARB: type = "samplerBuffer​"; break;
#endif
#ifdef GL_EXT_texture_array
case GL_TEXTURE_1D_ARRAY_EXT: type = "sampler1DArray"; break;
case GL_TEXTURE_2D_ARRAY_EXT: type = "sampler2DArray"; break;
#endif
#ifdef GL_ARB_texture_cube_map_array
case GL_TEXTURE_CUBE_MAP_ARRAY_ARB: type = "samplerCubeArray"; break;
#endif
#ifdef GL_ARB_texture_multisample
case GL_TEXTURE_2D_MULTISAMPLE: type = "sampler2DMS"; break;
case GL_TEXTURE_2D_MULTISAMPLE_ARRAY: type = "sampler2DMSArray​"; break;
#endif //defined(ARCH_DARWIN)
#endif
default: std::cerr << "Texture Type not supported "<< iter->second.type << std::endl; break;
}
// todo: check if texture type supports shadowtype
......@@ -1167,16 +1174,23 @@ QString ShaderGenDesc::toString() const
case GL_TEXTURE_2D: resStrm << "GL_TEXTURE_2D"; break;
case GL_TEXTURE_3D: resStrm << "GL_TEXTURE_3D"; break;
case GL_TEXTURE_CUBE_MAP: resStrm << "GL_TEXTURE_CUBE_MAP​"; break;
#if !defined(ARCH_DARWIN)
case GL_TEXTURE_RECTANGLE: resStrm << "GL_TEXTURE_RECTANGLE"; break;
case GL_TEXTURE_BUFFER: resStrm << "GL_TEXTURE_BUFFER​"; break;
case GL_TEXTURE_1D_ARRAY: resStrm << "GL_TEXTURE_1D_ARRAY"; break;
case GL_TEXTURE_2D_ARRAY: resStrm << "GL_TEXTURE_2D_ARRAY"; break;
case GL_TEXTURE_CUBE_MAP_ARRAY: resStrm << "GL_TEXTURE_CUBE_MAP_ARRAY"; break;
#ifdef GL_ARB_texture_rectangle //ARCH_DARWIN doesn't support all texture defines with all xcode version (xcode 5.0 seems to support all)
case GL_TEXTURE_RECTANGLE_ARB: resStrm << "GL_TEXTURE_RECTANGLE"; break;
#endif
#ifdef GL_ARB_texture_buffer_object
case GL_TEXTURE_BUFFER_ARB: resStrm << "GL_TEXTURE_BUFFER​"; break;
#endif
#ifdef GL_EXT_texture_array
case GL_TEXTURE_1D_ARRAY_EXT: resStrm << "GL_TEXTURE_1D_ARRAY"; break;
case GL_TEXTURE_2D_ARRAY_EXT: resStrm << "GL_TEXTURE_2D_ARRAY"; break;
#endif
#ifdef GL_ARB_texture_cube_map_array
case GL_TEXTURE_CUBE_MAP_ARRAY_ARB: resStrm << "GL_TEXTURE_CUBE_MAP_ARRAY"; break;
#endif
#ifdef GL_ARB_texture_multisample
case GL_TEXTURE_2D_MULTISAMPLE: resStrm << "GL_TEXTURE_2D_MULTISAMPLE"; break;
case GL_TEXTURE_2D_MULTISAMPLE_ARRAY: resStrm << "GL_TEXTURE_2D_MULTISAMPLE_ARRAY​"; break;
#endif //defined(ARCH_DARWIN)
#endif
default: std::cerr << "Texture Type with number "<< iter->second.type << " on stage "<< iter->first << " is not supported " << std::endl; break;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment