Porting from OpenGL to Directx

Started by
29 comments, last by xDarkice 12 years, 2 months ago

OpenGL interprets screen-space positions as the center of the pixel
DirectX interprets screen-space positions as the top-left corner of the pixel
(Or is it the other way round?)

Just because no one else mentioned this, OpenGL and Direct3D 10 assume center-points for pixels.
Direct3D 9, Direct3D 11, and GDI use pixel corners.






Right now I am resizing my viewport but it seems as if the width and height parameters are ignored, the frame will shift by my x and y coordinates but it wont use the width and height i specified so that it is running out of my window.

Do I have to set the backbuffer width and height? Do I have to change something at my orthogonal projection or my translation matrix?

If you are only setting the viewport on a resize, you need to also update your orthogonal matrix.




I got a problem that the textures are clipped when they reach the edges of the viewport. I am creating my VertexBuffer with the DoNotClip Flag and I am setting the RenderState.Clipping to false. Am I missing another flag?

I don’t see the problem.
The viewport should be the size of the screen. If anything goes out of the viewport it would be outside of the window and you would never know if it was clipped or not.
I see no clipping in your screen shot.


L. Spiro

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid

Advertisement
Thanks for your answer, please take a look at the snow at the bottom. The snow will lose one triangle of the quad. It only appears when I rotate these snow flocks. If they arent rotated they will display properly

By the way this is how I am roting a quad:

if (rect.Rotation != 0)
{
rect.Rotation = rect.Rotation * (float)Math.PI / 180;
float centerX = (rx1 + rx2) / 2f;
float centerY = -(ry1 + ry2) / 2f;

Matrix originTranslation = _Device.GetTransform(TransformState.World);
Matrix translationA = Matrix.Translation(-centerX, -centerY, 0);
Matrix rotation = Matrix.RotationZ(-rect.Rotation);
Matrix translationB = Matrix.Translation(centerX, centerY, 0);

Matrix result = translationA * rotation * translationB * originTranslation;

_Device.SetTransform(TransformState.World, result);
}


This is the full source code: http://pastebin.com/yDDuiZV1
I am happy for every improvement ideas =)

I think its the Orthographic Projection I'm using. If a Point of a Vertex would go over my Projection it wont show up I believe, but in OpenGL it does its really confusing and im stuck here

This topic is closed to new replies.

Advertisement