|
-
Apr 18th, 2002, 05:53 PM
#1
Thread Starter
PowerPoster
Won't render the triangle if....
Currently, I have using the following array of vertices to draw a triangle:
PHP Code:
CUSTOMVERTEX g_vertices[] =
{
{ -1.0f, -1.0f, 0.0f, D3DCOLOR_XRGB(255,0,255), }, // x, y, z, color
{ 1.0f, -1.0f, 0.0f, D3DCOLOR_XRGB(0,255,0), },
{ 0.0f, 1.0f, 0.0f, D3DCOLOR_XRGB(0,0,255),},
and I am also transforming the world matrix every time I render (in a loop) so the above triangle is rotated on X axis using the following code:
PHP Code:
//set the world matrics (rotate the object on Y)
D3DXMatrixRotationX(&mat, timeGetTime()/250.0f);
if(FAILED(lpD3DDev->SetTransform(D3DTS_WORLD, &mat)))
{
ShowError("Unable to set the world matrics");
return false;
}
Above code works fine but when I don't use the world transformation (I don't rotate any object means I don't use 2nd piece of code^^), the triangle won't show up. Why is it doing that?
-
Apr 18th, 2002, 07:28 PM
#2
Thread Starter
PowerPoster
Ahhh, thanks. Works now.
Another thing, to draw the triangle, I provided its vertices with the coordinates in very small and sometime negative numbers (eg 0.0f, 1.0f, -1.0f). How would I change that unit to pixels (eg 343, 343, 343) and how would I make Direct3D recognize that I am providing the points in pixels not the form I was providing in before?
-
Apr 18th, 2002, 07:56 PM
#3
Use the FVF:
Code:
D3DFVF_XYZ | D3DFVF_RHW | D3DFVF_DIFFUSE
I believe that is correct. Your vertex structure should look like this:
Code:
struct vertex
{
float x;
float y;
float z;
float rhw;
unsigned long color;
};
Set rhw to 1.0f. x and y are the screen pixel coordinates, and z is the raw depth in the depth buffer (i usually set this to something really small).
Z.
-
Apr 18th, 2002, 08:32 PM
#4
Thread Starter
PowerPoster
Thanks, now I also understand what rhw thingy is used for.
-
Apr 18th, 2002, 09:44 PM
#5
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|