Results 1 to 5 of 5

Thread: Weird Problem !!!

  1. #1
    Junior Member Newbie
    Join Date
    Oct 2002
    Posts
    9

    Weird Problem !!!

    Hi, im a newbie on OpenGL and what im trying to do is to render a square with 2 for-loops setting it pixel by pixel. The problem is that when i render it on some coordinates it works just fine but i have discovered that i get one horizontal and one vertical line going through the rectangle. I am doing this in XOR-mode and i need to keep doing that.

    Pleas, please help me with this weird problem. Listed below is all my code.
    --------------------
    #include <GL/glut.h>
    #include <windows.h>
    void myinit(void)
    {
    glClearColor(0.0, 0.0, 0.0, 0.0);
    glColor3f(1.0, 1.0, 1.0);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluOrtho2D(0.0, 500.0, 0.0, 500.0);
    glMatrixMode(GL_MODELVIEW);

    //enable XOR'ing
    glEnable(GL_COLOR_LOGIC_OP);
    glLogicOp(GL_XOR);
    }
    void display( void )
    {
    glClear(GL_COLOR_BUFFER_BIT);
    glBegin(GL_POINTS);
    for(int y = 100; y <= 300; y++)
    {
    for(int x = 200; x <= 400; x++)
    {
    glVertex2i(x, y);
    }
    }
    glEnd();
    glFlush(); /* clear buffers */
    }
    void main(int argc, char** argv)
    {
    /* Standard GLUT initialization */
    glutInit(&argc,argv);
    glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
    glutInitWindowSize(500,500);
    glutInitWindowPosition(0,0); glutCreateWindow("Test");
    glutDisplayFunc(display);

    myinit(); /* set attributes */

    glutMainLoop(); /* enter event loop */
    }

  2. #2
    Member Contributor
    Join Date
    Nov 2001
    Location
    Ireland
    Posts
    93

    Re: Weird Problem !!!

    Do you need to do it GL_POINTS?

  3. #3
    Junior Member Newbie
    Join Date
    Oct 2002
    Posts
    9

    Re: Weird Problem !!!

    Yes I do. This is just a simpler test but i have other drawinfunctions that in time will make up 3d-renering engine. So it has to be in points when im rendering my objects.

    Anyway, im starting to suspect that this problem that im having lies in my 3d-card. Im not sure yet though.

  4. #4
    Member Contributor
    Join Date
    Nov 2001
    Location
    Ireland
    Posts
    93

    Re: Weird Problem !!!

    Isnt there a GL_LINE_WIDTH eviqualent for points?
    Set that to 1.0 which it already probably is.

  5. #5
    Senior Member Regular Contributor
    Join Date
    Oct 2001
    Location
    Holland
    Posts
    179

    Re: Weird Problem !!!

    Take a closer look at your glOrtho setup.
    IIRC you should do a very small translation in the x and y direction ( 0.5, 0.5) or (0.375, 0.375) to make sure your OpenGL coordinates will correctly and reliably map to pixels in your window. This has to do with internal rounding errors.

    HTH

    Jean-Marc.

Similar Threads

  1. A very weird problem...
    By Nimrod in forum OpenGL: Windows
    Replies: 3
    Last Post: 12-30-2004, 07:11 AM
  2. Weird CVA Problem
    By nostgard in forum OpenGL: Advanced Coding
    Replies: 3
    Last Post: 05-20-2003, 02:53 PM
  3. Weird Problem
    By raverbach in forum OpenGL: Advanced Coding
    Replies: 2
    Last Post: 03-26-2003, 05:38 AM
  4. weird problem
    By in forum OpenGL: Basic Coding
    Replies: 6
    Last Post: 03-23-2003, 10:14 AM
  5. Weird GL_QUAD problem
    By janhorn in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 01-23-2002, 05:47 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean