3D game engines

Pages: 12
I'm looking to learn 3D game development. The engine has to run on Linux and Windows (and preferably other platforms) without much trouble. It also needs to be fee and royalty free, and ideally would be open source.

I'm not using Unity or UDK because those don't let you write native code, only script code, and that sucks.

At the moment I'm looking at Irrlicht but I don't much care for the design. It looks like a C library, and the code I've written so far is ridiculously verbose:
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
#include <cstdint>
#include <exception>
#include <irrlicht/irrlicht.h>
#include <memory>
#include <stdexcept>
#include <string>

using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;

int main()
{
    std::unique_ptr<IrrlichtDevice> device(createDevice(video::EDT_OPENGL, dimension2d<u32>(800, 600), 32, false, false, false, 0));
    if (!(device.get()))
        throw std::runtime_error("Error creating Irrlicht device");
    device.get()->setWindowCaption(L"DemonGame");
    device.get()->getGUIEnvironment()->addStaticText(L"DemonGame using Irrlicht OpenGL", rect<s32>(10, 10, 260, 22), true);
    std::unique_ptr<IAnimatedMesh> mesh(device->getSceneManager()->getMesh("assets/sydney.md2"));
    if (!(mesh.get()))
        throw std::runtime_error("Error loading mesh");
    std::unique_ptr<IAnimatedMeshSceneNode> node(device.get()->getSceneManager()->addAnimatedMeshSceneNode(mesh.get()));
    if (node.get()) {
        node.get()->setMaterialFlag(EMF_LIGHTING, false);
        node.get()->setMD2Animation(scene::EMAT_STAND);
        node.get()->setMaterialTexture(0, device.get()->getVideoDriver()->getTexture("assets/sydney.bmp"));
    }
    device.get()->getSceneManager()->addCameraSceneNode(0, vector3df(0, 30, -40), vector3df(0, 5, 0));
    while (device.get()->run()) {
        device.get()->getVideoDriver()->beginScene(true, true, SColor(255, 100, 101, 140));
        device.get()->getSceneManager()->drawAll();
        device.get()->getGUIEnvironment()->drawAll();
        device.get()->getVideoDriver()->endScene();
    }
    device.get()->drop();
    return 0;
}

Obviously my std::unique_ptr use isn't helping, but I had to do that so I wouldn't have to manually free the memory*. It shouldn't be using pointers in its interface anyway, it should be references.

Anyway, so I'm hoping someone knows of a better-designed 3D game engine/renderer. It's the rendering and the animation I really need - I can use other libs for sound and physics easily enough - but if the engine includes those, then so much the better.

As an example of what I think of when I say "good design", see any Boost library or Google's V8 Javascript engine.

Thanks a lot.

>2013
>manually freeing memory
ISHYGDDT
Last edited on
closed account (3qX21hU5)
Have you tried Orge3D? I personally haven't used it but have heard good things about it.
I haven't. I've heard of it, and I've heard that it's good in terms of what it can do, but I've also heard that its design is even worse than Irrlicht's. Honestly, I care more about how nice the code looks than how nice the graphics look (I'm going to spend far longer programming it than I'll ever spend playing it, after all!), so although Ogre might be more powerful, if the code will be worse then I probably won't use it.

[edit] I've looked at Ogre example code and it actually looks better, so I'm switching to that unless someone has a better suggestion.

p.s. Please no Blender, I want to have more than 5 frames per second.
Last edited on
It's not necessary to use the get method with unique_ptr like that. For the most part, you can use it like a normal pointer.
Last edited on
@htirwin
Thanks for the tip.
> Obviously my std::unique_ptr use isn't helping,
> but I had to do that so I wouldn't have to manually free the memory
I don't think that you should delete the pointer, that's what drop() is for.
But IrrlichtDevice::drop() is a member function, it can only free memory used by the instance, not the pointer to the instance itself, right? I'm not deleteing the pointer. I don't know what std::unique_ptr does in its destructor. I assume nothing.
Last edited on
I don't know what std::unique_ptr does in its destructor. I assume nothing.

If std::unique_ptr did nothing in its destructor, there would be no point in using it.


But IrrlichtDevice::drop() is a member function, it can only free memory used by the instance, not the pointer to the instance itself, right?

One can't really make that assumption. It could do any number of things, such as notify the owning object that it needs to be destroyed.

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
#include <deque>

struct A
{
    void dispose()
    {
        auto it = _owner.begin();
        while (&*it != this)
            ++it;
        _owner.erase(it);
    }

private:
    A(std::deque<A>& d) : _owner(d) {}

