Skip to main content
gamedev.net
🔒 Locked

procedural texture?

Started by laeuchli Nov 27, 2000 at 2:37 PM 4 replies 250+ views
Original Post
laeuchli
laeuchli
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
laeuchli
laeuchli
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
zedzeek
zedzeek
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
laeuchli
laeuchli
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

zedzeek
zedzeek
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

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.