Advertisement

To tile or Not to tile, thats the question....

Started by August 03, 2000 02:25 PM
4 comments, last by Hands 24 years, 4 months ago
I have a few questions in mind: 1-I have suceeded in creating smooth scrolling in a non-tile based map...but it was pretty slow.Now I wonder ,is it faster ,the smooth scrolling in tile-based maps? 2-Please...can any one show me how to use BltFast ,I just cant make it work!I have read the SDK help and even thought It wont work...please if anyone wants to make a good action today,explain me how to use it,with an example if its not asking too much (by the way sorry for the subject title...Im feeling a bit inspired today)
i''m not sure about your first question, but the second one i think i can help.
    //declarations of directdraw stuffLPDIRECTDRAW7 DD = NULL;        // DirectDraw objectLPDIRECTDRAWSURFACE7 DDSPrimary = NULL;// DDraw primary surfaceLPDIRECTDRAWSURFACE7 DDSBack = NULL;   // DDraw back surfaceLPDIRECTDRAWSURFACE7 DDSSprite = NULL;    // A sprite//then you have to initialize directx, set the display mode and //cooperative level// Create the primary surface with 1 back buffer    ZeroMemory(&ddsd, sizeof(ddsd));    ddsd.dwSize = sizeof(ddsd);    ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;    ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE |                          DDSCAPS_FLIP |                          DDSCAPS_COMPLEX;    ddsd.dwBackBufferCount = 1;    hRet = DD->CreateSurface(&ddsd, &DDSPrimary, NULL);    if (hRet != DD_OK)        return InitFail(hWnd, hRet, "CreateSurface FAILED");    // Get a pointer to the back buffer    ZeroMemory(&ddscaps, sizeof(ddscaps));    ddscaps.dwCaps = DDSCAPS_BACKBUFFER;    hRet = DDSPrimary->GetAttachedSurface(&ddscaps, &DDSBack);    if (hRet != DD_OK)        return InitFail(hWnd, hRet, "GetAttachedSurface FAILED");//load a bitmap into the DDSurface	DDSSprite = DDLoadBitmap(DD, "Sprite.bmp", 0, 0);    if (DDSSprite == NULL)        return InitFail(hWnd, hRet, "DDLoadBitmap failed");//set the color key (if needed)DDSetColorKey(DDSSprite, RGB(0, 0, 0));//then use bltfast like this://blit the sprite surface to the backbuffer//x & y are the coordinates of where to draw it on the backbufferDDSBack->BltFast(x, y, DDSSprite, NULL, DDBLTFAST_SRCCOLORKEY |DDBLTFAST_WAIT); //DDBLTFAST_WAIT tells DDraw to wait until it can draw, and then//draw, otherwise it returns an error//if you don''t want to draw the entire surface, make a rectangle and pass it in instead of NULL.//of course, you should do error checking on the return code of this//then you must flip the backbuffer to the screen like thisDDSPrimary->Flip(NULL, 0);//do error checking on the return code here too!    


I hope this helps.

t2sherm ô¿ô
t2sherm ô¿ô
Advertisement
BltFast() doesn''t clip, so it will always fail if you use it to try and blit to a surface that has a clipper attached, even if you stay within the clipping RECT(s). Maybe that is why you haven''t been able to get it to work?


-Ironblayde
Aeon Software
"Your superior intellect is no match for our puny weapons!"
to your question about what is faster i think the none-tile version is. In a tiled version u will have do o the clipping for every single tile, plus the time it takes your blt function for every tile. In a none-tiled version u wont have nearly as many blts and only 1 clip to worry about. The tilebased version uses less memory tho(if u have 1 large bitmap to display the bg at least).

I could be wrong, but thats my best guess.

Good luck.
I''d think the tile based would be faster (I don''t know, this is my best guess) and here''s why. Tiles are small, and since they repeat often you can store all your tiles in Video Memory which is fast, whereas when you get to big bitmaps you''re looking at storing that in system memory, and having to access that all the time would slow it down.

I''m probably wrong, but that''s my opinion on the subject.
Hey thanks for the reply, IronBlayde- That was exactly the problem why Bltfast wasn''t working thanks!and T2sherm- thanks for the example!

This topic is closed to new replies.

Advertisement