    std::deque<A>& _owner;
};

A* CreateA()
{
    static std::deque<A> a;
    a.emplace_back(a);

    return &a.back();
}

int main()
{
    A* a = CreateA();
    a->dispose();
}


The design is rather icky, of course.
Last edited on
delete this
http://irrlicht.sourceforge.net/docu/classirr_1_1_i_reference_counted.html
Basically, a shared pointer without the benefit of a destructor

> I don't know what std::unique_ptr does in its destructor. I assume nothing.
... then it would be leaking memory.
You could specify a deleter, but the default one must release the pointer, so delete

it's starting to bother me that all that you can be sure about c++ is that sizeof(char)==1
@cire, ne555
I didn't think of that, thanks. So, do you think it could result in a double-free if I use std::unique_ptr?
From what I've heard, Ogre is a bit of pain to set up but it's good once you get up and running.

Even used for some commercial games. I think Zombie Driver HD on Steam was one of them.

I guess the other option is to write a simple engine using OpenGL. Could be done using SFML to handle contexts and I/O.
Ogre doesn't look bad, actually; it looks better than what I read, but the tutorials aren't very good. I think I'm just going to wrap Irrlicht so that I can hide its ugliness.

I'd like to write my own 3D engine, but I'm already working on a 2D game and engine; making a 3D one would be too much work right now.

I just had a thought, actually. I'm going to look into using id Tech 4; it's GPL'd and everyone likes John Carmack, I'm sure his engines are well-designed.
closed account (zb0S216C)
I heard that Ogre3D is a bit slow. Have you looked into the CryENGINE? It's open-source, far more powerful than Ogre3D, cross-platform and it's fast.

Wazzak
Hmm, I imagine CryEngine is worth looking at, but their website is down right now. Are you sure it's the full engine and not just an SDK? UDK, for example, just lets you use their editing and scripting tools and you don't get to do any actual programming. It's just a glorified GameMaker. To get the actual UE3 you have to pay like $500,000. Also, id Tech 4 is GPL which means royalty free. The Google summary for CryEngine says it's free for non-commercial use which makes me think you have to pay a royalty if you want to sell your game. That's not going to be an issue for the foreseeable future, but eventually I might make a game I want to sell, and then I'm faced with either having to pay a fee and royalties or learn a whole new engine and port an entire codebase over to it, which would be almost like rewriting the game from scratch. I will look into it, though. Thanks for the suggestion.
Last edited on
Isn't the Source Engine entirely written in C++? If I recall there is no scripting involved, and all game logic is written in C++ as well. If you haven't, check out the source sdk
closed account (o1vk4iN6)
What would you program into UE3 that isn't already there ? You can do almost everything in unrealscript. The only reason I wouldn't use UDK is cause they want 25% of the revenue if you make more than 50k.
Also worth pointing out that you can bind dlls in udk.
im making a 3d game engine

just tell me some stuff you would like and ill do it
Last edited on
@Cheraphy
Good idea, although again if I wanted to sell my game I would most probably have to use another engine or face fees and royalties. The advantage of id's engines is that, other than the 5th one, they're GPL software, so they're free from royalties, and they use OpenGL, so they're easy to port to Linux - and that's if they don't support it out of the box. I really need something that runs on Linux because I don't like programming on Windows. I'll check out the royalty situation because I know Source runs on Linux.

@xerzi
It's not so much not having the source code to modify the engine as not being able to write in a language I'm comfortable with, not having a multiplatform engine (that's a big concern because I'm using Linux for development and because I don't want to support single-platform software), and also ideological reasons because I prefer open source. I can't imagine it looks as good on a CV either. I'm not expecting to ever get into game development professionally but I'd like to and if the opportunity were ever to arise, I think "wrote a 3D game in C++" looks better than "made a 3D game, hardly touching any code".

@Lachlan Easton
That would be better, although I imagine it's a lot of work without having the game's source code. Is there an API you can use? Because otherwise I imagine it's a lot of hooking and injecting and reverse-engineering.

@herrybiscuit
If you're serious, here's what I want from an otherwise complete game engine:
- runs on Windows and Linux (other platforms optional)
- open source
- uses OpenGL (other renderers (D3D, software) optional)
- lets me program in C++ (scripting languages optional)
- good, modern C++ design (see Boost, V8)
that's it. See you in two years I guess.
closed account (o1vk4iN6)
I think "wrote a 3D game in C++" looks better than "made a 3D game, hardly touching any code".

What part of the 3D game are you actually writing when you are using libraries like Ogre3D that pretty much do everything for you ?
Pages: 12