PDA

View Full Version : OpenGL points and lines



rapademic
01-02-2013, 04:34 PM
Here is the version information of OpenGL I am using

OpenGL version: 3.1.0 - Build 8.15.10.2559
OpenGL vendor: Intel
OpenGL renderer: Intel(R) HD Graphics Family

The following code in my display callback is:
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0f, 1.0f, 1.0f);
glBegin(GL_POINTS);
for(int r = 1; r < 250; ++r)
{
glVertex2i(2, r);
}
glEnd();

glColor3f(1.0f, 0.0f, 0.0f);
glBegin(GL_LINES);
glVertex2i(2, 1);
glVertex2i(2, 249);
glEnd();

This code should draw one line on top of the other but it renders the red line to the left of the white line. Can anyone explain this? Thanks.

thokra
01-03-2013, 01:58 AM
First of all, please read the forum rules on how to format your posts - especially pieces of code.

Can you post a screen shot of what's rendered?

rapademic
01-03-2013, 09:32 AM
No, I do not seem to have permission to attach files. Verbally this is what displays.
Bottom row of image: background
Next row of image: background pixel, red pixel, white pixel, background pixel, ...
Next row of image: background pixel, red pixel, white pixel, background pixel, ...
...

Horizontal lines do not have this offset problem, however I get one more horizontal point compared to plotting a line with the same coordinates.