PDA

View Full Version : enhance a 2d surface with opengl effects



XFire
03-24-2002, 02:06 PM
Greetings,
i am in desperate need of a tutorial or some demo code that teaches/demonstrates how to enhance a 2d surface (sdl/direct draw) with an opengl water/wave or plasma effect.
Please post a reply if you know something that could help...

Thank's in advance,
Mike

Morglum
03-25-2002, 01:38 AM
wait a minute, why do you want to use sdl or directdraw
to draw your surface ? If you need opengl to enhance it, then it would be much easier to draw the surface itself with opengl !

XFire
03-25-2002, 11:57 AM
Greetings again,
that's an interresting idea, the reason why i (currently) use sdl and dd is because i thought it would be a 2d only game as i started.
Do you think it would incerease performance if i would use opengl instead of sdl/dd? (40 frames dd, 28 frames sdl/linux)
Next thing is that i have to be able to modify some pixels before the surface gets drawn (which is the main reason for the low performance). I suppose if i draw directly to a ?texture? surface i have to lock it first (so it will not be displayed untill i finished the modifikations). That's why i think it would not increase performance that much.
I don't know much about opengl yet, but i am certain i can manage to rewrite the code in less than 3 weeks. Do you think it's worth the effort?
And how about a water effect? Do you think it would be possible to add it without loosing too much cpu time? I thougt about calculating the water effect just for each second frame.
But back to the main question, i am still in need of a tutorial or some demo code that illustrates how to programm a water effect.

Thank's in advance for any info,
Mike

nexusone
03-25-2002, 12:50 PM
For some good tutors: nehe.gamedev.net


Originally posted by XFire:
Greetings again,
that's an interresting idea, the reason why i (currently) use sdl and dd is because i thought it would be a 2d only game as i started.
Do you think it would incerease performance if i would use opengl instead of sdl/dd? (40 frames dd, 28 frames sdl/linux)
Next thing is that i have to be able to modify some pixels before the surface gets drawn (which is the main reason for the low performance). I suppose if i draw directly to a ?texture? surface i have to lock it first (so it will not be displayed untill i finished the modifikations). That's why i think it would not increase performance that much.
I don't know much about opengl yet, but i am certain i can manage to rewrite the code in less than 3 weeks. Do you think it's worth the effort?
And how about a water effect? Do you think it would be possible to add it without loosing too much cpu time? I thougt about calculating the water effect just for each second frame.
But back to the main question, i am still in need of a tutorial or some demo code that illustrates how to programm a water effect.

Thank's in advance for any info,
Mike

jpummill
03-25-2002, 06:14 PM
There are some tutorials for water effects at:
http://romka.demonews.com/opengl/demos/texture_eng.htm

and
[URL=http://www.sulaco.co.za/opengl3.htm]

I just tried an advanced search on Google for "water" + "OpenGL" + "demo" and got about 100 references.

[This message has been edited by jpummill (edited 03-25-2002).]

Morglum
03-26-2002, 06:57 AM
OpenGL and dd : same speed
sdl : slower

If you target only windows, the simplest solution would be to continue with dd & d3d. But if you want linux portability, use opengl ! For 2 reasons :
1) opengl will be much faster than sdl if you've got hardware acceleration
2) using opengl + glut, you get almost 100% portability : it's possible to write code that runs both under windows and linux, with nearly 0 changes. So it can make you spare time.

Morglum

XFire
03-26-2002, 11:52 AM
Greetings again,
thank's for your assistance! I've found a lovly looking demo on the demonews.com link.

bChambers
03-26-2002, 02:17 PM
Originally posted by Morglum:
wait a minute, why do you want to use sdl or directdraw
to draw your surface ?

Because you have to?

Whether or not you use GL, you have to create a rendering context in some way. In Windows, you can either do this with GDI, DD or SDL. I prefer SDL, because it's more portable, but YMMV.

...Chambers

zed
03-26-2002, 10:34 PM
>>OpenGL and dd : same speed
sdl : slower<<

aye, sdl uses dd for 2d + opengl for 3d thus how can the above make sense

Morglum
03-26-2002, 10:59 PM
Well I guess that passing through sdl must take some time. Look at the frame rates announced by xfire. But I agree that the speed difference is in many cases negligible or can be made so by doing some optimization.

[This message has been edited by Morglum (edited 03-27-2002).]

XFire
03-27-2002, 01:59 PM
Hi again,

i am almost certain that the bad frame rate at the linux port is caused by too much oter running tasks. Just an example if i start netscape, the frame rate drops down to about 12-14 frames/second (Netscape uses more than 50% of the rest cpu time).
Maybe i should try to write a small script that tries to 'nice' all high priority tasks to a lesser priority (just an idea), because there ain't much more left to optimize. (most of the game is already written in assembly language -optimized for speed - no complex instructions, best possilbe instruction pairing (allways leads to a pretty opaqu code http://www.opengl.org/discussion_boards/ubb/smile.gif ), as good as no address generation interlocks...

Also i doub't that many people will play the linux port, so i think i'll take a look at the linux performance just if i get some feedback.
But however,
thank's for the great support!