Need help figuring out what these compile errors mean...

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
Stu L Tissimus
Posts: 48
Joined: Thu Jul 15, 2004 8:45 pm
Location: Manhattan
Contact:

Need help figuring out what these compile errors mean...

Post by Stu L Tissimus »

Okay, yeah, I'm stupid. I'm trying to make (AKA take ideas from snippets posted on these forums >_>) my core class, starting off with the core video stuff. I tried compiling it, but no such luck. So, first, the files themselves:

Main.cpp

Code: Select all

#include <iostream>
#include <fstream>
#include <vector>

#include "MyEventReceiver.h"
#include "GameCore.h"

#include "Irrlicht.h"
#pragma comment(lib, "Irrlicht.lib")

using namespace irr;

int main() {
    /*
    GameCore MyCore;
    MyCore.InitDevice();
    IrrlichtDevice *device = MyCore.device;
    device->getSceneManager();
    video::IVideoDriver* driver = device->getVideoDriver();
	scene::ISceneManager* smgr = device->getSceneManager();
	
    device->getFileSystem()->addZipFileArchive("map-20kdm2.pk3");
	
	scene::IAnimatedMesh* mesh = smgr->getMesh("20kdm2.bsp");
	scene::IAnimatedMeshSceneNode* node;
	scene::IAnimatedMesh* mesh2 = smgr->getMesh("Soldier9.3ds");
	scene::IAnimatedMeshSceneNode* node2;
	
	scene::ISceneNode* camera = smgr->addCameraSceneNodeFPS();
	scene::ISceneNode* camera2 = smgr->addCameraSceneNodeFPS();
	int hello = MyCore.receiver.xplane;

	if (mesh)
	    node = smgr->addAnimatedMeshSceneNode(mesh, camera, -1, core::vector3df(10, 0, 0));
	    node2 = smgr->addAnimatedMeshSceneNode(mesh2, camera, -1, core::vector3df(500, 0, 0));}
	int lastFPS = -1;


	while(device->run())
	{
        driver->beginScene ( true, true, video::SColor ( 0, 0, 0, 0 ) );
        smgr->drawAll ( );
        driver->endScene ( ); 
		int fps = driver->getFPS();
		if (lastFPS != fps)
		{
			core::stringw str = L"Irrlicht Engine - Vertex and pixel shader example [";
			str += driver->getName();
			str += "] FPS:";
			str += fps;

			device->setWindowCaption(str.c_str());
			lastFPS = fps;
		}
		
		
	}
	device->drop();
	
	return 0;
	*/
}

GameCore.h

Code: Select all

#ifndef __GAMECORE_H__
#define __GAMECORE_H__

#include "Irrlicht.h"
#include <iostream>
#include "VideoCore.cpp"
using namespace std;
using namespace irr;

class GameCore {
        VideoCore() MyVideoCore;
}

#endif
VideoCore.h

Code: Select all

#ifndef __VIDEOCORE_H__
#define __VIDEOCORE_H__

#include "Irrlicht.h"
#include "MyEventReceiver.h"
using namespace std;
using namespace irr;

class VideoCore
{
    private:
           IrrlichtDevice*         device;
           scene::ISceneManager*   smgr;
           video::IVideoDriver*    driver;
           ITimer*                 timer;
           gui::IGUIEnvironment*   guiEnvironment;
           MyEventReceiver*        receiver;
           
           video::E_DRIVER_TYPE    deviceType;
           bool                    fullscreen;
           core::dimension2d<s32>  windowSize;
           
           
           
    public:
           VideoCore();
          ~VideoCore();
           bool Init();
                   
           IrrlichtDevice*         GetDevice         ( ) { return device; }
           video::IVideoDriver*    GetVideoDriver    ( ) { return driver; }
           scene::ISceneManager*   GetSceneManager   ( ) { return smgr; }
           gui::IGUIEnvironment*   GetGUIEnvironment ( ) { return guiEnvironment; }
           MyEventReceiver*        GetReceiver       ( ) { return receiver; }
           
