Jump to content
  • Advertisement
Sign in to follow this  
chinaSTU

about the render sequence

This topic is 3465 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 all,I am a chinese student, and a beginner of the game program. I want to know how can i render the objects accordding to the depth of objects. It means render the object(depth:0.5f)first,and then render the object(depth:10.0f). the code is here: stD3DVertex objData1[] = { {-0.3f, -0.4f, 0, D3DCOLOR_XRGB(255,255,255), 0, 1}, {0.3f, -0.4f, 0, D3DCOLOR_XRGB(255,255,255), 1, 1}, {0.3f, 0.4f, 0, D3DCOLOR_XRGB(255,255,255), 1, 0}, {0.3f, 0.4f, 0, D3DCOLOR_XRGB(255,255,255), 1, 0}, {-0.3f, 0.4f, 0, D3DCOLOR_XRGB(255,255,255), 0, 0}, {-0.3f, -0.4f, 0, D3DCOLOR_XRGB(255,255,255), 0, 1} }; stD3DVertex objData2[] = { {-0.3f, -0.4f,0.3f, D3DCOLOR_XRGB(255,255,255), 0, 1}, {0.3f, -0.4f, 0.3f, D3DCOLOR_XRGB(255,255,255), 1, 1}, {0.3f, 0.4f, 0.3f, D3DCOLOR_XRGB(255,255,255), 1, 0}, {0.3f, 0.4f, 0.3f, D3DCOLOR_XRGB(255,255,255), 1, 0}, {-0.3f, 0.4f, 0.3f, D3DCOLOR_XRGB(255,255,255), 0, 0}, {-0.3f, -0.4f, 0.3f, D3DCOLOR_XRGB(255,255,255), 0, 1} }; void RenderScene() { // Clear the backbuffer. g_D3DDevice->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,0,0), 1.0f, 0); // Begin the scene. Start rendering. g_D3DDevice->BeginScene(); D3DXMatrixRotationY(&g_rotation2,g_angle); // Build the world matrix and update angle. g_worldMatrix =g_rotation2; g_angle += 0.01f; if(g_angle >= 360) g_angle = 0.0f; // Set the world matrix. //g_D3DDevice->SetTransform(D3DTS_WORLD, &g_worldMatrix); // Apply the view (camera). g_D3DDevice->SetTransform(D3DTS_VIEW, &g_ViewMatrix); g_D3DDevice->SetTexture(0, g_Texture); g_D3DDevice->SetStreamSource(0, g_VertexBuffer2, 0, sizeof(stD3DVertex)); g_D3DDevice->SetFVF(D3DFVF_VERTEX); g_D3DDevice->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 2); // Draw square. g_D3DDevice->SetTexture(0, g_Texture); g_D3DDevice->SetStreamSource(0, g_VertexBuffer1, 0, sizeof(stD3DVertex)); g_D3DDevice->SetFVF(D3DFVF_VERTEX); g_D3DDevice->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 2); // End the scene. Stop rendering. g_D3DDevice->EndScene(); // Display the scene. g_D3DDevice->Present(NULL, NULL, NULL, NULL); } thanks for telling me。appreciate it。

Share this post


Link to post
Share on other sites
Advertisement
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!