NeoAsimov Posted January 20, 2004 Posted January 20, 2004 Hello, I have a little problem in DirectX 9 (using CSharp). I need to put a background(texture) to my scene. Everything work fine, my bitmap appear without problems. Im using a Quad to draw my texture on. The problem appear when I try to draw other primitive (triangle) in front of my Quad (background). There is some code: // The quad buffer. vertexTexture = new VertexBuffer( typeof(CustomVertex.TransformedColoredTextured), 4, device, Usage.WriteOnly, CustomVertex.TransformedColoredTextured.Format, Pool.Default); // Note: Im assigning my vertices correctly, I'll not post the code here. device.BeginScene(); // There im trying to write some colored triangle. for (int i = 0; i < LVRTSDisplay.SectorNumber;i++) { device.SetStreamSource( 0, vertexBuffer1, 0); device.VertexFormat = CustomVertex.TransformedColored.Format; device.DrawPrimitives(PrimitiveType.TriangleList, 0, (2 * LVRTSDisplay.ArcNumber)); } device.SetStreamSource( 0, vertexTexture, 0); device.VertexFormat = CustomVertex.TransformedColoredTextured.Format; device.SetTexture(0, textureBackground); device.DrawPrimitives(PrimitiveType.TriangleFan, 0, 2); device.EndScene(); device.Present(); The first time that I render this, I can see my first drawed triangles and after I can see my background. But the second time I render it, it's like if my triangles are now drawed. It seem to be the result of: device.SetTexture(0, textureBackground); device.DrawPrimitives(PrimitiveType.TriangleFan, 0, 2); If I switch my code and draw my background first, I'll never see my triangles. I really dont know what,s the problem there. Thank for your help/hints about this problem. Salutations, Quote
NeoAsimov Posted January 21, 2004 Author Posted January 21, 2004 Rectification! there his my illustrated problem: Before: Quote
hog Posted January 22, 2004 Posted January 22, 2004 I'm no expert, not by a long shot:( But the line in your render code; device.SetStreamSource( 0, vertexBuffer1, 0); Why are you using an array subscript and not simply; device.SetStreamSource( 0, vertexBuffer1, 0); Quote My website
NeoAsimov Posted January 22, 2004 Author Posted January 22, 2004 Hello! Becose I have an array of VertexMatric(this array is in reallity the green spots on the image.) Salutations, Quote
igotjunk Posted February 1, 2004 Posted February 1, 2004 just a thought, have you got the ZBuffer enabled? device.RenderState.ZBufferEnable = true; the zbuffer contains the flip screens pixels with a depth number ( z ) assigned to every pixel so as to draw layer apon layer while taking care of the problem of drawing with depth. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.