Archived

This topic is now archived and is closed to further replies.

RPTD

OGL forgets line?!

Recommended Posts

RPTD    340
i''ve tried to put in the 2d thingy using the methods describe elsewhere. so far points work without problems but lines are cranky. 1) the old rule of line not drawing the last point (common way) does not apply which makes it nasty to use it as a portable module (i can''t assume the line to look alike on different render modules like that) 2) sometimes OGL just forgets lines. for example if i render an etched box (to create the impression of a bevelled border) and i draw it top left corner of (0,0) it works. if i draw the same box at (0,5) it forgets the top line and the most left line... like they have never been there. there are coordinates the lines are drawn and others where they vanish. i suspect the problem coming from glOrtho which uses heavy fractions (2/width and alike) to create the matrix. looks to me like ogl cranks up my lines there. in DX you can write primitives directly to screen (using x,y,z,rhw) to bypass all troubles like projection matrix and alike. can I do same thing in OGL or do i have to live with vanishing lines?? for me this would be no acceptable solution though.

Share this post


Link to post
Share on other sites
PaulCesar    524
Set your project matrix to ortho, the size of the screen (instead o -1 to 1 make it something like 0 to 640 across. Then post it as though you are doing a normal scene, this will remove the problem

Share this post


Link to post
Share on other sites
RPTD    340
does not work.

my first glOrtho was:
glOrtho(x1, x2, y2, y1, -1, 1);

where (x1,y1)-(x2,y2) are the viewport coordinates (x:top-down, y:left-right)

even changing -1,1 like you stated does not help. the line just comes and goes depending what y offset i use.

Share this post


Link to post
Share on other sites
RPTD    340
additional infos about the troublesome lines.

i''ve defined (let''s say) a viewport from (0,10) to (100,110). now i draw using this 2d-line thingy a box around the limits of the viewport like this:
line (0,10) - (99,10)
line (99,10) - (99,109)
line (99,109) - (0,109)
line (0,109) - (0,0)

now the lines that tend to vanish depending on where i placed the viewport in y direction is the top line and the left line somtimes. can it be that the viewport is a bit picky about my line clipping it away?

or is it not a good idea to use glViewport to set the drawing area for my game internal 2d window? is that glScissor thingy better?

Share this post


Link to post
Share on other sites
RPTD    340
problem solved.

OGL clipped away the lines at the extends of the viewport because OGL uses the top-left corner of the pixel refered to by (x,y) to clip and at some points floating arithmetic inpreciseness caused the line to vanish.

i just moved the coordinates into the middle of the pixel and it worked, thus:
glVertex2f(x, y);
became
glVertex2f(x + 0.5, y + 0.5);

and the lines never disapeared again.

Share this post


Link to post
Share on other sites