WinMain() Troubles

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
AlexL
Posts: 184
Joined: Tue Mar 02, 2004 6:06 pm
Location: Washington State

WinMain() Troubles

Post by AlexL »

I've just started up a mini-project with Irrlicht, and I've run into some problems when it comes to running the .exe created. I'm using MSVC++ 6.0 SP5 with the DX9a SDK, and alot of the code I'm using is based off of the TechDemo.
Now onto the problem, when I run the .exe from the compile nothing will happen. I'm guessing that is because I don't have a function called inside of WinMain to start up Irrlicht, though when I've tried to call my function to start it - RBGame::run() - I get compile errors. I've posted some of the code below, if any one could help this would be greatly appericiated.

Code: Select all

int WINAPI WinMain(HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT)
{
	video::EDriverType driverType = video::EDT_DIRECTX9;
	return 0;
}

Code: Select all

class RBGame : public IEventReceiver
{
public:
	void run();
};

Code: Select all

void RBGame::run()
{
	IrrlichtDevice* device = createDevice(video::EDT_DIRECTX9, dimension2d<s32>(800,600), 16, false, true, 0);
	video::IVideoDriver* driver = device -> getVideoDriver();
	scene::ISceneManager* smgr = device -> getSceneManager();
	gui::IGUIEnvironment* guienv = device -> getGUIEnvironment();

	//--------------------------------------------------
	// Device Setup
	//--------------------------------------------------
	device -> setWindowCaption(L"Mini-Project - v0.1");

	//--------------------------------------------------
	// Interface Setup
	//--------------------------------------------------
	//Some of my code

	//--------------------------------------------------
	// Render Loop
	//--------------------------------------------------
	while(device->run())
	{
		driver -> beginScene(true, true, SColor(100,100,100,100));
		smgr -> drawAll();
		guienv -> drawAll();
		driver -> endScene();
	}
	device -> drop();
}
Arudil
Posts: 27
Joined: Sun Sep 28, 2003 7:59 am
Location: Germany
Contact:

Post by Arudil »

erm yes ;)
without calling the function.. the function won't be called.. or something like that..

you should declare an instance of RBGame, an then call the run function.

this could be ~like~ that (i didn't compile it or check for bugs ;))


int WINAPI WinMain(HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT)
{
video::EDriverType driverType = video::EDT_DIRECTX9;

RBGame gameInstance;
gameInstance::run();

return 0;
}


..if anybody says, that this code is wrong, and absolutly crap and that i don't know a bit about c++: you're right :p
Gonosz
Posts: 24
Joined: Wed Oct 29, 2003 4:21 pm
Location: Hungary (one joke and you're dead)

Post by Gonosz »

Actually, it's gameinstance.Run(), in the above context.

If you happen to create a console project in MSVC, you will have main() instead of winmain() I think.
AlexL
Posts: 184
Joined: Tue Mar 02, 2004 6:06 pm
Location: Washington State

Post by AlexL »

Arudil and Gonosz;
Thank you for your help, this was my problem :) As you've seen from this post, I've forgoten most everything. But it is slowly comming back to me :D
Post Reply