4 Replies - 1920 Views - Last Post: 21 November 2008 - 11:31 PM Rate Topic: -----

#1 Asen  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 21-November 08

debugging problem in VC++ 2008

Posted 21 November 2008 - 10:41 PM

Thank's for the quick registration to all.
I make my own project that uses bitmap. Finally, I've build it successfully and the compiled result's shown below.
==================================================================
------ Rebuild All started: Project: KungfuPanda, Configuration: Debug Win32 ------
Deleting intermediate and output files for project 'KungfuPanda', configuration 'Debug|Win32'
Compiling...
PO.cpp
c:\program files\microsoft sdks\windows\v6.0a\include\gl\glaux.h(17) : warning C4068: unknown pragma
c:\program files\microsoft sdks\windows\v6.0a\include\gl\glaux.h(374) : warning C4068: unknown pragma
c:\documents and settings\satellite\my documents\visual studio 2008\projects\vc++ project\kungfupanda\kungfupanda\po.cpp(33) : warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
c:\program files\microsoft visual studio 9.0\vc\include\stdio.h(237) : see declaration of 'fopen'
Compiling manifest to resources...
Microsoft Windows Resource Compiler Version 6.0.5724.0
Copyright Microsoft Corporation. All rights reserved.
Linking...
LINK : C:\Documents and Settings\SATELLITE\My Documents\Visual Studio 2008\Projects\VC++ PROJECT\KungfuPanda\Debug\KungfuPanda.exe not found or not built by the last incremental link; performing full link
Embedding manifest...
Microsoft Windows Resource Compiler Version 6.0.5724.0
Copyright Microsoft Corporation. All rights reserved.
Build log was saved at "file://c:\Documents and Settings\SATELLITE\My Documents\Visual Studio 2008\Projects\VC++ PROJECT\KungfuPanda\KungfuPanda\Debug\BuildLog.htm"
KungfuPanda - 0 error(s), 3 warning(s)
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========
===================================================================
This make me very happy, coz this is my first project but something bad appear while I start debuging.
It just like before, I mean while the windows form appear "would you like to run in fullscreen mode", whether I choose yes or no, it just start the appearence then disappear in seconds. Maybe in milliseconds.
What cause this problem. For every one who knows this case, please tell me. How to prevent the result not to disappear while it just start running ? A comment would be a real help. Please try to compile and run the code to see what's going on.
===================================================================
This is my first project code; If I run it should be a rotating box that contain Po bitmap.
I'm really confused now. Please tell me the way.
==================================================================
Here's the debugging log

===================================================================================================
'KungfuPanda.exe': Loaded 'C:\Documents and Settings\SATELLITE\My Documents\Visual Studio 2008\Projects\VC++ PROJECT\KungfuPanda\Debug\KungfuPanda.exe', Symbols loaded.
'KungfuPanda.exe': Loaded 'C:\WINDOWS\system32\ntdll.dll'
'KungfuPanda.exe': Loaded 'C:\WINDOWS\system32\kernel32.dll'
'KungfuPanda.exe': Loaded 'C:\WINDOWS\system32\glu32.dll'
'KungfuPanda.exe': Loaded 'C:\WINDOWS\system32\msvcrt.dll'
'KungfuPanda.exe': Loaded 'C:\WINDOWS\system32\opengl32.dll'
'KungfuPanda.exe': Loaded 'C:\WINDOWS\system32\advapi32.dll'
'KungfuPanda.exe': Loaded 'C:\WINDOWS\system32\rpcrt4.dll'
'KungfuPanda.exe': Loaded 'C:\WINDOWS\system32\gdi32.dll'
'KungfuPanda.exe': Loaded 'C:\WINDOWS\system32\user32.dll'
'KungfuPanda.exe': Loaded 'C:\WINDOWS\system32\ddraw.dll'
'KungfuPanda.exe': Loaded 'C:\WINDOWS\system32\dciman32.dll'
'KungfuPanda.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.VC90.DebugCRT_1fc8b3b9a1e18e3b_9.0.21022.8_x-ww_597c3456\msvcr90d.dll'
'KungfuPanda.exe': Loaded 'C:\WINDOWS\system32\imm32.dll'
'KungfuPanda.exe': Loaded 'C:\WINDOWS\system32\lpk.dll'
'KungfuPanda.exe': Loaded 'C:\WINDOWS\system32\usp10.dll'
'KungfuPanda.exe': Loaded 'C:\WINDOWS\system32\avgrsstx.dll'
'KungfuPanda.exe': Loaded 'C:\WINDOWS\system32\uxtheme.dll'
'KungfuPanda.exe': Loaded 'C:\WINDOWS\system32\MSCTF.dll'
'KungfuPanda.exe': Loaded 'C:\WINDOWS\system32\version.dll'
'KungfuPanda.exe': Unloaded 'C:\WINDOWS\system32\version.dll'
'KungfuPanda.exe': Loaded 'C:\WINDOWS\system32\MSCTFIME.IME'
'KungfuPanda.exe': Loaded 'C:\WINDOWS\system32\ole32.dll'
'KungfuPanda.exe': Loaded 'C:\WINDOWS\system32\oleaut32.dll'
'KungfuPanda.exe': Loaded 'C:\WINDOWS\system32\iglicd32.dll', Binary was not built with debug information.
'KungfuPanda.exe': Loaded 'C:\WINDOWS\system32\igldev32.dll', Binary was not built with debug information.
'KungfuPanda.exe': Loaded 'C:\WINDOWS\system32\mcd32.dll'
'KungfuPanda.exe': Unloaded 'C:\WINDOWS\system32\mcd32.dll'
The program '[896] KungfuPanda.exe: Native' has exited with code 0 (0x0).

