aboutsummaryrefslogtreecommitdiff
path: root/source/Irrlicht/CEAGLManager.h
blob: 65caa7aa8be2bd8f8590f670cd37201abfc66d60 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
// Copyright (C) 2015 Patryk Nadrowski
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in Irrlicht.h

#ifndef __C_EAGL_MANAGER_H_INCLUDED__
#define __C_EAGL_MANAGER_H_INCLUDED__


#ifdef _IRR_COMPILE_WITH_EAGL_MANAGER_

#include "SIrrCreationParameters.h"
#include "SExposedVideoData.h"
#include "IContextManager.h"

namespace irr
{
namespace video
{
	// EAGL manager.
	class CEAGLManager : public IContextManager
	{
	public:
		//! Constructor.
		CEAGLManager();

		//! Destructor.
		virtual ~CEAGLManager();

		// Initialize EAGL.
		/* This method checks if a view has CAEAGLLayer and grabs it if it does, anyway surface and context
		aren't create. */
		bool initialize(const SIrrlichtCreationParameters& params, const SExposedVideoData& data);

		// Terminate EAGL.
		/* Terminate EAGL context. This method break both existed surface and context. */
		void terminate();

		// Create EAGL surface.
		/* This method configure CAEAGLLayer. */
		bool generateSurface();

		// Destroy EAGL surface.
		/* This method reset CAEAGLLayer states. */
		void destroySurface();

		// Create EAGL context.
		/* This method create and activate EAGL context. */
		bool generateContext();

		// Destroy EAGL context.
		/* This method destroy EAGL context. */
		void destroyContext();

		const SExposedVideoData& getContext() const;

		bool activateContext(const SExposedVideoData& videoData, bool restorePrimaryOnZero);

		// Swap buffers.
		bool swapBuffers();

	private:
		SIrrlichtCreationParameters Params;
		SExposedVideoData Data;

		bool Configured;

        void* DataStorage;

		struct SFrameBuffer
		{
			SFrameBuffer() : BufferID(0), ColorBuffer(0), DepthBuffer(0)
			{
			}

			u32 BufferID;
			u32 ColorBuffer;
			u32 DepthBuffer;
		};

		SFrameBuffer FrameBuffer;
	};
}
}

#endif
#endif