Re: [PyOpenGL-Users] orthographic projection error
Brought to you by:
mcfletch
From: altern <al...@gm...> - 2006-12-14 09:00:55
|
hi greg Greg Ewing wrote: > altern wrote: >> The example draws a one pixel wide box in the borders of the window. >> In none of the sytems I tried so far the box was totally visible. >> There is always one or two sides missing just by one pixel. > > What coordinates are you using to draw the box, exactly? > You might need to offset them by half a pixel so that > the lines go through the centres of pixels. If you're > actually trying to draw a line between two pixels, > different systems may round it in different ways. This is the way i set the projection and draw the lines, being size=(800,600) in my example # the projection glOrtho(0, size[0], size[1], 0, 1, 0) # red marquee with diagonal lines cross glBegin(GL_LINE_LOOP) glColor3f(1,0,0) # glVertex2i(0,0) glVertex2i(size[0], size[1]) glVertex2i(0, size[1]) glVertex2i(size[0], 0) glVertex2i(0,0) # marquee glVertex2i(size[0], 0) glVertex2i(size[0], size[1]) glVertex2i(0, size[1]) glEnd() # end line loop I tried to replace all the 0 value in all vertexes by 0.5 but it doesnt work either. I also tried to change the glOrtho to glOrtho(0.5, size[0], size[1], 0.5, 1, 0) and also combining both with no luck. However if I set glOrtho like this glOrtho(-1, size[0], size[1]+1, 0, 1, 0) then it works fine on my Debian desktop and on my debian laptop but not on my laptop with XP. So I decided to do tests in all systems on my machines. This is the result: glOrtho(-1, size[0], size[1]+1, 0, 1, 0) works on Debian desktop with a matrox card works on Debian laptop with ATI glOrtho(-1, size[0], size[1]+1, -1, 1, 0) works on XP laptop with ATI glOrtho(-1, size[0]+1, size[1], 1, 0) works on XP Desktop with matrox card I also tested on and old mac ibook with ATI card running 10.4.8 and on that it works if i do glOrtho(0, size[0], size[1]+1, -1, 1, 0) Not very consistent. It seems to me that it might be more to do with the OS rather than with the cards themselves. The XP versions I am running are different but the Debian are pretty much the same. I attach my example in case anyone wants to test it out his/her machine. The glOrtho is on line 19 and i pasted different combinations of setup the glOrtho thanks! enrike |