Data ordering in a texture3D buffer

Started by lwjgl2015, December 11, 2015, 10:40:38

Previous topic - Next topic

lwjgl2015

I want to create a texture3D from a Buffer that I create programmatically rather than read it from file. Problem is: I don't understand how the data should be ordered. Specifically, assuming dimensions w x h x d, at which index in the buffer should point (x,y,z) reside?

Thanks

abcdef

This should help you, you basically just render a layer at a time
for( int d=0; d < depth; d++ ) 
{
    for( int h=0; h < height; h++ ) 
    {
        for( int w=0; w < width; w++ ) 
        {   
	    data.put( (byte) red ); // r
	    data.put( (byte) green ); // g
	    data.put( (byte) blue ); // b
	    data.put( (byte) 1 ); // a
        }
    }
}