1
votes

I am rendering lot of axis aligned 3D cubes. Each cube can be different from one another by the location of its center of the cube and/or color. This is how, I am rendering it right now

for (i = 0; i < num_of_cubes; ++i) {
 glTranslatef(center[i].x, center[i].y, center[i].z);
 DrawCube();
}

My DrawCube() simply renders 6 quads corresponding to each side of the cube, using glDrawElements with vertex data stored in VBO. glVertexPointer and glColorPointer is used to set the attribute elements.

This works, but I want to use Instanced rendering by making use of probably glDrawElementsInstanced(). However due to some legacy code of the project, I have to use fixed function pipeline.

Is it possible to do this with fixed pipeline? If yes how do I tell my GPU to use the Instance vbo of voxel centers and colors.

1
You could use a compatibility profile and switch on shaders only when you need them (in the new code), then turn them off again. That's why there's compatibility profile, to make transitioning easier. - datenwolf
Thanks. It took me some time, but I switched to compatability profile - iNFINITEi

1 Answers

0
votes

As commented by datenwolf, I switched to compatibilty profile. I was using Qt with a lot of existing fixed pipeline code. So I bind and unbind the shaders after each Instanced rendering.