Results 1 to 9 of 9

Thread: Open GLES application displays black screen

  1. #1
    Junior Member
    Join Date
    Apr 2012
    Posts
    10

    Open GLES application displays black screen

    Hi,
    I developed an Open GLES application to draw a triangle for ARM platform. The application is a win32 application.When i launched the application in my target device, a black screen is displayed. Any one please help me how to solve this problem.

    Thanks and Regards,
    Sowmya

  2. #2

    Re: Open GLES application displays black screen

    Can you post your code here? Cann't guess the exact problem with this much info

  3. #3
    Junior Member
    Join Date
    Apr 2012
    Posts
    10

    Re: Open GLES application displays black screen

    Hi ,

    Find my code:
    int WINAPI WinMain(HINSTANCE hInstance,
    HINSTANCE hPrevInstance,
    LPTSTR lpCmdLine,
    int nCmdShow)
    {
    MSG msg;
    WNDCLASS wc;

    hInst = hInstance;
    bool done = false;

    if(hWnd = FindWindow(szAppName,szAppName))
    {
    SetForegroundWindow((HWND)((ULONG) hWnd | 0x00000001));
    return 0;
    }

    wc.style = CS_HREDRAW | CS_VREDRAW;
    wc.lpfnWndProc = WndProc;
    wc.cbClsExtra = 0;
    wc.cbWndExtra = 0;
    wc.hInstance = hInstance;
    wc.hIcon = LoadIcon(hInstance, NULL);
    wc.hCursor = 0;
    wc.hbrBackground = 0;
    wc.lpszMenuName = NULL;
    wc.lpszClassName = szAppName;

    if(!RegisterClass(&wc))
    {
    return false;
    }
    hWnd = CreateWindow(szAppName,
    szAppName,
    WS_VISIBLE|WS_SYSMENU,
    200,
    150,
    400,
    200,
    NULL, NULL,
    hInst, NULL);
    if (!hWnd)
    {
    return FALSE;
    }
    if(!InitOGLES())
    {
    return FALSE;
    }
    ShowWindow(hWnd, nCmdShow);
    UpdateWindow(hWnd);
    while(!done)
    {
    if(PeekMessage(&msg,NULL,0,0,PM_REMOVE))
    {
    RETAILMSG(DEBUG,(_T("Entered13\r\n")));
    if(msg.message == WM_QUIT)
    {
    done = true;
    }
    else
    {
    TranslateMessage(&msg);
    DispatchMessage(&msg);
    }
    }
    else
    Render();
    }

    Clean();
    return 0;
    }

    LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
    {

    switch (message)
    {
    case WM_PAINT:
    ValidateRect(hWnd,NULL);
    break;
    case WM_DESTROY:
    PostQuitMessage(0);
    break;

    default:
    return DefWindowProc(hWnd, message, wParam, lParam);
    }
    return 0;
    }

    BOOL InitOGLES()
    {
    EGLConfig configs;
    EGLint matchingConfigs;

    const EGLint configAttribs[] =
    {
    EGL_RED_SIZE, 8,
    EGL_GREEN_SIZE, 8,
    EGL_BLUE_SIZE, 8,
    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
    };
    EGLint contextAttribs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE, EGL_NONE };

    hDC = GetDC(hWnd);

    glesDisplay = eglGetDisplay(hDC);

    eglInitialize(glesDisplay, NULL, NULL);
    assert(eglGetError() == EGL_SUCCESS);
    eglBindAPI(EGL_OPENGL_API);
    assert(eglGetError() == EGL_SUCCESS);
    eglChooseConfig(glesDisplay, configAttribs, &configs, 1, &matchingConfigs);
    assert(eglGetError() == EGL_SUCCESS);
    assert(matchingConfigs == 1);

    glesSurface = eglCreateWindowSurface(glesDisplay, configs, hWnd, NULL);
    assert(eglGetError() == EGL_SUCCESS);

    glesContext=eglCreateContext(glesDisplay,configs,N ULL,contextAttribs);
    assert(eglGetError() == EGL_SUCCESS);

    eglMakeCurrent(glesDisplay, glesSurface, glesSurface, glesContext);
    assert(eglGetError() == EGL_SUCCESS);
    glClearColorx(0, 0, 0, 0);
    glShadeModel(GL_SMOOTH);

    RECT r;
    GetWindowRect(hWnd, &r);
    glViewport(r.left, r.top, r.right - r.left, r.bottom - r.top);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrthox(FixedFromInt(-50), FixedFromInt(50),FixedFromInt(-50), FixedFromInt(50), FixedFromInt(-50), FixedFromInt(50));
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();

    return TRUE;
    }

    void Render()
    {
    static int rotation = 0;
    GLshort vertexArray[9] = {-25,-25,0, 25,-25,0, 0,25,0 };
    GLubyte colorArray[12] = {1,0,0,1, 0,1,0,1, 0,0,1,1};


    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glLoadIdentity();

    glTranslatex(0, 0, FixedFromInt(-10));
    glRotatex(FixedFromInt(rotation++), 0, ONE,0);

    glEnableClientState(GL_VERTEX_ARRAY);

    glVertexPointer(3, GL_SHORT, 0, vertexArray);

    glEnableClientState(GL_COLOR_ARRAY);

    glColorPointer(4,GL_UNSIGNED_BYTE, 0, colorArray);

    glDrawArrays(GL_TRIANGLES, 0, 3);

    glDisableClientState(GL_VERTEX_ARRAY);
    glDisableClientState(GL_COLOR_ARRAY);

    eglSwapBuffers(glesDisplay, glesSurface);
    }

    Regards,
    Sowmya

  4. #4

    Re: Open GLES application displays black screen

    As far as i can tell, you have cleared color buffer bit by calling glClear(GL_COLOR_BUFFER_BIT); But have not called glClearColor(0.25f,0.25f,0.5f,1.0f);
    glclear() clears the framebuffer with colors you have loaded. And you have to first load the colors by calling glClearColor().

    So add glClearColor(0.25f,0.25f,0.5f,1.0f); this call before glClear(GL_COLOR_BUFFER_BIT); . It will serve the purpose. Let me know, whether it clears your issue.

  5. #5
    Junior Member
    Join Date
    Apr 2012
    Posts
    10

    Re: Open GLES application displays black screen

    Hi,

    Thank you for the reply. I added glClearColor(0.25f,0.25f,0.5f,1.0f); but still the problem exists. Only black screen is displayed. Please give me some other suggestion.
    Note: OS iam used in the target device is WinCE 7.0. platform is iMX51.

    Thanks and Regards,
    Sowmya

  6. #6

    Re: Open GLES application displays black screen

    hmm.. I think that code needs debugging.
    Actually, i don't have windows platform to do it. If possible send me linux port of app.

    Try by removing glviewport() and glclearcolorx() call in your code.


    Regards,
    debinar

  7. #7
    Junior Member
    Join Date
    Apr 2012
    Posts
    10

    Re: Open GLES application displays black screen

    sorry.I don't have linux port of the application

  8. #8

    Re: Open GLES application displays black screen

    Is your issue solved..?
    Can you try by adding " EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT," in array "const EGLint configAttribs[].

  9. #9
    Junior Member
    Join Date
    Apr 2012
    Posts
    10

    Re: Open GLES application displays black screen

    Hi,

    My issue got solved. There is no enough memory in the system. I increased the memory then it started working.

    Regards,
    Sowmya

Similar Threads

  1. Open gles 2.0 object collision
    By nrgarach in forum OpenGL ES general technical discussions
    Replies: 5
    Last Post: 10-18-2012, 12:57 AM
  2. Screen Freezes and black screen during game execution on Win
    By Leena in forum OpenGL ES 2X - for programmable 3D graphics pipelines
    Replies: 0
    Last Post: 07-29-2009, 11:54 AM

Posting Permissions

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