I am amidst porting OGLES to Linux. I have made some good progress. When I do eglGetDisplay() I am passing the parameter of ‘(void*)"/dev/fb/0"’. The function succeeds, if I pass a parameter of NULL, the function fails. (any comments yet?)
I go thru the subsequent steps of setting up EGL and I clear the COLOR_BUFFER_BIT. In my egl.cpp, I modified my glSwapBuffers() to write the color buffer to a file. My mode is RGB565. I am able to copy this file into “/dev/fb/0” via a terminal, and voila!, my cleared color is displayed on the LCD.
But, if I try to draw a polygon and then display it using the above method, it still has only the cleared color.
Code:
int main(int argc, char** argv)
{
EGLConfig myConfig;
static const char sAppName[] =
"OpenGL Test (Linux)";
static EGLConfig sEglConfig;
EGLBoolean success;
EGLint numConfigs;
EGLint majorVersion;
EGLint minorVersion;
EGLint num_config = 1;
EGLint attrib_list[] = { EGL_ALPHA_SIZE, 0, EGL_RED_SIZE, 5,
EGL_GREEN_SIZE, 6, EGL_BLUE_SIZE, 5, EGL_DEPTH_SIZE, 16,
EGL_SURFACE_TYPE, EGL_WINDOW_BIT, EGL_NONE };
EGLDisplay m_eglDisplay = EGL_NO_DISPLAY;
EGLSurface m_eglSurface = EGL_NO_SURFACE;
EGLContext m_eglContext = EGL_NO_CONTEXT;
printf("Trying to get Display!
");
m_eglDisplay = eglGetDisplay((void*)"/dev/fb/0");
if (m_eglDisplay == EGL_NO_DISPLAY || eglGetError() != EGL_SUCCESS)
printf("It failed up on eglGetDisplay!
");
else
printf("It passed on eglGetDisplay!
");
printf("Trying to initialize the Display!
");
if (eglInitialize(m_eglDisplay, 0, 0) == EGL_FALSE || eglGetError() != EGL_SUCCESS)
printf("It failed up on initializing eglGetDisplay!
");
else
printf("It passed on initializing eglGetDisplay!
");
if (success != EGL_FALSE)
success = eglGetConfigs(m_eglDisplay, NULL, 0, &num_config);
if (success != EGL_FALSE)
success = eglChooseConfig(m_eglDisplay, attrib_list, &myConfig, 1, &num_config);
printf("Trying to get Context!
");
m_eglContext = eglCreateContext(m_eglDisplay, myConfig, 0, 0);
if (m_eglContext == EGL_NO_CONTEXT || eglGetError() != EGL_SUCCESS)
printf("It failed up on eglCreateContext!
");
else
printf("It passed on eglCreateContext!
");
m_eglSurface = eglCreateWindowSurface(m_eglDisplay, myConfig, 0, 0);
printf("Trying to get Surface!
");
if (m_eglSurface == EGL_NO_SURFACE || eglGetError() != EGL_SUCCESS)
printf("It failed up on eglCreateWindowSurface!
");
else
printf("It passed on eglCreateWindowSurface!
");
eglMakeCurrent(m_eglDisplay, m_eglSurface, m_eglSurface, m_eglContext);
const static GLfloat v[] = {
0.25, 0.25, 0.0,
0.75, 0.25, 0.0,
0.25, 0.75, 0.0,
0.75, 0.75, 0.0
};
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrthof(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
glVertexPointer(3, GL_FLOAT, 0, v);
glEnableClientState(GL_VERTEX_ARRAY);
/// display graphic ///
glClearColor(0.0, 1.0, 0.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT);
glColor4f (1.0, 0.0, 0.0, 1.0);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
/////
glFlush();
eglSwapBuffers(m_eglDisplay, m_eglSurface); // actually write to the RGB 16-bit file
return 0;
}