LWJGL Forum

Programming => OpenGL => Topic started by: lwjgl2015 on December 11, 2015, 10:40:38

Title: Data ordering in a texture3D buffer
Post by: lwjgl2015 on December 11, 2015, 10:40:38
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
Title: Re: Data ordering in a texture3D buffer
Post by: abcdef on December 11, 2015, 14:29:23
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
        }
    }
}