Jump to content
  • Advertisement
Sign in to follow this  
Speno

OpenGL Windows 7 Aero switching off automatically on game start

This topic is 2638 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a strange problem with creating a fullscreen OpenGL window,

That whenever I create a window that matches the resolution of my main screen, Windows 7 automatically switches off the Aero theme

Message:
"The current color scheme has exceeded its allowed memory so the color scheme has been automatically changed to improve performance. Click to see more information"

I am no longer calling ChangeScreenResolution, I am simply doing a window create with dimensions that match my screen.

The wierd thing is that the problem does not happen if I do one of the following:

1. Create a window 1 pixel smaller than my screen (there is a colored strip at the bottom of the screen)
2. Change the window style to WS_POPUPWINDOW (or any other window style) instead of WS_POPUP (this causes a 1px frame around the screen which I don't want)

I found this Thread of people (non developers) having the issue with multiscreen setups when doing anything graphically intensive.

The thing I don't understand is that no other game / application on my machine causes this problem when going fullscreen.

So what am I doing different?

More specific detials:

The problem always happens on the second call to SwapBuffers

For testing I have reproduced the problem under the following conditions:

No assets being loaded into memory
A Sleep(1000) between each render call to ensure im not hogging the cpu
Processing messages between each render
no rendering being done besides glClear and glSwapBuffers

Anyone else had this problem?

Share this post


Link to post
Share on other sites
Advertisement
The thing that happens when you completely cover the screen is that your driver will automatically switch to fullscreen mode, which doesn't happen when you use a window that leaves a pixel uncovered.
However, fullscreen shouldn't cause any problems. What hardware, OS and drivers do you have?

Start by running Windows Update, and then download the latest drivers directly from NVidia/AMD/Intel.
Also, make sure to use PFD_DOUBLEBUFFER and PFD_SUPPORT_COMPOSITION when selecting your pixel format.

If you still have problems after that, post your code for a minimal app that has the error. Here's one that works on my system if you want to compare. It's hard to say if your problem is in the code or with the drivers or OS.

#include <windows.h>
#include <gl/gl.h>

#pragma comment (lib, "opengl32.lib")

LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);


// Main
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
// Register windowclass
WNDCLASSEX wc = {0};
wc.cbSize = sizeof(wc);
wc.lpszClassName = TEXT("MyClass");
wc.hInstance = hInstance;
wc.lpfnWndProc = WndProc;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.style = CS_OWNDC;
RegisterClassEx(&wc);

// Create window
HWND hWnd = CreateWindowEx(
0,
wc.lpszClassName,
TEXT("OpenGL Window"),
WS_POPUP |
WS_CLIPSIBLINGS |
WS_CLIPCHILDREN,
0,
0,
GetSystemMetrics(SM_CXSCREEN),
GetSystemMetrics(SM_CYSCREEN),
NULL,
NULL,
hInstance,
NULL
);

// Get DC
HDC hDC = GetDC(hWnd);

// Pixelformat
PIXELFORMATDESCRIPTOR pfd = {0};
pfd.nSize = sizeof(pfd);
pfd.nVersion = 1;
pfd.dwFlags =
PFD_DRAW_TO_WINDOW |
PFD_SUPPORT_OPENGL |
PFD_DOUBLEBUFFER |
PFD_SUPPORT_COMPOSITION;
pfd.iPixelType = PFD_TYPE_RGBA;
pfd.cColorBits = 32;
pfd.cDepthBits = 24;

int pf = ChoosePixelFormat(hDC, &pfd);
SetPixelFormat(hDC, pf, &pfd);

// OpenGL context
HGLRC hGLRC = wglCreateContext(hDC);

wglMakeCurrent(hDC, hGLRC);

// Main loop
ShowWindow(hWnd, nCmdShow);
bool loop = true;
while(loop) {
MSG msg;
if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) != 0) {
if(msg.message == WM_QUIT)
loop = false;
else {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
else {
// Draw
glClear(GL_COLOR_BUFFER_BIT);

glRotatef(0.1f, 0.0f, 0.0f, 1.0f);

glBegin(GL_TRIANGLES);
glColor3f(1.0f, 0.0f, 0.0f);
glVertex2f(-1.0f, -1.0f);
glColor3f(0.0f, 1.0f, 0.0f);
glVertex2f(1.0f, -1.0f);
glColor3f(0.0f, 0.0f, 1.0f);
glVertex2f(0.0f, 1.0f);
glEnd();

SwapBuffers(hDC);
}
}

// Clean up
wglMakeCurrent(NULL, NULL);
wglDeleteContext(hGLRC);

UnregisterClass(wc.lpszClassName, hInstance);

return 0;
}

// Window procedure
LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) {
switch(msg) {
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}

return DefWindowProc(hWnd, msg, wParam, lParam);
}

Share this post


Link to post
Share on other sites
Thanks for the quick reply!

I compiled and executed your example line and can confirm it caused the same problem.

I did some more research, "no other games" causing the problem was false.

I ran through a few different engines on my machine and found a pattern, games using directx (K2_DirectX, Source Engine) for rendering were fine, games using opengl (Doom3, K2_OpenGL) all had the problem.

This means that it is a problem with my PC and not my engine.
I recently had to downgrade my drivers to stop an issue where swapbuffers would randomly take a long time every now and then (with vsync off)

I will have a play around with my drivers.

Thanks for your help.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!