Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!

1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Member Since 25 Jul 2012
Offline Last Active May 03 2014 08:13 PM

Topics I've Started

Trying to Convert Simple Java ECS to C++

01 March 2014 - 10:49 AM

Hi, I'm reading up on ECS on t-machine and other places, but now I'm trying to implement my own simple ECS. I'm stuck on trying to convert https://github.com/adamgit/Entity-System-RDBMS-Inspired-Java from Java to C++. In the EntityManager, he has a variable called componentStores which is defined as 

HashMap<Class, HashMap<Integer, ? extends Component>> componentStores;

However, I don't know the equivalent of this in C++.


So far, I've been able to create and generate entity ids, but I don't know how to actually add the component to the entity in a map. In the hashmap above, what types of data is it containing? Also, the second hashmap inside the hashmap, is the "? extends Component" supposed to be a pointer to a given Component? For example, I made a PositionComponent, would the hashmap contain a pointer to the PositionComponent? And, what is the point of the first data type "Class?" Sorry if this doesn't make sense, I don't fully understand what's happening, but the big question is how can you convert the hashmap into C++?


My entity header file looks like this:


#include <map>
#include <vector>
#include <cstdint>
#include <iostream>
#include <algorithm>

class EntityManager

        uint32_t create_entity();
        void kill_entity(uint32_t id);

        std::vector<uint32_t> entity_list;
        uint32_t assignable_entity_id;

        uint32_t generate_entity_id();


and this is my EntityManager source file

#include "EntityManager.h"

: assignable_entity_id(1)




uint32_t EntityManager::create_entity()
        uint32_t id = generate_entity_id();

        if (id < 1) {
                // throw error
                return 0;
        } else {
                return id;

uint32_t EntityManager::generate_entity_id()
        if (assignable_entity_id < UINT32_MAX) {
                std::cout << "Generated ID: " << assignable_entity_id << std::endl;
                return assignable_entity_id++;
        } else {
                for (unsigned int i = 1; i < UINT32_MAX; i++) {
                        std::vector<uint32_t>::iterator it = std::find(entity_list.begin(), entity_list.end(), i);
                        if (*it != i) {
                                std::cout << "Generated ID: " << i << std::endl;
                                return i;

                // throw error
                return 0;

void EntityManager::kill_entity(uint32_t id)
        std::vector<uint32_t>::iterator it = entity_list.begin();
        for (; it != entity_list.end(); it++) {
                if (*it == id) {
                        std::cout << "Killing Entity: " << *it << std::endl;

Any help would be greatly appreciated, thanks.

Need Help Implementing Entity Component Systems

31 January 2014 - 12:46 PM

Hello, so I've made a couple of basic games in C++ and AS3, through the traditional object oriented way, and then I came across an article about Entity Component Systems on GameDev. Everything made a lot more sense than having a big hierarchy of classes, but as I try to research more about this on google and gamedev, I only find explanations on how it works (and very partial implementations). I can't wrap my head around getting the design to work.


I've seen previous threads that have some code in them, but I still don't quite understand it. Is there any existing tutorials, books, resources, etc, that I could read to further understand how it works? It'd also help immensely if there's code to go along with it, as I don't understand much without some code. Also, if anyone has made a simple game or basic system showing how it works, I'd be very interested in seeing your code, most preferably in C++ as well. Thanks.

Is OpenGL Programming Guide 8th Edition Version 4.3 a good book to learn from?

19 May 2013 - 08:55 PM

Hi, I have a fairly good understanding of C++ and I made a couple of small little games in SFML. I decided to move onto OpenGL now and I was wondering whether I should pickup and get the OpenGL Programming Guide 8th Edition Version 4.3? I want your feedback on the book whether it's suitable for someone who's trying to learn OpenGL because I don't want to buy it, then find out that it's horrible and that I wasted my cash on it.


If this book is bad, then what are your suggestions to learning modern opengl? I dislike NeHe tutorials since they're old and deprecated. Also, if there's any other books that you suggest I should get then please leave a comment below or even a website to check out.



To learn SDL 1.2 or 2.0?

03 May 2013 - 06:48 PM

Hi, I'm deciding whether or not to learn SDL 1.2 or SDL 2.0 because I want to learn the API and create some games before moving onto OpenGL. I know SDL 2.0 is newer and is hardware accelerated, but there's not a lot of tutorials (at least updated ones) to learn from. Lazyfoo's tutorials are for version 1.2 and are generally the only recommended good tutorials to learn SDL.


I'm deciding to learn SDL, create a few games, come back, and render things in opengl instead of using SDL. I was deciding between SFML 2.0 and SDL 1.2 or 2.0 but the platforms supported in SDL is much bigger, and I felt it outweighed the difference between the two. Also, since a lot of indie and commercial game companies are using SDL, it seemed to be a better API to learn.


I'm learning SDL to start out with because I need more games created under my belt before I dive into OpenGL. Once I get better game concepts and stuff, I'll be then able to switch over to OpenGL for my rendering which will ease the process if I were to just start out with OpenGL and SDL and start to create games from there.



Eclipse parser/autocomplete not recognizing opengl functions? Any alternatives if Eclip...

27 March 2013 - 08:25 PM

Hi, I made a post about this on the Eclipse's forums with no luck ( http://www.eclipse.org/forums/index.php/t/463094/ ).


Basically, no opengl functions are being recognized by Eclipse's parser and are just telling me that it's an error (which is annoying). I'm using GLFW to create my opengl context and using GLEW to handle everything I need to include to use opengl. The program compiles and runs fine, but the auto complete is just not working for me. Also, I want to complete arguments from the functions. 


I want to know if anyone actually got Eclipse working with OpenGL and can complete functions WITH arguments. If this is unsolvable, is there any other alternatives to Eclipse that WILL get the job done? Excluding Visual Studio because I'm on Arch Linux. I'm using Vim as my text editor and using Eclim (which basically uses Eclipse to give me autocomplete, error check, etc) so I can still do everything in Vim without having to actually use an IDE, but if there's no other choice, I will switch to an IDE for the sake of function argument completion.