// get maximum texture size
mGlAbstraction.GetIntegerv(GL_MAX_TEXTURE_SIZE, &mMaxTextureSize);
+ // reset any potential previous errors
+ mGlAbstraction.GetError();
+
GLint numProgramBinaryFormats;
mGlAbstraction.GetIntegerv(GL_NUM_PROGRAM_BINARY_FORMATS_OES, &numProgramBinaryFormats);
if( GL_NO_ERROR == mGlAbstraction.GetError() && 0 != numProgramBinaryFormats )
{
DALI_ASSERT_ALWAYS( NULL != mProgramData.Get() && "Program data is not initialized" );
- Unload();
+ // If already linked don't do anything
+ if( mLinked )
+ {
+ return;
+ }
LOG_GL( "CreateProgram()\n" );
mProgramId = CHECK_GL( mContext, mGlAbstraction.CreateProgram() );
*/
~Program();
+ /**
+ * Load the shader, from a precompiled binary if available, else from source code
+ */
+ void Load();
+
private:
// default constructor, not defined
// assignment operator, not defined
Program& operator=( const Program& );
- /**
- * Load the shader, from a precompiled binary if available, else from source code
- */
- void Load();
-
/**
* Unload the shader
*/
mPrograms[geometryIndex].mUseDefaultForAllSubtypes = false;
}
- if( !precompiledBinary )
+ // if platform supports program binaries and we haven't yet saved a binary
+ if( context->CachedNumberOfProgramBinaryFormats() > 0 && !precompiledBinary )
{
- // The binary will have been compiled/linked during Program::New(), so save it
+ // this is the first time this shader is being used so force compilation
+ program->Load();
+
+ // The binary should now have been compiled/linked, so save it
if( shaderData->HasBinary() )
{
DALI_ASSERT_DEBUG( mPostProcessDispatcher != NULL );