Sparkle 0.0.1
Loading...
Searching...
No Matches
spk_wgl_context.hpp
1#pragma once
2
3#include <Windows.h>
4
5#include "structure/opengl/spk_view_region.hpp"
6#include "structure/win32/spk_window.hpp"
7
8namespace spk
9{
10 namespace OpenGL
11 {
17 {
18 public:
23 struct Version
24 {
28 size_t major = 4;
32 size_t minor = 5;
33 };
34
35 private:
36 ViewRegion _viewRegion;
37
38 using HandleDeviceContext = HDC;
39 using HandleRenderingContext = HGLRC;
40
41 Win32::Window &_window;
42 HandleDeviceContext _hdc;
43 HandleRenderingContext _hglrc;
44
45 void _setPixelFormatToDevice(HandleDeviceContext p_hdc);
46 spk::Extend2D _getClientSize();
47
48 public:
54 WglContext(Win32::Window &p_window, Version p_version);
55
57
58 WglContext(const WglContext &) = delete;
59 WglContext &operator=(const WglContext &) = delete;
60 WglContext(WglContext &&) = delete;
61 WglContext &operator=(WglContext &&) = delete;
62
66 void makeCurrent();
70 void releaseCurrent();
71
75 void clear();
80 void resize(const spk::Extend2D &p_extend2D);
84 void swap();
85
90 HandleDeviceContext deviceContext() const noexcept;
95 HandleRenderingContext renderingContext() const noexcept;
96 };
97 }
98}
Manages viewport and scissor rectangles and clearing.
Definition spk_view_region.hpp:26
void releaseCurrent()
Releases this context from the current thread.
Definition spk_wgl_context.cpp:173
void swap()
Swaps buffers.
Definition spk_wgl_context.cpp:193
WglContext(Win32::Window &p_window, Version p_version)
Creates an OpenGL context for a window with a desired version.
Definition spk_wgl_context.cpp:55
HandleRenderingContext renderingContext() const noexcept
Access to rendering context handle.
Definition spk_wgl_context.cpp:203
HandleDeviceContext deviceContext() const noexcept
Access to device context handle.
Definition spk_wgl_context.cpp:198
void makeCurrent()
Activates this context on the current thread.
Definition spk_wgl_context.cpp:165
void resize(const spk::Extend2D &p_extend2D)
Resizes viewport to match new client size.
Definition spk_wgl_context.cpp:187
void clear()
Clears using the current ViewRegion settings.
Definition spk_wgl_context.cpp:181
RAII wrapper over a Win32 HWND handle created by spk::Win32::Class.
Definition spk_window.hpp:20
Axis-aligned rectangle defined by an anchor point and size.
Definition spk_extend_2d.hpp:24
Desired OpenGL major/minor version numbers.
Definition spk_wgl_context.hpp:24
size_t major
Major version of the OpenGL context.
Definition spk_wgl_context.hpp:28
size_t minor
Minor version of the OpenGL context.
Definition spk_wgl_context.hpp:32