Here is the completed version of CreateDloWindow
BOOL CreateDloWindow ( HWND& hWnd , HDC hDC , HGLRC hRC , const uint32 width , const uint32 height , const bool isFullScreen ){ uint32 PixelFormat ; WNDCLASS wc ; DWORD dwExstyle ; DWORD dwstyle ; RECT WindowRect ; WindowRect.left = ( uint32 ) 0 ; WindowRect.right = ( uint32 ) width ; WindowRect.top = ( uint32 ) 0 ; WindowRect.bottom = ( uint32 ) height ; dlo :: Memory_Set ( &wc , 0 , sizeof ( WNDCLASS ) ) ; HINSTANCE hInst = GetModuleHandle ( NULL ) ; wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC ; wc.lpfnWndProc = ( WNDPROC ) WndProc ; wc.cbClsExtra = 0 ; wc.cbWndExtra = 0 ; wc.hInstance = hInst ; wc.hbrBackground = NULL ; wc.lpszMenuName = NULL ; wc.lpszClassName = TEXT ( "OpenGL" ) ; if ( !RegisterClass ( &wc ) ) { dlo :: DloLog :: print ( "Failed to register window class." ) ; return FALSE ; } if ( isFullScreen ) { DEVMODE dmScreenSettings ; dlo :: Memory_Set ( &dmScreenSettings , 0 , sizeof ( dmScreenSettings ) ) ; dmScreenSettings.dmSize = sizeof ( dmScreenSettings ) ; dmScreenSettings.dmPelsWidth = width ; dmScreenSettings.dmPelsHeight = height ; dmScreenSettings.dmBitsPerPel = 8 ; dmScreenSettings.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT ; if ( ChangeDisplaySettings ( &dmScreenSettings , CDS_FULLSCREEN ) != DISP_CHANGE_SUCCESSFUL ) { dlo :: DloLog :: print ( "Your video card do not support full screen." ) ; return FALSE ; } dwExstyle = WS_EX_APPWINDOW; dwstyle = WS_POPUP ; } else { dwExstyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE ; dwstyle = WS_OVERLAPPEDWINDOW ; } AdjustWindowRectEx ( &WindowRect , dwstyle , FALSE , dwExstyle ) ; if ( !( hWnd= CreateWindowEx ( dwExstyle, TEXT ( "OpenGL" ) , TEXT ( "Shadow Mapping" ) , dwstyle | WS_CLIPSIBLINGS | WS_CLIPCHILDREN , 0 , 0 , WindowRect.right - WindowRect.left , WindowRect.bottom - WindowRect.top , NULL , NULL , hInst , NULL ) ) ) { DestroyDloWindow ( hWnd , hDC , hRC ) ; dlo :: DloLog :: print ( "Window Creation Error." ) ; return FALSE ; } static PIXELFORMATDESCRIPTOR pfd = // pfd Tells Windows How We Want Things To Be { sizeof ( PIXELFORMATDESCRIPTOR ) , // Size Of This Pixel Format Descriptor 1, // Version Number PFD_DRAW_TO_WINDOW | // Format Must Support Window PFD_SUPPORT_OPENGL | // Format Must Support OpenGL PFD_DOUBLEBUFFER, // Must Support Double Buffering PFD_TYPE_RGBA, // Request An RGBA Format 8 , // Select Our Color Depth 0, 0, 0, 0, 0, 0, // Color Bits Ignored 0, // No Alpha Buffer 0, // Shift Bit Ignored 0, // No Accumulation Buffer 0, 0, 0, 0, // Accumulation Bits Ignored 32, // 32Bit Z-Buffer (Depth Buffer) 0, // No Stencil Buffer 0, // No Auxiliary Buffer PFD_MAIN_PLANE, // Main Drawing Layer 0, // Reserved 0, 0, 0 // Layer Masks Ignored }; if ( !( hDC = GetDC ( hWnd ) ) ) { DestroyDloWindow ( hWnd , hDC , hRC ) ; dlo :: DloLog :: print ( "Can't Create A GL Device Context." ) ; return FALSE ; } if ( !( PixelFormat = ChoosePixelFormat ( hDC , &pfd ) ) ) { DestroyDloWindow ( hWnd , hDC , hRC ) ; dlo :: DloLog :: print ( "Can't Find A Suitable PixelFormat." ) ; return FALSE ; } if ( !SetPixelFormat ( hDC , PixelFormat , &pfd ) ) { DestroyDloWindow ( hWnd , hDC , hRC ) ; dlo :: DloLog :: print ( "Can't Set The PixelFormat." ) ; return FALSE ; } if ( !( hRC = wglCreateContext ( hDC ) ) ) { DestroyDloWindow ( hWnd , hDC , hRC ) ; dlo :: DloLog :: print ( "Can't Create A GL Rendering Context." ) ; return FALSE ; } if ( !wglMakeCurrent ( hDC , hRC ) ) { DestroyDloWindow ( hWnd , hDC , hRC ) ; dlo :: DloLog :: print ( "Can't Activate The GL Rendering Context." ) ; return FALSE ; } ShowWindow ( hWnd , SW_SHOW ) ; SetForegroundWindow ( hWnd ) ; SetFocus ( hWnd ) ; InitRenderSystem ( width , height ) ; ReSizeDloWindow ( width , height ) ; return TRUE ;}
[Edited by - duoluoxianzhi on January 4, 2011 7:01:07 AM]