RenderInterfaceDirectx10.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #ifndef RENDERINTERFACEDIRECTX_H
  2. #define RENDERINTERFACEDIRECTX_H
  3. #include <Rocket/Core/RenderInterface.h>
  4. #include <d3d10.h>
  5. #include <d3dx10.h>
  6. /**
  7. A sample render interface for Rocket into DirectX 10.
  8. TODO:
  9. 1) Constant Buffers for variables
  10. @author Brian McDonald
  11. */
  12. class RenderInterfaceDirectX10 : public Rocket::Core::RenderInterface
  13. {
  14. public:
  15. RenderInterfaceDirectX10(ID3D10Device * pD3D10Device,float screenWidth,float screenHeight);
  16. virtual ~RenderInterfaceDirectX10();
  17. /// Called by Rocket when it wants to render geometry that it does not wish to optimise.
  18. virtual void RenderGeometry(Rocket::Core::Vertex* vertices, int num_vertices, int* indices, int num_indices, Rocket::Core::TextureHandle texture, const Rocket::Core::Vector2f& translation);
  19. /// Called by Rocket when it wants to compile geometry it believes will be static for the forseeable future.
  20. virtual Rocket::Core::CompiledGeometryHandle CompileGeometry(Rocket::Core::Vertex* vertices, int num_vertices, int* indices, int num_indices, Rocket::Core::TextureHandle texture);
  21. /// Called by Rocket when it wants to render application-compiled geometry.
  22. virtual void RenderCompiledGeometry(Rocket::Core::CompiledGeometryHandle geometry, const Rocket::Core::Vector2f& translation);
  23. /// Called by Rocket when it wants to release application-compiled geometry.
  24. virtual void ReleaseCompiledGeometry(Rocket::Core::CompiledGeometryHandle geometry);
  25. /// Called by Rocket when it wants to enable or disable scissoring to clip content.
  26. virtual void EnableScissorRegion(bool enable);
  27. /// Called by Rocket when it wants to change the scissor region.
  28. virtual void SetScissorRegion(int x, int y, int width, int height);
  29. /// Called by Rocket when a texture is required by the library.
  30. virtual bool LoadTexture(Rocket::Core::TextureHandle& texture_handle, Rocket::Core::Vector2i& texture_dimensions, const Rocket::Core::String& source);
  31. /// Called by Rocket when a texture is required to be built from an internally-generated sequence of pixels.
  32. virtual bool GenerateTexture(Rocket::Core::TextureHandle& texture_handle, const byte* source, const Rocket::Core::Vector2i& source_dimensions);
  33. /// Called by Rocket when a loaded texture is no longer required.
  34. virtual void ReleaseTexture(Rocket::Core::TextureHandle texture_handle);
  35. /// Returns the native horizontal texel offset for the renderer.
  36. float GetHorizontalTexelOffset();
  37. /// Returns the native vertical texel offset for the renderer.
  38. float GetVerticalTexelOffset();
  39. void setupEffect();
  40. private:
  41. //The D3D 10 Device
  42. ID3D10Device * m_pD3D10Device;
  43. //The Effect we are using to render GUI
  44. ID3D10Effect * m_pEffect;
  45. //The Current technique
  46. ID3D10EffectTechnique* m_pTechnique;
  47. //The Vertex Layout
  48. ID3D10InputLayout* m_pVertexLayout;
  49. //Effect varibales, used to send variables to the effect
  50. ID3D10EffectMatrixVariable * m_pProjectionMatrixVariable;
  51. ID3D10EffectMatrixVariable * m_pWorldMatrixVariable;
  52. ID3D10EffectShaderResourceVariable *m_pDiffuseTextureVariable;
  53. //Matrices
  54. D3DXMATRIX m_matProjection;
  55. D3DXMATRIX m_matWorld;
  56. //Renderstate Blocks
  57. ID3D10RasterizerState *m_pScissorTestEnable;
  58. ID3D10RasterizerState *m_pScissorTestDisable;
  59. //Holds if we have enabled scissor test
  60. bool m_ScissorEnabled;
  61. };
  62. #endif