This post has been edited by Asen: 21 November 2008 - 11:17 PM


Is This A Good Question/Topic? 0
  • +

Replies To: debugging problem in VC++ 2008

#2 n8wxs  Icon User is offline

  • --... ...-- -.. . -. ---.. .-- -..- ...
  • member icon

Reputation: 972
  • View blog
  • Posts: 3,878
  • Joined: 07-January 08

Re: debugging problem in VC++ 2008

Posted 21 November 2008 - 10:43 PM

Welcome!

Please post your code examples using - :code:
Was This Post Helpful? 0
  • +
  • -

#3 Asen  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 21-November 08

Re: debugging problem in VC++ 2008

Posted 21 November 2008 - 10:51 PM

[code]#include <windows.h>
#include <stdio.h>
#include <gl\gl.h>
#include <gl\glu.h>
#include <gl\glaux.h>

HDC hDC=NULL;
HGLRC hRC=NULL;
HWND hWnd=NULL;
HINSTANCE hInstance;

bool keys[256];
bool active=TRUE;
bool fullscreen=TRUE;

GLfloat xrot;
GLfloat yrot;
GLfloat zrot;

GLuint texture[1];

LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);

AUX_RGBImageRec *LoadBMP(char *Filename)
{
FILE *File=NULL;

if (!Filename)
{
return NULL;
}

File=fopen(Filename,"r");

if (File)
{
fclose(File);
return auxDIBImageLoad(Filename);
}

return NULL;
}

int LoadGLTextures()
{
int Status=FALSE;

AUX_RGBImageRec *TextureImage[1];

memset(TextureImage,0,sizeof(void *)*1);


if (TextureImage[0]=LoadBMP("Data/DragonWarrior.bmp"))
{
Status=TRUE;

glGenTextures(1, &texture[0]);


glBindTexture(GL_TEXTURE_2D, texture[0]);
glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[0]-&gt;sizeX, TextureImage[0]-&gt;sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]-&gt;data);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
}

if (TextureImage[0])
{
if (TextureImage[0]-&gt;data)
{
free(TextureImage[0]-&gt;data);
}

free(TextureImage[0]);
}

return Status;
}

GLvoid ReSizeGLScene(GLsizei width, GLsizei height)
{
if (height==0)
{
height=1;
}

glViewport(0,0,width,height);

glMatrixMode(GL_PROJECTION);
glLoadIdentity();

// Calculate The Aspect Ratio Of The Window
gluPerspective(45.0f,(GLfloat)width/(GLfloat)height,0.1f,100.0f);

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}

int InitGL(GLvoid)
{
if (!LoadGLTextures())
{
return FALSE;
}

glEnable(GL_TEXTURE_2D);
glShadeModel(GL_SMOOTH);
glClearColor(0.0f, 0.0f, 0.0f, 0.5f);
glClearDepth(1.0f);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
return TRUE;
}

int DrawGLScene(GLvoid)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glTranslatef(0.0f,0.0f,-5.0f);

glRotatef(xrot,1.0f,0.0f,0.0f);
glRotatef(yrot,0.0f,1.0f,0.0f);
glRotatef(zrot,0.0f,0.0f,1.0f);

glBindTexture(GL_TEXTURE_2D, texture[0]);

