View Full Version : loop drawing cubes
08-23-2012, 08:34 AM
I've an example with one cube. I want the cube is drawn again and again. He should be somewhere in the scene and not on the place before.
Can anyone help me please?
08-23-2012, 09:54 AM
Simply generate a random positions that make sense, put them into an array and while iterating over the cubes, simply fetch the position for the current cube and translate it using that position. If you're using shaders you can simply pass that position to the shader or use instancing where you will pass the complete array, or slices of arrays, to the shader. If you're using the fixed-function pipeline (i.e. GL 2.1- features) you need to employ the matrix stack and for each cube push the model-view, translate, draw the cube, and pop the matrix.
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.