Cogs.Core
GraphicsDeviceGL20.h
1#pragma once
2
3#include "../IGraphicsDevice.h"
4#include "../BaseGL/GLContext.h"
5#include "CapabilitiesGL20.h"
6#include "BuffersGL20.h"
7#include "TexturesGL20.h"
8#include "EffectsGL20.h"
9#include "RenderTargetsGL20.h"
10#include "../BaseGL/SyncObjects.h"
11
12#include "ContextGL20.h"
13#include "SwapChainGL20.h"
14
15
16namespace Cogs
17{
18 class ISwapChain;
19
21 {
22 public:
25
26 virtual bool initialize() override;
27 virtual bool setSettings(const GraphicsDeviceSettings& newSettings) override;
28
29 virtual ISwapChain* createSwapChain(struct WindowData* windowData) override;
30 virtual void deleteSwapChain(ISwapChain* swapChain) override;
31
32 virtual std::string getIdentifier() const override { return "OpenGL20"; }
33 virtual GraphicsDeviceType getType() const override { return GraphicsDeviceType::OpenGL20; }
34
35 virtual void setSize(int width, int height) override;
36 virtual bool getSize(int& w, int& h) const override;
37
38 virtual void beginFrame() override;
39 virtual void endFrame(uint32_t syncInterval = 0, uint32_t presentFlags = PresentFlags::None) override;
40
41 virtual void waitForCommandSync() override;
42 virtual void releaseResources() override;
43
45 virtual void activateSharedContext(SharedGraphicsContext*) override;
46 virtual void releaseSharedContext(SharedGraphicsContext*) override;
47
49 virtual BuffersGL20* getBuffers() override { return &buffers; }
50 virtual TexturesGL20* getTextures() override { return &textures; }
51 virtual RenderTargetsGL20* getRenderTargets() override { return &renderTargets; }
52 virtual EffectsGL20* getEffects() override { return &effects; }
53 virtual IPipelineStates* getPipelineStates() override { return nullptr; }
54 virtual ISyncObjects* getSyncObjects() override { return &syncObjects; }
55 virtual ContextGL20* getImmediateContext() override { return &context; }
56 virtual CapabilitiesGL20* getCapabilities() override { return &capabilities; }
57 virtual SwapChainGL20* getDefaultSwapChain() override { return &defaultSwapChain; }
58
59 GLContext& getShareContext() { return glShareContext; }
60
61 private:
62 BuffersGL20 buffers;
63 TexturesGL20 textures;
64 EffectsGL20 effects;
65 RenderTargetsGL20 renderTargets;
66 ContextGL20 context;
67 CapabilitiesGL20 capabilities;
68 GLSyncObjects syncObjects;
69 SwapChainGL20 defaultSwapChain;
70
71 RenderTargetHandle offscreenRenderTargetHandle;
72 TextureHandle offscreenTextureHandle;
73 RenderTargetHandle offscreenResolveRenderTargetHandle;
74 TextureHandle offscreenResolveTextureHandle;
75
76 bool initialized = false;
77
78 // A separate context only used for sharing and kept empty of objects,
79 // so that none of the context that set up a share has any objects.
80 GLContext glShareContext;
81 };
82}
virtual BuffersGL20 * getBuffers() override
Get a pointer to the buffer management interface.
virtual bool initialize() override
Initialises this graphics device.
virtual void activateSharedContext(SharedGraphicsContext *) override
Activates the given shared context on the calling thread.
virtual void endFrame(uint32_t syncInterval=0, uint32_t presentFlags=PresentFlags::None) override
Finalises frame rendering and presents the new frames to the display (if applicable).
virtual GraphicsDeviceType getType() const override
Get the type of the graphics device.
virtual std::string getIdentifier() const override
Get the graphics device identifier.
virtual SharedGraphicsContext * createSharedContext() override
Create a shared graphics context that can be used to activate another thread for rendering.
virtual void releaseResources() override
Release all resources used by this graphics device.
virtual ISyncObjects * getSyncObjects() override
Get a pointer to the sync object management interface.
virtual void beginFrame() override
Prepares the current frame for rendering.
virtual bool getSize(int &w, int &h) const override
Retrieve the current size of this graphics device's default swap chain.
virtual RenderTargetsGL20 * getRenderTargets() override
Get a pointer to the render target management interface.
virtual bool setSettings(const GraphicsDeviceSettings &newSettings) override
Updates settings for this graphics device.
virtual SwapChainGL20 * getDefaultSwapChain() override
Get a pointer to the default swap chain for this graphics device.
virtual void waitForCommandSync() override
Forces the calling thread to synchronise with the GPU.
virtual TexturesGL20 * getTextures() override
Get a pointer to the texture management interface.
virtual ContextGL20 * getImmediateContext() override
Get a pointer to the immediate context used to issue commands to the graphics device.
virtual void deleteSwapChain(ISwapChain *swapChain) override
Delete the specified SwapChain.
virtual CapabilitiesGL20 * getCapabilities() override
Get a pointer to the capability management interface used to query the graphics device capability fla...
virtual void releaseSharedContext(SharedGraphicsContext *) override
Releases the given shared context.
virtual ISwapChain * createSwapChain(struct WindowData *windowData) override
Create a new SwapChain and attach it to the provided window.
virtual void setSize(int width, int height) override
Resizes the output of this graphics device.
virtual IPipelineStates * getPipelineStates() override
Get a pointer to the pipeline state management interface.
virtual EffectsGL20 * getEffects() override
Get a pointer to the effect management interface.
virtual ResourceStatistics getResourceStatistics() override
Retrieve statistics about resources currently in use by this graphics device instance.
Represents a graphics device used to manage graphics resources and issue drawing commands.
Contains all Cogs related functionality.
Definition: FieldSetter.h:23
GraphicsDeviceType
Contains types of graphics devices that may be supported.
Definition: Base.h:48
@ OpenGL20
Graphics device using OpenGL, supporting at least OpenGL 2.0.
Settings for graphics device initialization.
Provides sync object management.
Definition: ISyncObjects.h:14
@ None
No flags.
Definition: Common.h:177
Allocation information.
Definition: Base.h:35