Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


glTexSubImage3D() with GL_TEXTURE_2D_ARRAY


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
No replies to this topic

#1 rgc183   Members   -  Reputation: 164

Like
0Likes
Like

Posted 12 December 2012 - 11:53 AM

I am trying to use gltexsubimage3D with the cube. When i use target as GL_texture_2D_array i get some weird o/p, however same code works fine with gl_texture_3d. I am copying my code and screenshots here: texture coordinates:
GLfloat tex_coordinates[]={
		0.0, 0.0,0.0,
		1.0, 0.0,1.0,
		1.0, 1.0,1.0,
		0.0, 1.0,0.0,

		0.0, 0.0,0.0,
		1.0, 0.0,1.0,
		1.0, 1.0,1.0,
		0.0, 1.0,0.0,

		0.0, 0.0,0.0,
		1.0, 0.0,1.0,
		1.0, 1.0,1.0,
		0.0, 1.0,0.0,

		0.0, 0.0,0.0,
		1.0, 0.0,1.0,
		1.0, 1.0,1.0,
		0.0, 1.0,0.0,

		0.0, 0.0,0.0,
		1.0, 0.0,1.0,
		1.0, 1.0,1.0,
		0.0, 1.0,0.0,

		0.0, 0.0,0.0,
		1.0, 0.0,1.0,
		1.0, 1.0,1.0,
		0.0, 1.0,0.0
};
Now, i am using 8*8*8 texture, so that i am applying 8 layers of 2D images to each face of the cube. My texture data is
for (int i=0; i<size/8; i++)
    {
	    dataRGBA[4*i]=255;
	    dataRGBA[4*i+1]=0;
	    dataRGBA[4*i+2]=0;
	    dataRGBA[4*i+3]=255;

	    sub_data[4*i]=255;
	    sub_data[4*i+1]=255;
	    sub_data[4*i+2]=255;
	    sub_data[4*i+3]=255;

    }

    for (int i=size/8; i<size/4; i++)
    {
	    dataRGBA[4*i]=0;
	    dataRGBA[4*i+1]=255;
	    dataRGBA[4*i+2]=0;
	    dataRGBA[4*i+3]=255;

	 sub_data[4*i]=128;
	    sub_data[4*i+1]=0;
	    sub_data[4*i+2]=58;
	    sub_data[4*i+3]=255;



    }
    for ( int i=size/4; i<(3*size)/8; i++)
    {
	    dataRGBA[4*i]=0;
	    dataRGBA[4*i+1]=0;
	    dataRGBA[4*i+2]=255;
	    dataRGBA[4*i+3]=255;

  sub_data[4*i]=128;
	    sub_data[4*i+1]=255;
	    sub_data[4*i+2]=58;
	    sub_data[4*i+3]=255;


    }

    for ( int i=(3*size)/8; i<(4*size)/8;i++)
    {
	    dataRGBA[4*i]=255;
	    dataRGBA[4*i+1]=0;
	    dataRGBA[4*i+2]=255;
	    dataRGBA[4*i+3]=255;


sub_data[4*i]=0;
	    sub_data[4*i+1]=0;
	    sub_data[4*i+2]=0;
	    sub_data[4*i+3]=255;


    }

   for ( int i=(4*size)/8; i<(5*size)/8;i++)
    {
	    dataRGBA[4*i]=56;
	    dataRGBA[4*i+1]=150;
	    dataRGBA[4*i+2]=255;
	    dataRGBA[4*i+3]=255;

   sub_data[4*i]=54;
	    sub_data[4*i+1]=100;
	    sub_data[4*i+2]=12;
	    sub_data[4*i+3]=255;

    }

	  for ( int i=(5*size)/8; i<(6*size)/8; i++)
    {
	    dataRGBA[4*i]=150;
	    dataRGBA[4*i+1]=255;
	    dataRGBA[4*i+2]=58;
	    dataRGBA[4*i+3]=255;

   sub_data[4*i]=56;
	    sub_data[4*i+1]=32;
	    sub_data[4*i+2]=155;
	    sub_data[4*i+3]=255;

    }

	  for ( int i=(6*size)/8; i<(7*size)/8; i++)
    {
	    dataRGBA[4*i]=150;
	    dataRGBA[4*i+1]=0;
	    dataRGBA[4*i+2]=255;
	    dataRGBA[4*i+3]=255;

sub_data[4*i]=222;
	    sub_data[4*i+1]=15;
	    sub_data[4*i+2]=155;
	    sub_data[4*i+3]=255;

    }
	  for ( int i=(7*size)/8; i<(8*size)/8; i++)
    {
	    dataRGBA[4*i]=100;
	    dataRGBA[4*i+1]=128;
	    dataRGBA[4*i+2]=58;
	    dataRGBA[4*i+3]=255;

    sub_data[4*i]=156;
	    sub_data[4*i+1]=202;
	    sub_data[4*i+2]=15;
	    sub_data[4*i+3]=255;

    }
glTexImage3D(*target11, 0, GL_RGBA, 8, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE,dataRGBA);
glTexSubImage3D(*target11,0,0, 0,0,8, 4, 8, GL_RGBA,GL_UNSIGNED_BYTE,sub_data);

glTexParameteri(*target11, GL_TEXTURE_MIN_FILTER,GL_NEAREST);
glTexParameteri(*target11, GL_TEXTURE_MAG_FILTER,GL_NEAREST);
glTexParameteri(*target11, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(*target11, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(*target11, GL_TEXTURE_WRAP_R, GL_REPEAT);
GL_TEXTURE_3D
YT8o9.png

GL_TEXTURE_2D_ARRAY
R0OUO.png

I tried changing filters. By removing subimage3D call, 2darray works fine.
code works fine when xoffset=yoffset=0 and width=height=8

Edited by rgc183, 13 December 2012 - 05:37 AM.


Sponsor:



Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS