Aurore
A Switch-like interface for your app, on every screen
Loading...
Searching...
No Matches
video.hpp
Go to the documentation of this file.
1/*
2 Copyright 2021 natinusala
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15*/
16
17#pragma once
18
19#include <nanovg.h>
20
21#include <cmath>
22#include <vector>
23
24// A VideoContext is responsible for providing a nanovg context for the app
25// (so by extension it manages all the graphics state as well as the window / context).
26// The VideoContext implementation must also provide the nanovg implementation. As such, there
27// can only be one VideoContext linked at any time in the binary.
28// Context creation and teardown can be done in the constructor and destructor.
30{
31 public:
32 virtual ~VideoContext() = default;
33
37 virtual void clear(NVGcolor color) = 0;
38
42 virtual void beginFrame() = 0;
43
47 virtual void endFrame() = 0;
48
54 virtual void resetState() = 0;
55
56 /*
57 * scale factor between window size and drawable size
58 */
59 virtual double getScaleFactor() = 0;
60
61 /*
62 * Full screen window at primary monitor
63 */
64 virtual void fullScreen(bool fs) { }
65
66 virtual NVGcontext* getNVGContext() = 0;
67
73 virtual bool readPixels(std::vector<unsigned char>* rgba, int* width, int* height) { return false; }
74
75 virtual void setSwapInterval(int interval) = 0;
76
77 virtual int getCurrentMonitorIndex() { return 0; }
78
79 static inline bool FULLSCREEN = false;
80
81 // The position and size of the window in the last non-full-screen mode
82 static inline float posX = NAN, posY = NAN;
83 static inline uint32_t sizeW = 0, sizeH = 0;
84
85 static inline int monitorIndex = 0;
86
87 static inline int swapInterval = 1;
88};
Definition video.hpp:30
virtual void resetState()=0
static int swapInterval
Definition video.hpp:87
static uint32_t sizeW
Definition video.hpp:83
virtual NVGcontext * getNVGContext()=0
static float posX
Definition video.hpp:82
virtual double getScaleFactor()=0
virtual void setSwapInterval(int interval)=0
virtual void fullScreen(bool fs)
Definition video.hpp:64
virtual void clear(NVGcolor color)=0
virtual int getCurrentMonitorIndex()
Definition video.hpp:77
static float posY
Definition video.hpp:82
static int monitorIndex
Definition video.hpp:85
virtual ~VideoContext()=default
virtual bool readPixels(std::vector< unsigned char > *rgba, int *width, int *height)
Definition video.hpp:73
static bool FULLSCREEN
Definition video.hpp:79
static uint32_t sizeH
Definition video.hpp:83
virtual void endFrame()=0
virtual void beginFrame()=0