NeHe Tutorial 01 - error?

Started by
10 comments, last by Ali_nz 18 years, 1 month ago
Hi Guys, I am trying to do NeHe's tutorial 01 http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=01 However I am getting the following error message: c:\documents and settings\al\my documents\visual studio 2005\projects\testing\testing\opengl1.cpp(74) : 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 I have tried typing in the code, and even copying it from his site but it still wont compile. I am in Visual C++ express. Thanks guys, -Al
Advertisement
Try the following :

Go to Projects->Projects Properties->Configuration Properties->C++
Change the "Detect 64-bit ... " to "no"
There is nothing that can't be solved. Just people that can't solve it. :)
Every Win32 function has two versions ANSI and Unicode -- MessageBoxA and MessageBoxW, for example. The W version is for Unicode and the A version is for standard ANSI characters. There is a switch or a symbol (_UNICODE) somewhere that enables the Unicode functions. It appears to be set in your situation. Sorry, I don't remember how to change it.

Instead of switching back to ANSI from Unicode, you could change your strings to Unicode, using wchar_t and the L string suffix and the "w" versions of the string functions (wcscpy, etc.), or make them work either way using TCHAR, _T(), and the "t" versions of the string functions (_tcscpy, etc.).
John BoltonLocomotive Games (THQ)Current Project: Destroy All Humans (Wii). IN STORES NOW!
I think this message has the answer, but I can not find those settings in project properties in VC++ express.

Anyone able to help pleaseeeeee

http://www.gamedev.net/community/forums/topic.asp?topic_id=380383


Ta
-AL
Quote:Original post by DesignerX
Try the following :

Go to Projects->Projects Properties->Configuration Properties->C++
Change the "Detect 64-bit ... " to "no"


64bit isn't the problem... Rather than change the Detect 64 bit to no, there is another option for Unicode characters... Change this to Not Set
I have not got any options like that under project properties.

I have:

+Common properties
Startup Project
Project Dependancies
Debug Source Files
+Configuration Properties
Configuartion

But again - they dont have any settings to do with unicode.

Please help

-Al

PS: I fixed some of the errors by changing:

MessageBox(NULL,"Window Creation Error.","ERROR",MB_OK|MB_ICONEXCLAMATION);
to
MessageBox(NULL,L"Window Creation Error.",L"ERROR",MB_OK|MB_ICONEXCLAMATION);
It is in the Configuration one but I will look tonight on mine so I can point you in the right direction.

Use DevC++ :) It's a simple project, so there's absolutely no need to use the huge VC++ 2005.
Quote:Original post by Ali_nz
MessageBox(NULL,"Window Creation Error.","ERROR",MB_OK|MB_ICONEXCLAMATION);
to
MessageBox(NULL,L"Window Creation Error.",L"ERROR",MB_OK|MB_ICONEXCLAMATION);

There's no need for you to use Unicode for such a simple project.
Quote:
I have not got any options like that under project properties.

I have:

+Common properties
Startup Project
Project Dependancies
Debug Source Files
+Configuration Properties
Configuartion

But again - they dont have any settings to do with unicode.

These are your 'Solution properties', which are a bit different from 'Project properties'. Follow these instructions to switch to ASCII:
Look at your 'Solution Explorer'.
For me, it's the box left to my code-window.
On its first line you'll see "Solution 'MyProject'(1 project)".
This is your Solution.
Directly below it is your project.
Right click it and go to properties.
Click on 'Configuration Properties'.
In the right half of the screen there will appear some options.
Click on 'Character Set', a member of 'Project Defaults'.
Change it to 'Not Set'.
Click on OK, compile your project and have fun!
Ok team, I finally worked out how to add the additional dependancies :-)))

Thanks!

Finally tho when I ran the program I got a blank window!!! Arrrgh.

Anyone able to tell me how to fix this???

Cheers again,

-Al
PS: One thing that scares the hell outta me is how many lines it took to draw a square???

This topic is closed to new replies.

Advertisement