PDA

View Full Version : How about picture in OpenGL...



El_Segador
07-02-2003, 06:15 PM
Hi everyone this is my first post here, I hope you will be able to help me.
Well, let me explain my needs.
I want to generate a flame candle movment using a picture(bmp for example).With morph algorithm I think I will be able to create the movment. But my problem is about how to display it with OpenGL?
The thing is I got to way I guess to use it:
- I apply on a quad my picture as a texture, but this is not a good solution because when the size of my picture will change, my texture will be to big for the quads for exemple and so it will be cut off. Moreover, a texture is apply once, and we can't change it when the program run, can we?
-the other way I thought is to display the picture using glBitmap() function and companie (glPixelZoom etc...). But the fact is that I don't know how to use them...

So If you got an idea about how I can display with OpenGL my first picture and then display the all others pictures that will be using to create the movement, please, tell me.
If you want more precisions (if I explain badly or whatever) please, feel free to write back to me.

I'waiting for your answers.

chowe6685
07-02-2003, 06:58 PM
based on what you said, I would avoid OpenGL. It's not really designed to display 2D images, while you could do that with glDrawPixels() (you'll have to check the redbook for that details), its not going to be that fast. If you need to use GL, your best bet would be to make all the images the same size and use a texture.

Sourpotato
07-02-2003, 10:29 PM
First of all, flame effect would be quite difficult for beginner.Alright you can take the flame picture as a big texture and animate texture directly by applying many quads with corresponding texels on the texture.
Nehe lesson 11 is about animated texture.

Another way is to use discrete particle system .Particle system is very very big topic.Nehe lesson 19 has very easy-understood approach about it.

The last is do with phyics. Take a look some flame animation already implemented in game like diablo II and quake III ,and study the movement of flame frame by frame.and get a idea how to move around your texels or your partical to simulate the flame .

Good luck.

El_Segador
07-02-2003, 11:52 PM
chowe6685> Which render do you advice me to use instead of OpenGL? Otherwise, I will continue my way with glDrawPixel so ^o^
But the thing is that I got just one image and I got to deform it into others image to create the mouvement (this is the idea) so I can't have texture with the same size...This the problem...But may be, this problem is no way. I mean may be we can't realise such a thing...

RunningRabbit>Yeah I know it's a bit hard(really, unfortunatly), but in fact is a subject of my internship, I got to search how can I do in this way...Else I think I understant you idea I will look at this tutorial thanks. Then I know that we can use particles, but it's an existing solution right, and I have to find a new. If I don't succeed in this way, well, my research stop here. Finally I look about video of flamme and I guess I understand quiet enough about the mouvement and I got my idea about how to generate it. But if I can't display the result well, it's not interesting. So first I want to find a way to display.

But may be my explanations were not enough good, so I think I should reexplane, sorry.
Well the idea is: I got one picture of a flame (say the size width 128 and high 256).
Well I want to create another picture and morph the source into this new to create a first mouvement(the mouvement will of 1s, and the morph about 30 f/s). And the way I want to create the second picture is: I generate a new size of the flame (so of the picture) and then I morph the base picture into this new and so on and so on. With this technique we got just a vertical mouvement (if we change only the high). But let's do it "easy" for the moment. The high of the "next picture" is generated randomly.Then when I got this, I will try to apply my idea about how to do an horizontal mouvement and mixed the two.
Well I guess this time it's ok. Yeah now let see this tutorial 11!

Oh! Of course if you think that this solutions is impossible tell me too ^o^
So if you got any ideas tell me(in this forum or by mail or ICQ...).

Thanks for all the futur answer and thanks to chowe6685 and RunningRabbit.

Edit Edit!Well I made a gif, if you want to see it to have an idea about what I am talking about...

[This message has been edited by El_Segador (edited 07-03-2003).]

Sourpotato
07-03-2003, 01:03 AM
Well, hwo long your reply is! http://www.opengl.org/discussion_boards/ubb/smile.gif
I am not sure. But it looks like this is same theory behind animated texture.Be warned in advance . the demo of the Nehe lesson 11 run slow on machine with Graphics cards inferior than tnt 2 .for Matrix G400 ,it is crawling .I have to say Matrix G400 is lousy 3D Graphics Cards

zeckensack
07-03-2003, 03:54 AM
Just adding some things that weren't answered yet.

Texture images needn't be static. You can respecify texture images or portions of it at any time during rendering, except of course inside a glBegin/glEnd pair. The latter restriction applies to a lot of things and is hardly specific to textures.

There seems to be mutual agreement that glTexSubImage2D is the way to go, even if you're going to replace the entire texture.

So if you wish you can animate a textured quad by changing the texture image.

Let's assume a static "prerendered" flame animation for a while.
If your 'animation phases' are small, you can instead use multiple textures, each one with a distinct animation phase, and cycle through these textures. This way you avoid constantly reuploading all phases when you've cycled through, but you consume more texture memory.

That's a tradeoff. The bigger the images are, and the more animation phases you have, the more bus traffic you can save. You'll have to decide whether it's worth the additional texture memory to do that.

El_Segador
07-03-2003, 04:23 PM
Sorry for my long reply RunningRabbit.
There is another...

RunningRabbit> I saw the tutorial 11, and I guess I will try to understand it and use it for my problem, will see. Thanks.

Zeckensack>Thanks to give me such answer, about the possibility to change a texture when the programm is running, I will see this glTexSubImage2D function and try. I guess the Nehe tutorial 11 use this technique, didn't it?
Well about the size of the picture, for the moment it's 128*256 but it's a candle flame so we can suppose that at the end, the picture will not be too big, si may be this is not a problem, but I will take care of it of course.

Well thanks you 3 to answering.
Any other suggestions?
For the moment no? Let's work so...