当前位置: 首页>>代码示例>>C++>>正文


C++ IDirect3DTexture9::GetLevelCount方法代码示例

本文整理汇总了C++中IDirect3DTexture9::GetLevelCount方法的典型用法代码示例。如果您正苦于以下问题:C++ IDirect3DTexture9::GetLevelCount方法的具体用法?C++ IDirect3DTexture9::GetLevelCount怎么用?C++ IDirect3DTexture9::GetLevelCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IDirect3DTexture9的用法示例。


在下文中一共展示了IDirect3DTexture9::GetLevelCount方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ImagePtr

ImagePtr D3D9VideoBufferManager::CreateImage(int iWidth, int iHeight, FORMAT Format)
{
    IDirect3DTexture9 * texture;
    HRESULT hr = D3DXCreateTexture(mD3D9Device, 
                                   iWidth,
                                   iHeight,
                                   1,
                                   0,
                                   D3D9Mapping::GetD3DFormat(Format),
                                   D3DPOOL_SYSTEMMEM,
                                   &texture);

    D3DErrorExceptionFunction(D3DXCreateTexture, hr);

    IDirect3DSurface9 * surface;
    texture->GetSurfaceLevel(0, &surface);
    D3DSURFACE_DESC desc;
    surface->GetDesc(&desc);

    D3D9Image * image = new D3D9Image();

    image->mWidth = desc.Width;
    image->mHeight = desc.Height;
    image->mSrcWidth = iWidth;
    image->mSrcHeight = iHeight;
    image->mFormat = D3D9Mapping::GetFormat(desc.Format);
    image->mMipmapLevel = texture->GetLevelCount();
    image->mD3D9Texture = texture;

    surface->Release();

    return ImagePtr(image);
}
开发者ID:ak4hige,项目名称:myway3d,代码行数:33,代码来源:MWD3D9VideoBufferManager.cpp

示例2:

TextureStorage9_2D::TextureStorage9_2D(Renderer9 *renderer, SwapChain9 *swapchain)
    : TextureStorage9(renderer, D3DUSAGE_RENDERTARGET)
{
    IDirect3DTexture9 *surfaceTexture = swapchain->getOffscreenTexture();
    mTexture = surfaceTexture;
    mMipLevels = surfaceTexture->GetLevelCount();

    mInternalFormat = swapchain->getRenderTargetInternalFormat();

    D3DSURFACE_DESC surfaceDesc;
    surfaceTexture->GetLevelDesc(0, &surfaceDesc);
    mTextureWidth = surfaceDesc.Width;
    mTextureHeight = surfaceDesc.Height;
    mTextureFormat = surfaceDesc.Format;

    mRenderTargets.resize(mMipLevels, nullptr);
}
开发者ID:MichaelKohler,项目名称:gecko-dev,代码行数:17,代码来源:TextureStorage9.cpp

示例3: initializeSerials

TextureStorage9_2D::TextureStorage9_2D(Renderer9 *renderer, SwapChain9 *swapchain)
    : TextureStorage9(renderer, D3DUSAGE_RENDERTARGET)
{
    IDirect3DTexture9 *surfaceTexture = swapchain->getOffscreenTexture();
    mTexture = surfaceTexture;
    mMipLevels = surfaceTexture->GetLevelCount();

    mInternalFormat = swapchain->GetBackBufferInternalFormat();

    D3DSURFACE_DESC surfaceDesc;
    surfaceTexture->GetLevelDesc(0, &surfaceDesc);
    mTextureWidth = surfaceDesc.Width;
    mTextureHeight = surfaceDesc.Height;
    mTextureFormat = surfaceDesc.Format;

    mRenderTarget = NULL;

    initializeSerials(1, 1);
}
开发者ID:contoso-d,项目名称:angle,代码行数:19,代码来源:TextureStorage9.cpp

示例4: switch


//.........这里部分代码省略.........

        for(u32 r = 0; r < desc.Height && textureFormat == D3DFMT_DXT1; r++)
        {
          u32* pixels = (u32*) (((u8*)lockedRect.pBits) + lockedRect.Pitch * r); 
          for(u32 c = 0; c < desc.Width; c++)
          {
            u32 masked = pixels[c] & 0xFF000000; 
            if(masked != 0xFF000000)
            {
              alpha = true; 
            }
            if(masked != 0xFF000000 && masked != 0x00000000)
            {
              textureFormat = D3DFMT_DXT5; 
              break; 
            }
          }
        }

        tempTexture->UnlockRect(0);

        tempTexture->Release(); 
      }

      int compressionRatio;
      switch ( textureFormat )
      {
      case D3DFMT_DXT1:
        {
          if (alpha)
          {
            compressionRatio = 8;
          }
          else
          {
            compressionRatio = 6;
          }
          break;
        }

      case D3DFMT_DXT5:
        {
          compressionRatio = 4;
          break;
        }

      default:
        {
          compressionRatio = 1;
          HELIUM_BREAK();
          break;
        }
      }

      if ( D3DXCreateTextureFromFileEx( device,
                                        file.c_str(),
                                        D3DX_DEFAULT,
                                        D3DX_DEFAULT,
                                        D3DX_DEFAULT,
                                        NULL,
                                        textureFormat, 
                                        pool,
                                        D3DX_DEFAULT,
                                        D3DX_DEFAULT,
                                        NULL,
                                        &sourceInfo,
                                        NULL,
                                        &texture ) == D3D_OK )
      {
        texture->SetAutoGenFilterType( D3DTEXF_ANISOTROPIC );

        if ( textureSize )
        {
          *textureSize = 0; 
          for(u32 i = 0; i < texture->GetLevelCount(); i++)
          {
            D3DSURFACE_DESC desc; 
            texture->GetLevelDesc(i, &desc); 
            *textureSize += desc.Width * desc.Height * 4 / compressionRatio;
          }
        }
      }
      else
      {
        Log::Warning( TXT( "Unable to create texture from file '%s'\n" ), file.c_str() );
      }
    }
    else
    {
      Log::Warning( TXT( "File '%s' does not exist\n" ), file.c_str() );
    }
  }

  if ( hasAlpha )
  {
    *hasAlpha = alpha;
  }

  return texture;
}
开发者ID:pthiben,项目名称:Helium,代码行数:101,代码来源:Render.cpp


注:本文中的IDirect3DTexture9::GetLevelCount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。