Debian Codegraph @

Sources/nCine/Graphics/RHI/GL/GLViewport.cpp

raw
1 #include "GLViewport.h"
2
3 namespace nCine::RHI::GL
4 {
5 GLViewport::State GLViewport::_state;
6
7 void GLViewport::SetRect(const Recti& rect)
8 {
9 if (rect.X != _state.rect.X || rect.Y != _state.rect.Y ||
10 rect.W != _state.rect.W || rect.H != _state.rect.H) {
11 FATAL_ASSERT(rect.W >= 0 && rect.H >= 0);
12 glViewport(rect.X, rect.Y, rect.W, rect.H);
13 _state.rect = rect;
14 }
15 }
16
17 void GLViewport::SetRect(GLint x, GLint y, GLsizei width, GLsizei height)
18 {
19 SetRect(Recti(x, y, width, height));
20 }
21
22 void GLViewport::Reapply()
23 {
24 glViewport(_state.rect.X, _state.rect.Y, _state.rect.W, _state.rect.H);
25 }
26
27 void GLViewport::SetState(State newState)
28 {
29 SetRect(newState.rect);
30 _state = newState;
31 }
32
33 void GLViewport::InitRect(GLint x, GLint y, GLsizei width, GLsizei height)
34 {
35 _state.rect.X = x;
36 _state.rect.Y = y;
37 _state.rect.W = width;
38 _state.rect.H = height;
39 }
40 }