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 |
void font::load(std::basic_string<wchar_t> name, unsigned int height, unsigned int width, int angle, unsigned int weight, font_attribute attributes) { DEBUG; HDC__* hDC = NULL; //hDC = GetDC(window::getInstance().getHwnd()); ///////////////// IDirect3DSurface9 *backbuffer = NULL; if(direct3d::getInstance().getDevice()->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &backbuffer) != D3D_OK) { EX(L"Failed to get backbuffer!"); } backbuffer->GetDC(&hDC); //////////////// if(hDC == NULL) { EX(L"Failed to get device context!"); // DIESE EXCEPTION KOMMT } if(!SetGraphicsMode(hDC, GM_ADVANCED)) { EX(L"Failed to set the graphics-mode!"); } font_ = CreateFontW( -MulDiv(height, GetDeviceCaps(hDC, LOGPIXELSY), 72), width, angle, angle, weight, attributes & italic, attributes & underline, attributes & strikeout, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS | OUT_DEVICE_PRECIS, CLIP_EMBEDDED, ANTIALIASED_QUALITY, FF_DONTCARE, name.c_str()); if(font_ == NULL) { EX(L"Failed to load font!"); } if(!ReleaseDC(NULL, hDC)) { EX(L"Failed to release device context!"); } } void font::draw(std::basic_string<wchar_t> text, int x, int y, unsigned long color) { tagRECT rect = {x, y, 0, 0}; HDC__* hDC = NULL; //hDC = GetDC(window::getInstance().getHwnd()); IDirect3DSurface9 *backbuffer = NULL; if(direct3d::getInstance().getDevice()->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &backbuffer) != D3D_OK) { EX(L"Failed to get backbuffer!"); } backbuffer->GetDC(&hDC); if(hDC == NULL) { EX(L"Failed to get device context!"); } SelectObject(hDC, font_); SetTextColor(hDC, color); SetBkMode(hDC, TRANSPARENT); DrawTextW(hDC, text.c_str(), -1, &rect, DT_CALCRECT); DrawTextW(hDC, text.c_str(), -1, &rect, DT_WORDBREAK | DT_NOCLIP); if(!ReleaseDC(NULL, hDC)) { EX(L"Failed to release device context!"); } } |
Zitat von »"DirectX SDK"«
GetDC fails on render targets unless they were created lockable (or, in the case of back buffers, with the D3DPRESENTFLAG_LOCKABLE_BACKBUFFER flag).
Zitat von »"DirectX SDK"«
Formats that contain Alpha are not supported because the GDI implementations don't have a well-defined behavior on the alpha channel.
Zitat
GetDC fails on render targets unless they were created lockable (or, in the case of back buffers, with the D3DPRESENTFLAG_LOCKABLE_BACKBUFFER flag).
Anonymous
unregistriert
Werbeanzeige