Archived

This topic is now archived and is closed to further replies.

Dogen

Bug when moving a surface with Blt in fullscreen

Recommended Posts

Hello I have a rather large image(2048*1536) that i display with Blt in fullscreen. I only draw a piece of the picture every time, so i can walk around in the large picture. But when i use my keyboard to move around in X-axis the picture moves down one pixel and up again in Y-axis very quick every 32 pixel i move in x-axis. Please can somebody help me with this very annoying problem. /dogen

Share this post


Link to post
Share on other sites
ok, here is some code:


lpdd->SetCooperativeLevel(hwnd,DDSCL_ALLOWMODEX | DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE | DDSCL_ALLOWREBOOT);
if(lpdd->SetDisplayMode(1024,768,16) !=DD_OK)
{
error << "Couldn´t set display mode" << endl;
return 0;
}

//create backbuffer here


IDirectDrawSurface *bild;//surface with my large image on
int x,y = 0;

while(true)
{
DDBLTFX ddbltfx;
ddbltfx.dwSize = sizeof(ddbltfx);
ddbltfx.dwFillColor = RGB16BIT(0, 0, 0);
lpddssecondary->Blt(NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &ddbltfx); //clear screen

if (KEY_DOWN(VK_RIGHT))
{
x+=1;
}
if (KEY_DOWN(VK_LEFT))
{
x-=1;
}

RECT source;
source.left = x;
source.top = y;
source.right = x + 500;
source.bottom = y + 500;

lpddssecondary->Blt(NULL, bild, &source, DDBLT_WAIT, NULL);

lpddsprimary->Flip(NULL, DDFLIP_WAIT);
}

Share this post


Link to post
Share on other sites
The only thing I can think of is the lack of boundary checking for x and y

provided x>0, y>0 and x+500
Also have you tried putting a dest rect in there with 0,0,500,500 or using bltfast with 0,0 coords.

Other than those guesses, I can''t see any other problems.

Oh, if you replace y with 0 (source rect) does the problem still exist ?

,Jay

Share this post


Link to post
Share on other sites
Whey
None of that helped except BltFast(0,0 ...
but then my picture wasn''t rescaled either.

However i noticed another thing that helped, i added a DDCOLORKEY to my surface and suddenly it moved very smoth.

I hate these nonlogical shit errors !

/Dogen

Share this post


Link to post
Share on other sites
If blitfast got rid of the Y up/down error, then somewhere either the source image is being draw out of bounds or the source rect its self is out of bounds. Check that Y value, try uses drawtext to get it up on the screen.

A colourkey could be masking the top or bottom row of pixels and thus eliminating any bounds problems, but its not an ideal solution.

Did you replace Y, it might throw up the error ?

source.left = x;
source.top = 0;
source.right = x + 500;
source.bottom = 500;

Note: I though scaling was very slow, why not increase the image size uses paintshop.

,Jay

Share this post


Link to post
Share on other sites