Created
October 22, 2020 17:03
-
-
Save untodesu/155aff78b3ce4c5e1c79e298ded87205 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class RenderContext final { | |
public: | |
RenderContext(Window *window) | |
{ | |
glfwMakeContextCurrent(window.window()); | |
} | |
void setViewport(const BaseViewport &viewport) | |
{ | |
s_viewport = viewport; | |
} | |
void setClearColor(int r, int g, int b, int a = 255) | |
{ | |
glClearColor(r / 255.0f, g / 255.0f, b / 255.0f, a / 255.0f); | |
} | |
void clear(bool color = true, bool depth = false, bool stencil = false) | |
{ | |
GLbitfield flags = 0; | |
if(color) | |
flags |= GL_COLOR_BUFFER_BIT; | |
if(depth) | |
flags |= GL_DEPTH_BUFFER_BIT; | |
if(stencil) | |
flags |= GL_STENCIL_BUFFER_BIT; | |
if(flags != 0) | |
glClear(flags); | |
} | |
private: | |
static BaseViewport s_viewport; | |
static ProjMode s_proj_mode; | |
}; | |
// | |
// ... | |
// | |
RenderContext r(window); | |
r.setClearColor(0, 0, 128); | |
r.clear(true, true); | |
r.xxx(...); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment