| Revision 3 (by moose, 2006/06/24 13:41:11) |
Finally a working version of the factory code :D
|
Planning:
Objects:
have vertexes, colors, normals, texture, uv coords
has flag for new texture
has methods to access the Render's vertex info
has flags for usage mode, hint to gl/render class about how to update the vertex/etc data
(akin to the vbo usage hints, and different access methods: Map, and SubData)
has children?
// Rename Plugin to Module?
class Object {
private:
};
Render class: list of objects
Plugin::Interface:
Render::Plugin:
Factory::Interface:
Plugin::Factory:
Render::Factory:
Render::VBOFactory:
Render::VAFactory
Render::Interface:
Dynamo::Interface:
static Plugin::FactoryList list;
Dynamo::Factory:
Dynamo::Plugin:
#define DynamoRegisterFactory(name)
bool name::registered = Dynamo::RegisterFactory< name >( name::Factory );
template
bool RegisterFactory(C )
{
}
namespace Factory {
struct Info { };
template
class Interface {
public:
const char *getName() { return name; }
const char *getDesc() { return desc; }
static Interface *factoryInstance() { if(self) return self; return new Interface; }
C *createInterface() { return new C; }
private:
static Interface *self;
const char *name;
const char *desc;
Interface() : name(0), desc(0) { self = this; }
~Interface() { self = 0; }
};
}
namespace Render {
struct Capabilities {
enum {
VertexBufferObject = 1, // allegro_gl_extensions_GL.ARB_vertex_buffer_object
VertexArray = 2, // allegro_gl_extensions_GL.EXT_vertex_array
};
};
struct Info {
const char *name;
const char *desc;
};
class Data;
class List {
public:
void addObject(Object *obj, Data *dat) { object_vector.push_back(obj); data_map[obj] = dat; }
Object *operator[](int i) { return object_vector[i]; }
Object *object(int i) { return object_vector[i]; }
Data *data(Object *obj) { return data_map[obj]; }
unsigned int count() { return object_vector.size(); }
bool init() { if(!self) new List(); if(self) return true; return false; }
private:
List() { self = this; }
~List() {}
static std::vector