Click here to Skip to main content
15,741,692 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am working on a graphics engine in c++ and DirectX 11. While importing scenes (using Assimp) I have to render multiple meshes with separate shaders. I do this by the following method
I have an std::vector to store shaders and another one for meshes. After I open the file I add all the meshes to that vector. Next, I iterate over the elements of the vector using a for loop and draw each of them separately. After having drawn all the meshes I swap the buffer. This works perfectly fine except for the framerate/performance which is terrible. I have a graphics card which should be able to handle AAA titles with ease but struggles to render a simple 3d model.

What I have tried:

I am not aware how this can be done more efficiently or how this kind of thing is supposed to be done.
Updated 14-Jun-19 1:10am

1 solution

You should optimize your code. Like adding all meshes to a vector isnt a good idea. What about having an array of structs with a single mesh and shader. This would reduce looping times.

And you should draw each mesh in a single step, but start the render engine once and draw ALL meshes.

void drawAll()
  Renderdata *renderConfig = configureRendering();//setup env, prepare buffers

  for( SingleRender *rendering in allRenderings ) {
    vector *data =;
    shader *shader =  rendering.shader;
    drawVector(renderConfig, data, shader);

  finalizeRendering();//swap to screen
  cleanUpConfig(renderConfig);//freeing resources

Think about some global preconfig data which doesnt need to be created at each drawAll() like the vector and shader data.

Make time output to find the REAL bottlenecks. :-O
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900