如何使用 IDirect3D9 功能
How to use IDirect3D9 functions
我正在尝试使用函数 GetAdapterIdentifier
,但由于某种原因,我一直收到错误消息
g++ main.cpp -ld3d9 -ld3dcompiler -lgdi32 -static -static-libstdc++ -o output
main.cpp: In function 'int main()':
main.cpp:22:59: error: cannot call member function 'virtual HRESULT IDirect3D9::GetAdapterIdentifier(UINT, DWORD, D3DADAPTER_IDENTIFIER9*)' without object
22 | HRESULT hResult = IDirect3D9::GetAdapterIdentifier(x ,xWord, &pIdentifier);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
make: *** [Makefile:7: build] Error 1
这是我的 main.cpp 文件,非常简单但仍然有错误
#include <iostream>
#include <d3d9.h>
#include <D3D9Types.h>
#include <tchar.h>
int main(void)
{
UINT x;
DWORD xWord;
D3DADAPTER_IDENTIFIER9 pIdentifier;
HRESULT hResult = IDirect3D9::GetAdapterIdentifier(x ,xWord, &pIdentifier);
return 0;
}
我正在使用Makefile
编译主文件
CC = g++
FILES = main.cpp
OUT_EXE = output
INCLUDES = -ld3d9 -ld3dcompiler -lgdi32 -static -static-libstdc++
build:$(FILES)
$(CC) $(FILES) $(INCLUDES) -o $(OUT_EXE)
找到这个 blog 帮助我得到这个答案
#include <iostream>
#include <d3d9.h>
#include <D3D9Types.h>
#include <tchar.h>
#include <string.h>
LPDIRECT3D9 g_pDirect3D = NULL;
LPDIRECT3DDEVICE9 g_pDirect3D_Device = NULL;
int main(void)
{
UINT x = 0; // Ordinal number that denotes the display adapter.
DWORD xWord = 0 ;
D3DADAPTER_IDENTIFIER9 pIdentifier ;
g_pDirect3D = Direct3DCreate9(D3D_SDK_VERSION);
HRESULT hResult = g_pDirect3D->GetAdapterIdentifier(x, xWord, &pIdentifier);
if (hResult == D3D_OK)
std::cout << "Successfully created DirectX handle " << std::endl;
else
std::cout << "Failed to create DirectX handle" << std::endl;
return 0;
}
Direct3DCreate9
创建一个句柄来调用来自
的函数
我正在尝试使用函数 GetAdapterIdentifier
,但由于某种原因,我一直收到错误消息
g++ main.cpp -ld3d9 -ld3dcompiler -lgdi32 -static -static-libstdc++ -o output
main.cpp: In function 'int main()':
main.cpp:22:59: error: cannot call member function 'virtual HRESULT IDirect3D9::GetAdapterIdentifier(UINT, DWORD, D3DADAPTER_IDENTIFIER9*)' without object
22 | HRESULT hResult = IDirect3D9::GetAdapterIdentifier(x ,xWord, &pIdentifier);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
make: *** [Makefile:7: build] Error 1
这是我的 main.cpp 文件,非常简单但仍然有错误
#include <iostream>
#include <d3d9.h>
#include <D3D9Types.h>
#include <tchar.h>
int main(void)
{
UINT x;
DWORD xWord;
D3DADAPTER_IDENTIFIER9 pIdentifier;
HRESULT hResult = IDirect3D9::GetAdapterIdentifier(x ,xWord, &pIdentifier);
return 0;
}
我正在使用Makefile
编译主文件
CC = g++
FILES = main.cpp
OUT_EXE = output
INCLUDES = -ld3d9 -ld3dcompiler -lgdi32 -static -static-libstdc++
build:$(FILES)
$(CC) $(FILES) $(INCLUDES) -o $(OUT_EXE)
找到这个 blog 帮助我得到这个答案
#include <iostream>
#include <d3d9.h>
#include <D3D9Types.h>
#include <tchar.h>
#include <string.h>
LPDIRECT3D9 g_pDirect3D = NULL;
LPDIRECT3DDEVICE9 g_pDirect3D_Device = NULL;
int main(void)
{
UINT x = 0; // Ordinal number that denotes the display adapter.
DWORD xWord = 0 ;
D3DADAPTER_IDENTIFIER9 pIdentifier ;
g_pDirect3D = Direct3DCreate9(D3D_SDK_VERSION);
HRESULT hResult = g_pDirect3D->GetAdapterIdentifier(x, xWord, &pIdentifier);
if (hResult == D3D_OK)
std::cout << "Successfully created DirectX handle " << std::endl;
else
std::cout << "Failed to create DirectX handle" << std::endl;
return 0;
}
Direct3DCreate9
创建一个句柄来调用来自