1 /* c-irrlicht --- C bindings for Irrlicht Engine
3 Copyright (C) 2019 Javier Sancho <jsf@jsancho.org>
5 This file is part of c-irrlicht.
7 c-irrlicht is free software; you can redistribute it and/or modify
8 it under the terms of the GNU Lesser General Public License as
9 published by the Free Software Foundation; either version 3 of the
10 License, or (at your option) any later version.
12 c-irrlicht is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 General Public License for more details.
17 You should have received a copy of the GNU Lesser General Public
18 License along with guile-irrlicht. If not, see
19 <http://www.gnu.org/licenses/>.
22 #include <cirrlicht/cirrlicht.h>
29 // ask user for driver
30 irr_video_E_DRIVER_TYPE driverType;
32 printf("Please select the driver you want for this example:\n" \
33 " (a) OpenGL 1.5\n (b) Direct3D 9.0c\n (c) Direct3D 8.1\n" \
34 " (d) Burning's Software Renderer\n (e) Software Renderer\n" \
35 " (f) NullDevice\n (otherKey) exit\n\n");
41 case 'a': driverType = irr_video_EDT_OPENGL; break;
42 case 'b': driverType = irr_video_EDT_DIRECT3D9;break;
43 case 'c': driverType = irr_video_EDT_DIRECT3D8;break;
44 case 'd': driverType = irr_video_EDT_BURNINGSVIDEO;break;
45 case 'e': driverType = irr_video_EDT_SOFTWARE; break;
46 case 'f': driverType = irr_video_EDT_NULL; break;
50 // create device and exit if creation failed
51 irr_core_dimension2d_u32 windowSize = {640, 480};
52 irr_IrrlichtDevice *device =
53 irr_createDevice(driverType, &windowSize, 16, false, false, false);
57 return 1; // could not create selected driver
60 // instances for doing things
61 irr_video_IVideoDriver* driver = irr_getVideoDriver(device);
62 irr_scene_ISceneManager* smgr = irr_getSceneManager(device);
65 irr_io_addFileArchive(irr_getFileSystem(device), "media/map-20kdm2.pk3",
66 true, true, irr_io_EFAT_UNKNOWN, "", NULL);
68 irr_scene_IAnimatedMesh* mesh = irr_scene_getMesh(smgr, "20kdm2.bsp");
69 irr_scene_ISceneNode* node;
72 node = irr_scene_addOctreeSceneNode(smgr, mesh, NULL, -1, 512, false);
76 irr_core_vector3df newpos = {-1300, -144, -1249};
77 irr_scene_setPosition(node, &newpos);
81 irr_scene_addCameraSceneNodeFPS(smgr, NULL, 100, 0.5, -1, NULL, 0, false, 0, false, true);
82 irr_gui_setVisibleCursor(irr_getCursorControl(device), false);
86 irr_video_SColor bgcolor = MAKE_COLOR(255, 200, 200, 200);
87 while (irr_run(device))
89 if (irr_isWindowActive(device))
91 irr_video_beginScene(driver, true, true, &bgcolor, NULL, NULL);
92 irr_scene_drawAll(smgr);
93 irr_video_endScene(driver);
95 int fps = irr_video_getFPS(driver);
99 const char *driverName = irr_video_getName(driver);
101 snprintf(NULL, 0, "Irrlicht Engine - Quake 3 Map example [%s] FPS:%d",
103 char *caption = (char*)malloc(capsize + 1);
104 snprintf(caption, capsize + 1,
105 "Irrlicht Engine - Quake 3 Map example [%s] FPS:%d",
108 irr_setWindowCaption(device, caption);