Jump to content
  • Advertisement
Sign in to follow this  
RenderCache

texture 3d basics

This topic is 5457 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hihi! jus wondering if anyone can enlighten me on this matter: i am trying to feed in some data into a texture 3d and test its usage using a pixelshader. i tried using a single float value and it works fine. but if values are in a vector or explict array, the results dun show. //this is the code which cannot work
int size = 3*3*2;
float* test = new float[size];
for(int i=0; i<size; i++)
	test = 1.0f;
	
glGenTextures(1, &g_texture3DID);
glBindTexture(GL_TEXTURE_3D, g_texture3DID);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, 3, 3, 2, 0, GL_RGBA, GL_FLOAT, &test[0]);

anyone? thx! RC

Share this post


Link to post
Share on other sites
Advertisement
1)The dimensions of the texture are not powers of 2.

2)The GL_FLOAT enum you use, means that each component of a texel is a float. Since you're using RGBA textures, each texel has 4 components. So, you need 4 floats to store a texel.

Share this post


Link to post
Share on other sites
Quote:
Original post by RenderCache
ok thx!
power of 2 is the answer


What I said in (2) is also important. If you don't fix it, you'll have also problems, and it might cause the program to crash.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!