PDA

View Full Version : Windows app crashing on Maximize (Windows XP)



BigBMan
01-11-2011, 06:29 PM
Any ideas why this is happening? My project is based on an earlier version of App.cpp so let me know if this has been fixed please. Looking into whether or not I can just disable the maximize button from the Win32 setup...

Seth
01-11-2011, 11:10 PM
Strange.. do the demos from svn work ok? If so, I'd see if you can update to the latest shared main.cpp if you aren't already using it, the App.* part shouldn't really matter.

It is pretty easy to disable the maximize button.

In main.cpp change:


DWORD style = WS_POPUP | WS_SYSMENU | WS_CAPTION | WS_SIZEBOX | WS_MAXIMIZEBOX | WS_MINIMIZEBOX;

to


DWORD style = WS_POPUP | WS_SYSMENU | WS_CAPTION | WS_SIZEBOX | WS_MINIMIZEBOX;

BigBMan
01-30-2011, 08:54 PM
Just confirmed that in Windows 7, the latest source does not crash when Maximizing/Minimizing.

A humble Request: can we change the desired resolution and stretch to the screen when maximizing or resizing? Can this be changed while the app is running?

Seth
01-30-2011, 11:12 PM
A humble Request: can we change the desired resolution and stretch to the screen when maximizing or resizing? Can this be changed while the app is running?

To clarify, you want a true screen resolution change instead of just the scaling that is happening now? Just scaling and leaving the real native resolution at whatever it is seems to be the most compatible these days, but does have its own problems, such as being slower (more pixels to process, a waste if your game is actually 800X600 and the desktop is much larger), and creating aspect ratio problems. (We don't have an "automatic engine-wide" letterboxing option to fix aspect ratios yet)

I did plan ahead to support "real" resolution changes though, only Main.cpp needs to be changed - internally, it's dropping all textures completely and reinitializing the hwnd and GL already, so the only thing to add is a rez change right before that happens.

But probably not something I will get to adding until I have a project that needs it and I can properly test it.

But to do it I think you'd just need to add a ChangeDisplaySettingsEx (http://msdn.microsoft.com/en-us/library/dd183413%28v=vs.85%29.aspx) command in main.cpp's InitWindow function.

After the old g_hWnd is destroyed, but before the new one is created.

BigBMan
03-16-2011, 11:45 PM
To clarify, I am using the "Windows Wide" setting as my primary screen size. Unfortunately not all laptops are exactly 800x1280, so I'd like to stretch the window to whatever native resolution is needed. I realize this runs the risk of getting horrible results, but I'm fine with that for now.

So should I still look into ChangeDisplaySettingsEx?

I saw you did have some code in WndProc that doesn't get executed. I tried removing the first break statement and I'm getting OpenGL errors.


case WM_SIZE:
{
break;

// Respond to the message:
int Width = LOWORD( lParam );
int Height = HIWORD( lParam );


if (Width != GetPrimaryGLX() || Height != GetPrimaryGLY())
{
LogMsg("Got new size: %d, %d", Width, Height);
GetBaseApp()->KillOSMessagesByType(OSMessage::MESSAGE_SET_VIDEO_ MODE);
GetBaseApp()->SetVideoMode(Width, Height, false, 0);

if (GetFakePrimaryScreenSizeX() != 0)
{
//we're stretching the screen to fit, so make this look a little better
//by drawing what we have during the drag operation. Why does it only
//draw when dragging bigger, not smaller? GL surface thing? Hrm.

RECT rect;
if (GetUpdateRect(g_hWnd, &rect, FALSE))
{
PAINTSTRUCT paint;
BeginPaint(g_hWnd, &paint);
#ifdef C_GL_MODE
SwapBuffers(g_hDC);
#endif
EndPaint(g_hWnd, &paint);
}
}
}
}

break;

BigBMan
03-17-2011, 12:17 AM
FYI, this'll get/set resolution to the native desktop res (in Windows):



void InitVideoSize()
{
#ifdef RT_WEBOS_ARM
return;
#endif

//the X/Y of the Windows setting is actually reversed.. it's confusing like this because most of the mobiles are "rotated" to landscape
//mode manually and it was just less changes to make to pretend we were rotating the Windows screen to play in "landscape" orientation
//to make testing consistent
AddVideoMode("Windows", 768, 1024, PLATFORM_ID_WINDOWS);
AddVideoMode("Windows Wide", 800, 1280, PLATFORM_ID_WINDOWS);
AddVideoMode("OSX", 768, 1024, PLATFORM_ID_OSX); //g_landScapeNoNeckHurtMode should be false when testing. Sort of buggy to emulate in Windows
AddVideoMode("OSX Wide", 800, 1280, PLATFORM_ID_OSX);

// get native window size
HWND hDesktopWnd = GetDesktopWindow();
HDC hDesktopDC = GetDC(hDesktopWnd);
int nScreenX = GetDeviceCaps(hDesktopDC, HORZRES);
int nScreenY = GetDeviceCaps(hDesktopDC, VERTRES);
ReleaseDC(hDesktopWnd, hDesktopDC);

AddVideoMode("native", nScreenY, nScreenX, PLATFORM_ID_WINDOWS);

AddVideoMode("iPhone", 320, 480, PLATFORM_ID_IOS);
AddVideoMode("iPad", 768, 1024, PLATFORM_ID_IOS);
AddVideoMode("iPad2", 768*2, 1024*2, PLATFORM_ID_IOS); //Note, you need a monitor bigger than 2048X1536 on Windows for this to work right,
//otherwise it clips the window size to the main monitor size. I don't have one...
AddVideoMode("iPhone4", 640, 960, PLATFORM_ID_IOS);

AddVideoMode("Palm Pre Plus", 320, 480, PLATFORM_ID_WEBOS);
AddVideoMode("Pixi", 320, 400, PLATFORM_ID_WEBOS);

AddVideoMode("G1", 320, 480, PLATFORM_ID_ANDROID);
AddVideoMode("G1 Landscape", 480, 320, PLATFORM_ID_ANDROID);
AddVideoMode("Nexus One", 480, 800, PLATFORM_ID_ANDROID);
AddVideoMode("Droid", 480, 854, PLATFORM_ID_ANDROID);
AddVideoMode("Droid Landscape", 854, 480, PLATFORM_ID_ANDROID); //g_landScapeNoNeckHurtMode should be false when testing
AddVideoMode("Nexus One Landscape", 800, 480, PLATFORM_ID_ANDROID); //g_landScapeNoNeckHurtMode should be false when testing

string desiredVideoMode = "native"; //name needs to match one of the ones defined below
g_landScapeNoNeckHurtMode = true; //if true, will rotate the screen so we can play in landscape mode in windows without hurting ourselves

SetVideoModeByName(desiredVideoMode);

GetBaseApp()->OnPreInitVideo(); //gives the app level code a chance to override any of these parms if it wants to
}

Seth
03-17-2011, 12:44 AM
Thanks. Ack, yeah that break; wasn't supposed to be there.. sloppy.

Patch committed.. also added a "Windows Native" setting based on your code, thanks.

BigBMan
03-17-2011, 01:24 AM
May want to fix this:

AddVideoMode("native", nScreenY, nScreenX, PLATFORM_ID_WINDOWS);

was previously


AddVideoMode("native", nScreenX, nScreenX, PLATFORM_ID_WINDOWS);

Sorry, and Thank you!

Seth
03-17-2011, 01:38 AM
Whups, fixed!