Visual C++ Debugging Problem

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Jan 2005
Posts: 3
Reputation: Sen is an unknown quantity at this point 
Solved Threads: 0
Sen Sen is offline Offline
Newbie Poster

Visual C++ Debugging Problem

 
0
  #1
Oct 19th, 2008
I tried to test Nehe's lesson 6 project. After I copied and pasted the source code, I compiled it and got the result below;
------ Build started: Project: TugasOpenGl2, Configuration: Debug Win32 ------
Compiling...
Tugas2.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\tugasopengl2\tugasopengl2\tugas2.cpp(41) : 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'
Linking...
Embedding manifest...
Build log was saved at "file://c:\Documents and Settings\SATELLITE\My Documents\Visual Studio 2008\Projects\TugasOpenGl2\TugasOpenGl2\Debug\BuildLog.htm"
TugasOpenGl2 - 0 error(s), 3 warning(s)
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

I thought there was no problem, then I press F5 to run it.
But the Error Form tell me that the "Initialization Failed"
After I closed it, there were several messages like this ;

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

Please help me !
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,350
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1462
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: Visual C++ Debugging Problem

 
0
  #2
Oct 19th, 2008
1) You will have to post the pragma from glaux.h that is cause the problem there.

2) warnning 4996: I always disable that because it isn't really a problem #pragma warning(disable: 4996) put that near the top of the *.cpp file

3) just ignore all those warnings you got after closing your program. Those are just normally and every program gets.

>>But the Error Form tell me that the "Initialization Failed"
Hard telling what cause that. Without seeing the code we are just shooting in the dark.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Jan 2005
Posts: 3
Reputation: Sen is an unknown quantity at this point 
Solved Threads: 0
Sen Sen is offline Offline
Newbie Poster

Re: Visual C++ Debugging Problem

 
0
  #3
Oct 19th, 2008
Thank's so much. I'll try it.
Reply With Quote Quick reply to this message  
Join Date: Jan 2005
Posts: 3
Reputation: Sen is an unknown quantity at this point 
Solved Threads: 0
Sen Sen is offline Offline
Newbie Poster

Re: Visual C++ Debugging Problem

 
0
  #4
