Original Post
Hello everyone,
Being new here, I'd like to introduce myself. Neurodoxx, french student in robotics, currently developing a C++/OpenGL isometric game engine.
My request is two-fold.
The engine I'm programming relies on a component based entity system to make sure a given entity only contains what it needs to carry out its duty. For instance, trigger entities won't need to display any sprite so they don't include the render component. It follows that some entities are not renderable. My engine is currently running a back to front painter's algorithm to display tiles on a map (hastily implemented as a multi-dimensional array to run tests quickly) and is unable to integrate displayable entities in the world. I came up with the idea (and I don't doubt that's a common way to do it) that my engine should deal with tiles and renderable entities the same way, which in OOP is easily done by deriving tiles and entities from the same -let's call it Drawable- interface. However, with my component-oriented design for the entity system I'm basically hitting a snag.
It appears to me that tiles should be implemented as entities at the cost of a relatively small overhead, yet I can't find an elegant way to iterate only over drawable entities in my render function. Should I split drawable and non-drawable entities into two different lists ?
I've been travelling all over the web to find a smart solution to address this issue but came up with no clue which might indicate I'm not following a good path, I fear, and as a result I can't sleep.
This problem apart, I know that some day I will need to perform depth-sorting over my list of displayable objects so as to draw them in the right order. This, in theory, I can deal with as I've seen many tutorials on how to do it efficiently. But can I, and if yes, how should I sort it in order to render exclusively objects located under the viewport ?
Thanks in advance for your feedback, and if you need code to make this less abstract, I can provide !
Have a good day !
Being new here, I'd like to introduce myself. Neurodoxx, french student in robotics, currently developing a C++/OpenGL isometric game engine.
My request is two-fold.
The engine I'm programming relies on a component based entity system to make sure a given entity only contains what it needs to carry out its duty. For instance, trigger entities won't need to display any sprite so they don't include the render component. It follows that some entities are not renderable. My engine is currently running a back to front painter's algorithm to display tiles on a map (hastily implemented as a multi-dimensional array to run tests quickly) and is unable to integrate displayable entities in the world. I came up with the idea (and I don't doubt that's a common way to do it) that my engine should deal with tiles and renderable entities the same way, which in OOP is easily done by deriving tiles and entities from the same -let's call it Drawable- interface. However, with my component-oriented design for the entity system I'm basically hitting a snag.
It appears to me that tiles should be implemented as entities at the cost of a relatively small overhead, yet I can't find an elegant way to iterate only over drawable entities in my render function. Should I split drawable and non-drawable entities into two different lists ?
I've been travelling all over the web to find a smart solution to address this issue but came up with no clue which might indicate I'm not following a good path, I fear, and as a result I can't sleep.
This problem apart, I know that some day I will need to perform depth-sorting over my list of displayable objects so as to draw them in the right order. This, in theory, I can deal with as I've seen many tutorials on how to do it efficiently. But can I, and if yes, how should I sort it in order to render exclusively objects located under the viewport ?
Thanks in advance for your feedback, and if you need code to make this less abstract, I can provide !
Have a good day !