• D3D9和OpenGL加载纹理图片的API是哪个?


    D3D9

    创建一个空纹理,当返回 S_OKppTexture 纹理对象指针不为 NULL 时,则表示该函数调用成功。

    HRESULT D3DXCreateTexture(
      _In_  LPDIRECT3DDEVICE9  pDevice,
      _In_  UINT               Width,
      _In_  UINT               Height,
      _In_  UINT               MipLevels,
      _In_  DWORD              Usage,
      _In_  D3DFORMAT          Format,
      _In_  D3DPOOL            Pool,
      _Out_ LPDIRECT3DTEXTURE9 *ppTexture
    );
    
    HRESULT D3DXCreateTextureFromFileInMemory(
      _In_  LPDIRECT3DDEVICE9  pDevice,
      _In_  LPCVOID            pSrcData,
      _In_  UINT               SrcDataSize,
      _Out_ LPDIRECT3DTEXTURE9 *ppTexture
    );
    
    HRESULT D3DXCreateTextureFromFileInMemoryEx(
      _In_    LPDIRECT3DDEVICE9  pDevice,
      _In_    LPCVOID            pSrcData,
      _In_    UINT               SrcDataSize,
      _In_    UINT               Width,
      _In_    UINT               Height,
      _In_    UINT               MipLevels,
      _In_    DWORD              Usage,
      _In_    D3DFORMAT          Format,
      _In_    D3DPOOL            Pool,
      _In_    DWORD              Filter,
      _In_    DWORD              MipFilter,
      _In_    D3DCOLOR           ColorKey,
      _Inout_ D3DXIMAGE_INFO     *pSrcInfo,
      _Out_   PALETTEENTRY       *pPalette,
      _Out_   LPDIRECT3DTEXTURE9 *ppTexture
    );
    

    D3DXCreateTextureFromFileInMemoryD3DXCreateTextureFromFileInMemoryEx 函数下断(注意看纹理对象指针 ppTexture 是否和上面创建的纹理对象是否一致),一般就可以把内存中的图像保存下来了。上面三个函数参数具体含义,请自行查看 https://docs.microsoft.com/zh-cn/windows/desktop/api/_direct3d9/ 官网。

    OpenGL

    
    void glGetTexImage(
            GLenum target,
     	GLint level,
     	GLenum format,
     	GLenum type,
     	GLvoid * pixels
    );
     
    void glGetnTexImage(
            GLenum target,
     	GLint level,
     	GLenum format,
     	GLenum type,
     	GLsizei bufSize,
     	void *pixels
    );
     
    void glGetTextureImage(	
             GLuint texture,
     	GLint level,
     	GLenum format,
     	GLenum type,
     	GLsizei bufSize,
     	void *pixels
    );
    

    具体参数请自行参考OPENGL API:https://www.khronos.org/registry/OpenGL-Refpages/gl4/

  • 相关阅读:
    【More Effective C++ 条款4】非必要不提供default constructor
    【More Effective C++ 条款3】最好不要以多态方式处理数组
    【C++】Debug模式和Release模式的区别
    【More Effective C++ 条款2】最好使用C++转型操作符
    【More Effective C++ 条款1】仔细区别pointers和references
    程序崩溃时的堆栈捕捉
    快速排序--来自维基百科
    十六进制转为字符串
    linux那些事
    svnsync备份
  • 原文地址:https://www.cnblogs.com/cheungxiongwei/p/10036932.html
Copyright © 2020-2023  润新知