Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
OpenFlipper-Free
OpenFlipper
Commits
e5d3acc4
Commit
e5d3acc4
authored
Apr 13, 2018
by
Kersten Schuster
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix mipmapping.
parent
7e4edb5f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
13 deletions
+23
-13
libs_required/ACG/GL/globjects.cc
libs_required/ACG/GL/globjects.cc
+18
-10
libs_required/ACG/GL/globjects.hh
libs_required/ACG/GL/globjects.hh
+1
-1
libs_required/ACG/Scenegraph/TextureNode.cc
libs_required/ACG/Scenegraph/TextureNode.cc
+4
-2
No files found.
libs_required/ACG/GL/globjects.cc
View file @
e5d3acc4
...
...
@@ -320,13 +320,16 @@ Texture2D::Texture2D(GLenum unit)
bool
Texture2D
::
autogenerateMipMaps
()
{
if
(
openGLVersion
(
3
,
0
))
{
// From OpenGL 3.0, glGenerateMipmap is supported and we should use that
// but glGenerateMipmap must be called AFTER the data was uploaded.
return
false
;
}
#ifdef GL_SGIS_generate_mipmap
if
(
supportsGenerateMipmap
())
{
//parameter based mipmap generation was removed in 3.1
if
(
openGLVersion
(
3
,
1
))
glGenerateMipmap
(
GL_TEXTURE_2D
);
else
parameter
(
GL_GENERATE_MIPMAP_SGIS
,
GL_TRUE
);
return
true
;
}
...
...
@@ -349,13 +352,14 @@ void Texture2D::disableAutogenerateMipMaps()
//-----------------------------------------------------------------------------
void
Texture2D
::
setData
(
GLint
_level
,
GLint
_internalFormat
,
GLsizei
_width
,
GLsizei
_height
,
void
Texture2D
::
setData
(
GLint
_level
,
GLint
_internalFormat
,
GLsizei
_width
,
GLsizei
_height
,
GLenum
_format
,
GLenum
_type
,
const
GLvoid
*
_data
)
{
const
GLvoid
*
_data
,
bool
_mipmaps
)
{
if
(
getUnit
()
==
GL_NONE
)
setUnit
(
GL_TEXTURE0
);
...
...
@@ -367,6 +371,10 @@ void Texture2D::setData(GLint _level,
else
glTexImage2D
(
GL_TEXTURE_2D
,
_level
,
_internalFormat
,
_width
,
_height
,
0
,
_format
,
_type
,
_data
);
// If mip maps should not be built on cpu and the OpenGL version is high enough, we go the default way
if
(
_mipmaps
&&
!
buildMipsCPU_
&&
openGLVersion
(
3
,
0
))
glGenerateMipmap
(
GL_TEXTURE_2D
);
width_
=
_width
;
height_
=
_height
;
internalFormat_
=
_internalFormat
;
...
...
@@ -642,7 +650,7 @@ bool Texture2D::loadFromFile( const std::string& _filename, GLenum _minFilter, G
QImage
gltex
=
ACG
::
Util
::
convertToGLFormat
(
qtex
);
setData
(
0
,
GL_RGBA
,
gltex
.
width
(),
gltex
.
height
(),
GL_RGBA
,
GL_UNSIGNED_BYTE
,
gltex
.
bits
());
setData
(
0
,
GL_RGBA
,
gltex
.
width
(),
gltex
.
height
(),
GL_RGBA
,
GL_UNSIGNED_BYTE
,
gltex
.
bits
()
,
mipmaps
);
}
}
...
...
libs_required/ACG/GL/globjects.hh
View file @
e5d3acc4
...
...
@@ -412,7 +412,7 @@ public:
void
disableAutogenerateMipMaps
();
// initialize and set texture data via glTexImage2D
void
setData
(
GLint
_level
,
GLint
_internalFormat
,
GLsizei
_width
,
GLsizei
_height
,
GLenum
_format
,
GLenum
_type
,
const
GLvoid
*
_data
);
void
setData
(
GLint
_level
,
GLint
_internalFormat
,
GLsizei
_width
,
GLsizei
_height
,
GLenum
_format
,
GLenum
_type
,
const
GLvoid
*
_data
,
bool
_mipmaps
=
false
);
// specify storage of texture (OpenGL 4.2)
// use setData with a nullptr instead if 4.2 is not available
...
...
libs_required/ACG/Scenegraph/TextureNode.cc
View file @
e5d3acc4
...
...
@@ -224,8 +224,9 @@ void TextureNode::setTextureDataGL ( GLuint _textureId,
applyTextureParameters
(
_textureId
);
bool
mipmaps
=
mipmapping_globally_active_
&&
mipmapping_
;
// Load the image
if
(
mipmap
ping_globally_active_
&&
mipmapping_
)
if
(
mipmap
s
)
tex
->
autogenerateMipMaps
();
tex
->
setData
(
0
,
// level
...
...
@@ -234,7 +235,8 @@ void TextureNode::setTextureDataGL ( GLuint _textureId,
_height
,
// height (2^m)
_format
,
// format
_type
,
// type
_data
);
// pointer to pixels
_data
,
// pointer to pixels
mipmaps
);
// mipmaps or not
// Unbind until we use it
ACG
::
GLState
::
bindTexture
(
GL_TEXTURE_2D
,
0
);
...
...
Write
Preview
Markdown
is supported
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