Jump to content
  • Advertisement
Sign in to follow this  
littlewater

About D3DFVF_XYZ and D3DFVF_XYZRHW

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

they are exclusive as everyone know ,when i try to change from xyzrhw to xyz format i meet a lot of questions: (i) if you use the format xyzrhw ,then you myabe have to use vertex-buffer-lock & unlock function to move the vetices , i couldn't move them through SetTransform(..) function. (ii) if you had been used format xyzrhw, when you want to change them to xyz-format, there should be do some more change besides the rhw in customvertex structure. The question now is the pixel format. i use 800*600 in xyzrhw format but after setting to xyz, the screen shows only about 620*400...... i don't kown how to change it to the correct format, the next post i will give the D3DPRESENT_PARAMETERS parameter. other in detail i should go on studying...any one can help me ?

Share this post


Link to post
Share on other sites
Advertisement
D3DPRESENT_PARAMETERS d3dpp;

ZeroMemory( &d3dpp, sizeof(d3dpp) );
d3dpp.BackBufferFormat = pMode.Format ; //use format of mode
d3dpp.BackBufferCount = 1 ; //make one back buffer
d3dpp.MultiSampleType = D3DMULTISAMPLE_NONE ;
d3dpp.hDeviceWindow = hWnd ;
d3dpp.EnableAutoDepthStencil = TRUE ;
d3dpp.AutoDepthStencilFormat = D3DFMT_D16 ;
d3dpp.Flags = 0 ; //flags

if (g_bWindowed)
{
d3dpp.BackBufferWidth = 0 ;
d3dpp.BackBufferHeight = 0 ;
d3dpp.Windowed = TRUE;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
}
else
{
d3dpp.BackBufferWidth = SCREEN_WIDTH ; //use mode width
d3dpp.BackBufferHeight = SCREEN_HEIGHT ; //use mode height
d3dpp.Windowed = FALSE;
d3dpp.SwapEffect = D3DSWAPEFFECT_FLIP; d3dpp.FullScreen_RefreshRateInHz = pMode.RefreshRate ; //use mode's refresh rate
d3dpp.FullScreen_PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT ;
}

Share this post


Link to post
Share on other sites
And I find that whatever size of the window , directx will automatic correct to the window i know i must do some error when setting the parameter...

what should i do...

Share this post


Link to post
Share on other sites
You need to read up on transformed versus untransformed vectors, and the geometry (T&L) pipeline. In short, specifying D3DFVF_XYZRHW says you'd like to skip the geometric transforms (anything you set with SetTransform(), and the viewport transform) and place the vectors directly on the screen at the (x,y,z) you specify (x-pixel from the left of the window, y-pixel from the top, and z-value for the depth buffer). D3DFVF_XYZ specifies you'd like the vectors to be transformed by those matrices and viewport to get them into screen space.

You then need to ask yourself why you're switching them. In general, things work best one way or the other.

Share this post


Link to post
Share on other sites
Thing goes well ... Thanks !

Now I want to choose the xyz format because I want to do the coordinate map ... maybe you don't call it this name ( just compute and change the projection space )

But i found the final coordinate was sth. error contrast to the coord i want...

i use 800*600 pixel format

and i want to use only the center-left region for game
the rect will be (40, 30), (640, 30), (40, 570), (640, 570)
i get the rect lefttop is (-0.9, 0.9), rightbottom is (0.6, -0.9)

and i compute as following:
(suppose x0 as the source pixel, and x1 as the dest pixel, and the same to y0,y1 )

x1 = (0.6 - ( -0.9 )) / ( 640 - 40 ) * x0 - 0.9
y1 = ( - 0.9 - 0.9) / (570 - 30) * y0 + 0.9

and the final matrix :
0.0025 0 0 0
[ 0 0.0045 0 0 ]
0 0 1 0
-0.9 0.9 0 1

but the actual rect i get is about 350 * 300 ... is anything wrong?

and by the way, i don't know where will be the z-axis after i changed the projection ?

Share this post


Link to post
Share on other sites
I take the following test:

set the fullscreen for the coordinate

i use

D3DXMatrixIdentity ( &matProj ) ;

matProj._11 = (FLOAT) ( 2.0 / 800.0 ) ;
matProj._41 = (FLOAT) -1.0000 ;
matProj._22 = (FLOAT) -( 2.0 / 600.0 ) ;
matProj._42 = (FLOAT) 1.0000 ;

g_pd3dDevice->SetTransform ( D3DTS_PROJECTION , &matProj ) ;

but i got (-200, -200) to (350, 300) not (0, 0) to (800, 600) or (-400, -300) to (400, 300)
and i still don't know where is the center...

Share this post


Link to post
Share on other sites
Quote:
Original post by littlewater

(i) if you use the format xyzrhw ,then you myabe have to use vertex-buffer-lock & unlock function to move the vetices , i couldn't move them through SetTransform(..) function.

If you use XYZRHW, indeed you can not do hardware transforms, and you'll have to lock and unlock the buffer each time a primitive is drawn. But do not worry. The locking and unlocking is very speedy. The plus side is, that drawing vertices in this mode is just crazy fast. I love the mode.

Share this post


Link to post
Share on other sites
sounds strange...

I often heard other people said:

You shouldn't move the point but depending on the matrix of world view projection...

PS: now it works right suddenly...... and i still don't know why...

Share this post


Link to post
Share on other sites
Quote:
Original post by Marmin
Quote:
Original post by littlewater

(i) if you use the format xyzrhw ,then you myabe have to use vertex-buffer-lock & unlock function to move the vetices , i couldn't move them through SetTransform(..) function.

If you use XYZRHW, indeed you can not do hardware transforms, and you'll have to lock and unlock the buffer each time a primitive is drawn. But do not worry. The locking and unlocking is very speedy. The plus side is, that drawing vertices in this mode is just crazy fast. I love the mode.


Shouldn't give any significant speed increase. I very much doubt the pipe's bottleneck is anything per-vertex.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!