Esempio n. 1
0
//----------------------------------------------------------------//
void MOAIGfxDeviceStateCache::SetScissorRect ( ZLRect rect ) {
	
	rect.Bless ();
	this->mViewRect.Clip ( rect );

	ZLRect& current = this->mScissorRect;
	
	if (	( current.mXMin != rect.mXMin ) ||
			( current.mYMin != rect.mYMin ) ||
			( current.mXMax != rect.mXMax ) ||
			( current.mYMax != rect.mYMax )) {
		
		this->OnGfxStateWillChange ();

		ZLRect deviceRect = this->mCurrentFrameBuffer->WndRectToDevice ( rect );

		s32 x = ( s32 )deviceRect.mXMin;
		s32 y = ( s32 )deviceRect.mYMin;
		
		u32 w = ( u32 )( deviceRect.Width () + 0.5f );
		u32 h = ( u32 )( deviceRect.Height () + 0.5f );

		w = h == 0 ? 0 : w;
		h = w == 0 ? 0 : h;
		
		zglScissor ( x, y, w, h );
		this->mScissorRect = rect;
	
		zglEnable ( ZGL_PIPELINE_SCISSOR );
	}
}
Esempio n. 2
0
//----------------------------------------------------------------//
void MOAIGfxDeviceStateCache::SetDepthFunc ( int depthFunc ) {

	if ( this->mDepthFunc != depthFunc ) {
	
		this->OnGfxStateWillChange ();
		
		this->mDepthFunc = depthFunc;
	
		if ( depthFunc ) {
			zglEnable ( ZGL_PIPELINE_DEPTH );
			zglDepthFunc ( this->mDepthFunc );
		}
		else {
			zglDisable ( ZGL_PIPELINE_DEPTH );
		}
	}
}
Esempio n. 3
0
//----------------------------------------------------------------//
void MOAIGfxDeviceStateCache::SetCullFunc ( int cullFunc ) {

	if ( this->mCullFunc != cullFunc ) {
	
		this->OnGfxStateWillChange ();
		
		this->mCullFunc = cullFunc;
	
		if ( cullFunc ) {
			zglEnable ( ZGL_PIPELINE_CULL );
			zglCullFace ( this->mCullFunc );
		}
		else {
			zglDisable ( ZGL_PIPELINE_CULL );
		}
	}
}
Esempio n. 4
0
//----------------------------------------------------------------//
void MOAIGfxDeviceStateCache::SetBlendMode ( const MOAIBlendMode& blendMode ) {

	if ( !this->mBlendEnabled ) {
	
		this->OnGfxStateWillChange ();
		
		zglEnable ( ZGL_PIPELINE_BLEND );
		
		this->mBlendMode = blendMode;
		zglBlendMode ( this->mBlendMode.mEquation );
		zglBlendFunc ( this->mBlendMode.mSourceFactor, this->mBlendMode.mDestFactor );
		this->mBlendEnabled = true;
	}
	else if ( !this->mBlendMode.IsSame ( blendMode )) {
	
		this->OnGfxStateWillChange ();
		
		this->mBlendMode = blendMode;
		zglBlendMode ( this->mBlendMode.mEquation );
		zglBlendFunc ( this->mBlendMode.mSourceFactor, this->mBlendMode.mDestFactor );
	}
}
Esempio n. 5
0
//----------------------------------------------------------------//
void MOAIBlendMode::Bind () {
	
	zglEnable ( ZGL_PIPELINE_BLEND );
	zglBlendMode ( this->mEquation );
	zglBlendFunc ( this->mSourceFactor, this->mDestFactor );
}