Example #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 );
	}
}
/**	@name	getRect
	@text	Returns the two dimensional boundary of the frame.

	@in		MOAIProfilerReportBox self
	@out	number xMin
	@out	number yMin
	@out	number xMax
	@out	number yMax
*/
int MOAIProfilerReportBox::_getRect ( lua_State* L ) {
	MOAI_LUA_SETUP ( MOAIProfilerReportBox, "U" )

	ZLRect rect = self->mFrame;
	rect.Bless ();
	
	lua_pushnumber ( state, rect.mXMin );
	lua_pushnumber ( state, rect.mYMin );
	lua_pushnumber ( state, rect.mXMax );
	lua_pushnumber ( state, rect.mYMax );

	return 4;
}
Example #3
0
//----------------------------------------------------------------//
ZLBox MOAIScriptDeck::ComputeMaxBounds () {

	ZLRect rect = this->mRect;

	if ( this->mOnTotalRect ) {
	
		MOAILuaStateHandle state = MOAILuaRuntime::Get ().State ();
		this->PushLocal ( state, this->mOnTotalRect );
		
		state.DebugCall ( 0, 4 );
		
		rect.mXMin = state.GetValue < float >( -4, 0.0f );
		rect.mYMin = state.GetValue < float >( -3, 0.0f );
		rect.mXMax = state.GetValue < float >( -2, 0.0f );
		rect.mYMax = state.GetValue < float >( -1, 0.0f );
		
		rect.Bless ();
	}
	
	ZLBox bounds;
	bounds.Init ( rect.mXMin, rect.mYMax, rect.mXMax, rect.mYMin, 0.0f, 0.0f );	
	return bounds;
}
Example #4
0
//----------------------------------------------------------------//
ZLBox MOAIScriptDeck::GetItemBounds ( u32 idx ) {
	
	ZLRect rect = this->mRect;
	
	if ( this->mOnRect ) {
	
		MOAILuaStateHandle state = MOAILuaRuntime::Get ().State ();
		this->PushLocal ( state, this->mOnRect );
		
		lua_pushnumber ( state, idx );
		state.DebugCall ( 1, 4 );
		
		rect.mXMin = state.GetValue < float >( -4, 0.0f );
		rect.mYMin = state.GetValue < float >( -3, 0.0f );
		rect.mXMax = state.GetValue < float >( -2, 0.0f );
		rect.mYMax = state.GetValue < float >( -1, 0.0f );
		
		rect.Bless ();
	}
	
	ZLBox bounds;
	bounds.Init ( rect.mXMin, rect.mYMax, rect.mXMax, rect.mYMin, 0.0f, 0.0f );	
	return bounds;
}
Example #5
0
//----------------------------------------------------------------//
void MOAIDraw::DrawRectEdges ( ZLRect rect, u32 edges ) {

	rect.Bless ();
	
	// right
	if ( edges & ZLRect::kRight ) {
		MOAIDraw::DrawLine ( rect.mXMax, rect.mYMin, rect.mXMax, rect.mYMax );
	}

	// top
	if ( edges & ZLRect::kTop ) {			
		MOAIDraw::DrawLine ( rect.mXMin, rect.mYMin, rect.mXMax, rect.mYMin );
	}

	// left
	if ( edges & ZLRect::kLeft ) {			
		MOAIDraw::DrawLine ( rect.mXMin, rect.mYMin, rect.mXMin, rect.mYMax );
	}

	// bottom
	if ( edges & ZLRect::kBottom ) {			
		MOAIDraw::DrawLine ( rect.mXMin, rect.mYMax, rect.mXMax, rect.mYMax );
	}	
}
Example #6
0
//----------------------------------------------------------------//
void MOAIDraw::DrawRectFill ( ZLRect rect, bool asTriStrip ) {

	rect.Bless ();
	MOAIDraw::DrawRectFill ( rect.mXMin, rect.mYMin, rect.mXMax, rect.mYMax, asTriStrip );
}