2012-11-01 16:19:01 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
2013-07-28 20:52:09 -07:00
|
|
|
#include "Common/CommonWindows.h"
|
2015-12-31 16:59:40 +01:00
|
|
|
#include "Windows/GPU/WindowsGraphicsContext.h"
|
2012-11-01 16:19:01 +01:00
|
|
|
|
2016-12-25 18:18:19 +01:00
|
|
|
namespace Draw {
|
2016-12-25 21:01:57 +01:00
|
|
|
class DrawContext;
|
2016-12-25 18:18:19 +01:00
|
|
|
}
|
2015-09-20 19:45:36 +02:00
|
|
|
|
2018-01-16 14:16:56 +01:00
|
|
|
class GLRenderManager;
|
|
|
|
|
|
2015-12-31 16:59:40 +01:00
|
|
|
class WindowsGLContext : public WindowsGraphicsContext {
|
|
|
|
|
public:
|
|
|
|
|
bool Init(HINSTANCE hInst, HWND window, std::string *error_message) override;
|
2017-12-15 12:40:38 +01:00
|
|
|
|
2018-01-16 14:16:56 +01:00
|
|
|
bool InitFromRenderThread(std::string *errorMessage) override;
|
2018-01-16 18:13:31 +01:00
|
|
|
void ShutdownFromRenderThread() override;
|
2018-01-16 14:16:56 +01:00
|
|
|
|
2015-12-31 16:59:40 +01:00
|
|
|
void Shutdown() override;
|
2023-08-11 00:58:24 +02:00
|
|
|
|
|
|
|
|
void Poll() override;
|
2015-12-31 16:59:40 +01:00
|
|
|
|
|
|
|
|
// Used during window resize. Must be called from the window thread,
|
|
|
|
|
// not the rendering thread or CPU thread.
|
|
|
|
|
void Pause() override;
|
|
|
|
|
void Resume() override;
|
|
|
|
|
void Resize() override;
|
|
|
|
|
|
2018-01-16 18:13:31 +01:00
|
|
|
void ThreadStart() override;
|
|
|
|
|
void ThreadEnd() override;
|
|
|
|
|
bool ThreadFrame() override;
|
2018-02-10 16:12:33 -08:00
|
|
|
void StopThread() override;
|
2018-01-16 14:16:56 +01:00
|
|
|
|
2017-02-06 11:20:27 +01:00
|
|
|
Draw::DrawContext *GetDrawContext() override { return draw_; }
|
2016-01-01 12:50:38 +01:00
|
|
|
|
|
|
|
|
private:
|
2020-07-28 19:06:29 +02:00
|
|
|
void ReleaseGLContext();
|
|
|
|
|
|
2018-01-16 14:16:56 +01:00
|
|
|
bool renderThread_;
|
2017-02-06 11:20:27 +01:00
|
|
|
Draw::DrawContext *draw_;
|
2018-01-16 14:16:56 +01:00
|
|
|
GLRenderManager *renderManager_;
|
|
|
|
|
HINSTANCE hInst_;
|
2016-01-01 12:50:38 +01:00
|
|
|
HDC hDC; // Private GDI Device Context
|
|
|
|
|
HGLRC hRC; // Permanent Rendering Context
|
2018-01-16 14:16:56 +01:00
|
|
|
HWND hWnd_; // Holds Our Window Handle
|
2016-01-01 12:50:38 +01:00
|
|
|
volatile bool pauseRequested;
|
|
|
|
|
volatile bool resumeRequested;
|
|
|
|
|
HANDLE pauseEvent;
|
|
|
|
|
HANDLE resumeEvent;
|
2015-12-31 16:59:40 +01:00
|
|
|
};
|