Jump to content
  • Advertisement
Sign in to follow this  
giugio

policy classes and graphics programming

This topic is 2213 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hello.
I trying to use policy classes , like that described in "moden c++ design" of Alexandrescu.
I wish create a simple project:

template <class CCreatorVboGl>
class VboManager: public CCreatorVboGl
{
Create(class CData vertexes){

. . .glvbo = CCreatorVboGl.Create(vertexes) ecc....
}
void Draw();
}
else
template <class CCreatorVboDx>
class VboManager: public CCreatorVboDx
{
Create(class CData vertexes){

. . .dxvbo = CCreatorVboDx.Create(vertexes) ecc....
}
void Draw();

}

i create an host class for each graphics entity(texture,vbo ecc...)and i send a CCreator
to the host class in this mode if i wish change the api from opengl to directx i simply change the creator object template parameter.
The question is : if i wish serialize the graphics elements how i do?
I think that is sufficent save the CData param of each element, then launch a Save for each CData classes.
but i must take care of the linkage ecc...
There is an example of serialization for non reinvent the wheel?
thanks

Share this post


Link to post
Share on other sites
Advertisement
Not a direct answer to your question, but: I really question the usefulness of serialising vertex buffer objects, and I doubly question the use of serialising a manager object. Serialising the vertex data is fine, but a vertex buffer object is implicitly linked to the driver context in which it is created - and unserialising it anywhere else would be highly dubious.

I'd suggest you separate out your model classes (i.e. vertex data), from your view classes (i.e. VBOs), and only support serialisation of your model classes.

Share this post


Link to post
Share on other sites

Not a direct answer to your question, but: I really question the usefulness of serialising vertex buffer objects, and I doubly question the use of serialising a manager object. Serialising the vertex data is fine, but a vertex buffer object is implicitly linked to the driver context in which it is created - and unserialising it anywhere else would be highly dubious.

I'd suggest you separate out your model classes (i.e. vertex data), from your view classes (i.e. VBOs), and only support serialisation of your model classes.




thanks swiftcoder,
Indeed My idea is to serialize just the data that create with the CCreator class the vbo, the CData, that has a list of vertexes(a list of 3dvector, sorry for my bad english).
I don't directly serializes the vbo , but the data that create it the last time that i create the vbo with the CCreator class,clearly if i modify the vbo(with mapping and unmapping)i must reflect the
changes on the data class CData.
This is the first problem , because if i change runtime a vbo with map unmap i do the work two time(one runtime on the vbo and one to my CData Class).
for do the serialization in the save function that is called for each entity with a vbo or other graphics element ,I save on disk only the CData class in binary mode , the problem is to load all the data classes and recreate the respective vbos and links from to these.
I'm in search for a robust serializing algorithm
Thanks.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!