示例#1
0
void
Compositor::DrawGeometry(const gfx::Rect& aRect,
                         const gfx::IntRect& aClipRect,
                         const EffectChain& aEffectChain,
                         gfx::Float aOpacity,
                         const gfx::Matrix4x4& aTransform,
                         const gfx::Rect& aVisibleRect,
                         const Maybe<gfx::Polygon3D>& aGeometry)
{
  if (!aGeometry) {
    DrawQuad(aRect, aClipRect, aEffectChain,
             aOpacity, aTransform, aVisibleRect);
    return;
  }

  // Cull invisible polygons.
  if (aRect.Intersect(aGeometry->BoundingBox()).IsEmpty()) {
    return;
  }

  gfx::Polygon3D clipped = aGeometry->ClipPolygon(aRect);
  nsTArray<gfx::Triangle> triangles = clipped.ToTriangles();

  for (gfx::Triangle& geometry : triangles) {
    const gfx::Rect intersection = aRect.Intersect(geometry.BoundingBox());

    // Cull invisible triangles.
    if (intersection.IsEmpty()) {
      continue;
    }

    MOZ_ASSERT(aRect.width > 0.0f && aRect.height > 0.0f);
    MOZ_ASSERT(intersection.width > 0.0f && intersection.height > 0.0f);

    gfx::TexturedTriangle triangle(Move(geometry));
    triangle.width = aRect.width;
    triangle.height = aRect.height;

    // Since the texture was created for non-split geometry, we need to
    // update the texture coordinates to account for the split.
    if (aEffectChain.mPrimaryEffect->mType == EffectTypes::RGB) {
      TexturedEffect* texturedEffect =
        static_cast<TexturedEffect*>(aEffectChain.mPrimaryEffect.get());

      UpdateTextureCoordinates(triangle, aRect, intersection,
                               texturedEffect->mTextureCoords);
    }

    DrawTriangle(triangle, aClipRect, aEffectChain,
                 aOpacity, aTransform, aVisibleRect);
  }
}
示例#2
0
VOID Render(float timeDelta)
{
	SetupMatrix() ;

	UpdateTextureCoordinates(timeDelta) ;

	// Clear the back-buffer to a RED color
	g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xff568800, 1.0f, 0 );

	// Begin the scene
	if( SUCCEEDED( g_pd3dDevice->BeginScene() ) )
	{
		RenderQuad() ;

		// End the scene
		g_pd3dDevice->EndScene();
	}

	// Present the back-buffer contents to the display
	g_pd3dDevice->Present( NULL, NULL, NULL, NULL );
}
示例#3
0
文件: mblare.c 项目: F5000/spree
void HandleMBlare(LPMYOBJ lpOb){
	LPMBLARESTATE State=lpOb->MBlare;
	int Status, N;
	static ActTime;
	if (GameFrozen||NowReplaying) return;
	lpD3DDevice->lpVtbl->GetMatrix(lpD3DDevice, CurrCameraM, &CameraMat);
	Status=State->Status;
	if (Status==MB_SLEEPING) {
		State->MBOK=FALSE;
		return;
	}
	if (Status==MB_STARTED) {
		GET_NEXT_POINT(State->LastPoints[0]);
		State->Status=MB_ONE_POINT_VALID;
	//	lpOb->Flags=TRANSPARENTOBJ|lpOb->Flags; //OBROBRIOOOOO!!!!!!!!
		State->FirstVertex=0;
		State->CV1.x=PVALUE(0.);
		State->CV1.y=PVALUE(1.);
		State->CV1.z=PVALUE(0.);
		if (!(State->MBOK)) State->Status=MB_SLEEPING;
		State->MBOK=FALSE;
	}
	else if (Status==MB_ONE_POINT_VALID) {
		GET_NEXT_POINT(State->LastPoints[1]);
		State->Status=MB_TWO_POINTS_VALIDS;
		State->VertexDrawn=2;
		State->StripsDrawn=0;
		if (!(State->MBOK)) State->Status=MB_SLEEPING;
		State->MBOK=FALSE;

	}
	else if (Status==MB_TWO_POINTS_VALIDS) {
		State->PrevD=MyTime();
		if ((State->CTime<=State->LTime)||
			(!(State->MBOK))) {
			State->Status=MB_SLEEPING;
			RENDERSTRIP();
			State->MBOK=FALSE;
			return;
		}
		if (State->CTime-State->LTime>=State->IncTime){
			GET_CURR_POINT();
			if (ComputeNewStrip(State)) {
				
				State->StripsDrawn++;
				State->VertexDrawn+=2;
				UpdateTextureCoordinates(State);
				State->LTime+=State->IncTime;
				PUSH_NEW_POINT();
			}
		}
		RENDERSTRIP();
		State->MBOK=FALSE;
	}
	else if (State->Status==MB_DISAPPEARING){
		if (State->StripsDrawn>0){
			State->DeltaD=DISAPPARITION_TIME/State->StripsDrawn;
			if (State->DeltaD<=1) State->DeltaD=1;
			ActTime=MyTime();
			//ActTime=State->PrevD+State->DeltaD/10;
			N=(ActTime-State->PrevD)/State->DeltaD;
			if (N>0) 
				State->PrevD+=N*State->DeltaD;
			State->StripsDrawn-=N;
			State->FirstVertex+=(N+N);
		}
		
		
		if (State->StripsDrawn<=0) {
		//	lpOb->Flags=lpOb->Flags&(~TRANSPARENTOBJ);
			State->Status=MB_SLEEPING;
			return;
		}
		UpdateTextureCoordinates(State);
		RENDERSTRIP();
		State->Status=MB_DISAPPEARING1;
	}
	else if (State->Status==MB_DISAPPEARING1){
		//ActTime+=State->DeltaD/10;
		ActTime=MyTime();
		N=(ActTime-State->PrevD)/State->DeltaD;
		if (N>0){ 
			State->PrevD+=N*State->DeltaD;
			State->StripsDrawn-=N;
			State->FirstVertex+=(N+N);
		}
		if (State->StripsDrawn<=1) {
			//lpOb->Flags=lpOb->Flags&(~TRANSPARENTOBJ);
			State->Status=MB_SLEEPING;
			return;
		}
		UpdateTextureCoordinates(State);
		RENDERSTRIP();
	}
	
}