Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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,

Posted

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);

My website
  • 2 weeks later...
Posted

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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...