PDA

View Full Version : How to draw correctly supporting much graphic cards



Huehnerschaender
26-08-2004, 04:55 PM
Hi there,

I am new to PowerDraw and I like the way it makes it possible to draw 2D things using 3D hardware. Very nice idea and very good implementation!

Now my question:

I am trying to convert a little part of a 2D game I was developing quite a time ago, and I discovered the following problem:
I need to use 800x600 resolution and my background-graphic is a still Image of this size. I load this image in an Imagelist and draw it by using RenderEffect-Routine of PowerDraw. Seems to work fine and fast using hardware... I tried out this little experiment on a computer with ATI Radeon 9000 mobility, works fine with more than 800 FPS in fullscreen.
On another PC with GeForce4 Ti 4200 it works fine also with nearly 1000 FPS in fullscreen mode.
Now the problem: I tested it on a PC with a shared memory Geforce 2MX/400 and every picture which has no size like 16*16,32*32,64*64,128*128 or 256*256 is shown just as a white square!
So how do I paint images which has size like 800*600 on older graphic cards, which support 3D but no textures of different sizes like mentioned above????
Lets stay at my little example. I want to paint a backgroun of size 800*600. How do I do this whithout getting problems on older graphic cards? Do I have to tile the background in 256*256-blocks? If it is so, then how would I e.g. rotate an image bigger than 256*256?
Maybe the question is stupid and you have a quick answer, but any hint would help me very much.
Thanks in advance.
Dirk

Paulius
26-08-2004, 07:07 PM
While newer graphics cards support non power of two textures there is a speed hit, so you should avoid them anyway. For say an image of 800x600 you could expand its dimensions to next power of two (which in this case would be 1024x1024) keeping the expanded area empty. A thing to note is that big textures with dimensions above 512 are slower on older cards and if you have a lot of them they?¢_Tll suck up video ram quite fast, so you might want to scale those 800x600 images to 512x512 and stretch them when drawing (it wont be too ugly as it?¢_Tll be bilinear filtered in hardware). I think PowerDraw has a general drawing function named TextureMap or something which allows you to specify texture and vertex coordinates so you can do rotations or any other transformations yourself. And on a side note about moving to hardware acceleration, remember that texture changes are expensive, so for best performance don?¢_Tt put every small image in a separate texture, but try to group some images in one texture and before drawing sort sprites by texture for best performance.

