Hi All,

Alex Reche <[EMAIL PROTECTED]> submitted this directly to me, but because I'm
not finished doing the Win32 build subdirectory updates I haven't yet checked
it for validity with the current code base, so I thought I'd pass it onto the
proper list to make sure it didn't fall through the cracks if it hadn't yet
been dealth with.

PS: I have not checked my OpenGL ref's to make sure I know what the "proper"
behavior is either, should there be any spec'd.

-Ted

--cut here for original message---

    Hello, my name is Alex, and I'm a spanish student in France. I'm
making a project that uses Mesa and I think that a found a bug.
    When I try to make two windows and copy the image of one to the
other, with glReadPixels and glDrawPixels y have the image reversed...
    I use Windows NT and the version 3.0 of Mesa.

With this code you have the error:
======================================
#include <GL/glut.h>

char image[4*256*256];

void glReadPixelsDisplayFunc(void) {
 glClearColor(0.0, 0.0, 0.0, 0.0);
 glClear (GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
 glColor3f (1.0, 1.0, 1.0);
 glEnable(GL_LINE_STIPPLE);
 glBegin(GL_LINE_STRIP);
  glVertex3f(0.5,0.5,0.5);
  glVertex3f(-0.5,-0.5,-0.5);
 glEnd();
 glFlush();
 glReadPixels(0,0,256,256,GL_RGBA, GL_UNSIGNED_BYTE,image);
 glutSwapBuffers();
}

void glDrawPixelsDisplayFunc(void) {
 glDrawPixels(256,256,GL_RGBA, GL_UNSIGNED_BYTE,image);
 glutSwapBuffers();
}

void ReshapeFunc(int w, int h) {
 w;h;
 glutReshapeWindow(256,256);
 glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
  gluOrtho2D(-1, 1, -1, 1);
 glMatrixMode(GL_MODELVIEW);
  glLoadIdentity();
 glViewport(0,0,256,256);
}

int main(int argc, char **argv) {

 glutInit(&argc, argv);
 glutInitWindowPosition(256,256);
 glutInitWindowSize(256,256);
 glutInitDisplayMode(GLUT_RGBA | GLUT_DEPTH | GLUT_DOUBLE);

 // Window for glReadPixels
 glutCreateWindow("glReadPixels");
 glutDisplayFunc(glReadPixelsDisplayFunc);
 glutReshapeFunc(ReshapeFunc);

 glutInitWindowPosition(520,256);

 // Window for glDrawPixels
 glutCreateWindow("glDrawPixels");
 glutDisplayFunc(glDrawPixelsDisplayFunc);
 glutReshapeFunc(ReshapeFunc);

 glutMainLoop();
}
==============================================

To fix the error I have modify one line in the wmesa.c file.

    In the line 1074 I have change:

        Color = GetPixel(DC, x+i, y);

    by:

        Color = GetPixel(DC, x+i, ctx->Buffer->Height - y - 1);

I don't know if this is the solution, but is the only that I can find...

    Please, say me how to solve this error or if my solution if good.

        Thanks
                Alex.

Reply via email to