PDA

View Full Version : Problem about line rasterization



codewings
02-20-2012, 06:59 PM
Hi, I created a simple opengl program and want to draw a simple line by using the following code
glBegin(GL_LINES);
glVertex2f(0.0f, 0.0f);
glVertex2f(100.0f, 0.0f);
glEnd();
but there is nothing and if I changed the code a bit
glBegin(GL_LINES);
glVertex2f(0.0f, 0.0f);
glVertex2f(100.0f, 0.01f);
glEnd();
I can got a straight line on the bottom of the window.

I am a newbie to opengl, so can anyone explain the reason? Thanks in advance

tksuoran
02-23-2012, 01:50 AM
Since the first line start and end is at the border of the screen, the first line is in risk to be clipped.

Draw lines from pixel centre to pixel centre - so offset by half a pixel up and start and end points to right and left.