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
ACGL
acgl
Commits
53320bc1
Commit
53320bc1
authored
Jun 27, 2013
by
Robert Menzel
Browse files
removed deprecated Texture interface
parent
2b7cada1
Changes
3
Hide whitespace changes
Inline
Side-by-side
include/ACGL/OpenGL/Objects/ShaderProgram.hh
View file @
53320bc1
...
...
@@ -238,19 +238,6 @@ public:
//! sets a texture uniform to a given texture unit and also binds the texture to the same unit
inline
void
setTexture
(
GLint
_location
,
const
ConstSharedTextureBase
&
_texture
,
GLint
_unit
)
const
{
glUniform1i
(
_location
,
_unit
);
_texture
->
bind
(
_unit
);
}
inline
void
setTexture
(
const
std
::
string
&
_nameInShader
,
const
ConstSharedTextureBase
&
_texture
,
GLint
_unit
)
const
{
setUniform
(
getUniformLocation
(
_nameInShader
),
(
GLint
)
_unit
);
_texture
->
bind
(
_unit
);
}
#ifdef ACGL_INCLUDE_DEPRECATED_FUNCTIONALITY
//! set the texture to the texture unit the uniform is set to.
//! Note: it is not guaranteed that all uniforms for textures are set to unique samplers by default after linking!
void
setTexture
(
const
std
::
string
&
_nameInShader
,
const
ConstSharedTexture
&
_texture
)
const
{
GLint
unit
;
GLint
uniformLocation
=
getUniformLocation
(
_nameInShader
);
if
(
uniformLocation
!=
-
1
)
{
glGetUniformiv
(
mObjectName
,
uniformLocation
,
&
unit
);
_texture
->
bind
(
unit
);
}
}
#endif
#if (ACGL_OPENGL_VERSION >= 41)
// DSA versions:
...
...
include/ACGL/OpenGL/Objects/Texture.hh
View file @
53320bc1
...
...
@@ -453,313 +453,6 @@ ACGL_SMARTPOINTER_TYPEDEFS(TextureCubeMap)
#ifdef ACGL_INCLUDE_DEPRECATED_FUNCTIONALITY
//
// Full compatibility with the old Texture class:
//
// Could mimic different kinds of textures in one class, not maintained anymore, use one of the
// other classes.
//
class
Texture
:
public
TextureBase
{
//ACGL_NOT_COPYABLE(Texture)
// ========================================================================================================= \/
// ============================================================================================ CONSTRUCTORS \/
// ========================================================================================================= \/
public:
Texture
(
GLenum
_target
)
:
TextureBase
(
_target
)
{
mFormat
=
GL_RGBA
;
mType
=
GL_UNSIGNED_BYTE
;
}
// ==================================================================================================== \/
// ============================================================================================ GETTERS \/
// ==================================================================================================== \/
public:
inline
GLenum
getFormat
(
void
)
const
{
return
mFormat
;
}
inline
GLenum
getType
(
void
)
const
{
return
mType
;
}
// ===================================================================================================== \/
// ============================================================================================ WRAPPERS \/
// ===================================================================================================== \/
public:
//! Set texture data for 1D, 2D or 3D textures
inline
void
setImageData
(
const
GLvoid
*
_pData
=
NULL
)
{
if
(
mWidth
>
1
&&
mHeight
>
1
&&
mDepth
>
1
)
{
//setImageData3D(_pData);
}
else
if
(
mWidth
>
1
&&
mHeight
>
1
)
{
setImageData2D
(
_pData
);
}
#ifndef ACGL_OPENGL_ES
else
{
setImageData1D
(
mTarget
,
mFormat
,
mType
,
_pData
);
}
#endif
}
//! Set texture data for 1D, 2D or 3D textures
inline
void
setImageData
(
const
GLvoid
*
_pData
,
GLsizei
_width
,
GLsizei
_height
=
1
,
GLsizei
_depth
=
1
)
{
mWidth
=
_width
;
mHeight
=
_height
;
mDepth
=
_depth
;
setImageData
(
_pData
);
}
//! Set texture data for 1D, 2D or 3D textures
inline
void
setImageData
(
const
GLvoid
*
_pData
,
GLsizei
_width
,
GLsizei
_height
,
GLsizei
_depth
,
GLenum
_internalFormat
,
GLenum
_format
,
GLenum
_type
)
{
mWidth
=
_width
;
mHeight
=
_height
;
mDepth
=
_depth
;
mInternalFormat
=
_internalFormat
;
mFormat
=
_format
;
mType
=
_type
;
setImageData
(
_pData
);
}
//! Set texture data
inline
void
setImageData2D
(
const
GLvoid
*
_pData
,
GLsizei
_width
,
GLsizei
_height
,
GLenum
_internalFormat
,
GLenum
_format
,
GLenum
_type
)
{
mInternalFormat
=
_internalFormat
;
mFormat
=
_format
;
mType
=
_type
;
setImageData2D
(
_pData
,
_width
,
_height
);
}
//! Set texture data
inline
void
setImageData2D
(
const
GLvoid
*
_pData
,
GLsizei
_width
,
GLsizei
_height
)
{
mWidth
=
_width
;
mHeight
=
_height
;
setImageData2D
(
_pData
);
}
//! Set texture data using the specified target for uploading the data
inline
void
setImageData2D
(
const
GLvoid
*
_pData
=
NULL
)
{
setImageData2D
(
mTarget
,
mFormat
,
mType
,
_pData
);
}
//! Set format for the cube maps that are uploaded
inline
void
setCubeMapFormat
(
GLsizei
_size
,
GLenum
_internalFormat
)
{
mWidth
=
_size
;
mHeight
=
_size
;
mDepth
=
0
;
mInternalFormat
=
_internalFormat
;
}
//! Set format for the cube maps that are uploaded including a default format and type
inline
void
setCubeMapFormat
(
GLsizei
_size
,
GLenum
_internalFormat
,
GLenum
_format
,
GLenum
_type
)
{
mWidth
=
_size
;
mHeight
=
_size
;
mDepth
=
0
;
mInternalFormat
=
_internalFormat
;
mFormat
=
_format
;
mType
=
_type
;
}
//! Set texture data for cube maps using the default format and type
/// @{
inline
void
setImageDataCubeMapPositiveX
(
const
GLvoid
*
_pData
=
NULL
)
{
setImageData2D
(
GL_TEXTURE_CUBE_MAP_POSITIVE_X
,
mFormat
,
mType
,
_pData
);
}
inline
void
setImageDataCubeMapNegativeX
(
const
GLvoid
*
_pData
=
NULL
)
{
setImageData2D
(
GL_TEXTURE_CUBE_MAP_NEGATIVE_X
,
mFormat
,
mType
,
_pData
);
}
inline
void
setImageDataCubeMapPositiveY
(
const
GLvoid
*
_pData
=
NULL
)
{
setImageData2D
(
GL_TEXTURE_CUBE_MAP_POSITIVE_Y
,
mFormat
,
mType
,
_pData
);
}
inline
void
setImageDataCubeMapNegativeY
(
const
GLvoid
*
_pData
=
NULL
)
{
setImageData2D
(
GL_TEXTURE_CUBE_MAP_NEGATIVE_Y
,
mFormat
,
mType
,
_pData
);
}
inline
void
setImageDataCubeMapPositiveZ
(
const
GLvoid
*
_pData
=
NULL
)
{
setImageData2D
(
GL_TEXTURE_CUBE_MAP_POSITIVE_Z
,
mFormat
,
mType
,
_pData
);
}
inline
void
setImageDataCubeMapNegativeZ
(
const
GLvoid
*
_pData
=
NULL
)
{
setImageData2D
(
GL_TEXTURE_CUBE_MAP_NEGATIVE_Z
,
mFormat
,
mType
,
_pData
);
}
/// @}
//! Set texture data for cube maps using a specific upload format and type per face
/// @{
inline
void
setImageDataCubeMapPositiveX
(
GLenum
_format
,
GLenum
_type
,
const
GLvoid
*
_pData
=
NULL
)
{
setImageData2D
(
GL_TEXTURE_CUBE_MAP_POSITIVE_X
,
_format
,
_type
,
_pData
);
}
inline
void
setImageDataCubeMapNegativeX
(
GLenum
_format
,
GLenum
_type
,
const
GLvoid
*
_pData
=
NULL
)
{
setImageData2D
(
GL_TEXTURE_CUBE_MAP_NEGATIVE_X
,
_format
,
_type
,
_pData
);
}
inline
void
setImageDataCubeMapPositiveY
(
GLenum
_format
,
GLenum
_type
,
const
GLvoid
*
_pData
=
NULL
)
{
setImageData2D
(
GL_TEXTURE_CUBE_MAP_POSITIVE_Y
,
_format
,
_type
,
_pData
);
}
inline
void
setImageDataCubeMapNegativeY
(
GLenum
_format
,
GLenum
_type
,
const
GLvoid
*
_pData
=
NULL
)
{
setImageData2D
(
GL_TEXTURE_CUBE_MAP_NEGATIVE_Y
,
_format
,
_type
,
_pData
);
}
inline
void
setImageDataCubeMapPositiveZ
(
GLenum
_format
,
GLenum
_type
,
const
GLvoid
*
_pData
=
NULL
)
{
setImageData2D
(
GL_TEXTURE_CUBE_MAP_POSITIVE_Z
,
_format
,
_type
,
_pData
);
}
inline
void
setImageDataCubeMapNegativeZ
(
GLenum
_format
,
GLenum
_type
,
const
GLvoid
*
_pData
=
NULL
)
{
setImageData2D
(
GL_TEXTURE_CUBE_MAP_NEGATIVE_Z
,
_format
,
_type
,
_pData
);
}
/// @}
//! Set texture data for some mipmap level.
/*!
If you upload a texture for a higher mipmap level, the function will automatically determine
its size calculating (w,h)/2^level where w and h are the width and height of the base texture.
Note: The function is not const, because it changes the corresponding GPU data
*/
inline
void
setImageDataMipMap2D
(
const
GLvoid
*
_pData
,
GLint
_mipmapLevel
,
GLsizei
_width
=
0
,
GLsizei
_height
=
0
)
{
glBindTexture
(
mTarget
,
mObjectName
);
glTexImage2D
(
mTarget
,
_mipmapLevel
,
mInternalFormat
,
_width
>
0
?
_width
:
mWidth
/
GLsizei
(
Math
::
Functions
::
pow
(
2.0
f
,
float
(
_mipmapLevel
))),
_height
>
0
?
_height
:
mHeight
/
GLsizei
(
Math
::
Functions
::
pow
(
2.0
f
,
float
(
_mipmapLevel
))),
0
,
//no border
mFormat
,
mType
,
_pData
);
}
//! Set data for specific area within the 2D texture
//! Note: The function is not const, because it changes the corresponding GPU data
inline
void
setSubImageData2D
(
const
GLvoid
*
_pData
,
GLint
_x
,
GLint
_y
,
GLsizei
_width
,
GLsizei
_height
)
{
glBindTexture
(
mTarget
,
mObjectName
);
glTexSubImage2D
(
mTarget
,
0
,
_x
,
_y
,
_width
,
_height
,
mFormat
,
mType
,
_pData
);
}
#ifndef ACGL_OPENGL_ES
//! Set data for specific area within the 3D texture
//! Note: The function is not const, because it changes the corresponding GPU data
inline
void
setSubImageData3D
(
const
GLvoid
*
_pData
,
GLint
_x
,
GLint
_y
,
GLint
_z
,
GLsizei
_width
,
GLsizei
_height
,
GLsizei
_depth
)
{
glBindTexture
(
mTarget
,
mObjectName
);
glTexSubImage3D
(
mTarget
,
0
,
_x
,
_y
,
_z
,
_width
,
_height
,
_depth
,
mFormat
,
mType
,
_pData
);
}
#endif
#ifndef ACGL_OPENGLES_VERSION_20
//! Returns a TextureData objects holding the contents of the texture
SharedTextureData
getImageData
(
GLint
_lod
=
0
,
GLenum
_type
=
GL_INVALID_ENUM
)
const
;
#endif
private:
virtual
void
resizeI
(
const
glm
::
uvec3
&
)
{
ACGL
::
Utils
::
error
()
<<
"new resize methods not supported in compatibility Texture class"
<<
std
::
endl
;
assert
(
0
);
}
//! Set texture data
inline
void
setImageData2D
(
GLenum
_uploadTarget
,
GLenum
_uploadFormat
,
GLenum
_uploadType
,
const
GLvoid
*
_pData
=
NULL
)
{
glBindTexture
(
mTarget
,
mObjectName
);
glTexImage2D
(
_uploadTarget
,
0
,
mInternalFormat
,
mWidth
,
mHeight
,
0
,
//no border
_uploadFormat
,
_uploadType
,
_pData
);
if
(
openGLCriticalErrorOccured
()
)
{
ACGL
::
Utils
::
error
()
<<
"could not generate 2D texture!"
<<
std
::
endl
;
}
}
#ifndef ACGL_OPENGL_ES
//! Set texture data
inline
void
setImageData1D
(
GLenum
_uploadTarget
,
GLenum
_uploadFormat
,
GLenum
_uploadType
,
const
GLvoid
*
_pData
=
NULL
)
{
openGLRareError
();
glBindTexture
(
mTarget
,
mObjectName
);
openGLRareError
();
glTexImage1D
(
_uploadTarget
,
0
,
mInternalFormat
,
mWidth
,
0
,
//no border
_uploadFormat
,
_uploadType
,
_pData
);
if
(
openGLCriticalErrorOccured
()
)
{
ACGL
::
Utils
::
error
()
<<
"could not generate 1D texture!"
<<
std
::
endl
;
}
}
#endif
// =================================================================================================== \/
// ============================================================================================ FIELDS \/
// =================================================================================================== \/
private:
GLenum
mFormat
;
GLenum
mType
;
};
ACGL_SMARTPOINTER_TYPEDEFS
(
Texture
)
#endif
}
// OpenGL
}
// ACGL
...
...
src/ACGL/OpenGL/Objects/Texture.cc
View file @
53320bc1
...
...
@@ -725,51 +725,3 @@ void TextureBase::texSubImage3D( const SharedTextureData &_data, GLint _mipmapLe
openGLRareError
();
}
#ifdef ACGL_INCLUDE_DEPRECATED_FUNCTIONALITY
//////////////////////////////////////////////////////////////////////////
//
// old Texture class:
#ifndef ACGL_OPENGLES_VERSION_20
SharedTextureData
Texture
::
getImageData
(
GLint
_lod
,
GLenum
_type
)
const
{
Image
img
;
img
.
mipmapLevel
=
_lod
;
return
getTextureImage
(
img
,
mFormat
,
_type
);
/*
if(_type == GL_INVALID_ENUM) _type = mType;
// remember the previously bound texture and bind this one
GLuint prevTexture = bindAndGetOldTexture();
// determine the required buffer size to hold the requested LOD level
GLint width, height, depth;
glGetTexLevelParameteriv(mTarget, _lod, GL_TEXTURE_WIDTH, &width);
glGetTexLevelParameteriv(mTarget, _lod, GL_TEXTURE_HEIGHT, &height);
glGetTexLevelParameteriv(mTarget, _lod, GL_TEXTURE_DEPTH, &depth);
// fetch the image data
int channels = 4;
if (mFormat == GL_RGB) channels = 3; // TODO: check the other channel types
GLubyte* imageData = new GLubyte[width * height * getGLTypeSize(_type) * channels];
glGetTexImage(mTarget, _lod, mFormat, _type, (GLvoid*)imageData);
// revert to the previously bound texture
glBindTexture(mTarget, prevTexture);
// store the image data and meta information in a TextureData object
SharedTextureData dataObject = SharedTextureData(new TextureData());
dataObject->setWidth(width);
dataObject->setHeight(height);
dataObject->setDepth(depth);
dataObject->setType(_type);
dataObject->setFormat(mFormat);
dataObject->setData(imageData); // dataObject will take care of freeing imageData
return dataObject;
*/
}
#endif // ES 2.0
#endif
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