Question

Sorry for asking but I just can't understand what's happening.

I'm a rookie in DirectX/SlimDX. I'm currently trying to create a control to show 3D points. I wrote the simplest kind of code, mostly using the 3rd SlimDX tutorial. I put a control to my form with a size of 200x200, and tried to draw points on it:

    for (float i = -0.5f; i <= 0.5f; i += 0.001f)
         cloud.Add(new Vertex(i, 0.001f, 0));

This is a line with an y coord close to 0 and x coords from -0.5 to 0.5.

Now, as I understand, if I mark a rectangle to viewport then the rectangle's origo is AT THE CENTER. Now, my control is 200x200 so at viewport creation I provide a viewport rectangle of (0,0,200,200). This line of mine thus should be shown at the center of the rectangle along the y axis. But what I get is this:

http://www.4shared.com/photo/xGlGwTWK/Untitled.html

My line is at the very bottom of the control. x coordinates seem to be good, but why is my line at the bottom where it should be at the center?

No world, view, projection matrices are in the game at all!, but the line is still in the wrong place. Can anyone explain me what's happening?

I uploaded a stripped off version of my project here, only 3 short files, with the simplest drawing possible: http://www.4shared.com/zip/uPKVbQKV/ScanForSO.html

Thank you all.

Was it helpful?

Solution

I seem to have found the answer. It's because the control is derived from Panel and the Panel's original size (which I guess is set from the Panel constructor) is 200x100. But, when I created the viewport, I set that up to be 200x200. Thus the origo was at the bottom center of the control. The control then resized to 200x200 and the device/viewport somehow followed automatically.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top