Sign in to follow this  
zny

multi texture problem.

Recommended Posts

zny    116
hi guys, i am working at a terrain edit program. i want to make some grass texture or other texture on some place, how can i do it?

Share this post


Link to post
Share on other sites
Boder    938
If you want to "fade" from one texture to another, I think you want 3D textures.

Check the Game Programming Wiki (gpwiki.org) they have a nice article

Share this post


Link to post
Share on other sites
zny    116
indeed, what i want is very sample.
for example, i have a bomb exploded somewhere, i want to a texture on there.
how can i do it?

Share this post


Link to post
Share on other sites
deavik    570
Are you already using multitexturing?

If it is, all that's required in your case is finding the correct TexCoords if you have a piece of geometry in the place where the bomb exploded.

Else, you will probably have to create a little quad in the area which is textured with the "explosion" texture. In this case multitexturing isn't required, but it'll require an extra pass for the explosion textured quad.

Share this post


Link to post
Share on other sites
zny    116
yes, now i save many quad for every explode.
because i do not want the explode disappear next frame.
so i want a better way.

i am interesting in that the 1st way you said.
how can i do it with multitexture?

Share this post


Link to post
Share on other sites
deavik    570
Quote:
Original post by zny
yes, now i save many quad for every explode.
because i do not want the explode disappear next frame.
so i want a better way.

i am interesting in that the 1st way you said.
how can i do it with multitexture?

From OpenGL 1.3, or earlier versions through the ARB_multitexture extension, you can use more than one "texture unit" for texturing. To use it, first check if your extension string contains "GL_ARB_multitexture". If it does, your hardware is guaranteed to have atleast 2 texture units.

The default texture unit selected is texture unit 0. Suppose you have a bound texture on texture unit 0, as usual. With multitexture, you may call:


glActiveTexture(GL_TEXTURE1); // this selects the new texture unit 1
glBindTexture(GL_TEXTURE_2D, explosion_texture); // bind explosion texture
glEnable(GL_TEXTURE_2D); // enable texturing (this state is maintained per texture unit)

// ...

// specifying texture coordinates
glMultiTexCoord2f(GL_TEXTURE0, 0.0, 0.0); // these are for your terrain texture
glMultiTexCoord2f(GL_TEXTURE1, 2.0, 3.0); // these are for your explosion texture
glVertex3f(...);


And that's it! There are plenty of tutorials on this subject on the internet, but unfortunately I couldn't find even one, so this short introduction above.

Hope this helps!

Share this post


Link to post
Share on other sites
zny    116
yeah, thanks very much!!what you said is right,it help me a lot.
but..... i don't konw how to say.

you know until a bullet is exploded, nobody knows the 2nd texture's position.
so the 2nd texture's position is not static.

what i said is right?

Share this post


Link to post
Share on other sites
zny    116
many thanks!

i have download the Stretch, but i can not find any cpp files or lib files,
could you tell me how did you do it?

Share this post


Link to post
Share on other sites
zny    116
yeah, i have found a sample method,

use glTexSubImage2D() can slove this problem easy,

and it works very good!

thanks so many people help me!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this