           int                     GetTime           ( ) { return timer->getTime ( ); }
           core::rect<s32>         GetViewPort       ( ) { return driver->getViewPort ( ); }
           int                     GetViewPortWidth  ( ) { return driver->getViewPort ( ).getWidth ( ); }
           int                     GetViewPortHeight ( ) { return driver->getViewPort ( ).getHeight ( ); }
           
           void SetDeviceType      ( video::E_DRIVER_TYPE deviceType )   { deviceType = deviceType; }
           void SetWindowSize      ( core::dimension2d<s32> windowSize ) { windowSize = windowSize; }
           void SetFullscreen      ( bool fullscreen )                   { fullscreen = fullscreen; }
};


#endif
VideoCore.cpp

Code: Select all

#include "VideoCore.h"
#include "MyEventReceiver.h"
#include "Irrlicht.h"
using namespace std;
using namespace irr;

// VideoCore Constructor
VideoCore::VideoCore ( ) 
{
    device =         NULL;
    smgr =           NULL;
    driver =         NULL;
    guiEnvironment = NULL;
    timer =          NULL;
    receiver =       NULL;
    
    deviceType =     NULL;
    fullscreen =     NULL;
    windowSize =     NULL;
}

// VideoCore Destructor 
VideoCore::~VideoCore ( )
{
   if ( receiver )
      delete receiver;
}

// VideoCore Initialization
VideoCore::Init()
{
    receiver = new MyEventReceiver ( );
    device = createDevice(deviceType, windowSize, windowSize, 32, fullscreen, false, false, receiver);
    
    if ( device )
    {
        smgr = device->getSceneManager ( );
        videoDriver = device->getVideoDriver ( );
        guiEnvironment = device->getGUIEnvironment ( );
        timer = device->getTimer ( );
        return true;
    }
    
    return false;    
}






Compile Errors:
http://img96.exs.cx/img96/5775/compileerrors5us.jpg
Laptop: P-M 1.6GHz|1024MB PC2800|Mob.Radeon9700Pro|60GB

Desktop: A-XP 2400+|512MB PC3200|Radeon 9700 Pro|180GB
Spintz
Posts: 1688
Joined: Thu Nov 04, 2004 3:25 pm

Post by Spintz »

Ok, a few errors/improvements...

Main.cpp -
You don't need to include MyEventReceiver.h, it's included through GameCore.h, from VideoCore.h.
You don't want to uncomment return 0;, the function must return a value.

GameCore.h -
#include "VideoCore.cpp, should be #include "VideoCore.h"
also, VideoCore() MyVideoCore, doesn't make sense. I think you want to maintain a pointer to the VideoCore object here right, ( the one and only VideoCore class that should be maintained by GameCore? ), so it should be, VideoCore* MyVideoCore;

VideoCore.h -
Really nothing wrong there, everything seems in order.

VideoCore.cpp -
You don't want to call, using namespace std;, you can't use a namespace unless it's been defined, and you have no includes which define that namespace. If you were including <iostream> or something, then sure, but not unless you are.
deviceType = NULL; does not work, deviceType is a variable of the type video::E_DRIVER_TYPE, so you want to set it's default value to, video::EDT_DIRECTX9 or video::EDT_OPENGL or whatever you want your default device type to be.
same for the windowSize = NULL; windowSize is a variable of the type core::dimension2d<s32>, you want to set this default value, to whatever default resolution you want your engine to run at, for example - windowSize = core::dimension2d<s32> ( 1024, 768 );
In your createDevice call, you have windowSize 2x, it should be, device = createDevice(deviceType, windowSize, 32, fullscreen, false, false, receiver);
You're also getting an error on the line where you're trying to set the point to your video driver. In you VideoCore class, you called the variable for that pointer 'driver', but you're calling it 'videoDriver' in VideoCore.cpp.

Other than those few small things, looks pretty good to start out with. If you wanted to get really fancy, you would make VideoCore a singleton model class, where you could only ever have one instance of it. Or, even better, you would make it a virutal base class, with all protected/private members, then have GameCore derive from it. I wouldn't worry about that for now though, you have the concept down, just a few typos to clean up! ;)
Stu L Tissimus
Posts: 48
Joined: Thu Jul 15, 2004 8:45 pm
Location: Manhattan
Contact:

