I'm currently rendering a large proportion of the graphics of my game using custom OpenGL primitive functions (e.g.
DrawPolygonFilled(), etc) drawing procedurally generated objects (e.g. trees). Typically the core of these functions is a
glEnd loop, and use
GL_POLYGON. While this generally works, I'm seeing some performance issues if I have too many objects using these functions on screen at once.
For instance, I could render a brick wall by drawing 128 small brick-coloured rectangles with an outline. Alternatively I could render a single OpenGL texture with these bricks pre-drawn, which takes up more video memory but seems to be less processor intensive.
With this in mind, my question is: how do I take the output of the primitive functions and store them in an OpenGL texture at runtime? I'm aware of how to do with with an
SDL_Surface, but I don't have access to the primitive drawing functions in SDL and SDL primitive drawing is very slow (one of the reasons why I switched to raw OpenGL in the first place).