Problem z CreateWindow

0

Witam poniżej wypisuje kod z tutoriala irrlicht http://irrlicht.sourceforge.net/docu/example014.html mam problem ponieważ wyskakują błedy przy "CreateWindow"
wcex.lpszClassName = Win32ClassName; ** TUTAJ WYPISUJE BŁĄD PRZY =**

oraz w każdej linijce z "CreateWindow" nie wiem czy brakuje mi jakiejś biblioteki. Visual jest dobrze skonfigurowany z silnikiem irrlicht ponieważ inne tutoriale działają.

Pozwole sobie jeszcze skopiować opis błędu

1>c:\users\luppo\documents\visual studio 2010\projects\klawiszologia\klawiszologia\klawiszologia.cpp(83): error C2440: '=' : cannot convert from 'const char *' to 'LPCWSTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>c:\users\luppo\documents\visual studio 2010\projects\klawiszologia\klawiszologia\klawiszologia.cpp(96): error C2664: 'CreateWindowExW' : cannot convert parameter 2 from 'const char *' to 'LPCWSTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>c:\users\luppo\documents\visual studio 2010\projects\klawiszologia\klawiszologia\klawiszologia.cpp(106): error C2664: 'CreateWindowExW' : cannot convert parameter 2 from 'const char [7]' to 'LPCWSTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>c:\users\luppo\documents\visual studio 2010\projects\klawiszologia\klawiszologia\klawiszologia.cpp(112): error C2664: 'CreateWindowExW' : cannot convert parameter 2 from 'const char [7]' to 'LPCWSTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>c:\users\luppo\documents\visual studio 2010\projects\klawiszologia\klawiszologia\klawiszologia.cpp(118): error C2664: 'CreateWindowExW' : cannot convert parameter 2 from 'const char [7]' to 'LPCWSTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

#include "StdAfx.h"



#include <irrlicht.h>
#ifndef _IRR_WINDOWS_
#error Windows only example
#else
#include <windows.h> // this example only runs with windows
#include <iostream>
#include "driverChoice.h"

using namespace irr;

#pragma comment(lib, "irrlicht.lib")

HWND hOKButton;
HWND hWnd;