Post by Stu L Tissimus »

Wow, thanks! ^_^
Laptop: P-M 1.6GHz|1024MB PC2800|Mob.Radeon9700Pro|60GB

Desktop: A-XP 2400+|512MB PC3200|Radeon 9700 Pro|180GB
Stu L Tissimus
Posts: 48
Joined: Thu Jul 15, 2004 8:45 pm
Location: Manhattan
Contact:

Post by Stu L Tissimus »

Laptop: P-M 1.6GHz|1024MB PC2800|Mob.Radeon9700Pro|60GB

Desktop: A-XP 2400+|512MB PC3200|Radeon 9700 Pro|180GB
Spintz
Posts: 1688
Joined: Thu Nov 04, 2004 3:25 pm

Post by Spintz »

If I see the code, I can help out, but the compiler output there isn't really useful. It's not saying which line number the errors are occuring on.
Stu L Tissimus
Posts: 48
Joined: Thu Jul 15, 2004 8:45 pm
Location: Manhattan
Contact:

Post by Stu L Tissimus »

Oh, heheh. Woops. I'll post the code in a few minutes, just taking a shower.
Laptop: P-M 1.6GHz|1024MB PC2800|Mob.Radeon9700Pro|60GB

Desktop: A-XP 2400+|512MB PC3200|Radeon 9700 Pro|180GB
Stu L Tissimus
Posts: 48
Joined: Thu Jul 15, 2004 8:45 pm
Location: Manhattan
Contact:

Post by Stu L Tissimus »

VideoCore.h

Code: Select all

#ifndef __VIDEOCORE_H__
#define __VIDEOCORE_H__

#include "Irrlicht.h"
#include "MyEventReceiver.h"
using namespace std;
using namespace irr;

class VideoCore
{
    private:
           IrrlichtDevice*         device;
           scene::ISceneManager*   smgr;
           video::IVideoDriver*    driver;
           ITimer*                 timer;
           gui::IGUIEnvironment*   guiEnvironment;
           MyEventReceiver*        receiver;
           
           video::E_DRIVER_TYPE    deviceType;
           bool                    fullscreen;
           core::dimension2d<s32>  windowSize;
           
           
           
    public:
           VideoCore();
          ~VideoCore();
           bool Init();
                   
           IrrlichtDevice*         GetDevice         ( ) { return device; }
           video::IVideoDriver*    GetVideoDriver    ( ) { return driver; }
           scene::ISceneManager*   GetSceneManager   ( ) { return smgr; }
           gui::IGUIEnvironment*   GetGUIEnvironment ( ) { return guiEnvironment; }
           MyEventReceiver*        GetReceiver       ( ) { return receiver; }
           
           int                     GetTime           ( ) { return timer->getTime ( ); }
           core::rect<s32>         GetViewPort       ( ) { return driver->getViewPort ( ); }
           int                     GetViewPortWidth  ( ) { return driver->getViewPort ( ).getWidth ( ); }
           int                     GetViewPortHeight ( ) { return driver->getViewPort ( ).getHeight ( ); }
           
           void SetDeviceType      ( video::E_DRIVER_TYPE deviceType )   { deviceType = deviceType; }
           void SetWindowSize      ( core::dimension2d<s32> windowSize ) { windowSize = windowSize; }
           void SetFullscreen      ( bool fullscreen )                   { fullscreen = fullscreen; }
};


#endif
GameCore.h

Code: Select all

#ifndef __GAMECORE_H__
#define __GAMECORE_H__

#include "Irrlicht.h"
#include <iostream>
#include "VideoCore.h"
using namespace std;
using namespace irr;

class GameCore {
        VideoCore* MyVideoCore;
}

#endif
main.cpp

Code: Select all

#include <iostream>
#include <fstream>
#include <vector>

#include "MyEventReceiver.h"
#include "GameCore.h"

#include "Irrlicht.h"
#pragma comment(lib, "Irrlicht.lib")

using namespace irr;

