Commit 8f61a37a authored by Philip Trettner's avatar Philip Trettner
Browse files

fixed stencil buffer support

parent 4f466797
......@@ -5,7 +5,8 @@ from Cheetah.Template import Template
#outCodeDir = "/home/ptrettner/projects/glow-tests/libs/glow/src/glow/objects/"
#outTestDir = "/home/ptrettner/projects/glow-tests/src/objects/tex-gen/"
#outCodeDir = "/home/ptrettner/projects/glow-minimal/extern/glow/src/glow/objects/"
outCodeDir = "/home/ptrettner/projects/tg-samples/extern/glow/src/glow/objects/"
#outCodeDir = "/home/ptrettner/projects/tg-samples/extern/glow/src/glow/objects/"
outCodeDir = "/home/ptrettner/projects/glow-samples/extern/glow/src/glow/objects/"
outTestDir = None
#outCodeDir = "/mnt/c/Users/Kunstwald/workspace/glow-samples/glow/src/glow/objects/"
#outTestDir = "/mnt/c/Users/Kunstwald/workspace/glow-tex-tests/"
......
......@@ -418,6 +418,7 @@ void $class::Bound$class::resize(${sizeParameter})
#if not $isMultisample and not $buffer
GLenum format = GL_RGBA;
GLenum type = GL_UNSIGNED_BYTE;
auto isIntegerFormat = isIntegerInternalFormat(texture->mInternalFormat);
switch (channelsOfInternalFormat(texture->mInternalFormat))
{
......@@ -444,8 +445,13 @@ void $class::Bound$class::resize(${sizeParameter})
format = GL_DEPTH_COMPONENT;
break;
case GL_DEPTH32F_STENCIL8:
case GL_DEPTH24_STENCIL8:
type = GL_UNSIGNED_INT_24_8;
format = GL_DEPTH_STENCIL;
break;
case GL_DEPTH32F_STENCIL8:
type = GL_FLOAT_32_UNSIGNED_INT_24_8_REV;
format = GL_DEPTH_STENCIL;
break;
......@@ -462,19 +468,19 @@ void $class::Bound$class::resize(${sizeParameter})
#if $buffer
warning() << "not implemented. " << to_string(texture);
#elif $cubemap and not $array
glTexImage${storageDim}D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, texture->mInternalFormat, ${sizeParameterCall}, 0, format, GL_UNSIGNED_BYTE, nullptr);
glTexImage${storageDim}D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, texture->mInternalFormat, ${sizeParameterCall}, 0, format, GL_UNSIGNED_BYTE, nullptr);
glTexImage${storageDim}D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, texture->mInternalFormat, ${sizeParameterCall}, 0, format, GL_UNSIGNED_BYTE, nullptr);
glTexImage${storageDim}D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, texture->mInternalFormat, ${sizeParameterCall}, 0, format, GL_UNSIGNED_BYTE, nullptr);
glTexImage${storageDim}D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, texture->mInternalFormat, ${sizeParameterCall}, 0, format, GL_UNSIGNED_BYTE, nullptr);
glTexImage${storageDim}D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, texture->mInternalFormat, ${sizeParameterCall}, 0, format, GL_UNSIGNED_BYTE, nullptr);
glTexImage${storageDim}D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, texture->mInternalFormat, ${sizeParameterCall}, 0, format, type, nullptr);
glTexImage${storageDim}D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, texture->mInternalFormat, ${sizeParameterCall}, 0, format, type, nullptr);
glTexImage${storageDim}D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, texture->mInternalFormat, ${sizeParameterCall}, 0, format, type, nullptr);
glTexImage${storageDim}D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, texture->mInternalFormat, ${sizeParameterCall}, 0, format, type, nullptr);
glTexImage${storageDim}D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, texture->mInternalFormat, ${sizeParameterCall}, 0, format, type, nullptr);
glTexImage${storageDim}D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, texture->mInternalFormat, ${sizeParameterCall}, 0, format, type, nullptr);
#else
#if $isMultisample
glTexImage${storageDim}DMultisample(texture->mTarget, samples, texture->mInternalFormat, ${sizeParameterCall}, fixedSamples);
texture->mSampleAmount = samples;
texture->mFixedSamples = fixedSamples;
#else
glTexImage${storageDim}D(texture->mTarget, 0, texture->mInternalFormat, ${sizeParameterCall}#if $cubemap and $array# * 6u#end if#, 0, format, GL_UNSIGNED_BYTE, nullptr);
glTexImage${storageDim}D(texture->mTarget, 0, texture->mInternalFormat, ${sizeParameterCall}#if $cubemap and $array# * 6u#end if#, 0, format, type, nullptr);
#end if
#end if
......
......@@ -361,6 +361,7 @@ inline GLuint channelsOfInternalFormat(GLenum internalFormat)
case GL_DEPTH_COMPONENT24:
case GL_DEPTH_COMPONENT32:
case GL_DEPTH_COMPONENT32F:
case GL_STENCIL_INDEX:
case GL_STENCIL_INDEX1:
case GL_STENCIL_INDEX4:
case GL_STENCIL_INDEX8:
......@@ -368,9 +369,9 @@ inline GLuint channelsOfInternalFormat(GLenum internalFormat)
return 1;
case GL_RG:
case GL_DEPTH_STENCIL: // ?
case GL_DEPTH24_STENCIL8: // ?
case GL_DEPTH32F_STENCIL8: // ?
case GL_DEPTH_STENCIL:
case GL_DEPTH24_STENCIL8:
case GL_DEPTH32F_STENCIL8:
return 2;
case GL_RGB:
......
......@@ -99,11 +99,14 @@ bool Framebuffer::internalCheckComplete()
auto status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
switch (status)
{
case GL_FRAMEBUFFER_COMPLETE:
if (status == GL_FRAMEBUFFER_COMPLETE)
return true;
if (mDepthAttachment.texture && mStencilAttachment.texture && mDepthAttachment.texture->getObjectName() != mStencilAttachment.texture->getObjectName())
error() << "NOTE: depth and stencil buffer are not the same texture. Drivers are not required to support this.";
switch (status)
{
case GL_FRAMEBUFFER_UNDEFINED:
error() << "Incomplete Framebuffer " << to_string(this);
error() << "Framebuffer not complete: GL_FRAMEBUFFER_UNDEFINED is returned if the specified framebuffer is the "
......
......@@ -308,6 +308,7 @@ void Texture1D::BoundTexture1D::resize(int width)
texture->mWidth = width;
GLenum format = GL_RGBA;
GLenum type = GL_UNSIGNED_BYTE;
auto isIntegerFormat = isIntegerInternalFormat(texture->mInternalFormat);
switch (channelsOfInternalFormat(texture->mInternalFormat))
{
......@@ -334,8 +335,13 @@ void Texture1D::BoundTexture1D::resize(int width)
format = GL_DEPTH_COMPONENT;
break;
case GL_DEPTH32F_STENCIL8:
case GL_DEPTH24_STENCIL8:
type = GL_UNSIGNED_INT_24_8;
format = GL_DEPTH_STENCIL;
break;
case GL_DEPTH32F_STENCIL8:
type = GL_FLOAT_32_UNSIGNED_INT_24_8_REV;
format = GL_DEPTH_STENCIL;
break;
......@@ -348,7 +354,7 @@ void Texture1D::BoundTexture1D::resize(int width)
break;
}
glTexImage1D(texture->mTarget, 0, texture->mInternalFormat, width, 0, format, GL_UNSIGNED_BYTE, nullptr);
glTexImage1D(texture->mTarget, 0, texture->mInternalFormat, width, 0, format, type, nullptr);
texture->mMipmapsGenerated = false;
}
......
......@@ -311,6 +311,7 @@ void Texture1DArray::BoundTexture1DArray::resize(int width, int layers)
texture->mLayers = layers;
GLenum format = GL_RGBA;
GLenum type = GL_UNSIGNED_BYTE;
auto isIntegerFormat = isIntegerInternalFormat(texture->mInternalFormat);
switch (channelsOfInternalFormat(texture->mInternalFormat))
{
......@@ -337,8 +338,13 @@ void Texture1DArray::BoundTexture1DArray::resize(int width, int layers)
format = GL_DEPTH_COMPONENT;
break;
case GL_DEPTH32F_STENCIL8:
case GL_DEPTH24_STENCIL8:
type = GL_UNSIGNED_INT_24_8;
format = GL_DEPTH_STENCIL;
break;
case GL_DEPTH32F_STENCIL8:
type = GL_FLOAT_32_UNSIGNED_INT_24_8_REV;
format = GL_DEPTH_STENCIL;
break;
......@@ -351,7 +357,7 @@ void Texture1DArray::BoundTexture1DArray::resize(int width, int layers)
break;
}
glTexImage2D(texture->mTarget, 0, texture->mInternalFormat, width, layers, 0, format, GL_UNSIGNED_BYTE, nullptr);
glTexImage2D(texture->mTarget, 0, texture->mInternalFormat, width, layers, 0, format, type, nullptr);
texture->mMipmapsGenerated = false;
}
......
......@@ -353,6 +353,7 @@ void Texture2D::BoundTexture2D::resize(int width, int height)
texture->mHeight = height;
GLenum format = GL_RGBA;
GLenum type = GL_UNSIGNED_BYTE;
auto isIntegerFormat = isIntegerInternalFormat(texture->mInternalFormat);
switch (channelsOfInternalFormat(texture->mInternalFormat))
{
......@@ -379,8 +380,13 @@ void Texture2D::BoundTexture2D::resize(int width, int height)
format = GL_DEPTH_COMPONENT;
break;
case GL_DEPTH32F_STENCIL8:
case GL_DEPTH24_STENCIL8:
type = GL_UNSIGNED_INT_24_8;
format = GL_DEPTH_STENCIL;
break;
case GL_DEPTH32F_STENCIL8:
type = GL_FLOAT_32_UNSIGNED_INT_24_8_REV;
format = GL_DEPTH_STENCIL;
break;
......@@ -393,7 +399,7 @@ void Texture2D::BoundTexture2D::resize(int width, int height)
break;
}
glTexImage2D(texture->mTarget, 0, texture->mInternalFormat, width, height, 0, format, GL_UNSIGNED_BYTE, nullptr);
glTexImage2D(texture->mTarget, 0, texture->mInternalFormat, width, height, 0, format, type, nullptr);
texture->mMipmapsGenerated = false;
}
......
......@@ -355,6 +355,7 @@ void Texture2DArray::BoundTexture2DArray::resize(int width, int height, int laye
texture->mLayers = layers;
GLenum format = GL_RGBA;
GLenum type = GL_UNSIGNED_BYTE;
auto isIntegerFormat = isIntegerInternalFormat(texture->mInternalFormat);
switch (channelsOfInternalFormat(texture->mInternalFormat))
{
......@@ -381,8 +382,13 @@ void Texture2DArray::BoundTexture2DArray::resize(int width, int height, int laye
format = GL_DEPTH_COMPONENT;
break;
case GL_DEPTH32F_STENCIL8:
case GL_DEPTH24_STENCIL8:
type = GL_UNSIGNED_INT_24_8;
format = GL_DEPTH_STENCIL;
break;
case GL_DEPTH32F_STENCIL8:
type = GL_FLOAT_32_UNSIGNED_INT_24_8_REV;
format = GL_DEPTH_STENCIL;
break;
......@@ -395,7 +401,7 @@ void Texture2DArray::BoundTexture2DArray::resize(int width, int height, int laye
break;
}
glTexImage3D(texture->mTarget, 0, texture->mInternalFormat, width, height, layers, 0, format, GL_UNSIGNED_BYTE, nullptr);
glTexImage3D(texture->mTarget, 0, texture->mInternalFormat, width, height, layers, 0, format, type, nullptr);
texture->mMipmapsGenerated = false;
}
......
......@@ -335,6 +335,7 @@ void Texture3D::BoundTexture3D::resize(int width, int height, int depth)
texture->mDepth = depth;
GLenum format = GL_RGBA;
GLenum type = GL_UNSIGNED_BYTE;
auto isIntegerFormat = isIntegerInternalFormat(texture->mInternalFormat);
switch (channelsOfInternalFormat(texture->mInternalFormat))
{
......@@ -361,8 +362,13 @@ void Texture3D::BoundTexture3D::resize(int width, int height, int depth)
format = GL_DEPTH_COMPONENT;
break;
case GL_DEPTH32F_STENCIL8:
case GL_DEPTH24_STENCIL8:
type = GL_UNSIGNED_INT_24_8;
format = GL_DEPTH_STENCIL;
break;
case GL_DEPTH32F_STENCIL8:
type = GL_FLOAT_32_UNSIGNED_INT_24_8_REV;
format = GL_DEPTH_STENCIL;
break;
......@@ -375,7 +381,7 @@ void Texture3D::BoundTexture3D::resize(int width, int height, int depth)
break;
}
glTexImage3D(texture->mTarget, 0, texture->mInternalFormat, width, height, depth, 0, format, GL_UNSIGNED_BYTE, nullptr);
glTexImage3D(texture->mTarget, 0, texture->mInternalFormat, width, height, depth, 0, format, type, nullptr);
texture->mMipmapsGenerated = false;
}
......
......@@ -353,6 +353,7 @@ void TextureCubeMap::BoundTextureCubeMap::resize(int width, int height)
texture->mHeight = height;
GLenum format = GL_RGBA;
GLenum type = GL_UNSIGNED_BYTE;
auto isIntegerFormat = isIntegerInternalFormat(texture->mInternalFormat);
switch (channelsOfInternalFormat(texture->mInternalFormat))
{
......@@ -379,8 +380,13 @@ void TextureCubeMap::BoundTextureCubeMap::resize(int width, int height)
format = GL_DEPTH_COMPONENT;
break;
case GL_DEPTH32F_STENCIL8:
case GL_DEPTH24_STENCIL8:
type = GL_UNSIGNED_INT_24_8;
format = GL_DEPTH_STENCIL;
break;
case GL_DEPTH32F_STENCIL8:
type = GL_FLOAT_32_UNSIGNED_INT_24_8_REV;
format = GL_DEPTH_STENCIL;
break;
......@@ -393,12 +399,12 @@ void TextureCubeMap::BoundTextureCubeMap::resize(int width, int height)
break;
}
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, texture->mInternalFormat, width, height, 0, format, GL_UNSIGNED_BYTE, nullptr);
glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, texture->mInternalFormat, width, height, 0, format, GL_UNSIGNED_BYTE, nullptr);
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, texture->mInternalFormat, width, height, 0, format, GL_UNSIGNED_BYTE, nullptr);
glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, texture->mInternalFormat, width, height, 0, format, GL_UNSIGNED_BYTE, nullptr);
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, texture->mInternalFormat, width, height, 0, format, GL_UNSIGNED_BYTE, nullptr);
glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, texture->mInternalFormat, width, height, 0, format, GL_UNSIGNED_BYTE, nullptr);
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, texture->mInternalFormat, width, height, 0, format, type, nullptr);
glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, texture->mInternalFormat, width, height, 0, format, type, nullptr);
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, texture->mInternalFormat, width, height, 0, format, type, nullptr);
glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, texture->mInternalFormat, width, height, 0, format, type, nullptr);
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, texture->mInternalFormat, width, height, 0, format, type, nullptr);
glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, texture->mInternalFormat, width, height, 0, format, type, nullptr);
texture->mMipmapsGenerated = false;
}
......
......@@ -355,6 +355,7 @@ void TextureCubeMapArray::BoundTextureCubeMapArray::resize(int width, int height
texture->mLayers = layers;
GLenum format = GL_RGBA;
GLenum type = GL_UNSIGNED_BYTE;
auto isIntegerFormat = isIntegerInternalFormat(texture->mInternalFormat);
switch (channelsOfInternalFormat(texture->mInternalFormat))
{
......@@ -381,8 +382,13 @@ void TextureCubeMapArray::BoundTextureCubeMapArray::resize(int width, int height
format = GL_DEPTH_COMPONENT;
break;
case GL_DEPTH32F_STENCIL8:
case GL_DEPTH24_STENCIL8:
type = GL_UNSIGNED_INT_24_8;
format = GL_DEPTH_STENCIL;
break;
case GL_DEPTH32F_STENCIL8:
type = GL_FLOAT_32_UNSIGNED_INT_24_8_REV;
format = GL_DEPTH_STENCIL;
break;
......@@ -395,7 +401,7 @@ void TextureCubeMapArray::BoundTextureCubeMapArray::resize(int width, int height
break;
}
glTexImage3D(texture->mTarget, 0, texture->mInternalFormat, width, height, layers * 6u, 0, format, GL_UNSIGNED_BYTE, nullptr);
glTexImage3D(texture->mTarget, 0, texture->mInternalFormat, width, height, layers * 6u, 0, format, type, nullptr);
texture->mMipmapsGenerated = false;
}
......
......@@ -290,6 +290,7 @@ void TextureRectangle::BoundTextureRectangle::resize(int width, int height)
texture->mHeight = height;
GLenum format = GL_RGBA;
GLenum type = GL_UNSIGNED_BYTE;
auto isIntegerFormat = isIntegerInternalFormat(texture->mInternalFormat);
switch (channelsOfInternalFormat(texture->mInternalFormat))
{
......@@ -316,8 +317,13 @@ void TextureRectangle::BoundTextureRectangle::resize(int width, int height)
format = GL_DEPTH_COMPONENT;
break;
case GL_DEPTH32F_STENCIL8:
case GL_DEPTH24_STENCIL8:
type = GL_UNSIGNED_INT_24_8;
format = GL_DEPTH_STENCIL;
break;
case GL_DEPTH32F_STENCIL8:
type = GL_FLOAT_32_UNSIGNED_INT_24_8_REV;
format = GL_DEPTH_STENCIL;
break;
......@@ -330,7 +336,7 @@ void TextureRectangle::BoundTextureRectangle::resize(int width, int height)
break;
}
glTexImage2D(texture->mTarget, 0, texture->mInternalFormat, width, height, 0, format, GL_UNSIGNED_BYTE, nullptr);
glTexImage2D(texture->mTarget, 0, texture->mInternalFormat, width, height, 0, format, type, nullptr);
}
......
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