IContextManager.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. #pragma once
  5. #include "SExposedVideoData.h"
  6. #include "SIrrCreationParameters.h"
  7. #include <string>
  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. //! Get the address of any OpenGL procedure (including core procedures).
  41. virtual void *getProcAddress(const std::string &procName) = 0;
  42. //! Swap buffers.
  43. virtual bool swapBuffers() = 0;
  44. };
  45. } // end namespace video
  46. } // end namespace irr