🔒 Locked
Problem with Direct/x basic surface creation
Advertisement
Original Post
Hi,
I''ve a little problem. The function bellow is called in a while, but it work one time and the second time (in the while) the application shut down suddently,
i''ve indicated you where is the bug... i don''t know why the creating function don''t work two times...
the call is like:
for (y = 0; y < j; y++)
{
for (x=0;x);
i++;
}
}
zone is a structure
thank you very much.
ps:
The is a lot of message box, but it''s to know where the function stop
LPDIRECTDRAWSURFACE7 bitmap_surface(LPCTSTR file_name)
{
HDC hdc;
HBITMAP bit;
LPDIRECTDRAWSURFACE7 surf;
bit=(HBITMAP) LoadImage(NULL,file_name,IMAGE_BITMAP,0,0,LR_DEFAULTSIZE|LR_LOADFROMFILE);
if (!bit)
return NULL;
BITMAP bitmap;
GetObject( bit, sizeof(BITMAP), &bitmap);
int surf_width = bitmap.bmWidth;
int surf_height = bitmap.bmHeight;
DDSURFACEDESC2 DDSD2Desc;
memset (&DDSD2Desc, 0, sizeof (DDSURFACEDESC2));
DDSD2Desc.dwSize = sizeof (DDSURFACEDESC2);
DDSD2Desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
DDSD2Desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY;
DDSD2Desc.dwHeight = surf_height;
DDSD2Desc.dwWidth = surf_width;
MessageBox(hWindow,"creation of the surface","prob",MB_OK);
HResult = lpDD7Interface->CreateSurface (&DDSD2Desc,
&surf,
NULL); // here the application bug the second time
MessageBox(hWindow,"surface created","prob",MB_OK);
if (HResult!=DD_OK)
{
MessageBox(hWindow,"surface BMP","prob",MB_OK);
Jeux_Quit();
return(0);
}else{
MessageBox(hWindow,"surface BMP","prob",MB_OK);
surf->GetDC(&hdc);
HDC bit_dc = CreateCompatibleDC(hdc);
SelectObject(bit_dc,bit);
BitBlt(hdc, 0,0, surf_width, surf_height,bit_dc,0,0,SRCCOPY);
surf->ReleaseDC(hdc);
DeleteDC(bit_dc);
DeleteObject(bit);
return surf;
}
}
thanks again
There''s nothing obviously wrong to me in the code.
Whats happening in between the calls to bitmap_surface?
Have you tried checking the return code (HResult) from CreateSurface to see what the error actually is?
Are you loading different bitmaps each time? Maybe the card you have doesn''t support the surface size you are attempting to create.
Sorry I can''t be much help...
Whats happening in between the calls to bitmap_surface?
Have you tried checking the return code (HResult) from CreateSurface to see what the error actually is?
Are you loading different bitmaps each time? Maybe the card you have doesn''t support the surface size you are attempting to create.
Sorry I can''t be much help...
what is i++ ?
can you show me your whilepart?
I think that the bug is there.
[edited by - pipo declown on August 1, 2002 8:27:57 AM]
can you show me your whilepart?
I think that the bug is there.
[edited by - pipo declown on August 1, 2002 8:27:57 AM]
the while parti is:
for (y = 0; y < j; y++)
{
for (x=0;x{
zone[y][x].nx = x;
zone[y][x].ny = y;
zone[y][x].hax = x*8;
zone[y][x].hay = y*6;
zone[y][x].lpsurface = bitmap_surface(img(i)); // the () replace the ][
i++;
}
}
img is a LPCSTR aray with "surf1.bmp" "surf2.bmp" etc...
the bmps are 800*600, and as the flag says, the surface is stocked in SYSTEMMEMORY
The is a HResult verif, but the apply stop without continue, it close... the bug is situated exactly at the CreateSurface method...
thanks for your posts
[edited by - Anneoldon on August 1, 2002 10:13:10 AM]
for (y = 0; y < j; y++)
{
for (x=0;x{
zone[y][x].nx = x;
zone[y][x].ny = y;
zone[y][x].hax = x*8;
zone[y][x].hay = y*6;
zone[y][x].lpsurface = bitmap_surface(img(i)); // the () replace the ][
i++;
}
}
img is a LPCSTR aray with "surf1.bmp" "surf2.bmp" etc...
the bmps are 800*600, and as the flag says, the surface is stocked in SYSTEMMEMORY
The is a HResult verif, but the apply stop without continue, it close... the bug is situated exactly at the CreateSurface method...
thanks for your posts
[edited by - Anneoldon on August 1, 2002 10:13:10 AM]
do it this way:
typedef struct ZONE{
//
///
////
/////
};
ZONE zone;
AND:
can you show me the whole while part?
while(...){..}
[edited by - pipo declown on August 1, 2002 10:40:28 AM]
typedef struct ZONE{
//
///
////
/////
};
ZONE zone;
AND:
bitmap_surface(img[i]); instead of img(i)
can you show me the whole while part?
while(...){..}
[edited by - pipo declown on August 1, 2002 10:40:28 AM]
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement