Sign in to follow this  


Recommended Posts

When looking at 3D projections and transformations I was thinking on 3Dsmax, which has multiple viewports. So I've tried to get my own viewport with logical units -1 to 1.

Now I wonder if I'm using a modern way of setting up a viewport. I have found these functions on msdn but I have no idea if these are still used nowadays.

hDC = BeginPaint(hWnd, &ps);
GetClientRect(hWnd, &client);

SetViewportOrgEx(hDC, client.right/2, client.bottom/2, 0);
SetViewportExtEx(hDC, client.right, client.bottom, 0);
SetWindowOrgEx(hDC, 0, 0 ,0);
SetWindowExtEx(hDC, 2, 2, 0);

Rectangle(hDC, 0, 0, 1, 1);
EndPaint(hWnd, &ps);

This code sets up my window to 2 logical units, from -1 to 1. So like DirectX uses his viewport.
And I've changed the viewport extends so when I scale the window, the objects in the window are scaled also.

Share this post

Link to post
Share on other sites

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