DirectX9.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. GWEN
  3. Copyright (c) 2010 Facepunch Studios
  4. See license in Gwen.h
  5. */
  6. #ifndef GWEN_RENDERERS_DIRECTX9_H
  7. #define GWEN_RENDERERS_DIRECTX9_H
  8. #include "Gwen/Gwen.h"
  9. #include "Gwen/BaseRender.h"
  10. struct VERTEXFORMAT2D
  11. {
  12. FLOAT x, y, z, rhw;
  13. DWORD color;
  14. float u, v;
  15. };
  16. #define D3DFVF_VERTEXFORMAT2D ( D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1 )
  17. namespace Gwen
  18. {
  19. namespace Renderer
  20. {
  21. class GWEN_EXPORT DirectX9 : public Gwen::Renderer::Base
  22. {
  23. public:
  24. DirectX9( IDirect3DDevice9* pDevice );
  25. ~DirectX9();
  26. virtual void Begin();
  27. virtual void End();
  28. virtual void Release();
  29. virtual void SetDrawColor(Gwen::Color color);
  30. virtual void DrawLine( int x, int y, int a, int b );
  31. virtual void DrawFilledRect( Gwen::Rect rect );
  32. virtual void LoadFont( Gwen::Font* pFont );
  33. virtual void FreeFont( Gwen::Font* pFont );
  34. virtual void RenderText( Gwen::Font* pFont, Gwen::Point pos, const Gwen::UnicodeString& text );
  35. virtual Gwen::Point MeasureText( Gwen::Font* pFont, const Gwen::UnicodeString& text );
  36. void StartClip();
  37. void EndClip();
  38. void DrawTexturedRect( Gwen::Texture* pTexture, Gwen::Rect pTargetRect, float u1=0.0f, float v1=0.0f, float u2=1.0f, float v2=1.0f );
  39. void LoadTexture( Gwen::Texture* pTexture );
  40. void FreeTexture( Gwen::Texture* pTexture );
  41. protected:
  42. void* m_pCurrentTexture;
  43. IDirect3DDevice9* m_pDevice;
  44. DWORD m_Color;
  45. void Flush();
  46. void AddVert( int x, int y );
  47. void AddVert( int x, int y, float u, float v );
  48. static const int MaxVerts = 1024;
  49. VERTEXFORMAT2D m_pVerts[MaxVerts];
  50. int m_iVertNum;
  51. Gwen::Font::List m_FontList;
  52. };
  53. }
  54. }
  55. #endif