static LRESULT CALLBACK CustomWndProc(HWND hWnd, UINT message,
		WPARAM wParam, LPARAM lParam)
{
	switch (message)
	{
	case WM_COMMAND:
		{
			HWND hwndCtl = (HWND)lParam;
			int code = HIWORD(wParam);

			if (hwndCtl == hOKButton)
			{
				DestroyWindow(hWnd);
				PostQuitMessage(0);
				return 0;
			}
		}
		break;
	case WM_DESTROY:
		PostQuitMessage(0);
		return 0;

	}

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



int main()
{
	// ask user for driver
	video::E_DRIVER_TYPE driverType=driverChoiceConsole();
	if (driverType==video::EDT_COUNT)
		return 1;

	printf("Select the render window (some dead window may exist too):\n"\
		" (a) Window with button (via CreationParam)\n"\
		" (b) Window with button (via beginScene)\n"\
		" (c) Own Irrlicht window (default behavior)\n"\
		" (otherKey) exit\n\n");

	char key;
	std::cin >> key;
	if (key != 'a' && key != 'b' && key != 'c')
		return 1;

	HINSTANCE hInstance = 0;
	// create dialog

	const char* Win32ClassName = "CIrrlichtWindowsTestDialog";

	WNDCLASSEX wcex;
	wcex.cbSize			= sizeof(WNDCLASSEX);
	wcex.style			= CS_HREDRAW | CS_VREDRAW;
	wcex.lpfnWndProc	= (WNDPROC)CustomWndProc;
	wcex.cbClsExtra		= 0;
	wcex.cbWndExtra		= DLGWINDOWEXTRA;
	wcex.hInstance		= hInstance;
	wcex.hIcon			= NULL;
	wcex.hCursor		= LoadCursor(NULL, IDC_ARROW);
	wcex.hbrBackground	= (HBRUSH)(COLOR_WINDOW);
	wcex.lpszMenuName	= 0;
	wcex.lpszClassName     =Win32ClassName;      ** //TUTAJ WYPISUJE BŁĄD PRZY =**//
	wcex.hIconSm		= 0;

	RegisterClassEx(&wcex);

	DWORD style = WS_SYSMENU | WS_BORDER | WS_CAPTION |
		WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_MAXIMIZEBOX | WS_MINIMIZEBOX | WS_SIZEBOX;

	int windowWidth = 440;
	int windowHeight = 380;

	hWnd = CreateWindow( Win32ClassName, "Irrlicht Win32 window example",    
		style, 100, 100, windowWidth, windowHeight,
		NULL, NULL, hInstance, NULL);

	RECT clientRect;
	GetClientRect(hWnd, &clientRect);
	windowWidth = clientRect.right;
	windowHeight = clientRect.bottom;

	// create ok button

	hOKButton = CreateWindow("BUTTON", "OK - Close", WS_CHILD | WS_VISIBLE | BS_TEXT,
		windowWidth - 160, windowHeight - 40, 150, 30, hWnd, NULL, hInstance, NULL);

	// create some text

	CreateWindow("STATIC", "This is Irrlicht running inside a standard Win32 window.\n"\
		"Also mixing with MFC and .NET Windows.Forms is possible.",
		WS_CHILD | WS_VISIBLE, 20, 20, 400, 40, hWnd, NULL, hInstance, NULL);
	a
	// create window to put irrlicht in

	HWND hIrrlichtWindow = CreateWindow("BUTTON", "",
			WS_CHILD | WS_VISIBLE | BS_OWNERDRAW,
			50, 80, 320, 220, hWnd, NULL, hInstance, NULL);
	video::SExposedVideoData videodata((key=='b')?hIrrlichtWindow:0);


	irr::SIrrlichtCreationParameters param;
	param.DriverType = driverType;
	if (key=='a')
		param.WindowId = reinterpret_cast<void*>(hIrrlichtWindow);

	irr::IrrlichtDevice* device = irr::createDeviceEx(param);

	// setup a simple 3d scene

	irr::scene::ISceneManager* smgr = device->getSceneManager();
	video::IVideoDriver* driver = device->getVideoDriver();

	if (driverType==video::EDT_OPENGL)
	{
		HDC HDc=GetDC(hIrrlichtWindow);
		PIXELFORMATDESCRIPTOR pfd={0};
		pfd.nSize=sizeof(PIXELFORMATDESCRIPTOR);
		int pf = GetPixelFormat(HDc);
		DescribePixelFormat(HDc, pf, sizeof(PIXELFORMATDESCRIPTOR), &pfd);
		pfd.dwFlags |= PFD_DOUBLEBUFFER | PFD_SUPPORT_OPENGL | PFD_DRAW_TO_WINDOW;
		pfd.cDepthBits=16;
		pf = ChoosePixelFormat(HDc, &pfd);
		SetPixelFormat(HDc, pf, &pfd);
		videodata.OpenGLWin32.HDc = HDc;
		videodata.OpenGLWin32.HRc=wglCreateContext(HDc);
		wglShareLists((HGLRC)driver->getExposedVideoData().OpenGLWin32.HRc, (HGLRC)videodata.OpenGLWin32.HRc);
	}
	scene::ICameraSceneNode* cam = smgr->addCameraSceneNode();
	cam->setTarget(core::vector3df(0,0,0));

	scene::ISceneNodeAnimator* anim =
		smgr->createFlyCircleAnimator(core::vector3df(0,15,0), 30.0f);
	cam->addAnimator(anim);
	anim->drop();

	scene::ISceneNode* cube = smgr->addCubeSceneNode(20);

	cube->setMaterialTexture(0, driver->getTexture("C:/Program Files/Microsoft Visual Studio 10.0/irrlicht-1.7.2/media/wall.bmp"));
	cube->setMaterialTexture(1, driver->getTexture("C:/Program Files/Microsoft Visual Studio 10.0/irrlicht-1.7.2/media/water.jpg"));
	cube->setMaterialFlag( video::EMF_LIGHTING, false );
	cube->setMaterialType( video::EMT_REFLECTION_2_LAYER );

	smgr->addSkyBoxSceneNode(
	driver->getTexture("C:/Program Files/Microsoft Visual Studio 10.0/irrlicht-1.7.2/media/irrlicht2_up.jpg"),
	driver->getTexture("C:/Program Files/Microsoft Visual Studio 10.0/irrlicht-1.7.2/media/irrlicht2_dn.jpg"),
	driver->getTexture("C:/Program Files/Microsoft Visual Studio 10.0/irrlicht-1.7.2/media/irrlicht2_lf.jpg"),
	driver->getTexture("C:/Program Files/Microsoft Visual Studio 10.0/irrlicht-1.7.2/media/irrlicht2_rt.jpg"),
	driver->getTexture("C:/Program Files/Microsoft Visual Studio 10.0/irrlicht-1.7.2/media/irrlicht2_ft.jpg"),
	driver->getTexture("C:/Program Files/Microsoft Visual Studio 10.0/irrlicht-1.7.2/media/irrlicht2_bk.jpg"));

	// show and execute dialog

	ShowWindow(hWnd , SW_SHOW);
	UpdateWindow(hWnd);

	// do message queue



	while (device->run())
	{
		driver->beginScene(true, true, 0, videodata);
		smgr->drawAll();
		driver->endScene();
	}

	/*
	The alternative, own message dispatching loop without Device->run()
	would look like this:
	*/

	/*MSG msg;
	while (true)
	{
		if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
		{
			TranslateMessage(&msg);
			DispatchMessage(&msg);

			if (msg.message == WM_QUIT)
				break;
		}

		// advance virtual time
		device->getTimer()->tick();

		// draw engine picture
		driver->beginScene(true, true, 0, (key=='c')?hIrrlichtWindow:0);
		smgr->drawAll();
		driver->endScene();
	}*/

	device->closeDevice();
	device->drop();

	return 0;
}
#endif // if windows

/*
That's it, Irrlicht now runs in your own windows window.
**/


0

tak po zmianie mam blad z linkerem:
1>klawiszologia.obj : error LNK2019: unresolved external symbol __imp__wglShareLists@8 referenced in function _main
1>klawiszologia.obj : error LNK2019: unresolved external symbol __imp__wglCreateContext@4 referenced in function _main
1>C:\Users\luppo\Documents\Visual Studio 2010\Projects\klawiszologia\Debug\klawiszologia.exe : fatal error LNK1120: 2 unresolved externals

w linker->input->AdditionalDependencis mam wpisane irrlicht.lib

0

Wystarczyło wpisać w googlu "wglShareLists". Pierwszy odnośnik:
http://msdn.microsoft.com/en-us/library/dd374390%28v=vs.85%29.aspx

a w nim na dole:
Header: Wingdi.h
Library: Opengl32.lib

Dodaj Opengl32.lib do linkera i się zbuduje.

1 użytkowników online, w tym zalogowanych: 0, gości: 1