Changeset 423 for trunk/src


Ignore:
Timestamp:
Aug 5, 1999, 9:23:04 PM (26 years ago)
Author:
hugh
Message:

Uses DIVEWRAP and fixed bug in surface generation (not setting up all values (Pixelformat))

Location:
trunk/src/ddraw
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/ddraw/OS2DDRAW.CPP

    r416 r423  
    126126  }
    127127
    128   ULONG rc = DiveOpen(&hDive, FALSE, &pFrameBuffer);
     128  ULONG rc = DiveOpen( &hDive,
     129                       FALSE,
     130                       &pFrameBuffer);
    129131  if(rc)
    130132  {
     
    135137  else
    136138  {
    137     rc = DiveQueryCaps(&dCaps,DIVE_BUFFER_SCREEN);
     139    WriteLog("DiveOpen OK\n");
     140    rc = DiveQueryCaps( &dCaps,
     141                        DIVE_BUFFER_SCREEN);
    138142  }
    139143
  • trunk/src/ddraw/OS2SURFACE.CPP

    r416 r423  
    359359    if( surfaceType & DDSCAPS_PRIMARYSURFACE)
    360360    {
    361       if( lpDraw->HasPrimarySurface())
    362       {
    363         lastError = DDERR_PRIMARYSURFACEALREADYEXISTS;
    364         return;
    365       }
    366 
    367361      #ifdef DEBUG
    368362        WriteLog("Primary surface!\n");
    369363      #endif
     364
     365      if( lpDraw->HasPrimarySurface())
     366      {
     367        #ifdef DEBUG
     368          WriteLog("Primary surface already exits!\n");
     369        #endif
     370        lastError = DDERR_PRIMARYSURFACEALREADYEXISTS;
     371        return;
     372      }
     373
    370374      if( (lpDDSurfaceDesc->dwFlags & DDSD_HEIGHT) ||
    371375          (lpDDSurfaceDesc->dwFlags & DDSD_WIDTH)  ||
     
    563567      DWORD dwBpp;
    564568      DWORD dwCaps;
     569      WriteLog( " Requested Size %dx%d\n",
     570                DDSurfaceDesc.dwWidth,
     571                DDSurfaceDesc.dwHeight);
     572
    565573      if(DDSurfaceDesc.dwFlags & DDSD_PIXELFORMAT)         // Pixelformat passed in ?
    566574      {
     575        WriteLog(" Pixelformat requested :");
    567576        // YES use it
    568577        if(DDSurfaceDesc.ddpfPixelFormat.dwFlags & DDPF_RGB)
     
    579588      }
    580589      else
     590      {
     591        WriteLog(" Use Screen Format :");
    581592        dwBpp = dwBytesPPDive << 3; // No use Screenformat
     593        lpDDSurfaceDesc->ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT);
     594        lpDDSurfaceDesc->ddpfPixelFormat.dwFourCC = (DWORD) lpDraw->GetScreenFourCC();
     595        lpDDSurfaceDesc->ddpfPixelFormat.dwRGBBitCount = dwBpp;
     596        DDSurfaceDesc.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT);
     597        DDSurfaceDesc.ddpfPixelFormat.dwFourCC = (DWORD) lpDraw->GetScreenFourCC();
     598        DDSurfaceDesc.ddpfPixelFormat.dwRGBBitCount = dwBpp;
     599        switch(DDSurfaceDesc.ddpfPixelFormat.dwRGBBitCount)
     600        {
     601          case 4:
     602            lpDDSurfaceDesc->ddpfPixelFormat.dwFlags = DDPF_PALETTEINDEXED4 | DDPF_RGB;
     603            DDSurfaceDesc.ddpfPixelFormat.dwFlags = DDPF_PALETTEINDEXED4 | DDPF_RGB;
     604            break;
     605          case 8:
     606            lpDDSurfaceDesc->ddpfPixelFormat.dwFlags = DDPF_PALETTEINDEXED8 | DDPF_FOURCC | DDPF_RGB;
     607            DDSurfaceDesc.ddpfPixelFormat.dwFlags = DDPF_PALETTEINDEXED8 | DDPF_FOURCC | DDPF_RGB;
     608            break;
     609          case 16:
     610            lpDDSurfaceDesc->ddpfPixelFormat.dwFlags = DDPF_FOURCC | DDPF_RGB;
     611            lpDDSurfaceDesc->ddpfPixelFormat.dwRBitMask = 0x0000F800;
     612            lpDDSurfaceDesc->ddpfPixelFormat.dwGBitMask = 0x000007E0;
     613            lpDDSurfaceDesc->ddpfPixelFormat.dwBBitMask = 0x0000001F;
     614            DDSurfaceDesc.ddpfPixelFormat.dwFlags = DDPF_FOURCC | DDPF_RGB;
     615            DDSurfaceDesc.ddpfPixelFormat.dwRBitMask = 0x0000F800;
     616            DDSurfaceDesc.ddpfPixelFormat.dwGBitMask = 0x000007E0;
     617            DDSurfaceDesc.ddpfPixelFormat.dwBBitMask = 0x0000001F;
     618            break;
     619          case 24:
     620          case 32:
     621            lpDDSurfaceDesc->ddpfPixelFormat.dwFlags = DDPF_FOURCC | DDPF_RGB;
     622            lpDDSurfaceDesc->ddpfPixelFormat.dwRBitMask = 0x00FF0000;
     623            lpDDSurfaceDesc->ddpfPixelFormat.dwGBitMask = 0x0000FF00;
     624            lpDDSurfaceDesc->ddpfPixelFormat.dwBBitMask = 0x000000FF;
     625            DDSurfaceDesc.ddpfPixelFormat.dwFlags = DDPF_FOURCC | DDPF_RGB;
     626            DDSurfaceDesc.ddpfPixelFormat.dwRBitMask = 0x00FF0000;
     627            DDSurfaceDesc.ddpfPixelFormat.dwGBitMask = 0x0000FF00;
     628            DDSurfaceDesc.ddpfPixelFormat.dwBBitMask = 0x000000FF;
     629            break;
     630          default:
     631            // Remove the Pixelformat flag
     632            lpDDSurfaceDesc->dwFlags &= ~DDSD_PIXELFORMAT;
     633            DDSurfaceDesc.dwFlags    &= ~DDSD_PIXELFORMAT;
     634            #ifdef DEBUG
     635              WriteLog("Unexpected BitDepth : %d\n",lpDraw->GetScreenBpp());
     636            #endif
     637            break;
     638        } // end switch
     639
     640      }
     641
     642      WriteLog("%d Bits\n",dwBpp);
    582643
    583644      // three possible situaltions
     
    593654        // 1.
    594655
     656        WriteLog(" Usersupplied Surface\n");
     657
    595658        if(NULL==DDSurfaceDesc.lpSurface)
    596659        {
     
    611674        dwPitchFB    = DDSurfaceDesc.lPitch;
    612675
    613         if( (lpDraw->dCaps.ulDepth ) == dwBpp )
     676        if( lpDraw->dCaps.ulDepth == dwBpp )
    614677        {
    615678          // Yes No Colorconversion is needed so point to the same buffer
     
    642705        {
    643706          // 2.
     707
     708          WriteLog(" Alloc on Load Texture?!\n");
    644709
    645710          dwCaps &= ~DDSCAPS_ALLOCONLOAD; // remove flag
     
    667732          // 3.
    668733
     734          WriteLog(" Alloc now!\n");
     735
    669736          lpDDSurfaceDesc->dwFlags  |= DDSD_PITCH|DDSD_LPSURFACE;
    670737          DDSurfaceDesc.dwFlags      = lpDDSurfaceDesc->dwFlags;
     
    696763          pFrameBuffer = (char*)(((int)pFBreal + 7) & ~7); // align to QWORD
    697764
     765          WriteLog( " Framebuffer @ %08X QWAligned @ %08X with a Pitch of %d",
     766                    pFBreal, pFrameBuffer, dwPitchFB);
     767
    698768          lpDDSurfaceDesc->lpSurface = pFrameBuffer;
    699769          DDSurfaceDesc.lpSurface    = pFrameBuffer;
    700770
    701           if(Mainchain)
    702           {
    703             // This surface is part of flipchain with the primary surface use dive to alloc
    704             diveBufNr = 0;
    705             DiveAllocImageBuffer( hDive,
    706                                   &diveBufNr,
    707                                   lpDraw->dCaps.fccColorEncoding,
    708                                   lpDDSurfaceDesc->dwWidth,
    709                                   lpDDSurfaceDesc->dwHeight,
    710                                   (lpDDSurfaceDesc->dwWidth * (lpDraw->dCaps.ulDepth/8) +7) & ~7,
    711                                   (PBYTE)pDiveBuffer);
    712           }
    713771
    714772          if( (lpDraw->dCaps.ulDepth ) == dwBpp )
    715773          {
     774            WriteLog(" No CC_Buffer needed\n");
    716775            // Yes => No Colorconversion is needed so point to the same buffer
    717776            pDiveBuffer  = pFrameBuffer;
     
    719778          else
    720779          {
    721             // No so we must create the Divebuffer to do the colortranslation
    722             // and blit to the real framebuffer on Unlock to do color conversion
    723             pDiveBuffer = (char*)malloc( lpDDSurfaceDesc->dwHeight *
    724                                  ((lpDDSurfaceDesc->dwWidth * (lpDraw->dCaps.ulDepth/8) +7) & ~7) );
    725 
     780            WriteLog(" Alloc CCBuf ");
     781            if(Mainchain)
     782            {
     783              WriteLog("with DIVE\n");
     784              // This surface is part of flipchain with the primary surface use dive to alloc
     785              diveBufNr = 0;
     786              DiveAllocImageBuffer( hDive,
     787                                    &diveBufNr,
     788                                    lpDraw->dCaps.fccColorEncoding,
     789                                    lpDDSurfaceDesc->dwWidth,
     790                                    lpDDSurfaceDesc->dwHeight,
     791                                    (lpDDSurfaceDesc->dwWidth * (lpDraw->dCaps.ulDepth/8) +7) & ~7,
     792                                    (PBYTE)pDiveBuffer);
     793            }
     794            else
     795            {
     796              WriteLog("with malloc");
     797              // No so we must create the Divebuffer to do the colortranslation
     798              // and blit to the real framebuffer on Unlock to do color conversion
     799              pDiveBuffer = (char*)malloc( lpDDSurfaceDesc->dwHeight *
     800                                   ((lpDDSurfaceDesc->dwWidth * (lpDraw->dCaps.ulDepth/8) +7) & ~7) );
     801            }
    726802          }
    727803
     
    821897  } // Endif DDCAPS is valid
    822898  else
     899  {
     900    WriteLog("CAPS not valid\n");
    823901    lastError = DDERR_INVALIDPARAMS;
    824 
     902  }
    825903  #ifdef DEBUG
    826904    WriteLog("Buf %X Screen Caps (%d,%d), bitcount %d\n\n", this, lpDraw->GetScreenHeight(), lpDraw->GetScreenWidth(),
Note: See TracChangeset for help on using the changeset viewer.