procedural texture?
Hey, I need to know how to create a procedural. I know how to do the math part, but I can''t think how to get it into a texture format in opengl. Lets suppose that I had generated RGB values for my texture with my math functions. How do I put them in a texture? Thanks,
Jesse
i stuck a demo of procedural water up on my site a little while ago
http://members.xoom.com/myBollux
http://members.xoom.com/myBollux
I''m still a little confused about creating the texture.
I''ve tried looking at your code, and everything would be fine, except, that your texture doesn''t seem to be a rgb texture(correct me if I''m wrong). How do I put rbg in a char struct??
Thanks
Jesse
I''ve tried looking at your code, and everything would be fine, except, that your texture doesn''t seem to be a rgb texture(correct me if I''m wrong). How do I put rbg in a char struct??
Thanks
Jesse
easy instead of storing the image as a char
ie
char colour[TEXTURESIZE][TEXTURESIZE];
use a RGB struct(or someit)
RGB colour[TEXTURESIZE][TEXTURESIZE];
RGB is
typedef unsigned char RGB[3]
btw there might be problems with the heap with such a large array
http://members.xoom.com/myBollux
ie
char colour[TEXTURESIZE][TEXTURESIZE];
use a RGB struct(or someit)
RGB colour[TEXTURESIZE][TEXTURESIZE];
RGB is
typedef unsigned char RGB[3]
btw there might be problems with the heap with such a large array
http://members.xoom.com/myBollux
ok ,thanks. I also found another way:
float ptexture[128][128][3];
void creatatest()
{
for(int y=0;y<128;y++)
for(int x=0;x<128;x++)
{
//rgbp temp={0,0,1};
ptexture[y][x][0]=0;
ptexture[y][x][1]=0;
ptexture[y][x][2]=1;
}
}
...
glTexImage2D(GL_TEXTURE_2D, 0, 3, 128, 128, 0, GL_RGB, GL_FLOAT, ptexture);
This as you could guess creates a blue texture.
Thanks for the help....
www.laeuchli.com/jesse
float ptexture[128][128][3];
void creatatest()
{
for(int y=0;y<128;y++)
for(int x=0;x<128;x++)
{
//rgbp temp={0,0,1};
ptexture[y][x][0]=0;
ptexture[y][x][1]=0;
ptexture[y][x][2]=1;
}
}
...
glTexImage2D(GL_TEXTURE_2D, 0, 3, 128, 128, 0, GL_RGB, GL_FLOAT, ptexture);
This as you could guess creates a blue texture.
Thanks for the help....
www.laeuchli.com/jesse
one other thing ive noticed the speed of using an unsigned char for the image is far quicker than a char
http://members.xoom.com/myBollux
http://members.xoom.com/myBollux
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement