IContextManager.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // Copyright (C) 2013-2015 Patryk Nadrowski
  2. // This file is part of the "Irrlicht Engine".
  3. // For conditions of distribution and use, see copyright notice in irrlicht.h
  4. #ifndef IRR_I_CONTEXT_MANAGER_H_INCLUDED
  5. #define IRR_I_CONTEXT_MANAGER_H_INCLUDED
  6. #include "SExposedVideoData.h"
  7. #include "SIrrCreationParameters.h"
  8. namespace irr
  9. {
  10. namespace video
  11. {
  12. // For system specific window contexts (used for OpenGL)
  13. class IContextManager : public virtual IReferenceCounted
  14. {
  15. public:
  16. //! Initialize manager with device creation parameters and device window (passed as exposed video data)
  17. virtual bool initialize(const SIrrlichtCreationParameters& params, const SExposedVideoData& data) =0;
  18. //! Terminate manager, any cleanup that is left over. Manager needs a new initialize to be usable again
  19. virtual void terminate() =0;
  20. //! Create surface based on current window set
  21. virtual bool generateSurface() =0;
  22. //! Destroy current surface
  23. virtual void destroySurface() =0;
  24. //! Create context based on current surface
  25. virtual bool generateContext() =0;
  26. //! Destroy current context
  27. virtual void destroyContext() =0;
  28. //! Get current context
  29. virtual const SExposedVideoData& getContext() const =0;
  30. //! Change render context, disable old and activate new defined by videoData
  31. //\param restorePrimaryOnZero When true: restore original driver context when videoData is set to 0 values.
  32. // When false: resets the context when videoData is set to 0 values.
  33. /** This is mostly used internally by IVideoDriver::beginScene().
  34. But if you want to switch threads which access your OpenGL driver you will have to
  35. call this function as follows:
  36. Old thread gives up context with: activateContext(irr::video::SExposedVideoData());
  37. New thread takes over context with: activateContext(videoDriver->getExposedVideoData());
  38. Note that only 1 thread at a time may access an OpenGL context. */
  39. virtual bool activateContext(const SExposedVideoData& videoData, bool restorePrimaryOnZero=false) =0;
  40. //! Swap buffers.
  41. virtual bool swapBuffers() =0;
  42. };
  43. } // end namespace video
  44. } // end namespace irr
  45. #endif