OpenGL 2D innaccuracy

BlitzMax Forums/OpenGL Module/OpenGL 2D innaccuracy

JoshK(Posted 2005) [#1]
I am writing some 2D commands, and need to draw pixel-perfect lines, points, and rectangles.

Let's say the client area is 400x300, and I want to draw a line (0,0,400,0), across the very top of the viewport.

1) I set glViewport to 0,0,400,300.

2) I set glOrtho to -200,200,-150,150.

3) I draw a line ((Ax-200),(300-Ay-150),(Bx-200),(300-By-150)) or ((0-200),(300-0-150),(400-200),(300-0-150)).

The line is one pixel too high, and lies offscreen. If I make a line across the very bottom, it lies offscreen as well. What is the correct mathematical change I need to make so that I can draw an arbitrary size window and get pixel-perfect results?

Thanks.


AntonyWells(Posted 2005) [#2]
(Everything)-1.

Scientifically speaking.


Azathoth(Posted 2005) [#3]
.


boomboommax(Posted 2005) [#4]
o_O


Najdorf(Posted 2005) [#5]
!?


TeraBit(Posted 2005) [#6]
Doesn't the way you are defining the window mean that the client area is actually 401x301.

200 + 200 and the centre point at 0,0
150 + 150 and the centre point at 0,0

Unless I misunderstand what glOrtho is doing..


Hotcakes(Posted 2005) [#7]
So this isn't fullscreen? You can't trust windowed mode, it's not official (beta, alpha, or something).