Jump to content
  • Advertisement
Sign in to follow this  
happySam

OpenGL Opengl game programming - p.38

This topic is 2586 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all,

I created an empty project with Visual C++ express 2008 and type in the following source code.
I got compile error:


Build started: Project: blank, Configuration: Debug|Win32

[font="arial"][size="+2"] Command Lines [/font] Creating temporary file "d:\0VisualCpp\blank\blank\Debug\RSP00000126562620.rsp" with contents
[
/Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /Gm /EHsc /RTC1 /MDd /Fp".\Debug/blank.pch" /Fo"Debug\\" /Fd"Debug\vc90.pdb" /W3 /c /ZI /TP .\blank.cpp
]
Creating command line "cl.exe @d:\0VisualCpp\blank\blank\Debug\RSP00000126562620.rsp /nologo /errorReport:prompt"
[font="arial"][size="+2"] Output Window [/font] Compiling...
blank.cpp
d:\0visualcpp\blank\blank\blank.cpp(27) : error C2664: 'TextOutW' : cannot convert parameter 4 from 'char [14]' to 'LPCWSTR'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
d:\0visualcpp\blank\blank\blank.cpp(56) : error C2440: '=' : cannot convert from 'const char [8]' to 'LPCWSTR'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
d:\0visualcpp\blank\blank\blank.cpp(71) : error C2664: 'CreateWindowExW' : cannot convert parameter 2 from 'const char [8]' to 'LPCWSTR'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
[font="arial"][size="+2"] Results [/font] Build log was saved at "file://d:\0VisualCpp\blank\blank\Debug\BuildLog.htm"
blank - 3 error(s), 0 warning(s)
[/quote]

I tried the demo code from this site and found it used "precompiled" header.
What is the proper way to compile this program?

Thanks in advance


#define WIN32_LEAN_AND_MEAN

#include <windows.h>

LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
PAINTSTRUCT paintStruct;
HDC hDC;
char string[] = "Hello, world!";

switch(message)
{
case WM_CREATE:
return 0;
break;

case WM_CLOSE:
PostQuitMessage(0);
return 0;
break;

case WM_PAINT:
hDC = BeginPaint(hwnd, &paintStruct);

SetTextColor(hDC, COLORREF(0x00FF0000));

TextOut(hDC, 150,150, string, sizeof(string)-1);

EndPaint(hwnd, &paintStruct);
return 0;
break;

default:
break;
}
return (DefWindowProc(hwnd, message, wParam, lParam));
}

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
WNDCLASSEX windowClass;
HWND hwnd;
MSG msg;
bool done;

windowClass.cbSize = sizeof(WNDCLASSEX);
windowClass.style = CS_HREDRAW | CS_VREDRAW;
windowClass.lpfnWndProc = WndProc;
windowClass.cbClsExtra = 0;
windowClass.cbWndExtra = 0;
windowClass.hInstance = hInstance;
windowClass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
windowClass.hCursor = LoadCursor(NULL, IDC_ARROW);
windowClass.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
windowClass.lpszMenuName = NULL;
windowClass.lpszClassName = "MyClass";
windowClass.hIconSm = LoadIcon(NULL, IDI_WINLOGO);

if (!RegisterClassEx(&windowClass))
return 0;

hwnd = CreateWindowEx(NULL,
"MyClass",
"A REAL Windows Application!",
WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_SYSMENU,
100, 100,
400, 400,
NULL,
NULL,
hInstance,
NULL);

if (!hwnd)
return 0;

done = false;

while (!done)
{
PeekMessage(&msg, hwnd, NULL, NULL, PM_REMOVE);

if (msg.message == WM_QUIT)
{
done = true;
}
else
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}

return msg.wParam;
}

Share this post


Link to post
Share on other sites
Advertisement
wild guess...


[color=#1C2837][size=2][color=#000088]char[color=#000000] [color=#000088]string[color=#666600][][color=#000000] [color=#666600]=[color=#000000] T([color=#008800]"Hello, world!")[color=#666600];

Share this post


Link to post
Share on other sites

wild guess...


[color="#1c2837"][color="#000088"]char [color="#000088"]string[color="#666600"][] [color="#666600"]=[color="#000000"] T([color="#008800"]"Hello, world!")[color="#666600"];

I got this error:
error C3861: 'T': identifier not found

Any more comments?

Share this post


Link to post
Share on other sites
I found it! It relates to unicode.

Projects > Properties > Configuration Properties > General > CharacterSet > "Use Multi-Byte Character support"

Then it's ok.

Thanks for attention.

Share this post


Link to post
Share on other sites
Hi kevonyang,

I tried your method and still got the compile errors.
char string[] = _T("Hello, world!");

Could you please list your complete code?
Are there any other settings for the project?

Thanks in advance

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!