Sign in to follow this  

[SlimDX] Changing resolution for MiniTri10 sample screws up aspect ratio.

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

I've tried to change the resolution for the MinTri10 (DX10) sample in the SlimDX Samples solution by doing this:
var form = new RenderForm("SlimDX - MiniTri Direct3D 10 Sample") { ClientSize = new Size(1280, 720) };
Everything renders, but the triangle looks stretched due to the aspect ratio becomming funky.

However, doing the same in the MinTri example (DX9) works perfectly:
var form = new RenderForm("SlimDX - MiniTri Direct3D9 Sample") { ClientSize = new Size(1280, 720) };
So what am I missing in the DX10 sample? All the methods/objects that take width/height parameter uses form.ClientSize.Width/Height and I can't see anywhere the aspect ratio is specified directly.

Share this post


Link to post
Share on other sites
The difference between the samples is to be expected - since they use a different technique for rendering. The DX9 sample uses Transformed Vertices (VertexFormat.PositionRhw), which means it is specifying the vertex positions in pixels.

On the other hand, the D3D10 sample uses a simple pass-through shader, which causes the vertices to go through some of the transformation pipeline.

The difference in the behavior when the window is resized is due to the difference in how each sample draws.

Share this post


Link to post
Share on other sites
Ok, I think I follow. But how would one go about to allow a 16:9 resolution in the DX10 examples?

I noticed that in the SimpleTriangle10 sample (thats using the Sample Framework from the SlimDX Samples) the triangle gets stretched when re-sizing, but the SimpleModel10 (planet + moon) the two models don't.

Edit: Oh stupid me, there is no WVP multiplication in the shader. And that's exactly what you said. Doh. Thanks :)

[Edited by - thr on December 28, 2010 2:46:38 AM]

Share this post


Link to post
Share on other sites
Note that the samples are just that, samples. They show how to initialize and use the SlimDX libraries, but not a heck of a lot more. As such, from a purely functionality point of view, they're pretty poor. But for doing what we request of them which is to show some of the ways to use SlimDX, such as accessing vertex buffers through the stream objects, they are short and to the point.

Also, if you're wondering about the extra bit of code in the SlimModel10 that came with the SDK (and is no longer in the SVN copy), it's just test code. You can safely remove it.

Share this post


Link to post
Share on other sites
Washu: Yeah, I actually did wonder about that code - I posted a question in these forums a few days ago about it even! :)

The reason the MiniTri10 sample caught me off guard was because I didn't look in the shader.

Thanks both of you for your help! :)

Share this post


Link to post
Share on other sites

This topic is 2546 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this