Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.

DG question

This topic is 5832 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

Hi, I have an problem with my blitting routine! I have made this screenshots, the first is a screenshot from my programm and the second is the BitmapFile who I try to blit. http://cpp.ufosnetwork.com/Image1.gif http://cpp.ufosnetwork.com/Image2.gif my routine:
bool CGraphic::drawAdvance (float x, float y, float rotation, D3DCOLOR color, CVideo &PrimaryVideoClass)
	VERTEX v1,v2,v3,v4;
	VERTEX Vertex_Array[4];

	D3DXMATRIX matRot, matTrans, matTrans2, matWorld;

	float Breite = (float)m_ImageInfo.Width;
	float Hoehe  = (float)m_ImageInfo.Height;

	v1.x		= x;
	v1.y		= y;
	v1.z		= 0.5f;
	v1.u		= 0.0f;
	v1.v		= 0.0f;
	v1.color	= color;

	v2.x		= Breite + x;
	v2.y		= y;
	v2.z		= 0.5f;
	v2.u		= 1.0f;
	v2.v		= 0.0f;
	v2.color	= color;

	v3.x		= x;
	v3.y		= Hoehe + y;
	v3.z		= 0.5f;
	v3.u		= 0.0f;
	v3.v		= 1.0f;
	v3.color	= color;

	v4.x		= Breite + x;
	v4.y		= Hoehe + y;
	v4.z		= 0.5f;
	v4.u		= 1.0f;
	v4.v		= 1.0f;
	v4.color	= color;

	Vertex_Array[0] = v2;
	Vertex_Array[1] = v1;
	Vertex_Array[2] = v4;
	Vertex_Array[3] = v3;

	D3DXMatrixRotationZ(&matRot, PI * rotation / 180);
	PrimaryVideoClass.getDevice()->SetTransform(D3DTS_WORLD, &matRot);

	D3DXMatrixTranslation(&matTrans,-x-(Breite/2),-y-(Hoehe/2), 0.0f);
	D3DXMatrixTranslation(&matTrans2,x+(Breite/2),y+(Hoehe/2), 0.0f); 
	D3DXMatrixMultiply(&matWorld, &matTrans, &matRot);

	D3DXMatrixMultiply(&matWorld, &matWorld, &matTrans2);

	PrimaryVideoClass.getDevice()->SetTransform(D3DTS_WORLD, &matWorld);
	PrimaryVideoClass.getDevice()->SetTexture(0, m_Texture);	

	PrimaryVideoClass.getDevice()->SetTextureStageState(0, D3DTSS_MINFILTER, D3DTEXF_LINEAR);
	PrimaryVideoClass.getDevice()->SetTextureStageState(0, D3DTSS_MAGFILTER, D3DTEXF_LINEAR);

	PrimaryVideoClass.getDevice()->SetTransform(D3DTS_PROJECTION, &PrimaryVideoClass.matProj);


	D3DXMatrixMultiply(&matWorld, &matWorld, &matTrans2); 
	D3DXMatrixRotationZ  (&matWorld, 0);
	PrimaryVideoClass.getDevice()->SetTransform(D3DTS_WORLD, &matWorld);

	return (true);

please help me! --------------------------------------- Coden ist das Schönste auf der Welt! [edited by - Hamster Patrick on June 2, 2002 4:03:00 AM] [edited by - Hamster Patrick on June 2, 2002 4:03:58 AM] [edited by - jim adams on June 2, 2002 2:21:35 PM]

Share this post

Link to post
Share on other sites
Please don't bump messages within such a short time (same day). Many people read the new messages and it will be seen.

[edited by - jim adams on June 2, 2002 2:22:40 PM]

Share this post

Link to post
Share on other sites
My guess is that you are asking about fill rules.

If you want to guarantee that a pixel on the screen will be drawn, you need to make sure that it is completely inside your primitive. If you drawing a screenspace rect (x,y,w,h), you should offset the coordinates to be (x-0.5,y-0.5,w,h). This will guarantee that (x,y) and (x+w-1,y+w-1) are both explicitly included. If your vertices are already in screenspace, this is easy to do manually by just subtracting 0.5 from each coordinate. If your vertices are not in screenspace, this is also easy enough to do in your projection matrix.

Offsetting the position by (-0.5,-0.5) has another benefit: If you are moving through texturespace at the same rate as you are moving through screenspace, when you draw the pixel (x,y) you will already be (0.5,0.5) into the texture. When using bilinear filtering, this should select only the top-left pixel of your texture. Whereas (0.0,0.0) would represent some average of all four corner pixels of your texture.

You might want to take a look at using ID3DXSprite, which I believe already takes this all into account.


Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!