policy classes and graphics programming

Started by
1 comment, last by giugio 11 years, 7 months ago
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
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.

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]


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.

This topic is closed to new replies.

Advertisement