Jump to content
  • Advertisement
Sign in to follow this  
gourky

WPF, SlimDx and 3D shapes are not displayed

This topic is 2885 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

Hello everybody,

I am using actually succefully the WPF with SlimDX (June 2010) in Net4.0 in an application. I can work with ortho projection in 2D. As soon as I try to display 3D objects, nothing is displayed.

As an example, I took the 'SimpleTriangle9' from SlimDx samples, and just add the matrix update from DirectX sdk :


private void set_matrix(Device device) {
int iTime = System.Environment.TickCount % 1000;
float fAngle = (float)(iTime * ( 2.0f * System.Math.PI ) / 1000.0f);
Matrix matWorld = Matrix.RotationY( fAngle );
device.SetTransform( TransformState.World, matWorld );

// Set up our view matrix. A view matrix can be defined given an eye point,
// a point to lookat, and a direction for which way is up. Here, we set the
// eye five units back along the z-axis and up three units, look at the
// origin, and define "up" to be in the y-direction.
Vector3 vEyePt = new Vector3( 0.0f, 3.0f,-5.0f );
Vector3 vLookatPt = new Vector3( 0.0f, 0.0f, 0.0f );
Vector3 vUpVec = new Vector3( 0.0f, 1.0f, 0.0f );
Matrix matView = Matrix.LookAtLH( vEyePt, vLookatPt, vUpVec );
device.SetTransform( TransformState.View, matView );

// For the projection matrix, we set up a perspective transform (which
// transforms geometry from 3D view space to 2D viewport space, with
// a perspective divide making objects smaller in the distance). To build
// a perpsective transform, we need the field of view (1/4 pi is common),
// the aspect ratio, and the near and far clipping planes (which define at
// what distances geometry should be no longer be rendered).
Matrix matProj=Matrix.PerspectiveFovLH( (float)System.Math.PI / 4, 1.0f, 1.0f, 100.0f );
device.SetTransform( TransformState.Projection, matProj );
}



in the rendering method

[source=c#]
protected override void OnRender() {
set_matrix(Context9.Device);
Context9.Device.SetStreamSource( 0, vertexBuffer, 0, Marshal.SizeOf( typeof( ColoredVertex ) ) );
Context9.Device.VertexDeclaration = vertexDecl;
Context9.Device.DrawPrimitives( PrimitiveType.TriangleList, 0, 1 );
}



This is working fine. You can see the triangle turning.

Then I took the 'WpfSample'. I replaced the sprite drawing with the triangle from 'SimpleTriangle9'.

But nothing is displaying.

Does anyone meet the same problem, and is there a solution ?

Thank you

Share this post


Link to post
Share on other sites
Advertisement
Hello,

For those who met the same problem, I found something :

on line 492 of the SlimDXControl.xaml.cs, change :

Device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, new Color4(System.Drawing.Color.Black), [color="#ff0000"]0, 0);

with

Device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, new Color4(System.Drawing.Color.Black), [color="#ff0000"]1, 0);

Then, everything is working.

Share this post


Link to post
Share on other sites

Hello,

For those who met the same problem, I found something :

on line 492 of the SlimDXControl.xaml.cs, change :

Device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, new Color4(System.Drawing.Color.Black), [color="#ff0000"]0, 0);

with

Device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, new Color4(System.Drawing.Color.Black), [color="#ff0000"]1, 0);

Then, everything is working.


Huh, interesting find. If you could file an issue for this on our issue tracker, it'd be appreciated.

Share this post


Link to post
Share on other sites

Hello,

For those who met the same problem, I found something :

on line 492 of the SlimDXControl.xaml.cs, change :

Device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, new Color4(System.Drawing.Color.Black), [color="#ff0000"]0, 0);

with

Device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, new Color4(System.Drawing.Color.Black), [color="#ff0000"]1, 0);

Then, everything is working.



Really interesting.... nice catch...

I have same WPF application... dot net 3.5 and slimdx..

But I have fortunatelly the same setting that you suggested.... My problem is little different than this...I also declare the matrix same thing to display 3D look of Thread(for showing stitching on garment). Now in couple of system its showing 3D stitch well but on few its not showing anything even after 3D setting display enable.

let me give little hardware information :

working well at my workstation with card NVIDIA Quadro NVS 290...But its fail to create 3D view that contain graphics card 256MB ATI Radeon (TM) HD 3450” ,[font="Arial"] [color="#000000"]I checked with couple of card performance checking tool but i havnt figure out reason of 3D not generation.[/font]


Thanks in advance
-CC

Share this post


Link to post
Share on other sites

Now in couple of system its showing 3D stitch well but on few its not showing anything even after 3D setting display enable.


I cannot give you an answer. Normally, if a driver does not support the feature, DirectX emulates it. It is what I understood. Try to set your device using software instead of hardware to see any changes. Check as well that if you are running win7 or vista with a Directx9d.Device and not Directx9d.DeviceEx, you might get speed problems. Make some sample with C++ to see if something is wrong with the csharp code. That's how I proceed.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!