Debug/Release problem

Started by
13 comments, last by BSXrider 22 years, 2 months ago
I've fallen into the trap which searching on google seems to catch a lot of people out. Merrily wrote my project always compiling in debug mode. Try it in release and it doesn't work. Arse. ACTUALLY it's quite a basic problem which I feel might be recognisable to someone, please? The rest of the game works fine. If I turn optimisations down to "default" instead of "optimize speed/size" it works. cheers, - seb Edited by - bsxrider on February 4, 2002 4:56:05 AM Edited by - bsxrider on February 4, 2002 4:56:52 AM
Advertisement
i think that could be something to do with you setting the dialog box as not having a 3d style or something, have a look at the dialog properties.
I''ve tried changing all that sort of thing. The annoying thing is that NeHe''s basecode (which that dialogue is from) compiles fine in release and debug modes. I''ve made quite a few little changes to the code, but nothing that you''d expect to make this problem occur. Grrr.

- seb
Or a variable you forgot to initialise somewhere (debug mode will set it to zero).

[ MSVC Fixes | STL | SDL | Game AI | Sockets | C++ Faq Lite | Boost ]
Code in assert statements will be stripped out too...
No asserts.

Will check that out Kylotan...

- seb
Of course it DOES work in release mode if I turn the optimisations off.

So what might that suggest?

- seb
Hmm.

Are you using a structure that contains chars or shorts? Maybe it''s an alignment problem.

I mean perhaps the structure is being 32bit aligned for Release, but not in Debug. I could well be shooting in the dark here.

It does look very much like the dialog is not being set up with 3D style tags though.

- Pete
Well, time to post a little code then, I guess. Where''s the code that creates that?

