|
|
@@ -16,8 +16,8 @@ int Texture::anisotropyLevel = 8;
|
|
|
// Constructor =
|
|
|
//======================================================================================================================
|
|
|
Texture::Texture():
|
|
|
- glId(numeric_limits<uint>::max()),
|
|
|
- type(GL_TEXTURE_2D)
|
|
|
+ glId( numeric_limits<uint>::max() ),
|
|
|
+ target( GL_TEXTURE_2D )
|
|
|
{
|
|
|
}
|
|
|
|
|
|
@@ -26,7 +26,7 @@ Texture::Texture():
|
|
|
//======================================================================================================================
|
|
|
bool Texture::load( const char* filename )
|
|
|
{
|
|
|
- type = GL_TEXTURE_2D;
|
|
|
+ target = GL_TEXTURE_2D;
|
|
|
if( glId != numeric_limits<uint>::max() )
|
|
|
{
|
|
|
ERROR( "Texture already loaded" );
|
|
|
@@ -42,20 +42,20 @@ bool Texture::load( const char* filename )
|
|
|
bind(0);
|
|
|
if( mipmappingEnabled )
|
|
|
{
|
|
|
- glTexParameteri( type, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR );
|
|
|
+ texParameter( GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR );
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- glTexParameteri( type, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
|
|
|
+ texParameter( GL_TEXTURE_MIN_FILTER, GL_LINEAR );
|
|
|
}
|
|
|
|
|
|
- glTexParameteri( type, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
|
|
|
+ texParameter( GL_TEXTURE_MAG_FILTER, GL_LINEAR );
|
|
|
|
|
|
- glTexParameterf( type, GL_TEXTURE_MAX_ANISOTROPY_EXT, anisotropyLevel );
|
|
|
+ texParameter( GL_TEXTURE_MAX_ANISOTROPY_EXT, float(anisotropyLevel) );
|
|
|
|
|
|
// leave to GL_REPEAT. There is not real performance impact
|
|
|
- glTexParameteri( type, GL_TEXTURE_WRAP_S, GL_REPEAT );
|
|
|
- glTexParameteri( type, GL_TEXTURE_WRAP_T, GL_REPEAT );
|
|
|
+ texParameter( GL_TEXTURE_WRAP_S, GL_REPEAT );
|
|
|
+ texParameter( GL_TEXTURE_WRAP_T, GL_REPEAT );
|
|
|
|
|
|
int format = (img.bpp==32) ? GL_RGBA : GL_RGB;
|
|
|
|
|
|
@@ -70,10 +70,10 @@ bool Texture::load( const char* filename )
|
|
|
intFormat = (img.bpp==32) ? GL_RGBA : GL_RGB;
|
|
|
}
|
|
|
|
|
|
- glTexImage2D( type, 0, intFormat, img.width, img.height, 0, format, GL_UNSIGNED_BYTE, img.data );
|
|
|
+ glTexImage2D( target, 0, intFormat, img.width, img.height, 0, format, GL_UNSIGNED_BYTE, img.data );
|
|
|
if( mipmappingEnabled )
|
|
|
{
|
|
|
- glGenerateMipmap(type);
|
|
|
+ glGenerateMipmap(target);
|
|
|
}
|
|
|
|
|
|
img.unload();
|
|
|
@@ -89,7 +89,7 @@ bool Texture::createEmpty2D( float width_, float height_, int internalFormat, in
|
|
|
{
|
|
|
DEBUG_ERR( glGetError() != GL_NO_ERROR ); // dont enter the func with prev error
|
|
|
|
|
|
- type = GL_TEXTURE_2D;
|
|
|
+ target = GL_TEXTURE_2D;
|
|
|
DEBUG_ERR( internalFormat>0 && internalFormat<=4 ); // deprecated internal format
|
|
|
DEBUG_ERR( glId != numeric_limits<uint>::max() ) // Texture already loaded
|
|
|
|
|
|
@@ -98,19 +98,19 @@ bool Texture::createEmpty2D( float width_, float height_, int internalFormat, in
|
|
|
bind();
|
|
|
|
|
|
if( mimapping )
|
|
|
- glTexParameteri( type, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR );
|
|
|
+ texParameter( GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR );
|
|
|
else
|
|
|
- glTexParameteri( type, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
|
|
|
+ texParameter( GL_TEXTURE_MIN_FILTER, GL_LINEAR );
|
|
|
|
|
|
texParameter( GL_TEXTURE_MAG_FILTER, GL_LINEAR );
|
|
|
texParameter( GL_TEXTURE_WRAP_S, GL_REPEAT );
|
|
|
texParameter( GL_TEXTURE_WRAP_T, GL_REPEAT );
|
|
|
|
|
|
// allocate to vram
|
|
|
- glTexImage2D( type, 0, internalFormat, width_, height_, 0, format_, type_, NULL );
|
|
|
+ glTexImage2D( target, 0, internalFormat, width_, height_, 0, format_, type_, NULL );
|
|
|
|
|
|
if( mimapping )
|
|
|
- glGenerateMipmap( type );
|
|
|
+ glGenerateMipmap( target );
|
|
|
|
|
|
GLenum errid = glGetError();
|
|
|
if( errid != GL_NO_ERROR )
|
|
|
@@ -158,5 +158,5 @@ void Texture::bind( uint unit ) const
|
|
|
WARNING("Max tex units passed");
|
|
|
|
|
|
glActiveTexture( GL_TEXTURE0+unit );
|
|
|
- glBindTexture( type, glId );
|
|
|
+ glBindTexture( target, glId );
|
|
|
}
|