04-14-2018, 04:55 PM
(This post was last modified: 04-25-2018, 05:20 PM by Brian Beuken.)
I was asked on a Facebook forum what design patterns were used in the book.
I explained I was using a simple baseobject/derived from format, commonly known as Flyweight. I then was criticized for using an outmoded and inefficient pattern!!! Oh well its the internet and everyone has an opinion on whats best and is happy to tell you.
But it's true.... I have never ever denied that the code in the book is very inefficient, but....
It is very easy to follow. I mean very easy to follow, which is what the books intent was, to create an easy to follow path of progress, despite the acknowledge inefficiencies.
But what are those inefficiencies? Well one relates mainly to the fact our OpenGLES2.0 GPU is not able to handle instances of objects, (well not directly) Meaning that though our code is easy to follow and expand, when it comes to sending it to the GPU the 1 group of draw calls per model is a bit of a frame killer.
Also if you don't produce a good quality base class and carefully design your classes, you can find yourself constantly adding content to the base class.. resulting in bloat, and redundancy in the base class which some/several derived classes don't need.
But I don't personally feel these are major issues, flyweight is easy to implement, easy to debug, and importantly easy to visualize. It tends to be my goto method for smaller projects.
Game programming patterns is a popular topic with coders who have gone past the beginner/intermediate steps of their development, there are many good books on it Robert Nystrom's Game Programming Patterns, is pretty much an industry standard. Feel free to read about flyweight (ignoring the suggestion to use instancing) on Roberts site, here, http://gameprogrammingpatterns.com/flyweight.html, and check the rest of the site out for other options you might try. His entire book is online, not sure I'd be that brave
I explained I was using a simple baseobject/derived from format, commonly known as Flyweight. I then was criticized for using an outmoded and inefficient pattern!!! Oh well its the internet and everyone has an opinion on whats best and is happy to tell you.
But it's true.... I have never ever denied that the code in the book is very inefficient, but....
It is very easy to follow. I mean very easy to follow, which is what the books intent was, to create an easy to follow path of progress, despite the acknowledge inefficiencies.
But what are those inefficiencies? Well one relates mainly to the fact our OpenGLES2.0 GPU is not able to handle instances of objects, (well not directly) Meaning that though our code is easy to follow and expand, when it comes to sending it to the GPU the 1 group of draw calls per model is a bit of a frame killer.
Also if you don't produce a good quality base class and carefully design your classes, you can find yourself constantly adding content to the base class.. resulting in bloat, and redundancy in the base class which some/several derived classes don't need.
But I don't personally feel these are major issues, flyweight is easy to implement, easy to debug, and importantly easy to visualize. It tends to be my goto method for smaller projects.
Game programming patterns is a popular topic with coders who have gone past the beginner/intermediate steps of their development, there are many good books on it Robert Nystrom's Game Programming Patterns, is pretty much an industry standard. Feel free to read about flyweight (ignoring the suggestion to use instancing) on Roberts site, here, http://gameprogrammingpatterns.com/flyweight.html, and check the rest of the site out for other options you might try. His entire book is online, not sure I'd be that brave
Brian Beuken
Lecturer in Game Programming at Breda University of Applied Sciences.
Author of The Fundamentals of C/C++ Game Programming: Using Target-based Development on SBC's
Lecturer in Game Programming at Breda University of Applied Sciences.
Author of The Fundamentals of C/C++ Game Programming: Using Target-based Development on SBC's