I draw in Direct3D9 models. Took a minimal example. Against the background is a plane with a texture, in front of it is a kettle, created by the function dx. Models are drawn on top of each other. How to draw the models correctly so that the teapot is in front of the plane, and not vice versa? Render code:
void D3DXDevice::PaintModel() { if (this->Device) { Device->Clear(NULL, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, Colors::White, 1, NULL); Device->BeginScene(); Device->SetFVF(Vertex::FVF); // Π½Π°ΡΡΡΠΎΠΉΠΊΠΈ, ΡΠ°ΠΌ ΡΠ΅ΠΊΡΡΡΡΡ, Π½ΠΎΡΠΌΠ°Π»ΠΈ ΠΈ ΠΏΡΠΎΡΠ΅Π΅ Device->SetStreamSource(0, this->models, 0, sizeof(Vertex)); // this->model - ΡΠΊΠ·Π΅ΠΌΠΏΠ»ΡΡ ΠΊΠ»Π°ΡΡΠ° ΠΌΠΎΠ΄Π΅Π»Ρ, (ΡΠ°ΠΌ Π²ΡΠ΅, ΠΌΠ°ΡΠ΅ΡΠΈΠ°Π», ΡΠ΅ΠΊΡΡΡΡ, ΠΈ Ρ.Π΄.) // ΠΎΡΡΠΈΡΠΎΠ²ΡΠ²Π°Π΅ΠΌ ΠΏΠ»ΠΎΡΠΊΠΎΡΡΡ // ΡΠ΄Π²ΠΈΠ³Π°Π΅ΠΌ ΠΌΠΈΡΠΎΠ²ΠΎΠ΅ ΠΏΡΠ΅ΠΎΠ±ΡΠ°Π·ΠΎΠ²Π°Π½ΠΈΠ΅ Π½Π° 20 Π΅Π΄ΠΈΠ½ΠΈΡ Π½Π° Π½Π°Ρ(ΠΏΠΎ -z) ΠΈ ΡΠΈΡΡΠ΅ΠΌ ΡΠ°ΠΉΠ½ΠΈΠΊ ID3DXMesh* Teapot; D3DXCreateTeapot(Device, &Teapot, 0); D3DXMATRIX trans; D3DXMatrixTranslation(&trans, 0.f, 0.f, -20.f); Device->SetTransform(D3DTS_WORLD, &trans); Teapot->DrawSubset(0); Teapot->Release(); Device->EndScene(); Device->Present(NULL, NULL, NULL, NULL); } } I attach a screenshot of the result. What technique should be used to draw everything correctly (I have a model, there are several textures in it, all this needs to be drawn not at once, but when switching materials, you can see in the screenshot how the models shine through each other).

