• Advertisement

Archived

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

DirectDraw7 overlay surfaces

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

I wanna use a DirectDraw7 overlayed surface as it''s described in the DX7SDK but I get an error about invalid pixel format. The DX7SDK sample (number 6) is missing that is referred to in the tutorial so I cannot try their program. The code fragments in the tutorial seem to be wrong at first glance (there are undeclared and unfererenced variables). Here is my code I assembled in Delphi 6.0 and it doesn''t work:
  
var
  hr: HRESULT;
  SurfaceDesc: TDDSURFACEDESC;
  DDCaps : TDDCaps;
begin
  hr := DirectDrawCreate(nil, FDirectDraw, nil);
  if hr <> DD_OK then raise Exception.Create(''Error:'' + DDErrorString(hr));
 
  hr := FDirectDraw.SetCooperativeLevel(Handle, DDSCL_NORMAL);
  if hr <> DD_OK then raise Exception.Create(''Error:'' + DDErrorString(hr));
 
  SurfaceDesc.dwSize := sizeof(SurfaceDesc);
  SurfaceDesc.dwFlags := DDSD_CAPS;
  SurfaceDesc.ddsCaps.dwCaps := DDSCAPS_PRIMARYSURFACE;
 
  hr := FDirectDraw.CreateSurface(SurfaceDesc, FPrimarySurface, nil);
  if hr <> DD_OK then raise Exception.Create(''Error:'' + DDErrorString(hr));
 
  DDCaps.dwSize := sizeof(DDCaps);
  hr := FDirectDraw.GetCaps(@DDCaps, nil);
  if hr <> DD_OK then raise Exception.Create(''Error:'' + DDErrorString(hr));
  if DDCaps.dwCaps and DDCAPS_OVERLAY <> DDCAPS_OVERLAY then raise Exception.Create(''Error:'' + DDErrorString(hr));
 
  SurfaceDesc.dwFlags := DDSD_CAPS or DDSD_HEIGHT or DDSD_WIDTH or DDSD_PIXELFORMAT;
  SurfaceDesc.ddsCaps.dwCaps := DDSCAPS_OVERLAY or DDSCAPS_VIDEOMEMORY;
  SurfaceDesc.dwWidth := 320;
  SurfaceDesc.dwHeight := 240;
 
  SurfaceDesc.ddpfPixelFormat.dwSize := SizeOf(SurfaceDesc.ddpfPixelFormat);
  SurfaceDesc.ddpfPixelFormat.dwFlags := DDPF_RGB;
  SurfaceDesc.ddpfPixelFormat.dwRGBBitCount := 32;
 
  hr := FDirectDraw.CreateSurface(SurfaceDesc, FOverlaySurface, nil);
  if hr <> DD_OK then raise Exception.Create(''Error:'' + DDErrorString(hr));

 
  
The error I receive is: "The pixel format was invalid as specified." PS: My final goal is to make a powerful and nice looking scaling routine that streches a bitmap directly to the screen using hardware acceleration for best performance.

Share this post


Link to post
Share on other sites
Advertisement

  • Advertisement