Y axis flipped when running OpenGL application over surfaceless EGL without a native window system

zhigang gong <[email protected]>
Newsgroups gmane.comp.video.mesa3d.user
Message-ID <[email protected]>
I'm trying to create a surfaceless EGL context with drm support on
intel's i965 platform and then run OpenGL on it directly
without a native window system.

Here is my pseudo code:

fd = open("/dev/dri/card0");
eglGetDRMDisplayMESA(fd);
eglInitialize();
ctx = eglCreateContext();
eglMakeCurrent(dp, EGL_NO_SURFACE, EGL_NO_SURFACE, ctx);
eglCreateDRMImageMESA(dp, attribs);
eglExportDRM...  /*Get the image's buffer handle. */
/* Use that handle to create a FB by using drmAddFB. */
glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_2D, texture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, image);

glGenFramebuffersEXT(1, &fb);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,
                             GL_COLOR_ATTACHMENT0_EXT,
                             GL_TEXTURE_2D,
                             texture,
                             0);

glViewport(0, 0, (GLsizei) 1366, (GLsizei) 768);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, 1366, 0, 768,  -1.0, 1.0);

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

glClearColor(0.0, 1.0, 0.0, 0.0);
glShadeModel(GL_FLAT);
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0, 0.0, 0.0);
glRectf(0, 0, 16, 16 );
glFlush();
}

I just found that the red rectangle goes to the upper-left corner of
the screen.
But according to OpenGL's standard, it should be at lower-left corner. The
default originl in OpenGL should be at lower left. Right? It shows
that the Y axis is
flipped. Is there any body can give a clue on this issue? Is this somehow a
bug for mesa/EGL or I did something wrong here. Any suggestion is welcome.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.