File: MFCGraphicsOperations.h

package info (click to toggle)
freespace2 24.2.0%2Brepack-3
  • links: PTS, VCS
  • area: non-free
  • in suites: forky, sid
  • size: 43,740 kB
  • sloc: cpp: 595,005; ansic: 21,741; python: 1,174; sh: 457; makefile: 243; xml: 181
file content (72 lines) | stat: -rw-r--r-- 1,614 bytes parent folder | download | duplicates (2)
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

#ifndef _MVC_GRAPHICS_OPERATIONS
#define _MVC_GRAPHICS_OPERATIONS
#pragma once

#include "globalincs/pstypes.h"
#include "osapi/osapi.h"

#include <glad/glad_wgl.h>

class MFCViewport : public os::Viewport
{
	HWND _windowHandle = nullptr;
	HDC _device_context = nullptr;
public:
	explicit MFCViewport(HWND hwnd, HDC dc);

	~MFCViewport() override;

	SDL_Window* toSDLWindow() override;

	std::pair<uint32_t, uint32_t> getSize() override;

	void swapBuffers() override;

	void setState(os::ViewportState state) override;

	void minimize() override;

	void restore() override;

	HDC getHDC();
};

class MFCOpenGLContext : public os::OpenGLContext
{
	// HACK: Since OpenGL apparently likes global state we also have to make this global...
	static void* _oglDllHandle;
	static size_t _oglDllReferenceCount;

	HGLRC _render_context = nullptr;
public:
	explicit MFCOpenGLContext(HGLRC hglrc);

	~MFCOpenGLContext() override;

	static void* wglLoader(const char* name);

	os::OpenGLLoadProc getLoaderFunction() override;

	bool setSwapInterval(int status) override;

	HGLRC getHandle();
};

class MFCGraphicsOperations : public os::GraphicsOperations
{
	HWND _windowHandle = nullptr;
public:

	explicit MFCGraphicsOperations(HWND hwnd);

	~MFCGraphicsOperations() override;

	std::unique_ptr<os::Viewport> createViewport(const os::ViewPortProperties& props) override;

	std::unique_ptr<os::OpenGLContext> createOpenGLContext(os::Viewport* port, const os::OpenGLContextAttributes& ctx) override;

	void makeOpenGLContextCurrent(os::Viewport* view, os::OpenGLContext* ctx) override;
};

#endif // _MVC_GRAPHICS_OPERATIONS