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
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
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:
[b]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[/b]
[This message has been edited by Cerv36 (edited 02-07-2003).]