Archived

This topic is now archived and is closed to further replies.

Debug/Release problem

This topic is 5824 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'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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Of course it DOES work in release mode if I turn the optimisations off.

So what might that suggest?

- seb

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
    
#include "globals.h"

#define WM_TOGGLEFULLSCREEN (WM_USER+1) // Application Define Message For Toggling


static bool g_isProgramLooping; // Window Creation Loop, For FullScreen toggle

static bool g_createFullScreen; // If true, Then Create Fullscreen


GL_Window window; // Window Structure






/////////////////////////////////////////////////////////////////////////////// SCREEN DIALOG PROCEDURE

bool 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 MAIN

int 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

Share this post


Link to post
Share on other sites
quote:
Original post by Kylotan
Well, time to post a little code then, I guess. Where's the code that creates that?



A little... a LITTLE!!!

I did plough through your code... I couldnt find anything that struck me as devastatingly incorrect. I could be wrong, of course. Whats RegisterWindowClass() do?

Edited by - Spiral on February 4, 2002 10:58:45 PM

Share this post


Link to post
Share on other sites
Thing is that code is NeHe''s "basecode 2". And the un-editiied version when downloaded works fine in all compile modes.

I''ve made some minor modifications (petty things like swapped "BOOL" "TRUE" and "FALSE" for "bool" "true" "false"). And built a whole project around it. And it doesn''t work properly. Arse.

I''ve just spent the last hour or so rebuilding resource files to see if that was the problem but it weren''t...

- seb

Share this post


Link to post
Share on other sites
Yup, typing that post out triggered the solution in my head.

NeHe''s basecode uses:

typedef int BOOL;
#ifndef FALSE
#define FALSE 0
#endif
#ifndef TRUE
#define TRUE 1
#endif

from windef.h


I didn''t like that so changed everything to bool/false/true instead. Changing it back solves my problem.

Peculiar.

- seb

Share this post


Link to post
Share on other sites
bool CALLBACK ScreenDlgProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam)

That was the guilty line.

Share this post


Link to post
Share on other sites