Jump to content
  • Advertisement
Sign in to follow this  
pjyelton

OpenGL How do I create textures on the fly?

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

I've seen a number of OpenGL progams where the creator describes creating textures on the fly during runtime instead of having the application load a texture from an external jpeg or bitmap. Anyone know where I can find some good examples or tutorials that show how this is done? Neither of my OpenGL books even mention it and I'm having a hard finding any information. Thanks!

Share this post


Link to post
Share on other sites
Advertisement
I can only think of two ways. One is to actually create the texture-data yourself and send it in using glTexImage2D, and the other is to render stuff using a FBO (or pbuffers depending on your hardware).
The first one probably isn't realtime and is probably best for procedurally generated textures.

Share this post


Link to post
Share on other sites
Thanks, I'll take a look. Would taking a solid external texture and letting the program manipulate the color be easier?

Share this post


Link to post
Share on other sites
Quote:
Original post by pjyelton
Would taking a solid external texture and letting the program manipulate the color be easier?


Procedurally generating textures is not complicated. It's the coming up with interesting procedural content that is complicated. I recommend you look at Perlin noise.

Apart from that, if you provide more info on what it is you actually want to do, I'm sure we can come up with some better advice.

Share this post


Link to post
Share on other sites
there is zero difference between the two

A/ read image data from file then call
glTexImage(...., data );

B/ create data procedurally + then call
glTexImage(...., data );

Share this post


Link to post
Share on other sites
Quote:
Apart from that, if you provide more info on what it is you actually want to do, I'm sure we can come up with some better advice.

Thanks, I really don't have a specific issue I am trying to solve, I'm basically teaching myself OpenGL through a couple pet projects like a terrain editor and a city skyline editor and I've just seen a few places where this idea is discussed and I'd like to try it out. For example, on the terrain editor I've seen where someone mentioned creating a cloud texture dynamically using the same height map that I create the terrain with. Or it would be nice to create a large texture that covers the terrain where high elevation is snow, steep cliffs are brown, etc but since the terrain is always randomly generated everytime the program is run it would be nice if I could randomly generate this texture as well. The last example I saw talked about creating random window lights that were textured onto city skyscrapers so basically take a solid dark color and randomly place dark and light windows. Hope this makes sense.

Share this post


Link to post
Share on other sites
You can also create textures on the fly using shaders. The 'Orange Book' (Opengl Shading Language by Randi Rost) is the place to go for examples. Chapter 6 has a basic 'brick' texture, created on the fly.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!