int main() {
    /*
    GameCore MyCore;
    MyCore.InitDevice();
    IrrlichtDevice *device = MyCore.device;
    device->getSceneManager();
    video::IVideoDriver* driver = device->getVideoDriver();
	scene::ISceneManager* smgr = device->getSceneManager();
	
    device->getFileSystem()->addZipFileArchive("map-20kdm2.pk3");
	
	scene::IAnimatedMesh* mesh = smgr->getMesh("20kdm2.bsp");
	scene::IAnimatedMeshSceneNode* node;
	scene::IAnimatedMesh* mesh2 = smgr->getMesh("Soldier9.3ds");
	scene::IAnimatedMeshSceneNode* node2;
	
	scene::ISceneNode* camera = smgr->addCameraSceneNodeFPS();
	scene::ISceneNode* camera2 = smgr->addCameraSceneNodeFPS();
	int hello = MyCore.receiver.xplane;

	if (mesh)
	    node = smgr->addAnimatedMeshSceneNode(mesh, camera, -1, core::vector3df(10, 0, 0));
	    node2 = smgr->addAnimatedMeshSceneNode(mesh2, camera, -1, core::vector3df(500, 0, 0));}
	int lastFPS = -1;


	while(device->run())
	{
        driver->beginScene ( true, true, video::SColor ( 0, 0, 0, 0 ) );
        smgr->drawAll ( );
        driver->endScene ( ); 
		int fps = driver->getFPS();
		if (lastFPS != fps)
		{
			core::stringw str = L"Irrlicht Engine - Vertex and pixel shader example [";
			str += driver->getName();
			str += "] FPS:";
			str += fps;

			device->setWindowCaption(str.c_str());
			lastFPS = fps;
		}
		
		
	}
	device->drop();
	*/
	return 0;
	
}
VideoCore.cpp

Code: Select all

#include "VideoCore.h"
#include "MyEventReceiver.h"
#include "Irrlicht.h"
using namespace irr;

// VideoCore Constructor
VideoCore::VideoCore ( ) 
{
    device =         NULL;
    smgr =           NULL;
    driver =         NULL;
    guiEnvironment = NULL;
    timer =          NULL;
    receiver =       NULL;
    
    deviceType =     video::EDT_OPENGL;
    fullscreen =     NULL;
    windowSize =     core::dimension2d<s32> ( 1024, 768 ); 
}

// VideoCore Destructor 
VideoCore::~VideoCore ( )
{
   if ( receiver )
      delete receiver;
}

// VideoCore Initialization
VideoCore::Init()
{
    receiver = new MyEventReceiver ( );
    device = createDevice(deviceType, windowSize, 32, fullscreen, false, false, receiver);
    
    if ( device )
    {
        smgr = device->getSceneManager ( );
        driver = device->getVideoDriver ( );
        guiEnvironment = device->getGUIEnvironment ( );
        timer = device->getTimer ( );
        return true;
    }
    
    return false;    
}    
Laptop: P-M 1.6GHz|1024MB PC2800|Mob.Radeon9700Pro|60GB

Desktop: A-XP 2400+|512MB PC3200|Radeon 9700 Pro|180GB
Spintz
Posts: 1688
Joined: Thu Nov 04, 2004 3:25 pm

Post by Spintz »

Only things I've found are you need a semi-colon at the end of the definition of the GameCore class in GameCore.h.

and in VideoCore.cpp, you don't have the return value of the Init(), change it to bool VideoCore::Init() and you should be fine.

As an FYI, missing semi-colons after a class definition in a .h file can really screw you up. It's not noticed directly by most compilers, you just see a lot of really stupid errors anytime after you include that file. I have a feeling if you get that semicolon in, you're compile errors will make more sense and you'll have a much easier time debugging any other problems you're having!!

Good luck!
Stu L Tissimus
Posts: 48
Joined: Thu Jul 15, 2004 8:45 pm
Location: Manhattan
Contact:

Post by Stu L Tissimus »

Thanks for your help! Still giving me errors, but these ones I can figure out :)
Laptop: P-M 1.6GHz|1024MB PC2800|Mob.Radeon9700Pro|60GB

Desktop: A-XP 2400+|512MB PC3200|Radeon 9700 Pro|180GB
Post Reply