I thought of combining large repeating meshes and push them to the GPU as a single mesh which improves performance, and I have created another constructor for my
which takes an instance of the
instance so the same data can be reused again and again without uploading it every frame to the GPU.
DynamicRenderer dynRenderer = ...;
This is how normally I render meshes. This renderer is a utility class which collects the data in a big VBO under the hood and streams it to the GPU, giving the ease of the immediate mode rendering with custom shaders. Now in case I want to store some meshes into a large meshes that I know they are static, I can combine them into a batch.
DynamicRenderer dynRenderer = ....;
MeshRenderer meshRenderer = new MeshRenderer(dynRenderer);
That's it, I can now freely render multiple static meshes in one go, and instead of streaming large meshes every frame, I can create them once into a batch, and call render as many times as I can do. It helps me as I can now reuse the dynamic renderer for rendering other entities or even dispose it altogether. It took me an hour, but is worth its time.