[ MSVC Fixes | STL | SDL | Game AI | Sockets | C++ Faq Lite | Boost ]
    #include "globals.h"#define WM_TOGGLEFULLSCREEN (WM_USER+1)									// Application Define Message For Togglingstatic bool g_isProgramLooping;											// Window Creation Loop, For FullScreen togglestatic bool g_createFullScreen;											// If true, Then Create FullscreenGL_Window			window;											    // Window Structure/////////////////////////////////////////////////////////////////////////////// SCREEN DIALOG PROCEDUREbool CALLBACK ScreenDlgProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam) {     switch (message)     {         case WM_COMMAND:             switch (LOWORD(wParam))             {			case IDOK:				if(!IsDlgButtonChecked(hwndDlg, IDC_FULLSCREEN))					window.init.isFullScreen = false;									// If Not, Run In Windowed Mode 									if(IsDlgButtonChecked(hwndDlg, IDC_16BPP))							window.init.bitsPerPixel	= 16;								// Bits Per Pixel 								else	window.init.bitsPerPixel	= 32;								// Bits Per Pixel								if(IsDlgButtonChecked(hwndDlg, IDC_640_480))				{					window.init.width			= 640;									// Window Width					window.init.height			= 480;									// Window Height				}				else				{					if(IsDlgButtonChecked(hwndDlg, IDC_800_600))					{						window.init.width		= 800;									// Window Width						window.init.height		= 600;									// Window Height					}					else					{						window.init.width		= 1024;									// Window Width						window.init.height		= 768;									// Window Height					}				}				EndDialog(hwndDlg, wParam); 				return true;             }			switch (HIWORD(wParam))			{			case BN_CLICKED:				CheckDlgButton(hwndDlg, lParam, BST_CHECKED);				break;			}			break;					case WM_INITDIALOG:		{			CheckDlgButton(hwndDlg,IDC_FULLSCREEN, BST_UNCHECKED);			CheckRadioButton(hwndDlg,IDC_640_480, IDC_1024_768, IDC_800_600);			CheckRadioButton(hwndDlg,IDC_16BPP, IDC_32BPP, IDC_32BPP);		}    }    return false; } ////////////////////////////////////////////////////////////////////////////////// WIN MAINint WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow){	Application			application;									// Application Structure	Keys				keys;											// Key Structure	bool				isMessagePumpActive;							// Message Pump Active?	MSG					msg;											// Window Message Structure	DWORD				tickCount;										// Used For The Tick Counter	// Fill Out Application Data	application.className = "OpenGL";									// Application Class Name	application.hInstance = hInstance;									// Application Instance	// Fill Out Window	ZeroMemory (&window, sizeof (GL_Window));							// Make Sure Memory Is Zeroed	window.keys					= &keys								// Window Key Structure	window.init.application		= &application							// Window Application	window.init.title			= "PonGLe";								// Window Title	window.init.width			= 640;									// Window Width	window.init.height			= 480;									// Window Height	window.init.bitsPerPixel	= 16;									// Bits Per Pixel	window.init.isFullScreen	= true;									// Fullscreen? (Set To true)	ZeroMemory (&keys, sizeof (Keys));									// Zero keys Structure	// Ask The User If They Want To Start In FullScreen Mode?	/*	if (MessageBox (HWND_DESKTOP, "Would You Like To Run In Fullscreen Mode?", "Start FullScreen?", MB_YESNO | MB_ICONQUESTION) == IDNO)	{		window.init.isFullScreen = false;								// If Not, Run In Windowed Mode	}    */    DialogBox(hInstance, MAKEINTRESOURCE(IDD_SCREENDLG),                      HWND_DESKTOP, (DLGPROC)ScreenDlgProc);     	// Register A Class For Our Window To Use	if (RegisterWindowClass (&application) == false)					// Did Registering A Class Fail?	{		// Failure		MessageBox (HWND_DESKTOP, "Error Registering Window Class!", "Error", MB_OK | MB_ICONEXCLAMATION);		return -1;														// Terminate Application	}	g_isProgramLooping = true;											// Program Looping Is Set To true	g_createFullScreen = window.init.isFullScreen;						// g_createFullScreen Is Set To User Default	while (g_isProgramLooping)											// Loop Until WM_QUIT Is Received	{		// Create A Window		window.init.isFullScreen = g_createFullScreen;					// Set Init Param Of Window Creation To Fullscreen?		if (CreateWindowGL (&window) == true)							// Was Window Creation Successful?		{			// At This Point We Should Have A Window That Is Setup To Render OpenGL			if (Initialize (&window, &keys) == false)					// Call User Intialization			{				// Failure				TerminateApplication (&window);							// Close Window, This Will Handle The Shutdown			}			else														// Otherwise (Start The Message Pump)			{	// Initialize was a success				isMessagePumpActive = true;								// Set isMessagePumpActive To true				while (isMessagePumpActive == true)						// While The Message Pump Is Active				{					// Success Creating Window.  Check For Window Messages					if (PeekMessage (&msg, window.hWnd, 0, 0, PM_REMOVE) != 0)					{						// Check For WM_QUIT Message						if (msg.message != WM_QUIT)						// Is The Message A WM_QUIT Message?						{							DispatchMessage (&msg);						// If Not, Dispatch The Message						}						else											// Otherwise (If Message Is WM_QUIT)						{							isMessagePumpActive = false;				// Terminate The Message Pump						}					}					else												// If There Are No Messages					{						if (window.isVisible == false)					// If Window Is Not Visible						{							WaitMessage ();								// Application Is Minimized Wait For A Message						}						else											// If Window Is Visible						{							// Process Application Loop							tickCount = GetTickCount ();				// Get The Tick Count							Update (tickCount - window.lastTickCount);	// Update The Counter							window.lastTickCount = tickCount;			// Set Last Count To Current Count							Draw ();									// Draw Our Scene							SwapBuffers (window.hDC);					// Swap Buffers (Double Buffering)						}					}				}														// Loop While isMessagePumpActive == true			}															// If (Initialize (...			// Application Is Finished			Deinitialize ();											// User Defined DeInitialization			DestroyWindowGL (&window);									// Destroy The Active Window		}		else															// If Window Creation Failed		{			// Error Creating Window			MessageBox (HWND_DESKTOP, "Error Creating OpenGL Window", "Error", MB_OK | MB_ICONEXCLAMATION);			g_isProgramLooping = false;									// Terminate The Loop		}	}																	// While (isProgramLooping)	UnregisterClass (application.className, application.hInstance);		// UnRegister Window Class	return 0;}																		// End Of WinMain()    


Edited by - bsxrider on February 4, 2002 7:32:00 PM

This topic is closed to new replies.

Advertisement