Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm working on a Component/Entity-System based game engine atm. And I have this little dilemma. I have simple geometrical structures which might be downloaded or created in game at some point. These structures are used to create models that are used in OpenGL and OpenGL ES and then for some collision processing. During dev and Beta I am quite ok with maintaining data copies for the physics and the display. But I started thinking about the future of this engine as I already invested some spare time over a year and a half in it. Now I would like to duplicate a few routines into OpenCL kernels and use the power of GPUs for the server side of my engine (and be ready for OpenCL enabled mobile hardware/software).

The structures are of variable size and moving or stationary structures can be deformed or broken... ATM the storage is very inefficient.

I thought of using a few mega arrays of GLfloat (Compatible with OpenCL) which would contain my structures depending on their size and pass only the transformations needed each frame. My Components would then point to these arrays.

Is it the right approach? If not, how to store the structure data to get it loaded only when needed to GPU memory and maintain the Component structure.

Do I even need a system and components to display and manipulate the structures?


Note: This is not a homework. It is more a question of interest to get a little multiplayer side project running as nicely as possible.


Note: I can't create an OpenCL tag so if someone else could and add it to the question it would be appreciated.

share|improve this question
    
I don't understand what you're asking. Are you asking if it's ok to have separate mesh representations for physics and graphics? How does OpenCL factor into this? Do you want to use OpenCL for physics calculations? –  bummzack Oct 3 '11 at 15:26
    
Basically I am not sure that a component based approach is the right thing here I want to use OpenCL for 2 things: deformation and physics. I also would like to share some data between OpenCL and OpenGL but this will probably be another question at another time once I get this working. –  Coyote Oct 3 '11 at 15:33
add comment

1 Answer

up vote 1 down vote accepted

I don't think you need an entity system for this at all; entity systems work well for gameplay-related code, where they are influencing behavior or properties in some fashion and can allow for rapid iteration in a very large way.

It sounds like your geometry packaging system (for lack of a better term) doesn't need that kind of wide flexibility, and in fact you wouldn't want to allow it since that could destabilize performance.

I would instead implement the system on its own, distinct from any kind of entity system, taking your requirements into account (which appear to be efficient storage of the shape data for both transport and utilizing in OpenCL for deformation computations, et cetera).

Once the system is in place, you can expose it to your gameplay objects via a component that acts as a proxy for the geometry package. Such a component would essentially be a dumb wrapper around a reference to one of these geometry packages that is itself managed by the geometry packaging system. This will let your entity system refer to and take advantage of that system without complicating that system's own design with the flexibility of the entity system.

(Incidentally, I think this is how one should generally approach interfacing physics and rendering systems with entity systems as well.)

share|improve this answer
    
Yeah... During the prototyping phase efficiency wasn't my priority... That is until now. I wanted to start refactoring but I am not willing to break everything until I have an idea of how to refactor all of this. –  Coyote Oct 3 '11 at 16:01
    
I think you are right... After going through a few google searches I guess I'll have to use the dumb components... or none at all. I'll implement the OpenCL part, test it bare-bone and then I'll see how to link that with the rest of the Engine. –  Coyote Oct 3 '11 at 18:33
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.