ENIGMA Forums

General fluff => General ENIGMA => Topic started by: Goombert on July 27, 2013, 06:16:10 pm

Title: Half Pixel Alignment
Post by: Goombert on July 27, 2013, 06:16:10 pm
If any of you have ever worked with SVG or other vector graphics then you know you need to do half pixel alignment. OpenGL and DirectX work the same way. If nobody noticed, there was a bug where drawing an outlined rectangle wouldn't fill the pixel in each of its 4 corners, that was due to half pixel alignment.

I resolved this by changing the orthographic projection code to offset by half pixels instead of full pixels.
Code: [Select]
glOrtho(x-1,x + width,y-1,y + height,0,1);
Should have been...
Code: [Select]
glOrtho(x-0.5,x + width,y-0.5,y + height,0,1);

Anyway I am committing the fix soon and 2D stuff will no longer be misaligned or have edge artifacts. This was just a friendly reminder to everyone. Also be aware that DirectX9 eclusively has a half texel bug regarding sampling which must be resolved in a shader.
Title: Re: Half Pixel Alignment
Post by: TheExDeus on July 28, 2013, 05:26:04 am
This was also fixed by changing the drawing functions to have a half-pixel offset a few days ago.