1

Well I'm learning DX11 and I hope someday I can start a simple 3D engine. I'm following tutorial series and I realised that I have no need to create any class to mantain my code (the tutorials also uses this procedural approach but I don't copy-paste the tutorial code, I try to understand the tutorial and then try to code the new stuff in my way), I can have the code 'understable' with just functions and global variables. So I wonder, when I have enough knowledge of the API and I want to start creating my own library, could this procedural approach have some downside? should I start writing some classes?

Thanks.

German
  • 139
  • 6
  • also, it would be important to me if someone could give me an example of which aspects of a game engine should be coded with a POO approach – German Dec 22 '12 at 18:12

1 Answers1

1

At the beginning i started with a little engine, which only consists of a bunch of procedures. For the first applications it worked and the developement was fast. But the more the application becomes complex the more the code became unreadable and really awful to maintain. Then I build the same with an OOP approach and nearly everything became better. The overall structure of the programm is easier and some problems are solved really neat with oop, e.g. collision-detection. You have an parent-class, e.g. CollidableObject, and derive many classes like CollidableSphere, CollidableCube or CollidableLine. For collision-testing you only have to work with the class CollidableObject and it doesn't matter which object it really is. This isn't really nice to handle with a procedural approach. There are many other examples, where oop is useful, e.g. you could model your particlesystem with many different type of particles (billboards,vertexlines,meshes,lights) and only have to implement a given pattern, to simply work with all together.

All in all I would advice to start as soon as possible with classes, but for the first funny hacking and learning a procedural approach isn't pretty but suitable.

Gnietschow
  • 3,070
  • 1
  • 18
  • 28