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: glDrawPixels() --- inverted pixmap

  1. #1
    Junior Member Newbie
    Join Date
    Feb 2003
    Posts
    9

    glDrawPixels() --- inverted pixmap

    Hello, I am new to OpenGL and am trying to display pixmaps (*.ppm format) from a disk. I read the data from the disk into an array okay and get it to display, but the image is upside-down. I know that this is how it is stored on the disk, but I was wondering if there is anyway to flip the image with the glDrawPixel() method.
    The OpenGL Super Bible says that: "You can specify a negative height to invert the display." But if I put a minus sign in front of the height parameter, NO image appears.
    Any help would be much apprecated!!
    Bob

  2. #2
    Senior Member OpenGL Pro
    Join Date
    May 2001
    Location
    Kristianstad,Skåne,Sweden
    Posts
    1,595

    Re: glDrawPixels() --- inverted pixmap

    Hi !

    You have to change the Y position for the image too, if you have a negative height you have to change to Y position to the other end of the image.

    Mikael

  3. #3
    Junior Member Newbie
    Join Date
    Feb 2003
    Posts
    9

    Re: glDrawPixels() --- inverted pixmap

    Hello Mikael,
    I appreciate your reply, but am uncertain what you mean by "changing the y-position". Sorry, I am a complete novice at this!! I included the source code I am using -- I based it on an example I have. I didn't see anything about moving the y-position in the book either; I may just not be looking in the right place. Thank you so much for your help.
    Bob


    void init_window(int argc, char**argv)
    {
    glutInit(&argc, argv); //initialize GLUT
    glutInitDisplayMode(GLUT_RGB); //specify display mode

    glutInitWindowSize(500, 400); //set window size
    glutInitWindowPosition(0,0); //set window position
    glutCreateWindow("CS 590 Project 1"); //create window--arg is the title
    }//end init_window()


    //Initializes other aspects
    void other_init()
    {
    glClearColor(1.0, 1.0, 1.0, 1.0); //Set background color
    glMatrixMode(GL_PROJECTION); //Modify Projection Matrix
    glLoadIdentity(); //set identity matrix
    glOrtho(-2040, 2040, -2040, 2040, -1.0, 1.0); //Orthographic view volume

    //glMatrixMode(GL_MODELVIEW); //Modify Model View in all following commands

    }//end other_init()


    //Sets the display values and draws the lines
    void display(void)
    {
    glClear(GL_COLOR_BUFFER_BIT); //clear color values
    glColor3f(0.5, 0.0, 0.9); //set forground color
    glLineWidth(2.0); //set line width
    //glPointSize(4.0);
    glDrawPixels(imageWidth, imageHeight, GL_RGB, GL_UNSIGNED_BYTE, pixArray);

    glEnd();

    glFlush(); //clear the buffer

    }//end display()

    Originally posted by mikael_aronsson:
    Hi !

    You have to change the Y position for the image too, if you have a negative height you have to change to Y position to the other end of the image.

    Mikael


    [This message has been edited by Cerv36 (edited 02-07-2003).]

Posting Permissions

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