How to initial openg es with mfc, thank you

I creat a opengl es project with mfc. It can excute on arm, but looks that initialization is not successful. Anyone know, how can I initial opengl es with MFC. Thank you very much.

My code like follwing, if initialization is successful, the backgroud shoud be red, but now, it is white.

BOOL CSysEMView::InitOGLES()
{
EGLConfig configs[10];
EGLint matchingConfigs;

const EGLint configAttribs[] =
{
EGL_RED_SIZE, 5,
EGL_GREEN_SIZE, 6,
EGL_BLUE_SIZE, 5,
EGL_ALPHA_SIZE, EGL_DONT_CARE,
EGL_DEPTH_SIZE, 16,
EGL_STENCIL_SIZE, EGL_DONT_CARE,
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
EGL_NONE, EGL_NONE
};

hDC = ::GetWindowDC(m_hWnd);

glesDisplay = eglGetDisplay(hDC);

if(!eglInitialize(glesDisplay, NULL, NULL))
return FALSE;

if(!eglChooseConfig(glesDisplay, configAttribs, &configs[0], 10, &matchingConfigs))
return FALSE;

if (matchingConfigs < 1) return FALSE;

glesSurface = eglCreateWindowSurface(glesDisplay, configs[0], m_hWnd, configAttribs);
if(!glesSurface) return FALSE;

glesContext = eglCreateContext(glesDisplay,configs[0],0,configAttribs);
if(!glesContext) return FALSE;

eglMakeCurrent(glesDisplay, glesSurface, glesSurface, glesContext);

glClearColorx(FixedFromFloat(1.0f), FixedFromFloat(0.0f), FixedFromFloat(0.0f), 0);

glShadeModel(GL_SMOOTH);

RECT rect;
GetClientRect(&rect);
glViewport(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top);

glMatrixMode(GL_PROJECTION);
glLoadIdentity();

GLfloat ratio = (GLfloat)(rect.right - rect.left)/(rect.bottom - rect.top);
Perspective(45.0f,ratio, 1.0f, 40.0f);

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
return TRUE;
}

You must have a call to glClear(GL_COLOR_BUFFER_BIT) and eglSwapBuffers() in the method/callback/msgproc which draws window content.

yes, you are right, thank you.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.