//----------------------------------------------------------------// USRect MOAILayoutFrame::GetScissorRect () { USRect scissorRect = this->GetFrame (); USMatrix4x4 mtx; mtx.Init ( this->mLocalToWorldMtx ); mtx.Append ( MOAIGfxDevice::Get ().GetWorldToWndMtx ( 1.0f, 1.0f )); mtx.Transform ( scissorRect ); return scissorRect; }
//----------------------------------------------------------------// void MOAIGfxDevice::BeginLayer () { float width = ( float )this->mWidth; float height = ( float )this->mHeight; MOAIViewport viewport; viewport.Init ( 0.0f, 0.0f, width, height ); viewport.SetScale ( width, -height ); viewport.SetOffset ( -1.0f, 1.0f ); this->SetViewport ( viewport ); for ( u32 i = 0; i < TOTAL_VTX_TRANSFORMS; ++i ) { this->mVertexTransforms [ i ].Ident (); } this->mUVTransform.Ident (); this->mCpuVertexTransformMtx.Ident (); this->mVertexMtxInput = VTX_STAGE_MODEL; this->mVertexMtxOutput = VTX_STAGE_MODEL; USMatrix4x4 projMtx; projMtx.Init ( viewport.GetProjMtx ()); this->mVertexTransforms [ VTX_PROJ_TRANSFORM ] = projMtx; // fixed function reset #if USE_OPENGLES1 if ( !this->IsProgrammable ()) { // load identity matrix glMatrixMode ( GL_MODELVIEW ); glLoadIdentity (); glMatrixMode ( GL_PROJECTION ); this->GpuLoadMatrix ( projMtx ); glMatrixMode ( GL_TEXTURE ); glLoadIdentity (); // reset the current vertex color glColor4f ( 1.0f, 1.0f, 1.0f, 1.0f ); // reset the point size glPointSize (( GLfloat )this->mPointSize ); } #endif }
//----------------------------------------------------------------// USRect MOAIScissorRect::GetScissorRect ( const USMatrix4x4& worldToWndMtx ) const { USVec3D vtx3D [ 4 ]; vtx3D [ 0 ].mX = this->mRect.mXMin; vtx3D [ 0 ].mY = this->mRect.mYMin; vtx3D [ 0 ].mZ = 0.0f; vtx3D [ 1 ].mX = this->mRect.mXMin; vtx3D [ 1 ].mY = this->mRect.mYMax; vtx3D [ 1 ].mZ = 0.0f; vtx3D [ 2 ].mX = this->mRect.mXMax; vtx3D [ 2 ].mY = this->mRect.mYMax; vtx3D [ 2 ].mZ = 0.0f; vtx3D [ 3 ].mX = this->mRect.mXMax; vtx3D [ 3 ].mY = this->mRect.mYMin; vtx3D [ 3 ].mZ = 0.0f; USMatrix4x4 mtx; mtx.Init ( this->GetLocalToWorldMtx ()); mtx.Append ( worldToWndMtx ); mtx.Project ( vtx3D [ 0 ]); mtx.Project ( vtx3D [ 1 ]); mtx.Project ( vtx3D [ 2 ]); mtx.Project ( vtx3D [ 3 ]); USRect scissorRect; scissorRect.Init ( vtx3D [ 0 ]); scissorRect.Grow ( vtx3D [ 1 ]); scissorRect.Grow ( vtx3D [ 2 ]); scissorRect.Grow ( vtx3D [ 3 ]); if ( this->mScissorRect ) { USRect parentRect = this->mScissorRect->GetScissorRect ( worldToWndMtx ); parentRect.Clip ( scissorRect ); } return scissorRect; }
//----------------------------------------------------------------// void MOAIGfxDevice::SetVertexTransform ( u32 id, const USAffine3D& transform ) { USMatrix4x4 mtx; mtx.Init ( transform ); this->SetVertexTransform ( id, mtx ); }
//----------------------------------------------------------------// void MOAIGfxDevice::SetUVTransform ( const USAffine3D& transform ) { USMatrix4x4 mtx; mtx.Init ( transform ); this->SetUVTransform ( mtx ); }