Huehnerschaender
26-08-2004, 07:14 PM
If anyone can say anything about this please quote your thoughts.
I need a quite quick reply on this because this "experiment" is just a trial on converting a really big project to PowerDraw. And if it works like I wish then I will be proud to make a statement at the beginning of the game`that it is powered by PowerDraw. I just don't want to mess around with all the 3D stuff to make a 2D game. But I have a good idea for a game and am programming Delphi for about 10 years. But my knowledge ends in programming 3D hardware. So I would be glad if I could use components like PowerDraw to fulfill my thoughts in real calculated pictures.
And till the actual moment I thought all would be working fine with PowerDraw, but then I found the issue with the GeForce 2MX/400.

Ok, I am just writing this because I saw about 9 "seeings" of my post and no answer.... and I need a "quick" answer, because I have time now to spend on my project..... in a few weeks it could have changed to "no time"...

thanks to everyone replying....

Dirk

Huehnerschaender
26-08-2004, 07:28 PM
Hi Paulius,

seems like you wrote your post when I did my second :o)
Sorry for my imapcience :o)

Ok, now to your post....

I understand the talking about texturesize etc. I also understand that I have to use textures smaller than 512*512... But I miss the answer to my question... How do I draw e.g. backgrounds sized 800*600 the best way...

Sure, I can tile all my images, I then can load every single part of it into different TAGFImages (in this case by 256*256 it would be 4*3 = 12 parts!!!) and then draw them on the screen. I am sure this will also work on the graphic card I mentioned before, because I tried to draw a "tile" on this card and then it worked...
But in fact I am programmer and no designer ( I have a friend who does graphics, and he does his job very satisfying), so I don't want to mess with more pictures than I have to. And then the next question is, maybe I want to rotate the background, containing 4*3 images of 256*256 (to fill the screen of 800*600), how do I do this?????? I have no experience in programming 3D so'it would be nice if you don't answer like "take the complement of vertex a and multiply it with face two, then add the matrice etc. :-) just joking, answer as you like, if I don't understand I will quote.....

Dirk

Paulius
26-08-2004, 08:40 PM
You don?¢_~t need to think 3D for this, thinking 2D is enough, but you?¢_Tll still need to think :wink: . I took a look at PowerDraw help files, TextureMap looks like this:
function TextureMap(Image: TAGFImage; PCoords: TPoint4; Color: TColor4; TexCoord: TTexCoord;
Effect: Integer): Integer
PCoords represents four corresponding points of the image on the screen, playing around with these will give you all you want. You want your texture stretched to the whole screen ?¢_" specify PCoords as your screen boundary size, you want rotation just rotate these four points in 2D. And there?¢_Ts no real sense to split images in small textures cause texture changes(change to using another texture when drawing, yes PowerDraw hides this from you) will be worse than the benefit from using small textures.

How do I draw e.g. backgrounds sized 800*600 the best way

you could expand its dimensions to next power of two or

scale those 800x600 images to 512x512 and stretch them when drawing

Huehnerschaender
27-08-2004, 08:18 AM
Hi Paulius,

I have just tested the 1024*1024 sized texture on the GeForce2MX/400 system and it works.
Thank you very much for your help.
I only need 1 texture for background at a time (sized 1024*1024) so I don't think that there will be memory-problems, even on smaller graphic cards. All other grahics are even smaller than 256*256.
Greetings and once more thanks,

Dirk

LP
27-08-2004, 02:20 PM
It's very recommended to use 256x256 texture size as a maximum, just to make sure it works on any video card. Simply open your 800x600 image in some editor and resize it to 256x256. Back in PowerDraw, draw it in 800x600 size. Using 1024x1024 texture just to draw background image isn't a very good idea (you waste a lot of memory and make your application compatible only with newest video cards).

Cheers,
Lifepower

P.S. Check http://www.mor.itesm.mx/~al375780/asphyre_beta.zip (full release coming... soon :wink:)

Paulius
27-08-2004, 03:15 PM
I thought that only practically extinct 3dfx boards up to Voodoo3 had maximum texture size of 256x256, no?

LP
27-08-2004, 03:29 PM
Well, my old Intel-powered video card on laptop has the same limitation, and few others have 512x512 as a maximum size. You can pretty much assume that most of video cards can handle bigger sizes, but since PowerDraw is made mainly to run on any hardware (thanks to Software Renderer), it's a good practice to not to overpass 256x256 texture size.

Huehnerschaender
27-08-2004, 06:45 PM
Hello Lifepower,

nice to hear something from the "master" himself :o)
If I understand your post right I would shrink my image to 256*256 and then stretch it back to 800*600. But this would mean I loose much quality of the background. It is necessary for my purposes to have the image on screen pixel by pixel as I draw it, because there are much interactionpoints for the user and it would look awful if I stretch it from 256*256.
Is there any other way to make my background appear like I draw it in 800*600 size? This is an essential question, because I really would like to use PowerDraw or Asphyre but I need this stupid background to be drawn properly...

Thanks for your time...

LP
28-08-2004, 02:59 AM
The quality loss is not that big, although if you need the highest quality possible, then dividing the bitmap or making large textures is the only option. I once needed a 1024x768 background image and I simply used multiple 256x256 textures to do it. For instance, you're having 800x600 image you want to render, extend it to 1024x768 and then use textures with size of 256x256 and pattern size of 256x256. That way you got 3x2 patterns and you simply draw them on the screen.

Hope this helps,
Lifepower

Huehnerschaender
28-08-2004, 07:16 AM
Hello,

thank you for your answer. I did it yesterday as you said and it works fine. There seems to be even no loss of speed doing this.
But now another question.
I have a Bitmap sized bigger than 256*256 which I want to rotate...
If I build it out of 4 tiles, how to rotate then? I think I can only rotate one image at a time, and the position of the other parts have to be exactly correct not to get black lines in the rotation. I am no mathematics expert, so a little hint or maybe a little piece of code could help me very much with this.

I think if I can manage this I have all I need to proceed with PowerDraw/Asphyre. That would be great, because even on a machine with GeForce2MX onboard I achieve about 100 FPS in windowed mode... thats great...

Huehnerschaender
28-08-2004, 06:10 PM
Hi there again,

I found out how to do the rotating of an image containing several textures. I use the TextureMap-routine and Rotate the Point4 and drawing it with the negative offset of texturesize. Works quite well, but as I thought before, there are nearly unvisible black lines between the different textures. But I think I can get rid of them playing around with the offset.
Now I am ready to go with PowerDraw.... :lol:
Thank you for your help paulius and Lifepower.

Oh, another question for you: How can I draw 3D primitives like cube or spheres???