Jump to content
  • Advertisement
Sign in to follow this  
itree

How to draw a background picture for 2D

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

Quote:
Original post by hcZeeWolf
... but remember - the APIs with programmer-simple interface are the slowest (simple for programmer OR fast-working - NEVER both).


I'm curious as to what leads to such a conclusion...

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by MasterWorks
Somebody correct me if I'm wrong but I think a lot of times a texture like this is just upsampled to 1024x512 or something like that. Maybe that could make it slower than expected.

One thing that really pissed me off when first learning D3D is that there's no easy way to just draw a pixel by pixel 'background', you need a large textured quad and the draw time is pretty slow relatively speaking. Expect your framerate to drop a lot, but always remember to track seconds per frame, not (the reciprocal) FPS or you will think it is worse than it really is.


Sprites are rounded up to a power of 2.

Writing the assembly code to blt an image pixel by pixel onto the back buffer is not really that hard. However, if your screen resolution changes, you will need to use a different image.

D3DSprite is the way to go. If its a background, disable z-buffer, alpha-blending, lighting and anything else you don't need, and if the image is to cover the whole screen, don't clear the back buffer each frame, just the z-buffer.

Share this post


Link to post
Share on other sites
Quote:
Original post by DBX
Quote:
Original post by hcZeeWolf
... but remember - the APIs with programmer-simple interface are the slowest (simple for programmer OR fast-working - NEVER both).


I'm curious as to what leads to such a conclusion...


It's an old, simple rule - the fastest code is the one you never call. Compare:


pobj->Init1();
pobj->Init2();
pobj->Init3();

/*
pobj2::Init()
{
pobj->Init1();
pobj->Init2();
pobj->Init3();
}
*/

pobj2->Init();



How do you think, which one is faster? I've had P120 with 4MB card and 24MB RAM for a long time. I run 3D rotating cube written in D3D8 (4 - 8 FPS) - it's code took about 100 lines. Simple to write, slow like sh... I run also height map terrain with ability to "fly" around the scene in pure DOS 6.22 (100 - 120 FPS) - about 4000 lines. Tooks weeks to write, fast like hell. And now you have your answer. Multitasking/threading systems, hardware-independent API's are the point where you loose performance. That's the price for simplicity of code. Greetz.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!