Results 1 to 3 of 3

Thread: how to initial openg es with mfc, thank you

  1. #1
    Junior Member
    Join Date
    Nov 2009
    Posts
    2

    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;
    }

  2. #2
    Junior Member
    Join Date
    Oct 2009
    Location
    France
    Posts
    11

    Re: how to initial openg es with mfc, thank you

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

  3. #3
    Junior Member
    Join Date
    Nov 2009
    Posts
    2

    Re: how to initial openg es with mfc, thank you

    yes, you are right, thank you.

Similar Threads

  1. Initial version of Vincent SC available on Sourceforge
    By hmwill in forum OpenGL SC for Safety Critical Markets
    Replies: 2
    Last Post: 12-15-2008, 12:33 AM
  2. MFC and OPENGL ES initial problem?
    By cruccruc in forum OpenGL ES general technical discussions
    Replies: 2
    Last Post: 03-29-2006, 11:51 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •