OldSchoolHack

Registrieren / Anmelden Deutsch

Benutzersuche: xthakingx

Such-Informationen
xthakingx
Themen im Forum
Thema Forum Letzter Beitrag Beiträge Zugriffe
icon

Go to first new post Text zeichnen (DX9) Erstellt am: Di 8. Apr 2014, 14:07

xthakingx

preview Vorschau

Go To Post

Hallo OSH!

Nach ein paar Tutorials etc bin ich zu dem hier gekommen:

TEXT Code:
  1. void DrawRect (LPDIRECT3DDEVICE9 Device_t, int X, int Y, int L, int H, D3DCOLOR color)
  2. {
  3. D3DRECT rect = {X, Y, X+L, Y+H};
  4. Device_t->Clear(1, &rect, D3DCLEAR_TARGET, color, 0, 0);
  5. }
  6.  
  7. void DrawFont (int X, int Y, D3DCOLOR Color, char *format, ...)
  8. {
  9. char buffer[256];
  10.  
  11. RECT FontRect = { X, Y, X + 120, Y + 16 };
  12. g_font->DrawText(NULL,      
  13.                               (LPCWSTR) buffer,  
  14.                                -1,          
  15.                                &FontRect,  
  16.                                DT_NOCLIP,
  17.                                Color);
  18.  
  19. }
  20.  
  21.  
  22.  
  23. HRESULT __stdcall hkEndScene(LPDIRECT3DDEVICE9 pDevice)
  24. {
  25. DrawRect(pDevice, 3, 10, 130, 130, txtBlack);
  26.  
  27. if (g_font == 0)
  28. {
  29. D3DXCreateFont(pDevice, 14, 0, FW_NORMAL, 1, false, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, ANTIALIASED_QUALITY, DEFAULT_PITCH | FF_DONTCARE, L"Arial", &g_font );
  30. }
  31. else
  32. {
  33. DrawFont ( 20, 50, txtRed, "Red" );
  34. g_font->OnLostDevice();
  35. g_font->OnResetDevice();
  36.  
  37. }
  38.  
  39. DrawFont(50,50,txtBlack,"Black");
  40.  
  41.  
  42. return pEndScene(pDevice);
  43. }

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 Go to last post
4 784
icon

Go to first new post Text zeichnen (DX9) Erstellt am: Di 8. Apr 2014, 14:07

xthakingx

preview 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 Go to last post
4 784
icon

Go to first new post Text zeichnen (DX9) Erstellt am: Di 8. Apr 2014, 14:07

xthakingx

preview Vorschau

Go To Post

TEXT Code:
  1. void DrawRect (LPDIRECT3DDEVICE9 Device_t, int X, int Y, int L, int H, D3DCOLOR color)
  2. {
  3. D3DRECT rect = {X, Y, X+L, Y+H};
  4. Device_t->Clear(1, &rect, D3DCLEAR_TARGET, color, 0, 0);
  5. }
  6.  
  7. void DrawFont (int X, int Y, D3DCOLOR Color, char *format, ...)
  8. {
  9. char buffer[256];
  10. va_list args;
  11. va_start (args, format);
  12. vsprintf (buffer,"Test", args);
  13. RECT FontRect = { X, Y, X + 120, Y + 16 };
  14. pFont->DrawText( NULL, (LPCWSTR)buffer, -1, &FontRect, DT_NOCLIP , Color );
  15. va_end (args);
  16. }
  17.  
  18.  
  19.  
  20. HRESULT __stdcall hkEndScene(LPDIRECT3DDEVICE9 pDevice)
  21. {
  22. DrawRect (pDevice, 10, 10, 200, 200, txtRed);
  23.  
  24. D3DXCreateFont(pDevice, 14, 0, FW_NORMAL, 1, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS,
  25. ANTIALIASED_QUALITY, DEFAULT_PITCH | FF_DONTCARE, L"Arial", &pFont);
  26.  
  27.  
  28. DrawFont(300, 50, txtRed, "Test");
  29.  
  30.  
  31. return pEndScene(pDevice);
  32. }

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 Go to last post
4 784
Downloads
Es wurden keine entsprechenden Downloads gefunden.