Problem creating Rendering Context
The code I use right now for setting up OpenGL works just fine on my system. But recently I noticed that when I run it on another, much slower system (300 Mhz Celeron with onboard graphics chip), I can only run in windowed mode, not in fullscreen. Since I only want to run on my system for the time being, it is not that bad, but eventually I''ll want to get rid of this problem. I think it is rather strange the program runs on other, faster systems. I have no clue about what can be wrong, so any suggestions will be highly appreciated, as usual
See you!
Do you use the code from a lesson ? If so, which lesson ?
Also, I''d recommend the standard thing : download the latest drivers for your video card.
We should create an acronym for this, shouldn''t we ?
Also, I''d recommend the standard thing : download the latest drivers for your video card.
We should create an acronym for this, shouldn''t we ?
What graphics card does the other (slower) machine have? And you''d need to post the window creation code etc for anyone to help you!
here is the code for my window creation function:
I have the latest drivers for my videocard. If you need any more code, just tell me but I try not to post too much unnecessary code. thnx!
int COGLWnd::CreateGLWnd(void){ InitGLWnd(); // initialize necessary parameters DWORD GLe_dwStyle; // window style DWORD GLe_dwExStyle; // window extended style unsigned int GLe_PixelFormat; // pixel format if (!RegisterClass(&WndClass)) // try to register the window class { if (GLe_ErrorMsg) { MessageBox( NULL,"Could not register WndClass.", "Error creating the window!", MB_ICONEXCLAMATION | MB_OK ); } return 1; } if (GLe_Fullscr) // if fullscreen mode requested { DEVMODE dmScreenSettings; // store screen settings in here memset(&dmScreenSettings,0,sizeof(dmScreenSettings)); // clear the memory dmScreenSettings.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT; // flaggs for members that are initialized dmScreenSettings.dmBitsPerPel = GLe_Bits; // set number of bits per pixel dmScreenSettings.dmPelsWidth = GLe_WndWidth; // set width dmScreenSettings.dmPelsHeight = GLe_WndHeight; // set height dmScreenSettings.dmSize = sizeof(dmScreenSettings); // set the size of the struct if (ChangeDisplaySettings(&dmScreenSettings, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL) { // try to change display settings if (GLe_ErrorMsg) // if errormsg required... { MessageBox( NULL, "Error changing display settings.", "Error creating window!", MB_OK | MB_ICONEXCLAMATION ); // pop up error message } return 2; // error code for unsuccessful settingchange } GLe_dwStyle = WS_POPUP; // no borders around a pop-up, we need that! GLe_dwExStyle = WS_EX_APPWINDOW; // force window on taskbar ShowCursor(FALSE); // hide the cursor } else // if windowed mode requested { GLe_dwStyle = WS_OVERLAPPEDWINDOW; // create overlapped window GLe_dwExStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE; // make raised edge around appwindow } AdjustWindowRectEx(&WndRect,GLe_dwStyle,FALSE,GLe_dwExStyle); // adjust the window size if (!(GLe_hWnd = CreateWindowEx( GLe_dwExStyle, GLe_WndClass, GLe_Title, GLe_dwStyle | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, 0, 0, WndRect.right-WndRect.left, WndRect.bottom-WndRect.top, 0, 0, GLe_hInstance, 0 ))) // create the window requested { KillGLWnd(); // kill GL window if (GLe_ErrorMsg) // if errormsg required... { MessageBox( NULL, "Error calling CreateWindowEx.", "Error creating the window!", MB_OK | MB_ICONEXCLAMATION ); // pop up error message if required } return 3; // error code for creating the window } if (!(GLe_hDC = GetDC(GLe_hWnd))) // try to get a Device Context { KillGLWnd(); // kill GL window if (GLe_ErrorMsg) // if errormsg required { MessageBox( NULL, "Could not get a Device Context.", "Error creating the window!", MB_OK | MB_ICONEXCLAMATION ); // pop up message } return 4; // error code for getting a DC } if (!(GLe_PixelFormat = ChoosePixelFormat(GLe_hDC,&GLe_pfd))) { // try to find a pixel format KillGLWnd(); // kill GL window if (GLe_ErrorMsg) // if errormsg required { MessageBox( NULL, "Could not find a pixel format.", "Error creating the window!", MB_OK | MB_ICONEXCLAMATION ); // pop up message } return 5; // error code for finding a pixel format } if (!(SetPixelFormat(GLe_hDC,GLe_PixelFormat,&GLe_pfd))) { // try to set the pixel format KillGLWnd(); // kill GL window if (GLe_ErrorMsg) // if errormsg required { MessageBox( NULL, "Could not set the pixel format.", "Error creating the window!", MB_OK | MB_ICONEXCLAMATION ); // pop up message } ProgEnd = true; return 6; // error code for setting the pixel format } if (!(GLe_hRC = wglCreateContext(GLe_hDC))) // try to create a Rendering Context { KillGLWnd(); // kill GL window if (GLe_ErrorMsg) // if errormsg required { MessageBox( NULL, "Could not create a Rendering Context.", "Error creating the window!", MB_OK | MB_ICONEXCLAMATION ); // pop up message } return 7; // error code for creating RC } if (!(wglMakeCurrent(GLe_hDC,GLe_hRC))) // try to activate RC { KillGLWnd(); // kill GL window if (GLe_ErrorMsg) // if errormsg required { MessageBox( NULL, "Could not activate the Rendering Context.", "Error creating the window!", MB_OK | MB_ICONEXCLAMATION ); // pop up message } return 8; // error code for activating RC } ShowWindow(GLe_hWnd, SW_SHOW); // show the window SetForegroundWindow(GLe_hWnd); // set window to the foreground SetFocus(GLe_hWnd); // set focus to the window ResizeGLWnd(GLe_WndWidth,GLe_WndHeight,GLe_Perspective); InputSys = new CInput; // create new input system object if (!InputSys->Init(GLe_hWnd,GLe_hInstance,I_KEYBOARD)) { // try to initialize input system if (GLe_ErrorMsg) { // pop up message MessageBox( NULL,"Error initializing the input system.", "Error calling InputSys->Init !", MB_ICONEXCLAMATION | MB_OK ); } return 9; // error code for initializing input system } GLe_InputOK = true; // inputsystem available return 0; // error code if no errors}int COGLWnd::KillGLWnd() { if (GLe_Fullscr) // check if we are in fullscreen mode { ChangeDisplaySettings(NULL,0); // go back to previous mode, i.e. desktop ShowCursor(TRUE); // show the cursor again } if (GLe_hRC) // check if we have a RC { if ((!wglMakeCurrent(NULL, NULL)) && GLe_ErrorMsg) { // try to release the RC MessageBox( NULL, "Error releasing the Rendering Context.", "Error destroying the window!", MB_OK | MB_ICONEXCLAMATION ); // pop up error message } if ((!wglDeleteContext(GLe_hRC)) && GLe_ErrorMsg) { // try to delete the RC MessageBox( NULL, "Error deleting the Rendering Context.", "Error destroying the window!", MB_OK | MB_ICONEXCLAMATION ); // pop up error message } GLe_hRC = NULL; // delete the RC } if (GLe_hDC && !ReleaseDC(GLe_hWnd,GLe_hDC) && GLe_ErrorMsg) { // try to release DC if one MessageBox( NULL, "Error releasing Device Context.", "Error destroying the window!", MB_OK | MB_ICONEXCLAMATION ); // pop up error message GLe_hDC = NULL; // delete DC } if (GLe_hWnd && !DestroyWindow(GLe_hWnd) && GLe_ErrorMsg) { // destroy hWnd if one MessageBox( NULL, "Error releasing the window handle.", "Error destroying the window!", MB_OK | MB_ICONEXCLAMATION ); // pop up error message GLe_hWnd = NULL; // delete window handle } if (!UnregisterClass(GLe_WndClass,GLe_hInstance) && GLe_ErrorMsg) { // try to unregister class MessageBox( NULL, "Error unregistering window class.", "Error destroying window!", MB_OK | MB_ICONEXCLAMATION ); // pop up error message GLe_hInstance = NULL; // delete application instance } if (GLe_InputOK) // if inputsystem availble { if (!InputSys->ShutDown()) { // try to shut down input system if (GLe_ErrorMsg) { // pop up error message MessageBox( NULL,"Error shutting down input system", "Error calling InputSys->ShutDown !", MB_ICONEXCLAMATION | MB_OK ); } return 10; // error code for input system shutdown } delete InputSys; // destroy InputSys object GLe_InputOK = false; // Inputsystem no longer available } return 0; // Error code if no errors}
I have the latest drivers for my videocard. If you need any more code, just tell me but I try not to post too much unnecessary code. thnx!
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement