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 |
#include <d3d9.h> #include <d3dx9.h> #include <dxerr9.h> #pragma once class GameFontRoutines{ public: //>= Version 1.0 ID3DXFont *ArialNormal12; HRESULT InitFonts(LPDIRECT3DDEVICE9 Device); int DrawText(LPCSTR text,DWORD color, int x, int y, int width, int height,ID3DXFont *font); }; |
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 |
#include "Font.h" #include "Framework.h" int GameFontRoutines::DrawText(LPCSTR text,DWORD color, int x, int y, int width, int height,ID3DXFont *font ) { RECT font_rect; int font_height; SetRect(&font_rect,x,y,width,height); font_height=font->DrawText(NULL,text,-1,&font_rect,DT_LEFT|DT_NOCLIP,color); return font_height; }; HRESULT GameFontRoutines::InitFonts(LPDIRECT3DDEVICE9 Device) { HRESULT hr; hr=D3DXCreateFont(id3d.pd3dDevice, //D3D Device 12, //Font height 0, //Font width FW_NORMAL, //Font Weight 1, //MipLevels false, //Italic DEFAULT_CHARSET, //CharSet OUT_DEFAULT_PRECIS, //OutputPrecision ANTIALIASED_QUALITY, //Quality DEFAULT_PITCH|FF_DONTCARE, //PitchAndFamily "Arial.tga", //pFacename, &ArialNormal12); //ppFont if (FAILED(hr)) MessageBox(NULL,"Fehler beim laden des Fonts","fehler",MB_OK); return 0; }; |
C-/C++-Quelltext |
|
1 2 3 4 5 |
GameFontRoutines* gff = NULL; gff->InitFonts(id3d.pd3dDevice);//Das ist in InitScene nicht in der Rendermethode ... DWORD color = 0x00ff0000; gff->DrawTextA("Hallo",color,8,8,19,19,gff->ArialNormal12); |
Werbeanzeige