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 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 |
void direct3d::init(unsigned int width, unsigned int height, unsigned int bpp, bool windowed) { DEBUG; // Werte an Attribute zuweisen width_ = width; height_ = height_; bpp_ = bpp; windowed_ = windowed; shutdown(); // DLL/Funktion laden dll_ = templates::loadDLL(L"d3d9.dll"); if(dll_ == NULL) { EX(L"Can't load DLL 'd3d9.dll'"); } Direct3DCreate9T Direct3DCreate9 = NULL; Direct3DCreate9 = templates::loadFunction<Direct3DCreate9T>(dll_, "Direct3DCreate9"); if(Direct3DCreate9 == NULL) { EX(L"Can't load function 'Direct3DCreate9'"); } // D3D object erstellen direct3d_ = Direct3DCreate9(D3D_SDK_VERSION); if(direct3d_ == NULL) { EX(L"Failed to create Direct3D- Object!"); } _D3DCAPS9 caps; // Grafikkarten specs _D3DPRESENT_PARAMETERS_ present_parameters; // Darstellung _D3DDISPLAYMODE display_mode; // Farbtiefe des Desktops memset(&present_parameters, 0, sizeof(_D3DPRESENT_PARAMETERS_)); memset(&caps, 0, sizeof(_D3DCAPS9)); memset(&display_mode, 0, sizeof(_D3DDISPLAYMODE)); if (direct3d_->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &display_mode) != D3D_OK) { EX(L"Failed to get display mode!"); } // Grafikkarten specs holen if (direct3d_->GetDeviceCaps(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, &caps) != D3D_OK) { EX(L"GetDeviceCaps() failed!"); } // Darstellungsparameter present_parameters.EnableAutoDepthStencil = true; // DepthStencil? Wir sagen ja! present_parameters.AutoDepthStencilFormat = D3DFMT_D16; // DepthStencil Format. present_parameters.hDeviceWindow = window::getInstance().getHwnd(); present_parameters.Windowed = windowed_; // Fenstermodus present_parameters.SwapEffect = D3DSWAPEFFECT_DISCARD; // Swapeffect present_parameters.BackBufferCount = 1; // Anzahl Backbuffer present_parameters.BackBufferWidth = width_; // Auflösung: Breite present_parameters.BackBufferHeight = height_; // Auflösung: Höhe present_parameters.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; // Vsync (aus) present_parameters.BackBufferFormat = display_mode.Format; // Format des Desktops if(bpp_ == 16) { present_parameters.BackBufferFormat = D3DFMT_R5G6B5; // Farbtiefe } else { present_parameters.BackBufferFormat = D3DFMT_X8R8G8B8; // Farbtiefe } if(windowed_) { } // VertexProcessing unsigned long vp = D3DCREATE_HARDWARE_VERTEXPROCESSING; if(caps.VertexProcessingCaps == 0) { vp = D3DCREATE_SOFTWARE_VERTEXPROCESSING; } // D3D Device erstellen HRESULT r = direct3d_->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, window::getInstance().getHwnd(), vp, &present_parameters, &device_); if(r != D3D_OK) { switch(r) { case D3DERR_DEVICELOST: EX(L"1"); break; case D3DERR_INVALIDCALL: EX(L"2"); break; case D3DERR_NOTAVAILABLE: EX(L"3"); break; case D3DERR_OUTOFVIDEOMEMORY: EX(L"4"); break; } } } |
Quellcode |
|
1 |
First-chance exception at 0x7c81eb33 in Osera.exe: Microsoft C++ exception: debug::exception at memory location 0x0012f904.. |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 |
void direct3d::endScene() { DEBUG; if(device_->EndScene() != D3D_OK) { EX(L"Failed to end render-scene!"); } if(device_->Present(0,0,0,0) != D3D_OK) { EX(L"Failed to present scene!"); //DIESE HIER } } |
Administrator
Anonymous
unregistriert
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 |
void direct3d::init(unsigned int width, unsigned int height, unsigned int bpp, bool windowed) { DEBUG; // Werte an Attribute zuweisen width_ = width; >> height_ = height_; // selbstzuweisung ?!?!?! //... |
Werbeanzeige