[QUESTION] D3D problems :D

Posts 18 of 8 · Page 1 of 1
[QUESTION] D3D problems :D
Ok, so I'm still planning on making game hacks sometime in the future and I'm following a Direct3D tutorial here but now I'm stuck.
I have already done everything that the guy on the tutorial page has done and the programs compiles just right no problems at all.
But, now I want to go a bit further. I want to draw 2 Triangles to the screen which are rotating. This isn't the problem either the problem is that I can see my 2nd smaller triangle through the other triangle :O

I think I know why, because I use a rather noob way of drawing these 2 triangles:

Code:
void render_frame(void)
{											//D3DCOLOR_XRGB(r, g, b)
    // clear the window to a deep blue		D3DCOLOR_ARGB(136, r, g, b);
    d3ddev->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);

    d3ddev->BeginScene();    // begins the 3D scene

            // select which vertex format we are using
        d3ddev->SetFVF(CUSTOMFVF);

         // SET UP THE PIPELINE

    D3DXMATRIX matRotateY;    // a matrix to store the rotation information

    static float index = 0.0f; index+=0.05f;    // an ever-increasing float value

    // build a matrix to rotate the model based on the increasing float value
    D3DXMatrixRotationY(&matRotateY, index);

    // tell Direct3D about our matrix
    d3ddev->SetTransform(D3DTS_WORLD, &matRotateY);

    D3DXMATRIX matView;    // the view transform matrix

    D3DXMatrixLookAtLH(&matView,
                       &D3DXVECTOR3 (0.0f, 0.0f, 10.0f),    // the camera position
                       &D3DXVECTOR3 (0.0f, 0.0f, 0.0f),    // the look-at position
                       &D3DXVECTOR3 (0.0f, 1.0f, 0.0f));    // the up direction

    d3ddev->SetTransform(D3DTS_VIEW, &matView);    // set the view transform to matView

    D3DXMATRIX matProjection;     // the projection transform matrix

    D3DXMatrixPerspectiveFovLH(&matProjection,
                               D3***oRadian(45),    // the horizontal field of view
                               (FLOAT)SCREEN_WIDTH / (FLOAT)SCREEN_HEIGHT, // aspect ratio
                               1.0f,    // the near view-plane
                               100.0f);    // the far view-plane

    d3ddev->SetTransform(D3DTS_PROJECTION, &matProjection);    // set the projection

   
       d3ddev->SetStreamSource(0, v_buffer, 0, sizeof(CUSTOMVERTEX) ); //Drawing my 1st triangle here

		
        // copy the vertex buffer to the back buffer  
        d3ddev->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 1);                     //Drawing my 1st triangle here


				
    
d3ddev->SetStreamSource(0, v_buffer1, 0, sizeof(CUSTOMVERTEX1));     //Drawing my 2nd triangle here
 d3ddev->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 1);                           //Drawing my 2nd triangle here

    d3ddev->EndScene();    // ends the 3D scene

    d3ddev->Present(NULL, NULL, NULL, NULL);   // displays the created frame on the screen
}
Yes, I did C&P this right out of the tutorial, that's how I learn, I read the tutorial copy the code and start playing around with the functions until I think I got it.
So can anyone help me?

-SCHiM
screenshot plz.
Quote Originally Posted by why06 View Post
screenshot plz.
Oops it seems like I'm a real idiot :O
I was fooled by my own program. The triangle doesn't disappear behind the 2nd triangle because it never goes there It's just hanging in front of the bigger triangle

But that raises another question, how can I make the 2nd triangle disappear behind the 1st??

Here's the video BTW: (I thought making a video would be clearer since my triangles are in a constant motion)


The I thought about using:
Code:
d3ddev->SetRenderState(D3DRS_CULLMODE,  D3DCULL_CCW);
But then my 1st triangle would be cut in half too
//Solved

My question is solved in the next page of the tutorial
Quote Originally Posted by schim View Post
//Solved

My question is solved in the next page of the tutorial
Next time try to EDIT if you can. We don't like double posting here at MPGH. I was looking for a solution for but not I can stop. What function did you end up calling?
Quote Originally Posted by mwb1234 View Post
Next time try to EDIT if you can. We don't like double posting here at MPGH. I was looking for a solution for but not I can stop. What function did you end up calling?
I ended up using a zbuffer wich is a buffer that keeps track of the distance between the camera and the screen
Here is an in depth explaination
Quote Originally Posted by schim View Post
I ended up using a zbuffer wich is a buffer that keeps track of the distance between the camera and the screen
Here is an in depth explaination
I was just wondering if you did it right. I know my D3D... Good work, and keep working hard. Programming takes a LOT of dedication to learn fully in depth. And D3D is a great place to learn to do chams
Quote Originally Posted by schim View Post
I ended up using a zbuffer wich is a buffer that keeps track of the distance between the camera and the screen
Here is an in depth explaination
yep, i was wondering if the triangles were infront of each other, or side by side or something, but since u figured it out goodjob.
Posts 18 of 8 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Need help?