Jump to content
  • Advertisement

Archived

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

wise_Guy

Wrong "mode" of surface????

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

Hello all! I''m having a slight problem with DirectX at present. I have one function that inits an offscreen surface for use as a sprite, and then another that (supposedly) locks that surface and copies data from a bitmap file. What''s wrong? Well, when I try to lock the surface, I get a DDERR_SURFACELOST error, and the help file advises me to Restore() my surface, but when I try to do so, I get a DDERR_WRONGMODE error! I have tried doing the restore() function inside the init function, and that works, so somehow, when the INIT function goes out of scope, and then the GRAB_BITMAP function comes into scope, the surface changes it''s mode, whatever that is... Before you ask, yes I am using pointers to the sprites so they should be staying INIT''ed... I am at a loss. Maybe if I firstly knew what a MODE was in the first place... i haven''t change the Bits Per Pixel that I know of... anyone know what''s going on? yours truly, wiseGuy

Share this post


Link to post
Share on other sites
Advertisement
a DDERR_WRONGMODE error is generated when you try to use a surface that has been created in another mode (for example when i switch to fullscreen, i have to recreate all surfaces or i get this error)
post up your init code, perhaps there is something wrong with it

Share this post


Link to post
Share on other sites
okies, here is my Sprite init code. Note that I init DirectDraw elsewhere and Yes I do init DX before all my sprites.


int initSprite(sprite *sprite, int width, int height, LPDIRECTDRAW ddraw, int flags)
{
//create the description object
DDSURFACEDESC ddsd;


sprite->x = sprite->y = 0;

memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS / DDSD_WIDTH / DDSD_HEIGHT;

ddsd.dwWidth = sprite->width = width;
ddsd.dwHeight = sprite->height = height;

//set the surface to an offscreen one
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;

//create the surface in VRAM
for (int i=0 ; i<(sprite->numframes) ; i++)
{
if (ddraw->CreateSurface(&ddsd, &(sprite->image), NULL) != DD_OK)
{
MessageBox(NULL, "couldn''t create off screen surface", "error", MB_OK);
return 0;
}

if (flags==0) //if we want transparency
{
//set transparent to pink
DDCOLORKEY colorkey;
colorkey.dwColorSpaceLowValue = RGB16BIT(255,0,255);
//colorkey.dwColorSpaceHighValue = RGB16BIT(256,56,141);

//set pink to be transparent
(sprite->image[i])->SetColorKey(DDCKEY_SRCBLT /*/ DDCKEY_COLORSPACE*/, &colorkey);
}
}

return 1;
}

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!