1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- /*
- GWEN
- Copyright (c) 2011 Facepunch Studios
- See license in Gwen.h
- */
- #ifndef GWEN_RENDERERS_GDIPLUS_H
- #define GWEN_RENDERERS_GDIPLUS_H
- #include "Gwen/Gwen.h"
- #include "Gwen/BaseRender.h"
- /*
- GDI(plus) is pretty slow for rendering GWEN, because we're
- re-rendering everything on redraw.
- Therefore its usage should be as a test - rather than production.
- // Note: For this to work you should be including
- #include <gdiplus.h>
- // Which we don't do in the header, for the sake of usability
- */
- namespace Gwen
- {
- namespace Renderer
- {
- class GDIPlus : public Gwen::Renderer::Base
- {
- public:
- GDIPlus( HWND pHWND );
- ~GDIPlus();
- virtual void Begin();
- virtual void End();
- virtual void SetDrawColor(Gwen::Color color);
- virtual void DrawLine( int x, int y, int a, int b );
- virtual void DrawFilledRect( Gwen::Rect rect );
- virtual void LoadFont( Gwen::Font* pFont );
- virtual void FreeFont( Gwen::Font* pFont );
- virtual void RenderText( Gwen::Font* pFont, Gwen::Point pos, const Gwen::UnicodeString& text );
- virtual Gwen::Point MeasureText( Gwen::Font* pFont, const Gwen::UnicodeString& text );
- void StartClip();
- void EndClip();
- void DrawTexturedRect( Gwen::Texture* pTexture, Gwen::Rect pTargetRect, float u1=0.0f, float v1=0.0f, float u2=1.0f, float v2=1.0f );
- void LoadTexture( Gwen::Texture* pTexture );
- void FreeTexture( Gwen::Texture* pTexture );
- protected:
- int m_iWidth;
- int m_iHeight;
- Gdiplus::Color m_Colour;
- HWND m_HWND;
- HDC m_hDC;
- ULONG_PTR m_gdiplusToken;
- Gdiplus::Graphics* graphics;
- };
- class GDIPlusBuffered : public GDIPlus
- {
- public:
- GDIPlusBuffered( HWND pHWND );
- ~GDIPlusBuffered();
- virtual void Begin();
- virtual void End();
- private:
- void CreateBackbuffer();
- void DestroyBackbuffer();
- Gdiplus::Bitmap* m_Bitmap;
- };
- }
- }
- #endif
|