Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: OpenGL points and lines

  1. #1
    Newbie Newbie
    Join Date
    Jan 2013
    Posts
    2

    OpenGL points and lines

    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.
    Last edited by rapademic; 01-03-2013 at 09:06 AM.

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Apr 2010
    Location
    Germany
    Posts
    1,099
    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?

  3. #3
    Newbie Newbie
    Join Date
    Jan 2013
    Posts
    2
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •