Centralizing a renderer, but using glBegin/glEnd, I have finally noticed that this is, hm... Impossible. Unless you do some fancy polymorphism tricks, or some type switching, you cannot centralize a renderer without using vertex arrays. Why?
All vertex arrays draw the same way, glDrawElements(), done, any type of geometry can be put in a vertex array, however, not every type of geometry glbegin/glend's the same way. Unless I have like, a virtual draw method in a base object class, and have each type of renderable object override that base function, which would be decentralizing the renderer, I must switch my MS3D structure to create a vertex array.
This simply will not do!
I have to change this structure, so I have one vertex structure, the vertex structure should contain of course, vertices, and then tex coords, then normals, maybe even an rgb. I also need an index struct.Code:class MS3DModel { public: MS3DModel(); virtual ~MS3DModel(); struct Vertex { char BoneID; float Location[3]; }; int NumVertices; Vertex *Vertices; struct Triangle { float VertexNormals[3][3]; float Textures1[3], Textures2[3]; int VertexIndices[3]; }; int NumTriangles; Triangle *Triangles; struct Mesh { int MaterialIndex; int NumTriangles; int *TriangleIndices; }; int NumMeshes; Mesh *Meshes; struct Material { float Ambient[4], Diffuse[4], Specular[4], Emissive[4]; float Shininess; GLuint Texture; char *TextureFilename; }; int NumMaterials; Material *Materials; bool Load( const std::string & name ); void ReloadTextures(); void Draw(); };
I need to throw all of these into a vertex array, setting the stride correctly for each type of array.
And then bam, one function call, draw an indexed MS3D Model with a VA. Now I can easily add support for other geometry types, and throw them in VA's, and then draw them all in the same way!
But, I digress, can someone please demonstrate throwing a struct of the right vertex information into a VA, as well as an index..
I know I need to modify the loading code for my ms3d file as well, this will be a huge task to undertake.
Remember, I need Normals, Tex Coords, Vertices, as well as an index.
I've done so much research on this topic, all I'm really missing is the syntax. Anyone willing to demonstrate?



LinkBack URL
About LinkBacks



