0

I am trying to use my class ResourceManagement in my levelmanager, so that I can start creating resources.

however I get the following error(s)

Severity Code Description Project File Line Suppression State Error C4430 missing type specifier - int assumed. Note: C++ does not support default-int levelmanager.h 49

Severity Code Description Project File Line Suppression State Error C2143 syntax error : missing ';' before '*' Diabro levelmanager.h 49

I have declared the ResourceManagement class as followed in the LevelManager.h

private:
    Ogre::Entity* _playerEntity;

    ResourceManagement* mgr;

and then use it like this in the LevelManager.cpp

mgr->createResource("Diabro\Diabro\media\models", "MESH", "ninja.mesh",  "Mesh", "meshes"); //location of file, codeType of resourcetype, name of resource, type of resource, resourcegroup
    mgr->loadResource("meshes");
    mgr->reloadResource("ninja.mesh", "meshes");
    mgr->unloadResource("ninja.mesh", "meshes");

ResourceManagement class

void ResourceManagement::initialize()
{

_groupManager == new Ogre::ResourceGroupManager;
}

void ResourceManagement::createResource(std::string pLocation, std::string pLocType, std::string pResourceName, std::string pResourceType, std::string pGroupName)
{
    _groupManager->getSingleton().addResourceLocation(pLocation , pLocType);
    _groupManager->getSingleton().declareResource(pResourceName, pResourceType, pGroupName);
    _groupManager->getSingleton().initialiseResourceGroup(pGroupName);
    // Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups(); can be used to just load all, need decision which we want
}


void ResourceManagement::unloadResource(std::string pResourceName, std::string pGroupName) // unloads a single resource
{
    Ogre::ResourcePtr ptr = _resourceMgr->getResourceByName(pResourceName);
    ptr->unload();
    _resourceMgr->remove(pResourceName);    
}


void ResourceManagement::unloadResourceGoup(std::string pGroupName)
{
    _groupManager->getSingleton().unloadResourceGroup(pGroupName);

}

void ResourceManagement::loadResource(std::string pGroupName)
{
    _groupManager->getSingleton().loadResourceGroup(pGroupName);
}


void ResourceManagement::reloadResource(std::string pResourceName, std::string pGroupName)
{
    Ogre::ResourcePtr ptr = _resourceMgr->load(pResourceName, pGroupName);
    ptr->escalateLoading();
    ptr->reload();

}
KevinTheGreat
  • 634
  • 5
  • 22
  • Can you show us your `ResourceManagement` class? – nitronoid Apr 26 '17 at 13:45
  • A declaration of `Ogre::Entity` and of `ResourceManagement` needs to be visible to the compiler (e.g. from another header file) before the code you have shown from LevelManager,h. If either declaration is not visible, that will explain the error messages. Similarly, a definition (not just declaration) of `ResourceManager` needs to be visible to the compiler before calling its member functions. – Peter Apr 26 '17 at 13:46
  • @Peter Definitions of functions are not needed for a compiler. Definitions are needed for a linker, which is invoked after the compilation has already completed. – Algirdas Preidžius Apr 26 '17 at 13:56
  • There should be at least one error before those, probably regarding a missing type declaration. (My crystal ball thinks that it's `ResourceManagement` and that your headers have a circular dependency.) – molbdnilo Apr 26 '17 at 13:59
  • Copy messages from the Output window instead of the Error List. – molbdnilo Apr 26 '17 at 14:00
  • @AlgirdasPreidžius - to call a member function of a class, the definition of the class (not just a declaration) needs to be visible to the compiler. `ResourceManager` is a class (evidenced by member functions of it being called in code) not a function. – Peter Apr 26 '17 at 14:00
  • @Peter Ah, Somehow I had functions on mind in addition to mistaking _class_ declarations with definitions. Yes, you are correct on that. – Algirdas Preidžius Apr 26 '17 at 14:09
  • So I tried to declare the manager in the levelManager.cpp like this `mgr = new ResourceManagement;` however it has the pure functional error – KevinTheGreat Apr 26 '17 at 14:23
  • @Peter Could you maybe show me an example where this is done, quiet new to C++ and Ogre – KevinTheGreat Apr 26 '17 at 14:58
  • 2
    Sorry, I won't do that. You're trying to jump into learning C++ and Ogre together - that's a recipe for disaster. Instead you need to learn C++ basics first without Ogre - start with a basic C++ textbook/tutorial. My comments above - or any example I might give - won't make any sense to you before you follow that basic text and reach a point of creating a simple project involving multiple source files and (at least) one header file. Once you understand such C++ basics, you'll be able to start learning Ogre - since Ogre documentation ASSUMES you already know those C++ basics. – Peter Apr 26 '17 at 16:34

0 Answers0