Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Glow
glow
Commits
8f61a37a
Commit
8f61a37a
authored
Apr 05, 2021
by
Philip Trettner
Browse files
fixed stencil buffer support
parent
4f466797
Changes
12
Hide whitespace changes
Inline
Side-by-side
scripts/tex-code-gen/gen-tex-code.py
View file @
8f61a37a
...
...
@@ -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/"
...
...
scripts/tex-code-gen/texture.cc.tmpl
View file @
8f61a37a
...
...
@@ -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
...
...
src/glow/common/ogl_typeinfo.hh
View file @
8f61a37a
...
...
@@ -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
:
...
...
src/glow/objects/Framebuffer.cc
View file @
8f61a37a
...
...
@@ -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 "
...
...
src/glow/objects/Texture1D.cc
View file @
8f61a37a
...
...
@@ -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
;
}
...
...
src/glow/objects/Texture1DArray.cc
View file @
8f61a37a
...
...
@@ -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
;
}
...
...
src/glow/objects/Texture2D.cc
View file @
8f61a37a
...
...
@@ -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
;
}
...
...
src/glow/objects/Texture2DArray.cc
View file @
8f61a37a
...
...
@@ -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
;
}
...
...
src/glow/objects/Texture3D.cc
View file @
8f61a37a
...
...
@@ -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
;
}
...
...
src/glow/objects/TextureCubeMap.cc
View file @
8f61a37a
...
...
@@ -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
;
}
...
...
src/glow/objects/TextureCubeMapArray.cc
View file @
8f61a37a
...
...
@@ -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
;
}
...
...
src/glow/objects/TextureRectangle.cc
View file @
8f61a37a
...
...
@@ -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
);
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment