|
Thema |
Forum |
Letzter Beitrag |
Beiträge |
Zugriffe |
 |
Text zeichnen (DX9)
Erstellt am: Di 8. Apr 2014, 14:07
xthakingx
Vorschau
Go To Post
Hallo OSH! Nach ein paar Tutorials etc bin ich zu dem hier gekommen: TEXT Code: void DrawRect (LPDIRECT3DDEVICE9 Device_t, int X, int Y, int L, int H, D3DCOLOR color) { D3DRECT rect = {X, Y, X+L, Y+H}; Device_t->Clear(1, &rect, D3DCLEAR_TARGET, color, 0, 0); } void DrawFont (int X, int Y, D3DCOLOR Color, char *format, ...) { char buffer[256]; RECT FontRect = { X, Y, X + 120, Y + 16 }; g_font->DrawText(NULL, (LPCWSTR) buffer, -1, &FontRect, DT_NOCLIP, Color); } HRESULT __stdcall hkEndScene(LPDIRECT3DDEVICE9 pDevice) { DrawRect(pDevice, 3, 10, 130, 130, txtBlack); if (g_font == 0) { D3DXCreateFont(pDevice, 14, 0, FW_NORMAL, 1, false, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, ANTIALIASED_QUALITY, DEFAULT_PITCH | FF_DONTCARE, L"Arial", &g_font ); } else { DrawFont ( 20, 50, txtRed, "Red" ); g_font->OnLostDevice(); g_font->OnResetDevice(); } DrawFont(50,50,txtBlack,"Black"); return pEndScene(pDevice); }
Allerdings kann kein Text gezeichnet werden ._. Also es kommt nix, compilieren geht schon und mit Quadraten geht es auch. Definiert ist alles (Farben etc) wo ist da mein fehler? mfg
|
VB, C/C++, Delphi, etc |
Sa 12. Apr 2014, 20:17
von xthakingx
|
4 |
784 |
 |
Text zeichnen (DX9)
Erstellt am: Di 8. Apr 2014, 14:07
xthakingx
Vorschau
Go To Post
das is kein copypast sondern eigener code -,- kommt zusammen von purple.d1amond und von nem tutorial von silverfire mit hooking. und ich kann nich viel selber programmieren, wenn ich nicht viel ahnung von directx hab...
|
VB, C/C++, Delphi, etc |
Sa 12. Apr 2014, 20:17
von xthakingx
|
4 |
784 |
 |
Text zeichnen (DX9)
Erstellt am: Di 8. Apr 2014, 14:07
xthakingx
Vorschau
Go To Post
TEXT Code: void DrawRect (LPDIRECT3DDEVICE9 Device_t, int X, int Y, int L, int H, D3DCOLOR color) { D3DRECT rect = {X, Y, X+L, Y+H}; Device_t->Clear(1, &rect, D3DCLEAR_TARGET, color, 0, 0); } void DrawFont (int X, int Y, D3DCOLOR Color, char *format, ...) { char buffer[256]; va_list args; va_start (args, format); vsprintf (buffer,"Test", args); RECT FontRect = { X, Y, X + 120, Y + 16 }; pFont->DrawText( NULL, (LPCWSTR)buffer, -1, &FontRect, DT_NOCLIP , Color ); va_end (args); } HRESULT __stdcall hkEndScene(LPDIRECT3DDEVICE9 pDevice) { DrawRect (pDevice, 10, 10, 200, 200, txtRed); D3DXCreateFont(pDevice, 14, 0, FW_NORMAL, 1, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, ANTIALIASED_QUALITY, DEFAULT_PITCH | FF_DONTCARE, L"Arial", &pFont); DrawFont(300, 50, txtRed, "Test"); return pEndScene(pDevice); }
D3DXCreateFont könnte ich mit einer if-Schleife ja notfalls nur einmal abrufen. Allerdings wird nur das rote Rechteck gezeichnet und dann hängt sich das D3D9-Testfenster auf. Dann eine Frage zu der va_list: Müssen zwingend optionale Argumente angegeben werden? Das Format bzw. mein Text steht da ja jetzt drinnen also sollte buffer gefüllt sein...
|
VB, C/C++, Delphi, etc |
Sa 12. Apr 2014, 20:17
von xthakingx
|
4 |
784 |