Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!
Werbeanzeige
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
INT WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, INT nCmdShow ) { // ::::::::::::::::::::::::::::::::::::: // Ausgabe-Fenster erzeugen // ::::::::::::::::::::::::::::::::::::: // WNDCLASSEX wc; HWND hWnd; CreateOutputWindow( wc, hWnd, hInstance ); // ::::::::::::::::::::::::::::::::::::: // DX initialisierungen ... // ::::::::::::::::::::::::::::::::::::: // cDX_Interface* DX_DEVICE = cDX_Interface::Create(); BOOL initOk = DX_DEVICE->InitDirectX(hWnd); // ... etc .. } |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
class cDX_Interface { protected: static cDX_Interface* pDX_Interface; LPDIRECT3D9 m_D3DObject; LPDIRECT3DDEVICE9 m_D3DDevice; cDX_Interface(); ~cDX_Interface(){} public: static cDX_Interface* Create(); HRESULT Destroy(); BOOL InitDirectX(HWND &hWnd); HRESULT CleanUpDirectX(); }; cDX_Interface* cDX_Interface::pDX_Interface = NULL; cDX_Interface::cDX_Interface(): m_D3DObject(NULL), m_D3DDevice(NULL) { // } cDX_Interface* cDX_Interface::Create() { if (pDX_Interface==NULL) { pDX_Interface = new cDX_Interface; return pDX_Interface; } return pDX_Interface; } HRESULT cDX_Interface::Destroy() { // Speicherbereich mit 0 auffüllen // Pointer löschen // Point-to Adresse löschen if (pDX_Interface) { SecureZeroMemory(&pDX_Interface,sizeof(pDX_Interface)); delete pDX_Interface; pDX_Interface = NULL; return S_OK; } // Keine Objektinstanz zum löschen vorhanden // RETURN: Invalid_Pointer return E_POINTER; } BOOL cDX_Interface::InitDirectX(HWND &hWnd) { // D3D Objekt erzeugen m_D3DObject = Direct3DCreate9(D3D_SDK_VERSION); if (m_D3DObject == NULL) { return E_FAIL; } // Darstellungsparameter D3DPRESENT_PARAMETERS presParams; SecureZeroMemory(&presParams,sizeof(presParams)); presParams.Windowed = TRUE; presParams.SwapEffect = D3DSWAPEFFECT_DISCARD; presParams.BackBufferFormat = D3DFMT_UNKNOWN; presParams.BackBufferCount = 1; // D3D Device erzeugen HRESULT hr = m_D3DObject->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_HARDWARE_VERTEXPROCESSING, &presParams, &m_D3DDevice ); // wenn Grafikkarte HARDWARE_VERTEXPROCESSING nicht unterstützt -> // SOFTWARE_VERTEXPROCESSING verwenden if (FAILED(hr)) { hr = m_D3DObject->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &presParams, &m_D3DDevice ); if(FAILED(hr)) { return FALSE; } else { return TRUE; } } |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
class cDX_Interface { protected: HWND m_hwnd; //... }; BOOL cDX_Interface::InitDirectX(HWND &hWnd) { m_hwnd = hWnd; //... }; |
C-/C++-Quelltext |
|
1 2 |
typedef void *HANDLE; #define DECLARE_HANDLE(name) struct name##__ { int unused; }; typedef struct name##__ *name |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
class cDX_Interface { protected: HWND* m_hwnd; //... }; BOOL cDX_Interface::InitDirectX(HWND* hWnd) { m_hwnd = hWnd; //... }; |
C-/C++-Quelltext |
|
1 |
BOOL initOk = DX_DEVICE->InitDirectX(&hWnd); |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 |
// D3D Device erzeugen HRESULT hr = m_D3DObject->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, (*m_hWnd),//hWnd, D3DCREATE_HARDWARE_VERTEXPROCESSING, &presParams, &m_D3DDevice ); |
Anonymous
unregistriert
Anonymous
unregistriert
Werbeanzeige