• 11
• 9
• 11
• 9
• 11

# Change win32 origin?

This topic is 606 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## 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.