Techniques for drawing objects in OpenGL -
techniques drawing large numbers of objects in opengl
i wondering techniques or methods use draw many objects on opengl.
for example, may have class represents brick, , maybe represents tree, or else random draw lamppost. say, have many bricks draw, or lampposts or that... calling draw method each 1 lead long code.
at moment using glut callback function draw "stuff" in world, brick or tree.
using globally accessible vector of base pointers
one idea had have classes inherit base class, , put base pointers vector - have vector global. way like:
for(int = 0; < vector_of_objects.size(); ++) vector_of_objects[i]->draw();
each object have draw function, draws opengl primitives.
an example of such class this. (this have been experimenting with.)
class box { public: void draw() { // drawing of box } // other members etc }
alternatives?
this doesn't seem idea, since creating new class house, require user remember add draw function called 'draw'... although trivial point, not big problem.
are different techniques used in industry or games development? advantage see method once loop put in draw function, can forget - having worry placing more items (or pointers) in globally accessible vector.
does have suggestions better alternative?
create interface stuff , inherit classes that. way nobody forget draw method needs implemented.
Comments
Post a Comment