# Change win32 origin?

## Recommended Posts

Hi

Win32 has the top left corner as the origin. I want the bottom left corner to be the origin as my raytracer defines the view place by bottom left.

When i render, my sky gradient is upside down for example because of this.

I have tried: SetViewportOrgEx(hdc, 0, height, NULL);

But it does nothing.

Any help would be greatly appreciated.

Thanks

##### Share on other sites

I'm not sure if there are such abilities in the Win32 API.

But for sure you could just revert it yourself by the code with few overhead:

void drawPixel(int x, int y, Vec3 color)
{
someW32PrintPixel(x, viewportHeight-y, color.rgb);
}


##### Share on other sites

Thanks, but i figured it out.

SetMapMode(hdc, MM_ISOTROPIC);
SetViewportOrgEx(hdc, 0, height, NULL);
SetWindowExtEx(hdc,1, -1,NULL);
SetViewportExtEx(hdc,1, 1,NULL);


Sets the y axis origin  to the bottom then flips the y axis.

## Create an account

Register a new account

• ## Partner Spotlight

• ### Forum Statistics

• Total Topics
627651
• Total Posts
2978406

• 10
• 12
• 22
• 13
• 33