Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Es2 mipmap #1

Merged
merged 1 commit into from

2 participants

@ghost

Fix Texture::Format::enableMipmapping() for es2 with a few more preprocessor macros. I thought about re-enabling the calls to glPixelStorei too (they were disabled for es1), but it seems to be working fine without (I think it just speeds up glReadPixels). Also, I'm pretty sure this whole bit will be rewritten in the future, as we've discussed that it needs an abstraction layer for different gl implementations.

@notlion
Owner

This looks good to me. I think you're right about it needing to be rewritten in future, but for now this branch can be considered ES2-only. Thanks!

@notlion notlion merged commit 4ec90e4 into notlion:es2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 26, 2012
  1. @richardeakin
This page is out of date. Refresh to see the latest.
Showing with 21 additions and 0 deletions.
  1. +21 −0 src/cinder/gl/Texture.cpp
View
21 src/cinder/gl/Texture.cpp
@@ -254,8 +254,11 @@ void Texture::init( const unsigned char *data, int unpackRowLength, GLenum dataF
glTexParameteri( mObj->mTarget, GL_TEXTURE_WRAP_T, format.mWrapT );
glTexParameteri( mObj->mTarget, GL_TEXTURE_MIN_FILTER, format.mMinFilter );
glTexParameteri( mObj->mTarget, GL_TEXTURE_MAG_FILTER, format.mMagFilter );
+
+#if ! defined( CINDER_GLES2 )
if( format.mMipmapping )
glGenerateMipmap( mObj->mTarget );
+#endif
if( mObj->mTarget == GL_TEXTURE_2D ) {
mObj->mMaxU = mObj->mMaxV = 1.0f;
}
@@ -271,6 +274,10 @@ void Texture::init( const unsigned char *data, int unpackRowLength, GLenum dataF
glTexImage2D( mObj->mTarget, 0, mObj->mInternalFormat, mObj->mWidth, mObj->mHeight, 0, dataFormat, type, data );
#if ! defined( CINDER_GLES )
glPixelStorei( GL_UNPACK_ROW_LENGTH, 0 );
+#endif
+#if defined( CINDER_GLES2 )
+ if( format.mMipmapping )
+ glGenerateMipmap( mObj->mTarget ); // comes after glTexImage2D in es2
#endif
}
@@ -285,8 +292,10 @@ void Texture::init( const float *data, GLint dataFormat, const Format &format )
glTexParameteri( mObj->mTarget, GL_TEXTURE_WRAP_T, format.mWrapT );
glTexParameteri( mObj->mTarget, GL_TEXTURE_MIN_FILTER, format.mMinFilter );
glTexParameteri( mObj->mTarget, GL_TEXTURE_MAG_FILTER, format.mMagFilter );
+#if ! defined( CINDER_GLES2 )
if( format.mMipmapping )
glGenerateMipmap( mObj->mTarget );
+#endif
if( mObj->mTarget == GL_TEXTURE_2D ) {
mObj->mMaxU = mObj->mMaxV = 1.0f;
}
@@ -301,6 +310,11 @@ void Texture::init( const float *data, GLint dataFormat, const Format &format )
}
else
glTexImage2D( mObj->mTarget, 0, mObj->mInternalFormat, mObj->mWidth, mObj->mHeight, 0, GL_LUMINANCE, GL_FLOAT, 0 ); // init to black...
+
+#if defined( CINDER_GLES2 )
+ if( format.mMipmapping )
+ glGenerateMipmap( mObj->mTarget ); // comes after glTexImage2D in es2
+#endif
}
void Texture::init( ImageSourceRef imageSource, const Format &format )
@@ -385,8 +399,11 @@ void Texture::init( ImageSourceRef imageSource, const Format &format )
glTexParameteri( mObj->mTarget, GL_TEXTURE_WRAP_T, format.mWrapT );
glTexParameteri( mObj->mTarget, GL_TEXTURE_MIN_FILTER, format.mMinFilter );
glTexParameteri( mObj->mTarget, GL_TEXTURE_MAG_FILTER, format.mMagFilter );
+#if ! defined( CINDER_GLES2 )
+ // note: in es2 this call must be done after glTexImage2D
if( format.mMipmapping )
glGenerateMipmap( mObj->mTarget );
+#endif
if( mObj->mTarget == GL_TEXTURE_2D ) {
mObj->mMaxU = mObj->mMaxV = 1.0f;
}
@@ -412,6 +429,10 @@ void Texture::init( ImageSourceRef imageSource, const Format &format )
imageSource->load( target );
glTexImage2D( mObj->mTarget, 0, mObj->mInternalFormat, mObj->mWidth, mObj->mHeight, 0, dataFormat, GL_FLOAT, target->getData() );
}
+#if defined( CINDER_GLES2 )
+ if( format.mMipmapping )
+ glGenerateMipmap( mObj->mTarget ); // comes after glTexImage2D in es2
+#endif
}
void Texture::update( const Surface &surface )
Something went wrong with that request. Please try again.