Oct 19th, 2008
Here's the source code;
  1. /*
  2.  * This Code Was Created By Jeff Molofee 2000
  3.  * A HUGE Thanks To Fredric Echols For Cleaning Up
  4.  * And Optimizing The Base Code, Making It More Flexible!
  5.  * If You've Found This Code Useful, Please Let Me Know.
  6.  * Visit My Site At nehe.gamedev.net
  7.  * Conversion to Visual Studio.NET done by GRANT JAMES(ZEUS)
  8.  */
  9. #pragma warning(disable: 4996)
  10. #include <windows.h> // Header File For Windows
  11. #include <stdio.h> // Header File For Standard Input/Output
  12. #include <gl\gl.h> // Header File For The OpenGL32 Library
  13. #include <gl\glu.h> // Header File For The GLu32 Library
  14. #include <gl\glaux.h> // Header File For The Glaux Library
  15.  
  16. HDC hDC=NULL; // Private GDI Device Context
  17. HGLRC hRC=NULL; // Permanent Rendering Context
  18. HWND hWnd=NULL; // Holds Our Window Handle
  19. HINSTANCE hInstance; // Holds The Instance Of The Application
  20.  
  21. bool keys[256]; // Array Used For The Keyboard Routine
  22. bool active=TRUE; // Window Active Flag Set To TRUE By Default
  23. bool fullscreen=TRUE; // Fullscreen Flag Set To Fullscreen Mode By Default
  24.  
  25. GLfloat xrot; // X Rotation ( NEW )
  26. GLfloat yrot; // Y Rotation ( NEW )
  27. GLfloat zrot; // Z Rotation ( NEW )
  28.  
  29. GLuint texture[1]; // Storage For One Texture ( NEW )
  30.  
  31. LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); // Declaration For WndProc
  32.  
  33. AUX_RGBImageRec *LoadBMP(char *Filename) // Loads A Bitmap Image
  34. {
  35. FILE *File=NULL; // File Handle
  36.  
  37. if (!Filename) // Make Sure A Filename Was Given
  38. {
  39. return NULL; // If Not Return NULL
  40. }
  41.  
  42. File=fopen(Filename,"r"); // Check To See If The File Exists
  43.  
  44. if (File) // Does The File Exist?
  45. {
  46. fclose(File); // Close The Handle
  47. return auxDIBImageLoad(Filename); // Load The Bitmap And Return A Pointer
  48. }
  49.  
  50. return NULL; // If Load Failed Return NULL
  51. }
  52.  
  53. int LoadGLTextures() // Load Bitmaps And Convert To Textures
  54. {
  55. int Status=FALSE; // Status Indicator
  56.  
  57. AUX_RGBImageRec *TextureImage[1]; // Create Storage Space For The Texture
  58.  
  59. memset(TextureImage,0,sizeof(void *)*1); // Set The Pointer To NULL
  60.  
  61. // Load The Bitmap, Check For Errors, If Bitmap's Not Found Quit
  62. if (TextureImage[0]=LoadBMP("Data/NeHe.bmp"))
  63. {
  64. Status=TRUE; // Set The Status To TRUE
  65.  
  66. glGenTextures(1, &texture[0]); // Create The Texture
  67.  
  68. // Typical Texture Generation Using Data From The Bitmap
  69. glBindTexture(GL_TEXTURE_2D, texture[0]);
  70. glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[0]->sizeX, TextureImage[0]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data);
  71. glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
  72. glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
  73. }
  74.  
  75. if (TextureImage[0]) // If Texture Exists
  76. {
  77. if (TextureImage[0]->data) // If Texture Image Exists
  78. {
  79. free(TextureImage[0]->data); // Free The Texture Image Memory
  80. }
  81.  
  82. free(TextureImage[0]); // Free The Image Structure
  83. }
  84.  
  85. return Status; // Return The Status
  86. }
  87.  
  88. GLvoid ReSizeGLScene(GLsizei width, GLsizei height) // Resize And Initialize The GL Window
  89. {
  90. if (height==0) // Prevent A Divide By Zero By
  91. {
  92. height=1; // Making Height Equal One
  93. }
  94.  
  95. glViewport(0,0,width,height); // Reset The Current Viewport
  96.  
  97. glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
  98. glLoadIdentity(); // Reset The Projection Matrix
  99.  
  100. // Calculate The Aspect Ratio Of The Window
  101. gluPerspective(45.0f,(GLfloat)width/(GLfloat)height,0.1f,100.0f);
  102.  
  103. glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
  104. glLoadIdentity(); // Reset The Modelview Matrix
  105. }
  106.  
  107. int InitGL(GLvoid) // All Setup For OpenGL Goes Here
  108. {
  109. if (!LoadGLTextures()) // Jump To Texture Loading Routine ( NEW )
  110. {
  111. return FALSE; // If Texture Didn't Load Return FALSE
  112. }
  113.  
  114. glEnable(GL_TEXTURE_2D); // Enable Texture Mapping ( NEW )
  115. glShadeModel(GL_SMOOTH); // Enable Smooth Shading
  116. glClearColor(0.0f, 0.0f, 0.0f, 0.5f); // Black Background
  117. glClearDepth(1.0f); // Depth Buffer Setup
  118. glEnable(GL_DEPTH_TEST); // Enables Depth Testing
  119. glDepthFunc(GL_LEQUAL); // The Type Of Depth Testing To Do
  120. glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Really Nice Perspective Calculations
  121. return TRUE; // Initialization Went OK
  122. }
  123.  
  124. int DrawGLScene(GLvoid) // Here's Where We Do All The Drawing
  125. {
  126. glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear The Screen And The Depth Buffer
  127. glLoadIdentity(); // Reset The View
  128. glTranslatef(0.0f,0.0f,-5.0f);
  129.  
  130. glRotatef(xrot,1.0f,0.0f,0.0f);
  131. glRotatef(yrot,0.0f,1.0f,0.0f);
  132. glRotatef(zrot,0.0f,0.0f,1.0f);
  133.  
  134. glBindTexture(GL_TEXTURE_2D, texture[0]);
  135.  
  136. glBegin(GL_QUADS);
  137. // Front Face
  138. glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f);
  139. glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f);
  140. glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, 1.0f);
  141. glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 1.0f);
  142. // Back Face
  143. glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f);
  144. glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f);
  145. glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, 1.0f, -1.0f);
  146. glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f);
  147. // Top Face
  148. glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f);
  149. glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, 1.0f, 1.0f);
  150. glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, 1.0f, 1.0f);
  151. glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, -1.0f);
  152. // Bottom Face
  153. glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, -1.0f, -1.0f);
  154. glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, -1.0f, -1.0f);
  155. glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f);
  156. glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f);
  157. // Right face
  158. glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f);
  159. glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, -1.0f);
  160. glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, 1.0f, 1.0f);
  161. glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f);
  162. // Left Face
  163. glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f);
  164. glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f);
  165. glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 1.0f);
  166. glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f);
  167. glEnd();
  168.  
  169. xrot+=0.3f;
  170. yrot+=0.2f;
  171. zrot+=0.4f;
  172. return TRUE; // Keep Going
  173. }
  174.  
  175. GLvoid KillGLWindow(GLvoid) // Properly Kill The Window
  176. {
  177. if (fullscreen) // Are We In Fullscreen Mode?
  178. {
  179. ChangeDisplaySettings(NULL,0); // If So Switch Back To The Desktop
  180. ShowCursor(TRUE); // Show Mouse Pointer
  181. }
  182.  
  183. if (hRC) // Do We Have A Rendering Context?
  184. {
  185. if (!wglMakeCurrent(NULL,NULL)) // Are We Able To Release The DC And RC Contexts?
  186. {
  187. MessageBox(NULL,"Release Of DC And RC Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
  188. }
  189.  
  190. if (!wglDeleteContext(hRC)) // Are We Able To Delete The RC?
  191. {
  192. MessageBox(NULL,"Release Rendering Context Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
  193. }
  194. hRC=NULL; // Set RC To NULL
  195. }
  196.  
  197. if (hDC && !ReleaseDC(hWnd,hDC)) // Are We Able To Release The DC
  198. {
  199. MessageBox(NULL,"Release Device Context Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
  200. hDC=NULL; // Set DC To NULL
  201. }
  202.  
  203. if (hWnd && !DestroyWindow(hWnd)) // Are We Able To Destroy The Window?
  204. {
  205. MessageBox(NULL,"Could Not Release hWnd.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
  206. hWnd=NULL; // Set hWnd To NULL
  207. }
  208.  
  209. if (!UnregisterClass("OpenGL",hInstance)) // Are We Able To Unregister Class
  210. {
  211. MessageBox(NULL,"Could Not Unregister Class.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
  212. hInstance=NULL; // Set hInstance To NULL
  213. }
  214. }
  215.  
  216. /* This Code Creates Our OpenGL Window. Parameters Are: *
  217.  * title - Title To Appear At The Top Of The Window *
  218.  * width - Width Of The GL Window Or Fullscreen Mode *
  219.  * height - Height Of The GL Window Or Fullscreen Mode *
  220.  * bits - Number Of Bits To Use For Color (8/16/24/32) *
  221.  * fullscreenflag - Use Fullscreen Mode (TRUE) Or Windowed Mode (FALSE) */
  222.  
  223. BOOL CreateGLWindow(char* title, int width, int height, int bits, bool fullscreenflag)
  224. {
  225. GLuint PixelFormat; // Holds The Results After Searching For A Match
  226. WNDCLASS wc; // Windows Class Structure
  227. DWORD dwExStyle; // Window Extended Style
  228. DWORD dwStyle; // Window Style
  229. RECT WindowRect; // Grabs Rectangle Upper Left / Lower Right Values
  230. WindowRect.left=(long)0; // Set Left Value To 0
  231. WindowRect.right=(long)width; // Set Right Value To Requested Width
  232. WindowRect.top=(long)0; // Set Top Value To 0
  233. WindowRect.bottom=(long)height; // Set Bottom Value To Requested Height
  234.  
  235. fullscreen=fullscreenflag; // Set The Global Fullscreen Flag
  236.  
  237. hInstance = GetModuleHandle(NULL); // Grab An Instance For Our Window
  238. wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; // Redraw On Size, And Own DC For Window.
  239. wc.lpfnWndProc = (WNDPROC) WndProc; // WndProc Handles Messages
  240. wc.cbClsExtra = 0; // No Extra Window Data
  241. wc.cbWndExtra = 0; // No Extra Window Data
  242. wc.hInstance = hInstance; // Set The Instance
  243. wc.hIcon = LoadIcon(NULL, IDI_WINLOGO); // Load The Default Icon
  244. wc.hCursor = LoadCursor(NULL, IDC_ARROW); // Load The Arrow Pointer
  245. wc.hbrBackground = NULL; // No Background Required For GL
  246. wc.lpszMenuName = NULL; // We Don't Want A Menu
  247. wc.lpszClassName = "OpenGL"; // Set The Class Name
  248.  
  249. if (!RegisterClass(&wc)) // Attempt To Register The Window Class
  250. {
  251. MessageBox(NULL,"Failed To Register The Window Class.","ERROR",MB_OK|MB_ICONEXCLAMATION);
  252. return FALSE; // Return FALSE
  253. }
  254.  
  255. if (fullscreen) // Attempt Fullscreen Mode?
  256. {
  257. DEVMODE dmScreenSettings; // Device Mode
  258. memset(&dmScreenSettings,0,sizeof(dmScreenSettings)); // Makes Sure Memory's Cleared
  259. dmScreenSettings.dmSize=sizeof(dmScreenSettings); // Size Of The Devmode Structure
  260. dmScreenSettings.dmPelsWidth = width; // Selected Screen Width
  261. dmScreenSettings.dmPelsHeight = height; // Selected Screen Height
  262. dmScreenSettings.dmBitsPerPel = bits; // Selected Bits Per Pixel
  263. dmScreenSettings.dmFields=DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT;
  264.  
  265. // Try To Set Selected Mode And Get Results. NOTE: CDS_FULLSCREEN Gets Rid Of Start Bar.
  266. if (ChangeDisplaySettings(&dmScreenSettings,CDS_FULLSCREEN)!=DISP_CHANGE_SUCCESSFUL)
  267. {
  268. // If The Mode Fails, Offer Two Options. Quit Or Use Windowed Mode.
  269. 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)
  270. {
  271. fullscreen=FALSE; // Windowed Mode Selected. Fullscreen = FALSE
  272. }
  273. else
  274. {
  275. // Pop Up A Message Box Letting User Know The Program Is Closing.
  276. MessageBox(NULL,"Program Will Now Close.","ERROR",MB_OK|MB_ICONSTOP);
  277. return FALSE; // Return FALSE
  278. }
  279. }
  280. }
  281.  
  282. if (fullscreen) // Are We Still In Fullscreen Mode?
  283. {
  284. dwExStyle=WS_EX_APPWINDOW; // Window Extended Style
  285. dwStyle=WS_POPUP; // Windows Style
  286. ShowCursor(FALSE); // Hide Mouse Pointer
  287. }
  288. else
  289. {
  290. dwExStyle=WS_EX_APPWINDOW | WS_EX_WINDOWEDGE; // Window Extended Style
  291. dwStyle=WS_OVERLAPPEDWINDOW; // Windows Style
  292. }
  293.  
  294. AdjustWindowRectEx(&WindowRect, dwStyle, FALSE, dwExStyle); // Adjust Window To True Requested Size
  295.  
  296. // Create The Window
  297. if (!(hWnd=CreateWindowEx( dwExStyle, // Extended Style For The Window
  298. "OpenGL", // Class Name
  299. title, // Window Title
  300. dwStyle | // Defined Window Style
  301. WS_CLIPSIBLINGS | // Required Window Style
  302. WS_CLIPCHILDREN, // Required Window Style
  303. 0, 0, // Window Position
  304. WindowRect.right-WindowRect.left, // Calculate Window Width
  305. WindowRect.bottom-WindowRect.top, // Calculate Window Height
  306. NULL, // No Parent Window
  307. NULL, // No Menu
  308. hInstance, // Instance
  309. NULL))) // Dont Pass Anything To WM_CREATE
  310. {
  311. KillGLWindow(); // Reset The Display
  312. MessageBox(NULL,"Window Creation Error.","ERROR",MB_OK|MB_ICONEXCLAMATION);
  313. return FALSE; // Return FALSE
  314. }
  315.  
  316. static PIXELFORMATDESCRIPTOR pfd= // pfd Tells Windows How We Want Things To Be
  317. {
  318. sizeof(PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor
  319. 1, // Version Number
  320. PFD_DRAW_TO_WINDOW | // Format Must Support Window
  321. PFD_SUPPORT_OPENGL | // Format Must Support OpenGL
  322. PFD_DOUBLEBUFFER, // Must Support Double Buffering
  323. PFD_TYPE_RGBA, // Request An RGBA Format
  324. bits, // Select Our Color Depth
  325. 0, 0, 0, 0, 0, 0, // Color Bits Ignored
  326. 0, // No Alpha Buffer
  327. 0, // Shift Bit Ignored
  328. 0, // No Accumulation Buffer
  329. 0, 0, 0, 0, // Accumulation Bits Ignored
  330. 16, // 16Bit Z-Buffer (Depth Buffer)
  331. 0, // No Stencil Buffer
  332. 0, // No Auxiliary Buffer
  333. PFD_MAIN_PLANE, // Main Drawing Layer
  334. 0, // Reserved
  335. 0, 0, 0 // Layer Masks Ignored
  336. };
  337.  
  338. if (!(hDC=GetDC(hWnd))) // Did We Get A Device Context?
  339. {
  340. KillGLWindow(); // Reset The Display
  341. MessageBox(NULL,"Can't Create A GL Device Context.","ERROR",MB_OK|MB_ICONEXCLAMATION);
  342. return FALSE; // Return FALSE
  343. }
  344.  
  345. if (!(PixelFormat=ChoosePixelFormat(hDC,&pfd))) // Did Windows Find A Matching Pixel Format?
  346. {
  347. KillGLWindow(); // Reset The Display
  348. MessageBox(NULL,"Can't Find A Suitable PixelFormat.","ERROR",MB_OK|MB_ICONEXCLAMATION);
  349. return FALSE; // Return FALSE
  350. }
  351.  
  352. if(!SetPixelFormat(hDC,PixelFormat,&pfd)) // Are We Able To Set The Pixel Format?
  353. {
  354. KillGLWindow(); // Reset The Display
  355. MessageBox(NULL,"Can't Set The PixelFormat.","ERROR",MB_OK|MB_ICONEXCLAMATION);
  356. return FALSE; // Return FALSE
  357. }
  358.  
  359. if (!(hRC=wglCreateContext(hDC))) // Are We Able To Get A Rendering Context?
  360. {
  361. KillGLWindow(); // Reset The Display
  362. MessageBox(NULL,"Can't Create A GL Rendering Context.","ERROR",MB_OK|MB_ICONEXCLAMATION);
  363. return FALSE; // Return FALSE
  364. }
  365.  
  366. if(!wglMakeCurrent(hDC,hRC)) // Try To Activate The Rendering Context
  367. {
  368. KillGLWindow(); // Reset The Display
  369. MessageBox(NULL,"Can't Activate The GL Rendering Context.","ERROR",MB_OK|MB_ICONEXCLAMATION);
  370. return FALSE; // Return FALSE
  371. }
  372.  
  373. ShowWindow(hWnd,SW_SHOW); // Show The Window
  374. SetForegroundWindow(hWnd); // Slightly Higher Priority
  375. SetFocus(hWnd); // Sets Keyboard Focus To The Window
  376. ReSizeGLScene(width, height); // Set Up Our Perspective GL Screen
  377.  
  378. if (!InitGL()) // Initialize Our Newly Created GL Window
  379. {
  380. KillGLWindow(); // Reset The Display
  381. MessageBox(NULL,"Initialization Failed.","ERROR",MB_OK|MB_ICONEXCLAMATION);
  382. return FALSE; // Return FALSE
  383. }
  384.  
  385. return TRUE; // Success
  386. }
  387.  
  388. LRESULT CALLBACK WndProc( HWND hWnd, // Handle For This Window
  389. UINT uMsg, // Message For This Window
  390. WPARAM wParam, // Additional Message Information
  391. LPARAM lParam) // Additional Message Information
  392. {
  393. switch (uMsg) // Check For Windows Messages
  394. {
  395. case WM_ACTIVATE: // Watch For Window Activate Message
  396. {
  397. if (!HIWORD(wParam)) // Check Minimization State
  398. {
  399. active=TRUE; // Program Is Active
  400. }
  401. else
  402. {
  403. active=FALSE; // Program Is No Longer Active
  404. }
  405.  
  406. return 0; // Return To The Message Loop
  407. }
  408.  
  409. case WM_SYSCOMMAND: // Intercept System Commands
  410. {
  411. switch (wParam) // Check System Calls
  412. {
  413. case SC_SCREENSAVE: // Screensaver Trying To Start?
  414. case SC_MONITORPOWER: // Monitor Trying To Enter Powersave?
  415. return 0; // Prevent From Happening
  416. }
  417. break; // Exit
  418. }
  419.  
  420. case WM_CLOSE: // Did We Receive A Close Message?
  421. {
  422. PostQuitMessage(0); // Send A Quit Message
  423. return 0; // Jump Back
  424. }
  425.  
  426. case WM_KEYDOWN: // Is A Key Being Held Down?
  427. {
  428. keys[wParam] = TRUE; // If So, Mark It As TRUE
  429. return 0; // Jump Back
  430. }
  431.  
  432. case WM_KEYUP: // Has A Key Been Released?
  433. {
  434. keys[wParam] = FALSE; // If So, Mark It As FALSE
  435. return 0; // Jump Back
  436. }
  437.  
  438. case WM_SIZE: // Resize The OpenGL Window
  439. {
  440. ReSizeGLScene(LOWORD(lParam),HIWORD(lParam)); // LoWord=Width, HiWord=Height
  441. return 0; // Jump Back
  442. }
  443. }
  444.  
  445. // Pass All Unhandled Messages To DefWindowProc
  446. return DefWindowProc(hWnd,uMsg,wParam,lParam);
  447. }
  448.  
  449. int WINAPI WinMain( HINSTANCE hInstance, // Instance
  450. HINSTANCE hPrevInstance, // Previous Instance
  451. LPSTR lpCmdLine, // Command Line Parameters
  452. int nCmdShow) // Window Show State
  453. {
  454. MSG msg; // Windows Message Structure
  455. BOOL done=FALSE; // Bool Variable To Exit Loop
  456.  
  457. // Ask The User Which Screen Mode They Prefer
  458. if (MessageBox(NULL,"Would You Like To Run In Fullscreen Mode?", "Start FullScreen?",MB_YESNO|MB_ICONQUESTION)==IDNO)
  459. {
  460. fullscreen=FALSE; // Windowed Mode
  461. }
  462.  
  463. // Create Our OpenGL Window
  464. if (!CreateGLWindow("NeHe's Texture Mapping Tutorial",640,480,16,fullscreen))
  465. {
  466. return 0; // Quit If Window Was Not Created
  467. }
  468.  
  469. while(!done) // Loop That Runs While done=FALSE
  470. {
  471. if (PeekMessage(&msg,NULL,0,0,PM_REMOVE)) // Is There A Message Waiting?
  472. {
  473. if (msg.message==WM_QUIT) // Have We Received A Quit Message?
  474. {
  475. done=TRUE; // If So done=TRUE
  476. }
  477. else // If Not, Deal With Window Messages
  478. {
  479. TranslateMessage(&msg); // Translate The Message
  480. DispatchMessage(&msg); // Dispatch The Message
  481. }
  482. }
  483. else // If There Are No Messages
  484. {
  485. // Draw The Scene. Watch For ESC Key And Quit Messages From DrawGLScene()
  486. if ((active && !DrawGLScene()) || keys[VK_ESCAPE]) // Active? Was There A Quit Received?
  487. {
  488. done=TRUE; // ESC or DrawGLScene Signalled A Quit
  489. }
  490. else // Not Time To Quit, Update Screen
  491. {
  492. SwapBuffers(hDC); // Swap Buffers (Double Buffering)
  493. }
  494.  
  495. if (keys[VK_F1]) // Is F1 Being Pressed?
  496. {
  497. keys[VK_F1]=FALSE; // If So Make Key FALSE
  498. KillGLWindow(); // Kill Our Current Window
  499. fullscreen=!fullscreen; // Toggle Fullscreen / Windowed Mode
  500. // Recreate Our OpenGL Window
  501. if (!CreateGLWindow("NeHe's Texture Mapping Tutorial",640,480,16,fullscreen))
  502. {
  503. return 0; // Quit If Window Was Not Created
  504. }
  505. }
  506. }
  507. }
  508.  
  509. // Shutdown
  510. KillGLWindow(); // Kill The Window
  511. return (msg.wParam); // Exit The Program
  512. }
I've compiled it ang get the result below;

------ Build started: Project: TugasOpenGl2, Configuration: Debug Win32 ------
Compiling...
Tugas2.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
Linking...
Embedding manifest...
Build log was saved at "file://c:\Documents and Settings\SATELLITE\My Documents\Visual Studio 2008\Projects\TugasOpenGl2\TugasOpenGl2\Debug\BuildLog.htm"
TugasOpenGl2 - 0 error(s), 2 warning(s)
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

Then I ran it but it still didn't change. I mean when it start to be in running mode, the result that should appear couldn't stay long. It just disappear in second, and told me that the Initialization Failed.

What should I do?
Last edited by Ancient Dragon; Oct 19th, 2008 at 7:53 am. Reason: add code tags
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,350
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1462
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: Visual C++ Debugging Problem

 
0
  #5
Oct 19th, 2008
I didn't get the errors you got using VC++ 2008 Express. Probably one (or both) of two reasons

2) Read this short tutorial about how to set up the project's environment.

3) download and install the Windows Platform SDK from Microsoft site. It contains the openGL headers and libs.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC