samedi 26 mars 2016

How to call a static function in main.cpp from another source file?

I have a method called initializeObjects() in my main.cpp file, and I want to call it from a method in another source file, named Scene.cpp. How do I do that? This is my main.cpp file, without the headers:

static void initializeObjects();
int main() {
    Scene myScene;
    myScene.render(640,480);
    return 0;
}

void initializeObjects(){
    //Add a plane of gray color
    Scene::shapes.push_back(std::make_shared<Plane>(Vector3D(0,1,1), Vector3D(0,0,80), COLOR_GRAY));
    //Add two spheres
    Scene::shapes.push_back(std::make_shared<Sphere>(100.0, Vector3D(0,50,0), COLOR_WHITE));
    Scene::shapes.push_back(std::make_shared<Sphere>(60.0,ORIGIN, COLOR_RED));
}

Aucun commentaire:

Enregistrer un commentaire