glBegin(GL_QUADS);
// muka depan
glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f);
glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f);
glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, 1.0f);
glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 1.0f);
// muka belakang
glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f);
glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f);
glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, 1.0f, -1.0f);
glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f);
// muka atas
glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f);
glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, 1.0f, 1.0f);
glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, 1.0f, 1.0f);
glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, -1.0f);
// muka bawah
glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, -1.0f, -1.0f);
glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, -1.0f, -1.0f);
glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f);
glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f);
// muka kanan
glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f);
glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, -1.0f);
glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, 1.0f, 1.0f);
glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f);
// muka kiri
glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f);
glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f);
glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 1.0f);
glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f);
glEnd();

xrot+=0.3f;
yrot+=0.2f;
zrot+=0.4f;
return TRUE;
}

GLvoid KillGLWindow(GLvoid)
{
if (fullscreen)
{
ChangeDisplaySettings(NULL,0);
ShowCursor(TRUE);
}

if (hRC)
{
if (!wglMakeCurrent(NULL,NULL))
{
MessageBox(NULL,"Release Of DC And RC Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
}

if (!wglDeleteContext(hRC))
{
MessageBox(NULL,"Release Rendering Context Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
}
hRC=NULL;
}

if (hDC && !ReleaseDC(hWnd,hDC))
{
MessageBox(NULL,"Release Device Context Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
hDC=NULL;
}

if (hWnd && !DestroyWindow(hWnd))
{
MessageBox(NULL,"Could Not Release hWnd.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
hWnd=NULL;
}

if (!UnregisterClass("OpenGL",hInstance))
{
MessageBox(NULL,"Could Not Unregister Class.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
hInstance=NULL;
}
}



BOOL CreateGLWindow(char* title, int width, int height, int bits, bool fullscreenflag)
{
GLuint PixelFormat;
WNDCLASS wc;
DWORD dwExStyle;
DWORD dwStyle;
RECT WindowRect;
WindowRect.left=(long)0;
WindowRect.right=(long)width;
WindowRect.top=(long)0;
WindowRect.bottom=(long)height;

fullscreen=fullscreenflag;

hInstance = GetModuleHandle(NULL);
wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
wc.lpfnWndProc = (WNDPROC) WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(NULL, IDI_WINLOGO);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = NULL;
wc.lpszMenuName = NULL;
wc.lpszClassName = "OpenGL";

if (!RegisterClass(&wc))
{
MessageBox(NULL,"Failed To Register The Window Class.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return FALSE;
}

if (fullscreen)
{
DEVMODE dmScreenSettings;
memset(&dmScreenSettings,0,sizeof(dmScreenSettings));
dmScreenSettings.dmSize=sizeof(dmScreenSettings);
dmScreenSettings.dmPelsWidth = width;
dmScreenSettings.dmPelsHeight = height;
dmScreenSettings.dmBitsPerPel = bits;
dmScreenSettings.dmFields=DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT;


if (ChangeDisplaySettings(&dmScreenSettings,CDS_FULLSCREEN)!=DISP_CHANGE_SUCCESSFUL)
{

if (MessageBox(NULL,"The Requested Fullscreen Mode Is Not Supported By\nYour Video Card. Use Windowed Mode Instead?","NeHe GL",MB_YESNO|MB_ICONEXCLAMATION)==IDYES)
{
fullscreen=FALSE;
}
else
{

MessageBox(NULL,"Program Will Now Close.","ERROR",MB_OK|MB_IConstop);
return FALSE;
}
}
}

if (fullscreen)
{
dwExStyle=WS_EX_APPWINDOW;
dwStyle=WS_POPUP;
ShowCursor(FALSE);
}
else
{
dwExStyle=WS_EX_APPWINDOW | WS_EX_WINDOWEDGE;
dwStyle=WS_OVERLAPPEDWINDOW;
}

AdjustWindowRectEx(&WindowRect, dwStyle, FALSE, dwExStyle);

// Create The Window
if (!(hWnd=CreateWindowEx( dwExStyle,
"OpenGL",
title,
dwStyle |
WS_CLIPSIBLINGS |
WS_CLIPCHILDREN,
0, 0,
WindowRect.right-WindowRect.left,
WindowRect.bottom-WindowRect.top,
NULL,
NULL,
hInstance,
NULL)))
{
KillGLWindow();
MessageBox(NULL,"Window Creation Error.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return FALSE;
}

static PIXELFORMATDESCRIPTOR pfd=
{
sizeof(PIXELFORMATDESCRIPTOR),
1,
PFD_DRAW_TO_WINDOW |
PFD_SUPPORT_OPENGL |
PFD_DOUBLEBUFFER,
PFD_TYPE_RGBA,
bits,
0, 0, 0, 0, 0, 0,
0,
0,
0,
0, 0, 0, 0,
16,
0,
0,
PFD_MAIN_PLANE,
0,
0, 0, 0
};

if (!(hDC=GetDC(hWnd)))
{
KillGLWindow();
MessageBox(NULL,"Can't Create A GL Device Context.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return FALSE;
}

if (!(PixelFormat=ChoosePixelFormat(hDC,&pfd)))
{
KillGLWindow();
MessageBox(NULL,"Can't Find A Suitable PixelFormat.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return FALSE;
}

if(!SetPixelFormat(hDC,PixelFormat,&pfd))
{
KillGLWindow();
MessageBox(NULL,"Can't Set The PixelFormat.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return FALSE;
}

if (!(hRC=wglCreateContext(hDC)))
{
KillGLWindow();
MessageBox(NULL,"Can't Create A GL Rendering Context.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return FALSE;
}

if(!wglMakeCurrent(hDC,hRC))
{
KillGLWindow();
MessageBox(NULL,"Can't Activate The GL Rendering Context.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return FALSE;
}

ShowWindow(hWnd,SW_SHOW);
SetForegroundWindow(hWnd);
SetFocus(hWnd);
ReSizeGLScene(width, height);

if (!InitGL())
{
KillGLWindow();
MessageBox(NULL,"Initialization Failed.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return FALSE;
}

return TRUE;
}

LRESULT CALLBACK WndProc( HWND hWnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam)
{
switch (uMsg)
{
case WM_ACTIVATE:
{
if (!HIWORD(wParam))
{
active=TRUE;
}
else
{
active=FALSE;
}

return 0;
}

case WM_SYSCOMMAND:
{
switch (wParam)
{
case SC_SCREENSAVE:
case SC_MONITORPOWER:
return 0;
}
break; &

This post has been edited by Asen: 21 November 2008 - 11:24 PM

Was This Post Helpful? 0
  • +
  • -

#4 Asen  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 21-November 08

Re: debugging problem in VC++ 2008

Posted 21 November 2008 - 11:20 PM

 										
		  }

		  case WM_CLOSE:									   
		  {
			   PostQuitMessage(0);							 
			   return 0;									   
		  }

		  case WM_KEYDOWN:							 
		  {
			   keys[wParam] = TRUE;						
			   return 0;									   
		  }

		  case WM_KEYUP:									   
		  {
			   keys[wParam] = FALSE;						
			   return 0;									   
		  }

		  case WM_SIZE:									   
		  {
			   ReSizeGLScene(LOWORD(lParam),HIWORD(lParam));  
			   return 0;								  
		  }
	 }

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

int WINAPI WinMain(	 HINSTANCE	 hInstance,			  
						 HINSTANCE	 hPrevInstance,		 
						 LPSTR		  lpCmdLine,			  
						 int			   nCmdShow)			  
{
	 MSG		  msg;											
	 BOOL	 done=FALSE;									   

	
	 if (MessageBox(NULL,"Would You Like To Run In Fullscreen Mode?", "Start FullScreen?",MB_YESNO|MB_ICONQUESTION)==IDNO)
	 {
		  fullscreen=FALSE;								  
	 }

	
	 if (!CreateGLWindow("NeHe's Texture Mapping Tutorial",640,480,16,fullscreen))
	 {
		  return 0;											
	 }

	 while(!done)											
	 {
		  if (PeekMessage(&msg,NULL,0,0,PM_REMOVE))	
		  {
			   if (msg.message==WM_QUIT)				   
			   {
					done=TRUE;								  
			   }
			   else											
			   {
					TranslateMessage(&msg);				   
					DispatchMessage(&msg);				   
			   }
		  }
		  else												 
		  {
			   if ((active && !DrawGLScene()) || keys[VK_ESCAPE])	
			   {
					done=TRUE;								  
			   }
			   else											
			   {
					SwapBuffers(hDC);						
			   }

			   if (keys[VK_F1])						
			   {
					keys[VK_F1]=FALSE;						
					KillGLWindow();							 
					fullscreen=!fullscreen;				   
					// Recreate Our OpenGL Window
					if (!CreateGLWindow("NeHe's Texture Mapping Tutorial",640,480,16,fullscreen))
					{
						 return 0;							 
					}
			   }
		  }
	 }

	 KillGLWindow();											
	 return (msg.wParam);								  
}

This post has been edited by Asen: 21 November 2008 - 11:26 PM

Was This Post Helpful? 0
  • +
  • -

#5 Asen  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 21-November 08

Re: debugging problem in VC++ 2008

Posted 21 November 2008 - 11:31 PM

I'm really confused now. Please tell me, what should I do to run the code normally. It just can't show the result for a long time. Once it appears, then it disappears soon without let me see the result. The compiled log doesn't tell me any sign of wrong. Please help me. Maybe I should add something in the code or in the project tools bar. I don't know what to do.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1