Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

laeuchli

procedural texture?

This topic is 6410 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

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

Share this post


Link to post
Share on other sites
Advertisement
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!