Jump to content
  • Advertisement
Sign in to follow this  
dessler.michelle

[SlimDX] Problem trying to render a triangle in WPFSample project

This topic is 2442 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 there,

I'm using SlimDX (March 2011) and I'm trying to render a triangle in the WPFSample (WPF Interop folder) application that comes with the SlimDX. The code to render the triangle was copied from the example SimpleTirangle9 but I get an exception when trying to create the vertex buffer.

In the file MyRenderEngine.cs in its constructor I just added the following line to create the vertex buffer


vertices = new VertexBuffer(device, Marshal.SizeOf(typeof(Vertex)) * 3, Usage.WriteOnly, VertexFormat.None, Pool.Managed);


I've added a break point there and when I execute that statement I get the exception.

However when I run the SimpleTriangle9 project it works fine.

Can someone explain me why is this happening?

Here you can download the modified source code http://hotfile.com/d...-_Copy.zip.html

Thank you,

Michelle.

Share this post


Link to post
Share on other sites
Advertisement
Welcome to the forum.

I for one can't tell from that line alone, and directly asking to download and debug your project is a bit impolite, especially for a new poster.

You can do yourself a favor by learning about the DirectX Debug Runtime. My guess that exception (what kind of exception) is an DX API call failure. The debug runtimes should tell you what it is. Then come back again, if you can't solve it yourself.

Share this post


Link to post
Share on other sites

Welcome to the forum.

I for one can't tell from that line alone, and directly asking to download and debug your project is a bit impolite, especially for a new poster.

You can do yourself a favor by learning about the DirectX Debug Runtime. My guess that exception (what kind of exception) is an DX API call failure. The debug runtimes should tell you what it is. Then come back again, if you can't solve it yourself.


Hi Unbird and thank you for your cordiality,

Here's the exception I get when running the project: "D3DERR_INVALIDCALL: Invalid call (-2005530516)"

and here's the StackTrace


at SlimDX.Result.Throw[T](Object dataKey, Object dataValue)
at SlimDX.Result.Record[T](Int32 hr, Boolean failed, Object dataKey, Object dataValue)
at SlimDX.Direct3D9.VertexBuffer..ctor(Device device, Int32 sizeInBytes, Usage usage, VertexFormat format, Pool pool)
at WpfSample.MyRenderEngine..ctor(MyDataModel dataModel) in D:\Projects\WPF Interop - Copy\WpfSample\MyRenderEngine.cs:line 63
at WpfSample.WpfWindow..ctor() in D:\Projects\WPF Interop - Copy\WpfSample\WpfWindow.xaml.cs:line 71

I don't have any idea why it's happening because the same code in the project [color="#1C2837"]SimpleTirangle9 run well however when adding the same code to the [color="#1C2837"]WPFSample then I get that exception.
[color="#1C2837"] [color="#1C2837"]Any idea about how to solve this?
[color="#1C2837"]
[color="#1c2837"]Thank you,

[color="#1c2837"]Michelle

[color="#1c2837"]PD: I sent the whole project because it's very small and because the most of the people in any forum ask for the source code to see what's the problem.

Share this post


Link to post
Share on other sites
You're closer, but not close enough. The DirectX debug runtimes tells you even more (mostly and hopefully) than what you just posted. DirectX API call failures (the exception) will - unfortunately - only tell you, well, that they failed, but not why. D3DERR_INVALIDCALL is not very conclusive, is it ?

Read the article I linked to carefully and do what it tells. What you posted is not from the DirectX debug runtime, but just the usual debug log from visual studio.

I actually do know already what it is, but I want to guide you through the process, because you really should learn to use the DX debug runtimes. Programming DirectX without them is just too painful.


PD: I sent the whole project because it's very small and because the most of the people in any forum ask for the source code to see what's the problem.
[/quote]

It's fine when you have been asked for, yes, but not as a original post IMO. First, you have to show what you have done already.

Share this post


Link to post
Share on other sites

I actually do know already what it is, but I want to guide you through the process, because you really should learn to use the DX debug runtimes. Programming DirectX without them is just too painful.


OK, I'll download the SDK today so tomorrow I'll install it and I'll see how that debug works and if I can't solve the problem by myself I'll ask you to guide me and if I can solve it I'll let you know anyways.

I like your style.



It's fine when you have been asked for, yes, but not as a original post IMO. First, you have to show what you have done already.
[/quote]

You're right! I'll have it into account for the next time.

Thank you once again.

Michelle

Share this post


Link to post
Share on other sites
Hi Unbird,


I’ve downloaded the DirectX SDK and DebugView and finally I solved the problem I had. Here’s the error

[5780] Direct3D9: (ERROR) :D3DPOOL_MANAGED is not valid withIDirect3DDevice9Ex

So I changed the parameter Pool.Managed in the statement


vertices = new VertexBuffer(device, Marshal.SizeOf(typeof(Vertex)) * 3, Usage.WriteOnly, VertexFormat.None, Pool.Managed);


With Pool.Default and now it works, I can see the triangle :-)

But I've a question, why Pool.Managed doesn’t work with WPF?

Also, in the DirectX Control Panel if I check the option "Breakon D3D9 Error" then the same app become stunned and I see the following messagesin the DebugView

.....

[828] Direct3D9: :DoneExclusiveMode

[828] Direct3D9: (ERROR) :Invalid iBackBuffer parameterpassed to GetBackBuffer

Why can this be happening?

Thank you once again

Michelle

Share this post


Link to post
Share on other sites
Hi Erik,

Thank you for your help. I read the article and I see the changes in the DirectX for Windows Vista. I didn't know about these new features added to DirectX9 for Vista.

Can you tell me why this messages is shown in DebugView in the WPF example when I add the triangle to the scene?


[color="#1C2837"].....

[828] Direct3D9: (ERROR) :Invalid iBackBuffer parameterpassed to GetBackBuffer
[color="#1C2837"][/quote]
[color="#1C2837"]
[color="#1C2837"]I realized that it only happens in the WPF example from SlimDX because I tested the example SimpleTriangle9 and that messages doesn't appear in the DebugView.
[color="#1C2837"]
[color="#1C2837"]Thank you,
[color="#1C2837"]
[color="#1C2837"]Michelle

Share this post


Link to post
Share on other sites
Looks like an attempt is made to get a back-buffer from the D3D device that fails because there are fewer back-buffers than requested. If the program works and you don't call any such functions yourself, perhaps SlimDX works behind the scenes by attempting to request a back-buffer and then handling the error or something like that, but the debug output is still displayed. Just a guess.

Share this post


Link to post
Share on other sites
Hi Ereik,


Looks like an attempt is made to get a back-buffer from the D3D device that fails because there are fewer back-buffers than requested. If the program works and you don't call any such functions yourself, perhaps SlimDX works behind the scenes by attempting to request a back-buffer and then handling the error or something like that, but the debug output is still displayed. Just a guess.



Yes the application works and I don't call any such functions so I think you're right with your guess anyways I'll see how can I ask directly to the SlimDX's developers.

Thank you very much for your help.

Thank you guys biggrin.gif

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!