OpenGL and Visual Studio Express 2008
I recently set up Visual C++ 2008 Express Edition and OpenGL on my Windows XP and Windows Vista computers. I had a few issues, but it is working now. I have a step by step tutorial below and also outlined some of the issues I had.
This is also a guide on just setting up your development environment on Windows for OpenGL programming. If you are like me, I am starting out doing game programming and want to add OpenGL graphics.
The OpenGL tutorials I am using are from NeHe's Website and here is a Visual C++ 2008 and OpenGL Guide I used.
Getting OpenGL to Work With Visual C++ 2008
Follow each step, unless you have already done one of these steps.
1. Install Visual C++ 2008 Express Edition
This is a free C++ IDE from Microsoft that is an excellent tool to start with, if you are interested in programming on a Windows environment.
You can find Visual C++ 2008 on the Visual Studio Express download page on Microsoft's site. It only works on Windows XP and up. If you have an older version of windows you might want to find Visual C++ 2005 and then use this Visual C++ 2005 and OpenGL tutorial.
2. Install Windows SDK for Windows Server 2008 and .NET Framework 3.5
This is the equivalent to the Windows� Server 2003 SP1 Platform SDK that Visual C++ 2005 users installed. It contains the main OpenGL libraries. You can download the Windows SDK for Windows Server 2008 and .NET Framework from the Microsoft website.
The installation will take a little while.
3. Install the GLUT Libraries
These are additional libraries that come in handy down the road. Some code samples you find may use them, so I find it best to just have them around right off the bat.
GLUT itself is a bit old, but there is another one called freeglut that is a little more actively maintained. I install both of them. Download freeglut from the freeglut SourceForge page. I download the original GLUT from Nate Robins' site.
For both downloads, unzip them and do the following:
- Copy all the .h files into the C:\Program Files\Microsoft SDKs\Windows\v6.1\Include\GL folder. This should be glut.h, freeglut.h, freeglut_ext.h, and freeglut_std.h.
- Copy all the .lib files into the C:\Program Files\Microsoft SDKs\Windows\v6.1\Lib folder. This should be freeglut.lib and glut32.lib.
- Copy all the .dll files into the C:\Windows\system32 folder. This should be freeglut.dll and glut32.dll.
4. Create Your First Project
Create a project in Visual C++ with whatever name you like and set the template as Win32 Project. Click OK.
Click Next on the following screen and you will be taken to Application Settings. Check on Empty Project and then click OK. Your new project has been created.
Declare the dependencies for your project.
- Click on Project -> [project name] Properties.
- Expand Configuration Properties.
- In the Configuration dropdown, select All Configurations.
- Select Linker -> Input.
- In the Additional Dependencies field, enter in GlU32.Lib OpenGL32.Lib freeglut.lib glut32.lib. Then click OK.
5. Create Your First Source File
I recommend a .cpp file. I recommned downloading the source code from NeHe's Lesson 2 and copying into the file you just created.
Press F7 to compile it and F5 to run it.
It should be working at this point. If not, post a comment and I will try and help out.
Problems Setting Up OpenGL and Visual C++ 2008 Express Edition
Character Set Error
When I try to compile the project, I get the following error:
------ Build started: Project: Test, Configuration: Debug Win32 ------
Compiling...
main.cpp
c:\documents and settings\neil galloway\my documents\visual studio 2008\projects\test\test\main.cpp(87) : error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char [29]' to 'LPCWSTR'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
c:\documents and settings\neil galloway\my documents\visual studio 2008\projects\test\test\main.cpp(92) : error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char [34]' to 'LPCWSTR'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
c:\documents and settings\neil galloway\my documents\visual studio 2008\projects\test\test\main.cpp(99) : error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char [31]' to 'LPCWSTR'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
c:\documents and settings\neil galloway\my documents\visual studio 2008\projects\test\test\main.cpp(105) : error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char [24]' to 'LPCWSTR'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
c:\documents and settings\neil galloway\my documents\visual studio 2008\projects\test\test\main.cpp(109) : error C2664: 'UnregisterClassW' : cannot convert parameter 1 from 'const char [7]' to 'LPCWSTR'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
c:\documents and settings\neil galloway\my documents\visual studio 2008\projects\test\test\main.cpp(111) : error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char [28]' to 'LPCWSTR'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
c:\documents and settings\neil galloway\my documents\visual studio 2008\projects\test\test\main.cpp(147) : error C2440: '=' : cannot convert from 'const char [7]' to 'LPCWSTR'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
c:\documents and settings\neil galloway\my documents\visual studio 2008\projects\test\test\main.cpp(151) : error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char [37]' to 'LPCWSTR'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
c:\documents and settings\neil galloway\my documents\visual studio 2008\projects\test\test\main.cpp(169) : error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char [94]' to 'LPCWSTR'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
c:\documents and settings\neil galloway\my documents\visual studio 2008\projects\test\test\main.cpp(176) : error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char [24]' to 'LPCWSTR'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
c:\documents and settings\neil galloway\my documents\visual studio 2008\projects\test\test\main.cpp(209) : error C2664: 'CreateWindowExW' : cannot convert parameter 2 from 'const char [7]' to 'LPCWSTR'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
c:\documents and settings\neil galloway\my documents\visual studio 2008\projects\test\test\main.cpp(212) : error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char [23]' to 'LPCWSTR'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
c:\documents and settings\neil galloway\my documents\visual studio 2008\projects\test\test\main.cpp(241) : error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char [34]' to 'LPCWSTR'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
c:\documents and settings\neil galloway\my documents\visual studio 2008\projects\test\test\main.cpp(248) : error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char [35]' to 'LPCWSTR'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
c:\documents and settings\neil galloway\my documents\visual studio 2008\projects\test\test\main.cpp(255) : error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char [27]' to 'LPCWSTR'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
c:\documents and settings\neil galloway\my documents\visual studio 2008\projects\test\test\main.cpp(262) : error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char [37]' to 'LPCWSTR'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
c:\documents and settings\neil galloway\my documents\visual studio 2008\projects\test\test\main.cpp(269) : error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char [41]' to 'LPCWSTR'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
c:\documents and settings\neil galloway\my documents\visual studio 2008\projects\test\test\main.cpp(281) : error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char [23]' to 'LPCWSTR'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
c:\documents and settings\neil galloway\my documents\visual studio 2008\projects\test\test\main.cpp(358) : error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char [42]' to 'LPCWSTR'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Build log was saved at "file://c:\Documents and Settings\Neil Galloway\My Documents\Visual Studio 2008\Projects\Test\Test\Debug\BuildLog.htm"
Test - 19 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
This can be fixed by doing the following:
- Project -> [projectname] Properties
- In the Configuration dropdown, pick All Configurations.
- Expand Configuration Properties.
- Select General.
- Change the Character Set to be Use Multi-Byte Character Set.
The errors should go away the next time you compile.
Can't Include glaux.h
The first time I compiled, I received the following error:
------ Build started: Project: Test, Configuration: Debug Win32 ------
Compiling...
main.cpp
c:\documents and settings\neil galloway\my documents\visual studio 2008\projects\test\test\main.cpp(12) : fatal error C1083: Cannot open include file: 'gl\glaux.h': No such file or directory
Build log was saved at "file://c:\Documents and Settings\Neil Galloway\My Documents\Visual Studio 2008\Projects\Test\Test\Debug\BuildLog.htm" Test - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
This is because the glaux.h has not been added to the include folder. You can do this if you want, but the glaux.h library is old and out dated based on most user comments on the internet. A lot of the examples, especially from NeHe, do not even use the code inside it anymore. I can usually just comment out or remove the
#includefrom the code and it will be fine.
Set Up Dependencies For The Project
When the dependencies are not there, I received the following error trying to compile:
------ Build started: Project: OpenGLTest, Configuration: Debug Win32 ------ Compiling... WinMain.cpp Compiling manifest to resources... Microsoft (R) Windows (R) Resource Compiler Version 6.0.5724.0 Copyright (C) Microsoft Corporation. All rights reserved. Linking... WinMain.obj : error LNK2019: unresolved external symbol _gluPerspective@32 referenced in function "void __cdecl ReSizeGLScene(int,int)" (?ReSizeGLScene@@YAXHH@Z) WinMain.obj : error LNK2019: unresolved external symbol __imp__glLoadIdentity@0 referenced in function "void __cdecl ReSizeGLScene(int,int)" (?ReSizeGLScene@@YAXHH@Z) WinMain.obj : error LNK2019: unresolved external symbol __imp__glMatrixMode@4 referenced in function "void __cdecl ReSizeGLScene(int,int)" (?ReSizeGLScene@@YAXHH@Z) WinMain.obj : error LNK2019: unresolved external symbol __imp__glViewport@16 referenced in function "void __cdecl ReSizeGLScene(int,int)" (?ReSizeGLScene@@YAXHH@Z) WinMain.obj : error LNK2019: unresolved external symbol __imp__glHint@8 referenced in function "int __cdecl InitGL(void)" (?InitGL@@YAHXZ) WinMain.obj : error LNK2019: unresolved external symbol __imp__glDepthFunc@4 referenced in function "int __cdecl InitGL(void)" (?InitGL@@YAHXZ) WinMain.obj : error LNK2019: unresolved external symbol __imp__glEnable@4 referenced in function "int __cdecl InitGL(void)" (?InitGL@@YAHXZ) WinMain.obj : error LNK2019: unresolved external symbol __imp__glClearDepth@8 referenced in function "int __cdecl InitGL(void)" (?InitGL@@YAHXZ) WinMain.obj : error LNK2019: unresolved external symbol __imp__glClearColor@16 referenced in function "int __cdecl InitGL(void)" (?InitGL@@YAHXZ) WinMain.obj : error LNK2019: unresolved external symbol __imp__glShadeModel@4 referenced in function "int __cdecl InitGL(void)" (?InitGL@@YAHXZ) WinMain.obj : error LNK2019: unresolved external symbol __imp__glEnd@0 referenced in function "int __cdecl DrawGLScene(void)" (?DrawGLScene@@YAHXZ) WinMain.obj : error LNK2019: unresolved external symbol __imp__glVertex3f@12 referenced in function "int __cdecl DrawGLScene(void)" (?DrawGLScene@@YAHXZ) WinMain.obj : error LNK2019: unresolved external symbol __imp__glBegin@4 referenced in function "int __cdecl DrawGLScene(void)" (?DrawGLScene@@YAHXZ) WinMain.obj : error LNK2019: unresolved external symbol __imp__glTranslatef@12 referenced in function "int __cdecl DrawGLScene(void)" (?DrawGLScene@@YAHXZ) WinMain.obj : error LNK2019: unresolved external symbol __imp__glClear@4 referenced in function "int __cdecl DrawGLScene(void)" (?DrawGLScene@@YAHXZ) WinMain.obj : error LNK2019: unresolved external symbol __imp__wglDeleteContext@4 referenced in function "void __cdecl KillGLWindow(void)" (?KillGLWindow@@YAXXZ) WinMain.obj : error LNK2019: unresolved external symbol __imp__wglMakeCurrent@8 referenced in function "void __cdecl KillGLWindow(void)" (?KillGLWindow@@YAXXZ) WinMain.obj : error LNK2019: unresolved external symbol __imp__wglCreateContext@4 referenced in function "int __cdecl CreateGLWindow(char *,int,int,int,bool)" (?CreateGLWindow@@YAHPADHHH_N@Z)
MSVCRTD.lib(crtexe.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup C:\devkitPro\projects\OpenGLTest\Debug\OpenGLTest.exe : fatal error LNK1120: 19 unresolved externals Build log was saved at "file://c:\devkitPro\projects\OpenGLTest\Debug\BuildLog.htm" OpenGLTest - 20 error(s), 0 warning(s) ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
To set up OpenGL dependencies for a project, refer to the declaring the dependencies section in Create You First Project section above.
That should fix the problem, try recompiling now.
Change the Application Type
I have also experienced the following error when I compile:
------ Build started: Project: OpenGLTest, Configuration: Debug Win32 ------ Linking... MSVCRTD.lib(crtexe.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup C:\devkitPro\projects\OpenGLTest\Debug\OpenGLTest.exe : fatal error LNK1120: 1 unresolved externals Build log was saved at "file://c:\devkitPro\projects\OpenGLTest\Debug\BuildLog.htm" OpenGLTest - 2 error(s), 0 warning(s) ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
This was caused by not picking the right application type when I created the project. In this example, I chose Win32 Console Application at the startup. To change it, I did the following:
- Click on Project -> [project name] Properties.
- Expand Configuration Properties.
- In the Configuration dropdown, select All Configurations.
- Select Linker -> System.
- Change the Subsystem field to be Windows (in the case it was Console or try the opposite if it already is Windows). Click OK.
If you enjoyed this post, then make sure you subscribe to my RSS feed or subscribe for email updates. Only one email a day and only if there was a new post.
Related Posts
Win32 Application and Logging To The Console
Time for NDS Homebrew
Keep Text Formatting In HTML Using The pre Tag
Visual Appeal At Trade Exhibits
Canadian Election 2008 - Conservative Minority
Category: Computers
32 Comments
Matt Moen Says:
2008-04-09 01:20:53
Very nice tutorial. You are a better writer than me.
As long as you're using OpenGL why not go one step further and make your code portable? Instead of using Windows API look into Simple DirectMedia Layer - it provides basic cross-platform window control, sound, and input. SDL is well maintained and documented with extended libraries for working with compressed image formats, sound mixing, font rendering, network communications, and more.
If you're interested, check out my latest tutorial for setting up SDL and OpenGL in Visual C++.
Neil Galloway Says:
2008-04-09 08:47:39
I will check that out for sure. I am sticking with OpenGL because I am actually doing a coding project for the Nintendo DS and the libnds library has a base set of OpenGL functions to use. I find it easier to code some parts in a windows environment and then port it over to help in learning it.
Christian Mathiesen Says:
2008-05-07 19:20:46
Hey dude thanks a lot man! It freaking gave me such a headache trying to figure out the multi-byte character thing!
Keep up the good work!
Christian
daniel Says:
2008-05-13 08:30:02
thanks for putting up that information, saved me lots of time
Trev Says:
2008-05-16 22:41:24
Hey- I really appreciate you taking the time to write this! Saved me time, and headache!
Joshua Says:
2008-05-21 05:04:58
Thanks for your tutorial. Unfortunately, I got the following error message:
------ Build started: Project: opengltest2, Configuration: Debug Win32 ------
Embedding manifest...
.\Debug\opengltest2.exe.intermediate.manifest : general error c1010070: Failed to load and parse the manifest. The system cannot find the file specified.
Build log was saved at "file://c:\Documents and Settings\Joshua\My Documents\Visual Studio 2008\Projects\opengltest2\Debug\BuildLog.htm"
opengltest2 - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Anonymous Says:
2008-05-21 17:49:26
thanks
Joe Says:
2008-06-05 03:19:22
I'm trying to get this to run on my 64bit Vista Business system. The directories are all different of course. How can I make this work?
Allard Says:
2008-06-17 11:01:50
I need freeglut.dll for C# (VCS2008EE) can I use the same file as you used for C++ or where do I find the freeglut.dll file I need?
Anonymous Says:
2008-06-20 05:26:31
if you can find some files on step " 3. Install the GLUT Libraries", you can download from link below
http://cs.selu.edu/~soconnell/freeglut.zip
Anonymous Says:
2008-06-26 11:56:12
Thanks alot, man! I was having alot of trouble with the "MessageBoxW" thing.
carox Says:
2008-06-30 07:19:51
I ran th program :
#include
#include
#include
#include
// *************** mylnitt) **************
void mylnit(void)
{
glClearColour(1.0,1.0,1.0,0.0); // set white background colour
gIColour3f(0.0f,0.0f, 0.0f); // set the drawing colour
gIPointSize(4.0); // One 'dot' is a 4 by 4 pixel
gIMatrixMode(GL_PROJECTION);
glLoadldentity();
gluOrtho2D(0.0,800.0,0.0,600.0);
}
// *********************** mylrisplayt) ***********
void myDisplay(void)
{
gIClear(GL_COLOUR_BUFFER_BIT); // clear the screen
gIBegin(GL_OLYGON); //Draw the polygon with the following vertex point
glVertex2i(l00,100);
gIVertex2i(lOO,300);
gIVertex2i(400,300);
gIVertex2i(600,150);
glVertex2i(400,100);
glEnd() ;
glflush();
}// send all output to the display
// ****************** main function ********************
void main(int argc, char** argv)
{
glutInit(&argc, argv) ; // initialise the toolkit
glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB); // set display mode
glutInitWindowSize(800,600); // set window size
glutInitWindowPosition( I00,100); // set window position on your screen
glutCreateWindow("OpenGL Window"); // Open the screen window with this name
glutDisplayFunc(myDisplay); // register redraw function
myInit();
glutMainLoop(); // go into a perpetual loop
}
But I am getting the following error:
1>------ Build started: Project: p34_filled polygon, Configuration: Debug Win32 ------
1>Embedding manifest...
1>Project : error PRJ0003 : Error spawning 'mt.exe'.
1>Build log was saved at "file://c:\Program Files\Microsoft Visual Studio\My Projects\p34_filled polygon\p34_filled polygon\Debug\BuildLog.htm"
1>p34_filled polygon - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I am not getting the possible error. Can you plz help.
Regards,
Carox.
Joe Piechuck Says:
2008-07-01 22:34:31
Could someone please help me? I can't finish step 3. I cannot find freeglut.lib I downloaded versions 2.2 and 2.4, and I can't find it within either.
dOob InaY Says:
2008-07-07 15:49:34
I did all the steps and when I build the solution for the lesson2, it tell me that plenty of functions are not in the opengl32.dll ? (compilation work)
Thanks
Al Fkaa Says:
2008-08-21 01:36:10
Joe Piechuck: You can find freeglut.lib here: http://users.cs.dal.ca/~sbrooks/csci3161/reference/installingForWindows.NET/index.html
Krisite Says:
2008-09-05 22:31:09
Thanks for this page it has helped alot but I am still getting an error
1>Embedding manifest...
1>.\Debug\example glut.exe.intermediate.manifest : general error c1010070: Failed to load and parse the manifest. The system cannot find the file specified.
1>Build log was saved at "file://c:\Users\Kristie\Documents\Visual Studio 2008\Projects\example glut\example glut\Debug\BuildLog.htm"
1>example glut - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
What do I do !! Please help!!
Anonymous Says:
2008-09-05 22:41:42
I fixed the problem above now it's saying this
fatal error C1083: Cannot open include file: 'glut.h': No such file or directory
1>Build log was saved at "file://c:\Users\Kristie\Documents\Visual Studio 2008\Projects\example glut\example glut\Debug\BuildLog.htm"
but it is there i put it there
Toufic Says:
2008-09-07 19:32:17
Great man, thanks a lot!
Joe Says:
2008-09-09 23:35:04
After spending maybe 5 hours trying to get some form of openGL going I found your page and it was the very last tip (changed from window to console) that allowed my sample program to build.
Thank you, and google.
Dwight Says:
2008-09-19 19:47:51
hi I have this problem.
1>MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup
1>C:\Users\Dwight Noel\Documents\school\Summer 2008\test\lessons\Debug\lessons.exe : fatal error LNK1120: 1 unresolved externals
1>Build log was saved at "file://c:\Users\Dwight\Documents\school\Summer 2008\test\lessons\Debug\BuildLog.htm"
1>lessons - 2 error(s), 0 warning(s)
Anonymous[2] Says:
2008-10-03 15:51:46
Thanks man, ur site is excellent!!! After searching for weeks, I found ur site. It was like light through a dark tunnel
Anon Says:
2008-10-06 16:05:37
Great site, man. It's helped a lot. Keep up the good work.
SRH Says:
2008-10-13 18:55:22
You've got some good information here... thanks.
I'm still having problems though. This is for a computer graphics class, and this is my first time using Visual C++ (I prefer C#).
Anyway, I tried copying in the sample code from my professor, and I keep getting the following errors:
------ Build started: Project: CGLab, Configuration: Debug Win32 ------
Compiling...
triangle.cpp
c:\program files\microsoft visual studio 9.0\vc\include\stdlib.h(371) : error C2381: 'exit' : redefinition; __declspec(noreturn) differs
d:\program files\microsoft sdks\windows\v6.1\include\gl\glut.h(151) : see declaration of 'exit'
c:\program files\microsoft visual studio 9.0\vc\include\stdlib.h(371) : warning C4985: 'exit': attributes not present on previous declaration.
d:\program files\microsoft sdks\windows\v6.1\include\gl\glut.h(151) : see declaration of 'exit'
Build log was saved at "file://c:\Documents and Settings\Solomon\My Documents\Visual Studio 2008\Projects\CGLab\CGLab\Debug\BuildLog.htm"
CGLab - 1 error(s), 1 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I haven't had any luck fixing this. Any help would be greatly appreciated.
SRH Says:
2008-10-13 19:15:58
One more thing...
I've noticed that putting #include
------ Build started: Project: CGLab, Configuration: Debug Win32 ------
Compiling...
triangle.cpp
Linking...
MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup
C:\Documents and Settings\Solomon\My Documents\Visual Studio 2008\Projects\CGLab\Debug\CGLab.exe : fatal error LNK1120: 1 unresolved externals
Build log was saved at "file://c:\Documents and Settings\Solomon\My Documents\Visual Studio 2008\Projects\CGLab\CGLab\Debug\BuildLog.htm"
CGLab - 2 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Not sure if that information is helpful...
sen Says:
2008-10-17 20:46:48
I'm a newbie in VC++ express 2008, I started it by selecting the step below ;
File --> New --> Project --> win 32 project --> enter name then ok --> welcome to win 32 application wizard --> I choose next --> check the empty project --> click finish.
After that, I didn't see anything that belong to the text field, I mean only start page so that I couldn't even paste a source code in to the empty project which I've created.
What should I do then ?
Anonymous Says:
2008-10-17 21:00:35
This is for all guys who stuck in Gl.h, Glu.h, GLAUX.h or else. Get it free all the complete library, dll, and header files in http://www.swiftless.com. This link gave me all.
For every body who wants to help me please tell me the way to start my first program. I still couldn't see anything except the start page.
sen Says:
2008-10-17 21:06:35
Here it's the complete link http://www.swiftless.com/tutorials/opengl/gldrivers.html
This web also contain superior guide.
All tutorial is free.
Please help, i can't wait for any longer.
I didn't see anything that belong to the text field, I mean only start page so that I couldn't even paste a source code in to the empty project which I've created.
How to make it rigth ?
sen Says:
2008-10-18 21:55:18
I've already solve my first problem about adding new item (ctrl + shift + A). Now I try 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 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 !
Aldo Says:
2008-10-26 00:22:22
PROBLEM:
1>MSVCRTD.lib(crtexew.obj) : error LNK2019: símbolo externo _WinMain@16 sin resolver al que se hace referencia en la función ___tmainCRTStartup
How can I resolve it?
please help!
Thaks
huyfamilykhmer Says:
2008-11-20 17:46:53
PROBLEM:
1>MSVCRTD.lib(crtexew.obj) : error LNK2019: símbolo externo _WinMain@16 sin resolver al que se hace referencia en la función ___tmainCRTStartup
You have to add the following text to your project property->Configuration Properties-->Linker>Command Line: Additional options: /SUBSYSTEM:WINDOWS /ENTRY:mainCRTStartup
Hope this will help.
Cheers.
sen Says:
2008-11-21 22:16:36
Hello, it goes wrong again but I don't know where to make it right.
Last time the code that should be no wrong coz I builded it successfully just stuck in type conversion. I mean no pragma use or others. It just my fault that just uses the code without make suitable type.
Now 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 (R) Windows (R) Resource Compiler Version 6.0.5724.0
Copyright (C) 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 (R) Windows (R) Resource Compiler Version 6.0.5724.0
Copyright (C) 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", wether 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.
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 is my first project code; If I run it should be a rotating box that contain Po bitmap.
#include
#include
#include
#include
#include
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]->sizeX, TextureImage[0]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->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]->data)
{
free(TextureImage[0]->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;
}
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);
}
sen Says:
2008-11-21 22:20:32
Hello everyone, please help me.