All pastes #1257976 Raw Edit

Stuff

public cpp v1 · immutable
#1257976 ·published 2008-11-16 19:36 UTC
rendered paste body
//i'm going to try and comment this all as heavily as possible//because by all accounts i'll look back over it and be appalled.#include <iostream>#include <fstream>#include <irrlicht.h>#include <irrklang.h>#include "tbyshared.h"//basic includesusing namespace irr;using namespace irr::video;using namespace irr::gui;using namespace irr::scene;using namespace irrklang;using namespace std;//get rid of prefixes#pragma comment(lib, "Irrlicht.lib")#pragma comment(lib, "Irrklang.lib")//link to dlls//try thisE_DRIVER_TYPE driverType = EDT_OPENGL;int videoWidth = 640;int videoHeight;bool fullscreen = false;bool menuenabled = true;IrrlichtDevice *device = 0;IGUIEnvironment* guienv = 0;ISceneManager* smgr = 0;IVideoDriver* driver = 0;//BEGIN FUNCTIONSint main(){	LoadConfig();	//parse the config	videoHeight = 3*(videoWidth/4);	IrrlichtDevice *device = createDevice(driverType, core::dimension2d<s32>(videoWidth,videoHeight));	//create a new device, with driverType in a window, 640x480	if (device == 0)		return 1;	//if it failed to work, the programs sods off	IVideoDriver* driver = device->getVideoDriver();	ISceneManager* smgr = device->getSceneManager();	IGUIEnvironment* guienv = device->getGUIEnvironment();	ISoundEngine* soundengine = createIrrKlangDevice();	//pointers to cut down on typing	device->getFileSystem()->addZipFileArchive("./map-20kdm2.pk3");	//allow filesystem to read from the pk3	IAnimatedMesh* mesh = smgr->getMesh("20kdm2.bsp");	ISceneNode* node = 0;	//load the map and create a node	if (mesh)		node = smgr->addOctTreeSceneNode(mesh->getMesh(0));	//if the map loaded, turn it into a node	if (node)		node->setPosition(core::vector3df(-1300,-144,-1249));	//if that worked, set it up to be in the right place.	smgr->addCameraSceneNodeFPS();	//add a first person camera to the scene manager	device->getCursorControl()->setVisible(false);	//disable the mouse cursor	int lastFPS = -1;	//set up the FPS counter	while(device->run())	{		driver->beginScene(true, true, video::SColor(0,200,200,200));		//start the scene		smgr->drawAll();		//draw the scene		DrawBaseGUI(guienv);		guienv->drawAll();		//draw the GUI		driver->endScene();		//end the scene		int fps = driver->getFPS();		//set "fps" to the current FPS rate		if (lastFPS != fps) //if the FPS rate has changed:		{			core::stringw str = L"Trench Breakthrough: Ypres BETA BUILD ";			str += TBY_BUILDVER;			str += " [";			str += driver->getName();			str += "] FPS:";			str += fps;			device->setWindowCaption(str.c_str());			lastFPS = fps;			//set the title with the map name, driver and new fps rate.		}	}	device->drop();	//kill the device	return 0;	//end the program}