# About eglGetDisplay Crash

**URL:** <https://forums.imgtec.com/t/about-eglgetdisplay-crash/880>\
**Category:** PowerVR Insider\
**Created:** [October 27, 2010, 12:58am UTC](https://forums.imgtec.com/t/about-eglgetdisplay-crash/880 "2010-10-27T00:58:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![wswqwps](https://avatars.discourse-cdn.com/v4/letter/w/a5b964/32.png) [@wswqwps](https://forums.imgtec.com/u/wswqwps)\
**Post date:** [October 27, 2010, 12:58am UTC](https://forums.imgtec.com/t/about-eglgetdisplay-crash/880/1 "2010-10-27T00:58:30Z")

</div>

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:  
  
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; WNDCLASS wcex;  
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; memset((void\*)&wcex, 0, sizeof(WNDCLASS));  
  
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; wcex.style&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; = 0;  
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; wcex.lpfnWndProc&nbsp;&nbsp;&nbsp; = (WNDPROC)WndProc;  
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; wcex.cbClsExtra&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; = 0;  
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; wcex.cbWndExtra&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; = 0;  
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; wcex.hInstance&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; = g\_Instance;  
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; wcex.hIcon&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; = SOS\_NULL;   
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; wcex.hCursor&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; = LoadCursor(0, IDC\_ARROW);   
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; wcex.hbrBackground&nbsp;&nbsp;&nbsp; = SOS\_NULL;  
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; wcex.lpszMenuName&nbsp;&nbsp;&nbsp; = SOS\_NULL;   
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; wcex.lpszClassName&nbsp;&nbsp;&nbsp; = g\_GameClass;   
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; RegisterClass(&wcex);&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;   
  
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // Create window  
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; int clientWidth = 0;  
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; clientWidth += GetSystemMetrics(SM\_CXBORDER) \* 2;  
  
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; int clientHeight = 0;  
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; clientHeight += GetSystemMetrics(SM\_CYCAPTION);  
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; clientHeight += GetSystemMetrics(SM\_CYBORDER) \* 2;  
  
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; g\_MainWnd = CreateWindow( g\_GameClass, g\_GameTitle,  
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; WS\_VISIBLE | WS\_SYSMENU | WS\_BORDER | WS\_CAPTION | WS\_CLIPCHILDREN | WS\_CLIPSIBLINGS,  
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; (GetSystemMetrics(SM\_CXSCREEN) - g\_GlobalRender-\>GetWidth() ) / 2,  
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; (GetSystemMetrics(SM\_CYSCREEN) - g\_GlobalRender-\>GetHeight()) / 2,  
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; g\_GlobalRender-\>GetWidth() + clientWidth,  
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; g\_GlobalRender-\>GetHeight() + clientHeight,  
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 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.
