aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
blob: bd4c24374f7505f006e2780927bdbcfe2617cc51 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include <RezLoader.h>
#include <irrlicht.h>
#include <cstdlib>
#include <iostream>

int main(int argc, char *argv[])
{
    int ret = EXIT_FAILURE;
    irr::IrrlichtDevice *device = irr::createDevice(irr::video::EDT_OPENGL);
    irr::io::IFileSystem *fs;
    irr::io::IFileArchive *archive;
    irr::io::IReadFile *f = nullptr;
    RezLoader rezloader;

    if (!device)
    {
        std::cerr << "irr::createDevice failed\n";
        goto end;
    }

    device->setWindowCaption(L"GlobalOps");
    archive = rezloader.createArchive("globalops.rez", true, false);

    if (!archive)
    {
        std::cerr << "Could not open globalops.rez\n";
        goto end;
    }

    fs = device->getFileSystem();
    fs->addFileArchive(archive);
    fs->addArchiveLoader(&rezloader);
    f = fs->createAndOpenFile("interface/blueprints/antarctica_tacmap.dtx");

    if (!f)
        goto end;
#if 0
    if (b.parse()
        || !(f = b.open("interface/blueprints/antarctica_tacmap.dtx"))
        || dtx.parse(*f)
        || !(f = b.open("models/grenades/v_frag.abc"))
        || abc.parse(*f))
        goto end;
#endif

    while (device->run())
    {
        irr::video::IVideoDriver *driver = device->getVideoDriver();
        irr::scene::ISceneManager *smgr = device->getSceneManager();
        irr::gui::IGUIEnvironment *guienv = device->getGUIEnvironment();

        driver->beginScene();
        smgr->drawAll();
        guienv->drawAll();
        driver->endScene();
    }

    ret = EXIT_SUCCESS;

end:

    if (f && !f->drop())
    {
        std::cerr << "irr::IReadFile::drop failed\n";
        ret = EXIT_FAILURE;
    }

    if (device && !device->drop())
    {
        std::cerr << "irr::IrrlichtDevice::drop failed\n";
        ret = EXIT_FAILURE;
    }

    return ret;
}