aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp108
1 files changed, 56 insertions, 52 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 382cc93..bd4c243 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1,71 +1,75 @@
-#define SDL_MAIN_HANDLED
-
-#include <abc.h>
-#include <dtx.h>
-#include <rez.h>
-#include <GL/gl.h>
-#include <osg/GLExtensions>
-#include <osg/State>
-#include <osgViewer/GraphicsWindow>
-#include <osgViewer/Viewer>
-#include <osgViewer/ViewerEventHandlers>
+#include <RezLoader.h>
+#include <irrlicht.h>
#include <cstdlib>
-#include <cstdio>
#include <iostream>
int main(int argc, char *argv[])
{
- std::unique_ptr<rez::file> f, abcf;
- rez::ball b("globalops.rez");
- abc abc;
- dtx dtx;
- osgViewer::Viewer viewer;
- osg::Camera *cam;
- osg::GraphicsContext *gfx;
- osg::State *state;
- osg::GLExtensions *ext;
- osgViewer::GraphicsWindow *gfxw;
+ 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;
- viewer.setUpViewInWindow(0, 0, 640, 480);
- viewer.realize();
- cam = viewer.getCamera();
- gfx = cam->getGraphicsContext();
- gfxw = dynamic_cast<osgViewer::GraphicsWindow *>(gfx);
+ if (!device)
+ {
+ std::cerr << "irr::createDevice failed\n";
+ goto end;
+ }
- if (!gfxw)
+ device->setWindowCaption(L"GlobalOps");
+ archive = rezloader.createArchive("globalops.rez", true, false);
+
+ if (!archive)
{
- std::cerr << "Failed to cast osgViewe::GraphicContext to "
- "osgViewer::GraphicsWindow\n";
- return EXIT_FAILURE;
+ std::cerr << "Could not open globalops.rez\n";
+ goto end;
}
- gfxw->setWindowName("GlobalOps");
- state = gfx->getState();
- state->initializeExtensionProcs();
- ext = osg::GLExtensions::Get(state->getContextID(), true);
+ 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
- if (!ext)
+ while (device->run())
{
- std::cerr << "osg::GLExtensions::Get failed\n";
- return EXIT_FAILURE;
+ 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();
}
- else if (!ext->isCompressedTexImage2DSupported())
+
+ ret = EXIT_SUCCESS;
+
+end:
+
+ if (f && !f->drop())
{
- std::cerr << "OpenGL extension glCompressedTextImage2D not supported\n";
- return EXIT_FAILURE;
+ std::cerr << "irr::IReadFile::drop failed\n";
+ ret = EXIT_FAILURE;
}
- else if (!ext->isTextureCompressionS3TCSupported)
+
+ if (device && !device->drop())
{
- std::cerr << "OpenGL extension GL_EXT_texture_compression_s3tc "
- "not supported\n";
- return EXIT_FAILURE;
+ std::cerr << "irr::IrrlichtDevice::drop failed\n";
+ ret = EXIT_FAILURE;
}
- else 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))
- return EXIT_FAILURE;
- return viewer.run();
+ return ret;
}