Imagination PowerVR SDK Blog

About eglGetDisplay Crash


#1

Hi all, in my code, I wrote:

m_EGLDisplay = eglGetDisplay((NativeDisplayType)EGL_DEFAULT_DISPLAY);

But when I run it the program carshed and said “Microsoft C++ exception: std::runtime_error at memory location 0x0012fb04” but does not give extra useful info. I alreay created my window with code below:

        WNDCLASS wcex;
        memset((void*)&wcex, 0, sizeof(WNDCLASS));

        wcex.style            = 0;
        wcex.lpfnWndProc    = (WNDPROC)WndProc;
        wcex.cbClsExtra        = 0;
        wcex.cbWndExtra        = 0;
        wcex.hInstance        = g_Instance;
        wcex.hIcon            = SOS_NULL;
        wcex.hCursor        = LoadCursor(0, IDC_ARROW);
        wcex.hbrBackground    = SOS_NULL;
        wcex.lpszMenuName    = SOS_NULL;
        wcex.lpszClassName    = g_GameClass;
        RegisterClass(&wcex);       

        // Create window
        int clientWidth = 0;
        clientWidth += GetSystemMetrics(SM_CXBORDER) * 2;

        int clientHeight = 0;
        clientHeight += GetSystemMetrics(SM_CYCAPTION);
        clientHeight += GetSystemMetrics(SM_CYBORDER) * 2;

        g_MainWnd = CreateWindow( g_GameClass, g_GameTitle,
            WS_VISIBLE | WS_SYSMENU | WS_BORDER | WS_CAPTION | WS_CLIPCHILDREN | WS_CLIPSIBLINGS,
            (GetSystemMetrics(SM_CXSCREEN) - g_GlobalRender->GetWidth() ) / 2,
            (GetSystemMetrics(SM_CYSCREEN) - g_GlobalRender->GetHeight()) / 2,
            g_GlobalRender->GetWidth() + clientWidth,
            g_GlobalRender->GetHeight() + clientHeight,
            SOS_NULL, SOS_NULL, g_Instance, SOS_NULL);

And the g_MainWnd is a non-null value. So anyone know how this happen or give any tips? Thanks in advance.