• Advertisement

Archived

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

Disappearing Textures in DX7

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

Some or all textures disappear several minutes into my DX7 flight sim leaving only rgb (non-textured) meshes visible. The only way to get textures back is to reboot - Clear() and EvictManagedTextures() has no effect, nor does changing display parameters in windows. Presumably I''m really hosing something in my ATI Rage 3D board. I originally thought it was related to my blitting or drawing to a texture surface to update cockpit dials each frame, but the problem also occurs if I bypass the update. Could a large 512x512x16b texture (the cockpit instruments) be the problem, or a mix of 128x128 and 256x256 textures? Any speculation or similar experiences would be helpful! My code to create textures: (maybe one of you experts can spot something)
LPDIRECTDRAWSURFACE7 CreateTextureFromBitmap(LPDIRECT3DDEVICE7 lpDevice,
  HBITMAP hbm)
{
  LPDIRECTDRAWSURFACE7  lpDDS;
  D3DDEVICEDESC7        ddDesc;

  if(FAILED(lpDevice->GetCaps(&ddDesc))) return NULL;

  BITMAP bm;
  GetObject(hbm,sizeof(BITMAP),&bm);

  DDSURFACEDESC2 ddsd;
  ZeroMemory(&ddsd,sizeof(ddsd));
  ddsd.dwSize=sizeof(ddsd);
  ddsd.dwFlags=DDSD_CAPS|DDSD_HEIGHT|DDSD_WIDTH|DDSD_PIXELFORMAT|DDSD_TEXTURESTAGE;
  ddsd.ddsCaps.dwCaps=DDSCAPS_TEXTURE;
  ddsd.dwWidth=bm.bmWidth;
  ddsd.dwHeight=bm.bmHeight;
  ddsd.ddpfPixelFormat=gddpf;//same as primary- (16b:1-5-5-5)

  //Texture Manage if avail
  if(ddDesc.deviceGUID==IID_IDirect3DHALDevice)
     { ddsd.ddsCaps.dwCaps2=DDSCAPS2_TEXTUREMANAGE; } 
  else
  if(ddDesc.deviceGUID==IID_IDirect3DTnLHalDevice)
     { ddsd.ddsCaps.dwCaps2=DDSCAPS2_TEXTUREMANAGE; } 
  else 
     { ddsd.ddsCaps.dwCaps |= DDSCAPS_SYSTEMMEMORY; }

  //adjust texture size if driver requires it
  if(ddDesc.dpcTriCaps.dwTextureCaps & D3DPTEXTURECAPS_POW2)
  {
    for(ddsd.dwWidth=1;  bm.bmWidth>ddsd.dwWidth;   ddsd.dwWidth<<=1);
    for(ddsd.dwHeight=1; bm.bmHeight>ddsd.dwHeight; ddsd.dwHeight<<=1);
  }
  if(ddDesc.dpcTriCaps.dwTextureCaps & D3DPTEXTURECAPS_SQUAREONLY)
  {
    if(ddsd.dwWidth>ddsd.dwHeight) ddsd.dwHeight=ddsd.dwWidth;
    else                           ddsd.dwWidth=ddsd.dwHeight;
  }

  //find device supported pixelformat
  lpDevice->EnumTextureFormats(TextureSearchCB,&ddsd.ddpfPixelFormat);
  if(ddsd.ddpfPixelFormat.dwSize==0)
  { ErrMsg("No Compatible Texture Format"); return NULL; }

  rc=lpDD7->CreateSurface(&ddsd,&lpDDS,NULL);
  if (rc!=DD_OK) { xDDMsg("CreateSurface: Texture",rc); return NULL; }

  HDC hdcbm=CreateCompatibleDC(NULL);
  if(hdcbm==NULL) { return NULL; }

  SelectObject(hdcbm,hbm);

  HDC hdctex;
  if(FAILED(lpDDS->GetDC(&hdctex)))
  { ErrMsg("lpDDS->GetDC"); return NULL; }

  BitBlt(hdctex,0,0,bm.bmWidth,bm.bmHeight,hdcbm,0,0,SRCCOPY);

  lpDDS->ReleaseDC(hdctex);
  DeleteDC(hdcbm);
  
  return lpDDS;
}
[/CODE]    

Share this post


Link to post
Share on other sites
Advertisement

  • Advertisement