mirror of
https://github.com/korenkonder/ReDIVA.git
synced 2026-10-10 08:08:35 +03:00
Replaced glScissor and glViewport with gl_state functions
This commit is contained in:
@@ -335,9 +335,11 @@ void gl_state_get() {
|
||||
glGetBooleanv(GL_MULTISAMPLE, &gl_state.multisample);
|
||||
glGetBooleanv(GL_PRIMITIVE_RESTART, &gl_state.primitive_restart);
|
||||
glGetIntegerv(GL_PRIMITIVE_RESTART_INDEX, (GLint*)&gl_state.primitive_restart_index);
|
||||
glGetIntegerv(GL_SCISSOR_BOX, (GLint*)&gl_state.scissor_box);
|
||||
glGetBooleanv(GL_SCISSOR_TEST, &gl_state.scissor_test);
|
||||
glGetBooleanv(GL_STENCIL_TEST, &gl_state.stencil_test);
|
||||
glGetIntegerv(GL_STENCIL_WRITEMASK, (GLint*)&gl_state.stencil_mask);
|
||||
glGetIntegerv(GL_VIEWPORT, (GLint*)&gl_state.viewport);
|
||||
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||
gl_state.polygon_front_face_mode = GL_FILL;
|
||||
@@ -361,6 +363,28 @@ GLuint gl_state_get_program() {
|
||||
return gl_state.program;
|
||||
}
|
||||
|
||||
gl_state_rect gl_state_get_scissor() {
|
||||
return gl_state.scissor_box;
|
||||
}
|
||||
|
||||
void gl_state_get_scissor(GLint& x, GLint& y, GLsizei& width, GLsizei& height) {
|
||||
x = gl_state.scissor_box.x;
|
||||
y = gl_state.scissor_box.y;
|
||||
width = gl_state.scissor_box.width;
|
||||
height = gl_state.scissor_box.height;
|
||||
}
|
||||
|
||||
gl_state_rect gl_state_get_viewport() {
|
||||
return gl_state.viewport;
|
||||
}
|
||||
|
||||
void gl_state_get_viewport(GLint& x, GLint& y, GLsizei& width, GLsizei& height) {
|
||||
x = gl_state.viewport.x;
|
||||
y = gl_state.viewport.y;
|
||||
width = gl_state.viewport.width;
|
||||
height = gl_state.viewport.height;
|
||||
}
|
||||
|
||||
void gl_state_set_blend_func(GLenum src, GLenum dst, bool force) {
|
||||
if (force || gl_state.blend_src_rgb != src || gl_state.blend_dst_rgb != dst
|
||||
|| gl_state.blend_src_alpha != GL_ONE || gl_state.blend_dst_alpha != GL_ONE_MINUS_SRC_ALPHA) {
|
||||
@@ -473,6 +497,25 @@ void gl_state_set_primitive_restart_index(GLuint index, bool force) {
|
||||
}
|
||||
}
|
||||
|
||||
void gl_state_set_scissor(const gl_state_rect& rect, bool force) {
|
||||
if (force || gl_state.scissor_box.x != rect.x || gl_state.scissor_box.y != rect.y
|
||||
|| gl_state.scissor_box.width != rect.width || gl_state.scissor_box.height != rect.height) {
|
||||
glScissor(rect.x, rect.y, rect.width, rect.height);
|
||||
gl_state.scissor_box = rect;
|
||||
}
|
||||
}
|
||||
|
||||
void gl_state_set_scissor(GLint x, GLint y, GLsizei width, GLsizei height, bool force) {
|
||||
if (force || gl_state.scissor_box.x != x || gl_state.scissor_box.y != y
|
||||
|| gl_state.scissor_box.width != width || gl_state.scissor_box.height != height) {
|
||||
glScissor(x, y, width, height);
|
||||
gl_state.scissor_box.x = x;
|
||||
gl_state.scissor_box.y = y;
|
||||
gl_state.scissor_box.width = width;
|
||||
gl_state.scissor_box.height = height;
|
||||
}
|
||||
}
|
||||
|
||||
void gl_state_set_stencil_mask(GLuint mask, bool force) {
|
||||
if (force || gl_state.stencil_mask != mask) {
|
||||
glStencilMask(mask);
|
||||
@@ -480,6 +523,25 @@ void gl_state_set_stencil_mask(GLuint mask, bool force) {
|
||||
}
|
||||
}
|
||||
|
||||
void gl_state_set_viewport(const gl_state_rect& rect, bool force) {
|
||||
if (force || gl_state.viewport.x != rect.x || gl_state.viewport.y != rect.y
|
||||
|| gl_state.viewport.width != rect.width || gl_state.viewport.height != rect.height) {
|
||||
glScissor(rect.x, rect.y, rect.width, rect.height);
|
||||
gl_state.viewport = rect;
|
||||
}
|
||||
}
|
||||
|
||||
void gl_state_set_viewport(GLint x, GLint y, GLsizei width, GLsizei height, bool force) {
|
||||
if (force || gl_state.viewport.x != x || gl_state.viewport.y != y
|
||||
|| gl_state.viewport.width != width || gl_state.viewport.height != height) {
|
||||
glViewport(x, y, width, height);
|
||||
gl_state.viewport.x = x;
|
||||
gl_state.viewport.y = y;
|
||||
gl_state.viewport.width = width;
|
||||
gl_state.viewport.height = height;
|
||||
}
|
||||
}
|
||||
|
||||
void gl_state_use_program(GLuint program, bool force) {
|
||||
if (force || gl_state.program != program) {
|
||||
glUseProgram(program);
|
||||
|
||||
Reference in New Issue
Block a user