Jump to content
  • Advertisement
Sign in to follow this  
protemus

Help please!!! 2D over 3D

This topic is 5453 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

ok, I'll re-post this with a bit more information because no one answered. This is a pretty frustrating problem for me as it is a show stopper on my 2D engine. The 2D is running above the 3D in my game. here is a bit of the 2D initialization code...
D3DXMatrixOrthoLH( mDirectXContext->OrthographicMatrix(), mDirectXContext->ScreenWidth(), mDirectXContext->ScreenHeight(), 1.0f, 800000.0f );
mDirectXContext->MatrixStack()->LoadIdentity();
mDirectXContext->MatrixStack()->Translate(-((mDirectXContext->ScreenWidth()/2)),((mDirectXContext->ScreenHeight()/2)),0);
mDirectXContext->Device()->SetTransform( D3DTS_PROJECTION, mDirectXContext->OrthographicMatrix() );

This is the problem section that runs about 40 times/frame and gives about 26 Frames per second...

	//declare a pointer to the pixel information
	DXWVertexStruct* vertexStruct = NULL;
	//allocate the correct memory for the vertexs
	vertexStruct = new DXWVertexStruct[4];
	vertexStruct[0].color = color;
	vertexStruct[0].x = 0;
	vertexStruct[0].y = 0;
	vertexStruct[0].z = *mCurrentDrawingDepth;

	vertexStruct[1].color = color;
	vertexStruct[1].x = 1024;
	vertexStruct[1].y = 0;
	vertexStruct[1].z = *mCurrentDrawingDepth;

	vertexStruct[2].color = color;
	vertexStruct[2].x = 0;
	vertexStruct[2].y = -768;
	vertexStruct[2].z = *mCurrentDrawingDepth;

	vertexStruct[3].color = color;
	vertexStruct[3].x = 1024;
	vertexStruct[3].y = -768;
	vertexStruct[3].z = *mCurrentDrawingDepth;

	mDirectXContext->Device()->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP,2,vertexStruct,sizeof(DXWVertexStruct));

	//free our memory
	delete [] vertexStruct;

I change ONLY the size in the following code and it yields frame rates of 230 Frames per second...

	//declare a pointer to the pixel information
	DXWVertexStruct* vertexStruct = NULL;
	//allocate the correct memory for the vertexs
	vertexStruct = new DXWVertexStruct[4];
	vertexStruct[0].color = color;
	vertexStruct[0].x = 0;
	vertexStruct[0].y = 0;
	vertexStruct[0].z = *mCurrentDrawingDepth;

	vertexStruct[1].color = color;
	vertexStruct[1].x = 10;
	vertexStruct[1].y = 0;
	vertexStruct[1].z = *mCurrentDrawingDepth;

	vertexStruct[2].color = color;
	vertexStruct[2].x = 0;
	vertexStruct[2].y = -10;
	vertexStruct[2].z = *mCurrentDrawingDepth;

	vertexStruct[3].color = color;
	vertexStruct[3].x = 10;
	vertexStruct[3].y = -10;
	vertexStruct[3].z = *mCurrentDrawingDepth;

	mDirectXContext->Device()->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP,2,vertexStruct,sizeof(DXWVertexStruct));

	//free our memory
	delete [] vertexStruct;

Why the big difference? I am stumped. Is there something I am doing wrong here, or am I conceptually thinking of something wrong...? why would the size of the quads cause such a huge frame rate reduction? Would it be better to grab the surface and render directly to vid mem? This would allow for any size textures I am pretty sure, but what are the problems in mixing this with 3D in the background... Does anyone have any links on doing 2D above a 3D game? Please help, any suggestions would be appreciated. Do you need more info on the problem?

Share this post


Link to post
Share on other sites
Advertisement
You are seeing the effects of fill rate on performance. When you draw a bigger quad, more pixels must be pushed around, and hence your frame rate drops. Some video cards are more fill rate limited than others, so your app may show more or less slow down on another machine.

Share this post


Link to post
Share on other sites
Is there any way to limit the FPS hit on this? I am drawing my windows back to front and allowing my front windows to obscure my back windows. Will setting clipping regions and drawing front to back alleviate some of this, or will the overhead of creating arbitrary clipping holes and drawing around them outweigh the benefits?

i.e. is there any way to not draw pixels I know are obscured?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!