2015-05-19 06:21:33 +02:00
|
|
|
// Copyright 2015 Citra Emulator Project
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
2016-04-30 17:34:51 +02:00
|
|
|
#include <glad/glad.h>
|
|
|
|
#include "common/common_funcs.h"
|
|
|
|
#include "common/logging/log.h"
|
2016-09-21 08:52:38 +02:00
|
|
|
#include "video_core/renderer_opengl/gl_state.h"
|
2016-04-30 17:34:51 +02:00
|
|
|
|
2015-05-19 06:21:33 +02:00
|
|
|
OpenGLState OpenGLState::cur_state;
|
|
|
|
|
|
|
|
OpenGLState::OpenGLState() {
|
|
|
|
// These all match default OpenGL values
|
|
|
|
cull.enabled = false;
|
|
|
|
cull.mode = GL_BACK;
|
2015-08-31 17:03:21 +02:00
|
|
|
cull.front_face = GL_CCW;
|
2015-05-19 06:21:33 +02:00
|
|
|
|
|
|
|
depth.test_enabled = false;
|
|
|
|
depth.test_func = GL_LESS;
|
|
|
|
depth.write_mask = GL_TRUE;
|
|
|
|
|
2015-05-29 03:41:37 +02:00
|
|
|
color_mask.red_enabled = GL_TRUE;
|
|
|
|
color_mask.green_enabled = GL_TRUE;
|
|
|
|
color_mask.blue_enabled = GL_TRUE;
|
|
|
|
color_mask.alpha_enabled = GL_TRUE;
|
|
|
|
|
2015-05-19 06:21:33 +02:00
|
|
|
stencil.test_enabled = false;
|
|
|
|
stencil.test_func = GL_ALWAYS;
|
|
|
|
stencil.test_ref = 0;
|
2016-11-27 18:30:03 +01:00
|
|
|
stencil.test_mask = 0xFF;
|
|
|
|
stencil.write_mask = 0xFF;
|
2015-08-20 17:11:09 +02:00
|
|
|
stencil.action_depth_fail = GL_KEEP;
|
|
|
|
stencil.action_depth_pass = GL_KEEP;
|
|
|
|
stencil.action_stencil_fail = GL_KEEP;
|
2015-05-19 06:21:33 +02:00
|
|
|
|
2017-11-09 04:50:42 +01:00
|
|
|
blend.enabled = true;
|
2016-05-12 22:57:15 +02:00
|
|
|
blend.rgb_equation = GL_FUNC_ADD;
|
|
|
|
blend.a_equation = GL_FUNC_ADD;
|
2015-05-19 06:21:33 +02:00
|
|
|
blend.src_rgb_func = GL_ONE;
|
|
|
|
blend.dst_rgb_func = GL_ZERO;
|
|
|
|
blend.src_a_func = GL_ONE;
|
|
|
|
blend.dst_a_func = GL_ZERO;
|
|
|
|
blend.color.red = 0.0f;
|
|
|
|
blend.color.green = 0.0f;
|
|
|
|
blend.color.blue = 0.0f;
|
|
|
|
blend.color.alpha = 0.0f;
|
|
|
|
|
2015-05-26 00:39:03 +02:00
|
|
|
logic_op = GL_COPY;
|
|
|
|
|
2015-05-19 06:21:33 +02:00
|
|
|
for (auto& texture_unit : texture_units) {
|
|
|
|
texture_unit.texture_2d = 0;
|
2015-08-30 13:41:28 +02:00
|
|
|
texture_unit.sampler = 0;
|
2016-02-26 01:12:38 +01:00
|
|
|
}
|
|
|
|
|
2018-03-09 15:46:34 +01:00
|
|
|
texture_cube_unit.texture_cube = 0;
|
|
|
|
texture_cube_unit.sampler = 0;
|
|
|
|
|
2018-05-19 12:54:50 +02:00
|
|
|
texture_buffer_lut_rg.texture_buffer = 0;
|
|
|
|
texture_buffer_lut_rgba.texture_buffer = 0;
|
|
|
|
|
2018-04-11 14:47:02 +02:00
|
|
|
image_shadow_buffer = 0;
|
|
|
|
image_shadow_texture_px = 0;
|
|
|
|
image_shadow_texture_nx = 0;
|
|
|
|
image_shadow_texture_py = 0;
|
|
|
|
image_shadow_texture_ny = 0;
|
|
|
|
image_shadow_texture_pz = 0;
|
|
|
|
image_shadow_texture_nz = 0;
|
|
|
|
|
2016-04-17 00:57:57 +02:00
|
|
|
draw.read_framebuffer = 0;
|
|
|
|
draw.draw_framebuffer = 0;
|
2015-05-19 06:21:33 +02:00
|
|
|
draw.vertex_array = 0;
|
|
|
|
draw.vertex_buffer = 0;
|
2016-04-17 00:57:57 +02:00
|
|
|
draw.uniform_buffer = 0;
|
2015-05-19 06:21:33 +02:00
|
|
|
draw.shader_program = 0;
|
2018-04-09 23:27:16 +02:00
|
|
|
draw.program_pipeline = 0;
|
2017-08-17 09:46:59 +02:00
|
|
|
|
2017-11-25 21:54:35 +01:00
|
|
|
scissor.enabled = false;
|
|
|
|
scissor.x = 0;
|
|
|
|
scissor.y = 0;
|
|
|
|
scissor.width = 0;
|
|
|
|
scissor.height = 0;
|
|
|
|
|
|
|
|
viewport.x = 0;
|
|
|
|
viewport.y = 0;
|
|
|
|
viewport.width = 0;
|
|
|
|
viewport.height = 0;
|
|
|
|
|
2017-08-17 09:46:59 +02:00
|
|
|
clip_distance = {};
|
2015-05-19 06:21:33 +02:00
|
|
|
}
|
|
|
|
|
2016-04-17 00:57:57 +02:00
|
|
|
void OpenGLState::Apply() const {
|
2015-05-19 06:21:33 +02:00
|
|
|
// Culling
|
|
|
|
if (cull.enabled != cur_state.cull.enabled) {
|
|
|
|
if (cull.enabled) {
|
|
|
|
glEnable(GL_CULL_FACE);
|
|
|
|
} else {
|
|
|
|
glDisable(GL_CULL_FACE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cull.mode != cur_state.cull.mode) {
|
|
|
|
glCullFace(cull.mode);
|
|
|
|
}
|
|
|
|
|
2015-08-31 17:03:21 +02:00
|
|
|
if (cull.front_face != cur_state.cull.front_face) {
|
|
|
|
glFrontFace(cull.front_face);
|
|
|
|
}
|
|
|
|
|
2015-05-19 06:21:33 +02:00
|
|
|
// Depth test
|
|
|
|
if (depth.test_enabled != cur_state.depth.test_enabled) {
|
|
|
|
if (depth.test_enabled) {
|
|
|
|
glEnable(GL_DEPTH_TEST);
|
|
|
|
} else {
|
|
|
|
glDisable(GL_DEPTH_TEST);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (depth.test_func != cur_state.depth.test_func) {
|
|
|
|
glDepthFunc(depth.test_func);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Depth mask
|
|
|
|
if (depth.write_mask != cur_state.depth.write_mask) {
|
|
|
|
glDepthMask(depth.write_mask);
|
|
|
|
}
|
|
|
|
|
2015-05-29 03:41:37 +02:00
|
|
|
// Color mask
|
|
|
|
if (color_mask.red_enabled != cur_state.color_mask.red_enabled ||
|
2016-09-18 02:38:01 +02:00
|
|
|
color_mask.green_enabled != cur_state.color_mask.green_enabled ||
|
|
|
|
color_mask.blue_enabled != cur_state.color_mask.blue_enabled ||
|
|
|
|
color_mask.alpha_enabled != cur_state.color_mask.alpha_enabled) {
|
|
|
|
glColorMask(color_mask.red_enabled, color_mask.green_enabled, color_mask.blue_enabled,
|
|
|
|
color_mask.alpha_enabled);
|
2015-05-29 03:41:37 +02:00
|
|
|
}
|
|
|
|
|
2015-05-19 06:21:33 +02:00
|
|
|
// Stencil test
|
|
|
|
if (stencil.test_enabled != cur_state.stencil.test_enabled) {
|
|
|
|
if (stencil.test_enabled) {
|
|
|
|
glEnable(GL_STENCIL_TEST);
|
|
|
|
} else {
|
|
|
|
glDisable(GL_STENCIL_TEST);
|
|
|
|
}
|
2015-05-25 20:34:09 +02:00
|
|
|
}
|
2015-05-19 06:21:33 +02:00
|
|
|
|
|
|
|
if (stencil.test_func != cur_state.stencil.test_func ||
|
2016-09-18 02:38:01 +02:00
|
|
|
stencil.test_ref != cur_state.stencil.test_ref ||
|
|
|
|
stencil.test_mask != cur_state.stencil.test_mask) {
|
2015-05-19 06:21:33 +02:00
|
|
|
glStencilFunc(stencil.test_func, stencil.test_ref, stencil.test_mask);
|
|
|
|
}
|
|
|
|
|
2015-08-20 17:11:09 +02:00
|
|
|
if (stencil.action_depth_fail != cur_state.stencil.action_depth_fail ||
|
2016-09-18 02:38:01 +02:00
|
|
|
stencil.action_depth_pass != cur_state.stencil.action_depth_pass ||
|
|
|
|
stencil.action_stencil_fail != cur_state.stencil.action_stencil_fail) {
|
|
|
|
glStencilOp(stencil.action_stencil_fail, stencil.action_depth_fail,
|
|
|
|
stencil.action_depth_pass);
|
2015-08-20 17:11:09 +02:00
|
|
|
}
|
|
|
|
|
2015-05-19 06:21:33 +02:00
|
|
|
// Stencil mask
|
|
|
|
if (stencil.write_mask != cur_state.stencil.write_mask) {
|
|
|
|
glStencilMask(stencil.write_mask);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Blending
|
|
|
|
if (blend.enabled != cur_state.blend.enabled) {
|
|
|
|
if (blend.enabled) {
|
|
|
|
glEnable(GL_BLEND);
|
2015-05-26 00:39:03 +02:00
|
|
|
glDisable(GL_COLOR_LOGIC_OP);
|
2015-05-19 06:21:33 +02:00
|
|
|
} else {
|
|
|
|
glDisable(GL_BLEND);
|
2015-05-26 00:39:03 +02:00
|
|
|
glEnable(GL_COLOR_LOGIC_OP);
|
2015-05-19 06:21:33 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (blend.color.red != cur_state.blend.color.red ||
|
2016-09-18 02:38:01 +02:00
|
|
|
blend.color.green != cur_state.blend.color.green ||
|
|
|
|
blend.color.blue != cur_state.blend.color.blue ||
|
|
|
|
blend.color.alpha != cur_state.blend.color.alpha) {
|
|
|
|
glBlendColor(blend.color.red, blend.color.green, blend.color.blue, blend.color.alpha);
|
2015-05-19 06:21:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (blend.src_rgb_func != cur_state.blend.src_rgb_func ||
|
2016-09-18 02:38:01 +02:00
|
|
|
blend.dst_rgb_func != cur_state.blend.dst_rgb_func ||
|
|
|
|
blend.src_a_func != cur_state.blend.src_a_func ||
|
|
|
|
blend.dst_a_func != cur_state.blend.dst_a_func) {
|
|
|
|
glBlendFuncSeparate(blend.src_rgb_func, blend.dst_rgb_func, blend.src_a_func,
|
|
|
|
blend.dst_a_func);
|
2015-05-19 06:21:33 +02:00
|
|
|
}
|
|
|
|
|
2016-05-12 22:57:15 +02:00
|
|
|
if (blend.rgb_equation != cur_state.blend.rgb_equation ||
|
2016-09-18 02:38:01 +02:00
|
|
|
blend.a_equation != cur_state.blend.a_equation) {
|
2016-05-12 22:57:15 +02:00
|
|
|
glBlendEquationSeparate(blend.rgb_equation, blend.a_equation);
|
|
|
|
}
|
|
|
|
|
2015-05-26 00:39:03 +02:00
|
|
|
if (logic_op != cur_state.logic_op) {
|
|
|
|
glLogicOp(logic_op);
|
|
|
|
}
|
|
|
|
|
2015-05-19 06:21:33 +02:00
|
|
|
// Textures
|
2015-08-30 13:41:28 +02:00
|
|
|
for (unsigned i = 0; i < ARRAY_SIZE(texture_units); ++i) {
|
|
|
|
if (texture_units[i].texture_2d != cur_state.texture_units[i].texture_2d) {
|
2017-06-16 15:16:28 +02:00
|
|
|
glActiveTexture(TextureUnits::PicaTexture(i).Enum());
|
2015-08-30 13:41:28 +02:00
|
|
|
glBindTexture(GL_TEXTURE_2D, texture_units[i].texture_2d);
|
|
|
|
}
|
|
|
|
if (texture_units[i].sampler != cur_state.texture_units[i].sampler) {
|
|
|
|
glBindSampler(i, texture_units[i].sampler);
|
2015-05-19 06:21:33 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-09 15:46:34 +01:00
|
|
|
if (texture_cube_unit.texture_cube != cur_state.texture_cube_unit.texture_cube) {
|
|
|
|
glActiveTexture(TextureUnits::TextureCube.Enum());
|
|
|
|
glBindTexture(GL_TEXTURE_CUBE_MAP, texture_cube_unit.texture_cube);
|
|
|
|
}
|
|
|
|
if (texture_cube_unit.sampler != cur_state.texture_cube_unit.sampler) {
|
|
|
|
glBindSampler(TextureUnits::TextureCube.id, texture_cube_unit.sampler);
|
|
|
|
}
|
|
|
|
|
2018-05-19 12:54:50 +02:00
|
|
|
// Texture buffer LUTs
|
|
|
|
if (texture_buffer_lut_rg.texture_buffer != cur_state.texture_buffer_lut_rg.texture_buffer) {
|
|
|
|
glActiveTexture(TextureUnits::TextureBufferLUT_RG.Enum());
|
|
|
|
glBindTexture(GL_TEXTURE_BUFFER, texture_buffer_lut_rg.texture_buffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Texture buffer LUTs
|
|
|
|
if (texture_buffer_lut_rgba.texture_buffer !=
|
|
|
|
cur_state.texture_buffer_lut_rgba.texture_buffer) {
|
|
|
|
glActiveTexture(TextureUnits::TextureBufferLUT_RGBA.Enum());
|
|
|
|
glBindTexture(GL_TEXTURE_BUFFER, texture_buffer_lut_rgba.texture_buffer);
|
|
|
|
}
|
|
|
|
|
2018-04-11 14:47:02 +02:00
|
|
|
// Shadow Images
|
|
|
|
if (image_shadow_buffer != cur_state.image_shadow_buffer) {
|
|
|
|
glBindImageTexture(ImageUnits::ShadowBuffer, image_shadow_buffer, 0, GL_FALSE, 0,
|
|
|
|
GL_READ_WRITE, GL_R32UI);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (image_shadow_texture_px != cur_state.image_shadow_texture_px) {
|
|
|
|
glBindImageTexture(ImageUnits::ShadowTexturePX, image_shadow_texture_px, 0, GL_FALSE, 0,
|
|
|
|
GL_READ_ONLY, GL_R32UI);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (image_shadow_texture_nx != cur_state.image_shadow_texture_nx) {
|
|
|
|
glBindImageTexture(ImageUnits::ShadowTextureNX, image_shadow_texture_nx, 0, GL_FALSE, 0,
|
|
|
|
GL_READ_ONLY, GL_R32UI);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (image_shadow_texture_py != cur_state.image_shadow_texture_py) {
|
|
|
|
glBindImageTexture(ImageUnits::ShadowTexturePY, image_shadow_texture_py, 0, GL_FALSE, 0,
|
|
|
|
GL_READ_ONLY, GL_R32UI);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (image_shadow_texture_ny != cur_state.image_shadow_texture_ny) {
|
|
|
|
glBindImageTexture(ImageUnits::ShadowTextureNY, image_shadow_texture_ny, 0, GL_FALSE, 0,
|
|
|
|
GL_READ_ONLY, GL_R32UI);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (image_shadow_texture_pz != cur_state.image_shadow_texture_pz) {
|
|
|
|
glBindImageTexture(ImageUnits::ShadowTexturePZ, image_shadow_texture_pz, 0, GL_FALSE, 0,
|
|
|
|
GL_READ_ONLY, GL_R32UI);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (image_shadow_texture_nz != cur_state.image_shadow_texture_nz) {
|
|
|
|
glBindImageTexture(ImageUnits::ShadowTextureNZ, image_shadow_texture_nz, 0, GL_FALSE, 0,
|
|
|
|
GL_READ_ONLY, GL_R32UI);
|
|
|
|
}
|
|
|
|
|
2015-05-19 06:21:33 +02:00
|
|
|
// Framebuffer
|
2016-04-17 00:57:57 +02:00
|
|
|
if (draw.read_framebuffer != cur_state.draw.read_framebuffer) {
|
|
|
|
glBindFramebuffer(GL_READ_FRAMEBUFFER, draw.read_framebuffer);
|
|
|
|
}
|
|
|
|
if (draw.draw_framebuffer != cur_state.draw.draw_framebuffer) {
|
|
|
|
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, draw.draw_framebuffer);
|
2015-05-19 06:21:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Vertex array
|
|
|
|
if (draw.vertex_array != cur_state.draw.vertex_array) {
|
|
|
|
glBindVertexArray(draw.vertex_array);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Vertex buffer
|
|
|
|
if (draw.vertex_buffer != cur_state.draw.vertex_buffer) {
|
|
|
|
glBindBuffer(GL_ARRAY_BUFFER, draw.vertex_buffer);
|
|
|
|
}
|
|
|
|
|
2015-11-10 17:58:53 +01:00
|
|
|
// Uniform buffer
|
|
|
|
if (draw.uniform_buffer != cur_state.draw.uniform_buffer) {
|
|
|
|
glBindBuffer(GL_UNIFORM_BUFFER, draw.uniform_buffer);
|
|
|
|
}
|
|
|
|
|
2015-05-19 06:21:33 +02:00
|
|
|
// Shader program
|
|
|
|
if (draw.shader_program != cur_state.draw.shader_program) {
|
|
|
|
glUseProgram(draw.shader_program);
|
|
|
|
}
|
|
|
|
|
2018-04-09 23:27:16 +02:00
|
|
|
// Program pipeline
|
|
|
|
if (draw.program_pipeline != cur_state.draw.program_pipeline) {
|
|
|
|
glBindProgramPipeline(draw.program_pipeline);
|
|
|
|
}
|
|
|
|
|
2017-11-25 21:54:35 +01:00
|
|
|
// Scissor test
|
|
|
|
if (scissor.enabled != cur_state.scissor.enabled) {
|
|
|
|
if (scissor.enabled) {
|
|
|
|
glEnable(GL_SCISSOR_TEST);
|
|
|
|
} else {
|
|
|
|
glDisable(GL_SCISSOR_TEST);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (scissor.x != cur_state.scissor.x || scissor.y != cur_state.scissor.y ||
|
|
|
|
scissor.width != cur_state.scissor.width || scissor.height != cur_state.scissor.height) {
|
|
|
|
glScissor(scissor.x, scissor.y, scissor.width, scissor.height);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (viewport.x != cur_state.viewport.x || viewport.y != cur_state.viewport.y ||
|
|
|
|
viewport.width != cur_state.viewport.width ||
|
|
|
|
viewport.height != cur_state.viewport.height) {
|
|
|
|
glViewport(viewport.x, viewport.y, viewport.width, viewport.height);
|
|
|
|
}
|
|
|
|
|
2017-08-17 09:46:59 +02:00
|
|
|
// Clip distance
|
|
|
|
for (size_t i = 0; i < clip_distance.size(); ++i) {
|
|
|
|
if (clip_distance[i] != cur_state.clip_distance[i]) {
|
|
|
|
if (clip_distance[i]) {
|
2017-09-27 01:26:09 +02:00
|
|
|
glEnable(GL_CLIP_DISTANCE0 + static_cast<GLenum>(i));
|
2017-08-17 09:46:59 +02:00
|
|
|
} else {
|
2017-09-27 01:26:09 +02:00
|
|
|
glDisable(GL_CLIP_DISTANCE0 + static_cast<GLenum>(i));
|
2017-08-17 09:46:59 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-19 06:21:33 +02:00
|
|
|
cur_state = *this;
|
|
|
|
}
|
2015-08-06 04:22:06 +02:00
|
|
|
|
2017-11-25 21:54:35 +01:00
|
|
|
OpenGLState& OpenGLState::ResetTexture(GLuint handle) {
|
|
|
|
for (auto& unit : texture_units) {
|
2016-04-17 00:57:57 +02:00
|
|
|
if (unit.texture_2d == handle) {
|
2015-08-06 04:22:06 +02:00
|
|
|
unit.texture_2d = 0;
|
|
|
|
}
|
|
|
|
}
|
2018-03-09 15:46:34 +01:00
|
|
|
if (texture_cube_unit.texture_cube == handle)
|
|
|
|
texture_cube_unit.texture_cube = 0;
|
2018-05-19 12:54:50 +02:00
|
|
|
if (texture_buffer_lut_rg.texture_buffer == handle)
|
|
|
|
texture_buffer_lut_rg.texture_buffer = 0;
|
|
|
|
if (texture_buffer_lut_rgba.texture_buffer == handle)
|
|
|
|
texture_buffer_lut_rgba.texture_buffer = 0;
|
2018-04-11 14:47:02 +02:00
|
|
|
if (image_shadow_buffer == handle)
|
|
|
|
image_shadow_buffer = 0;
|
|
|
|
if (image_shadow_texture_px == handle)
|
|
|
|
image_shadow_texture_px = 0;
|
|
|
|
if (image_shadow_texture_nx == handle)
|
|
|
|
image_shadow_texture_nx = 0;
|
|
|
|
if (image_shadow_texture_py == handle)
|
|
|
|
image_shadow_texture_py = 0;
|
|
|
|
if (image_shadow_texture_ny == handle)
|
|
|
|
image_shadow_texture_ny = 0;
|
|
|
|
if (image_shadow_texture_pz == handle)
|
|
|
|
image_shadow_texture_pz = 0;
|
|
|
|
if (image_shadow_texture_nz == handle)
|
|
|
|
image_shadow_texture_nz = 0;
|
2017-11-25 21:54:35 +01:00
|
|
|
return *this;
|
2015-08-06 04:22:06 +02:00
|
|
|
}
|
|
|
|
|
2017-11-25 21:54:35 +01:00
|
|
|
OpenGLState& OpenGLState::ResetSampler(GLuint handle) {
|
|
|
|
for (auto& unit : texture_units) {
|
2016-04-17 00:57:57 +02:00
|
|
|
if (unit.sampler == handle) {
|
2015-08-30 13:41:28 +02:00
|
|
|
unit.sampler = 0;
|
|
|
|
}
|
|
|
|
}
|
2018-03-09 15:46:34 +01:00
|
|
|
if (texture_cube_unit.sampler == handle) {
|
|
|
|
texture_cube_unit.sampler = 0;
|
|
|
|
}
|
2017-11-25 21:54:35 +01:00
|
|
|
return *this;
|
2015-08-30 13:41:28 +02:00
|
|
|
}
|
|
|
|
|
2017-11-25 21:54:35 +01:00
|
|
|
OpenGLState& OpenGLState::ResetProgram(GLuint handle) {
|
|
|
|
if (draw.shader_program == handle) {
|
|
|
|
draw.shader_program = 0;
|
2015-08-06 04:22:06 +02:00
|
|
|
}
|
2017-11-25 21:54:35 +01:00
|
|
|
return *this;
|
2015-08-06 04:22:06 +02:00
|
|
|
}
|
|
|
|
|
2018-04-09 23:27:16 +02:00
|
|
|
OpenGLState& OpenGLState::ResetPipeline(GLuint handle) {
|
|
|
|
if (draw.program_pipeline == handle) {
|
|
|
|
draw.program_pipeline = 0;
|
|
|
|
}
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2017-11-25 21:54:35 +01:00
|
|
|
OpenGLState& OpenGLState::ResetBuffer(GLuint handle) {
|
|
|
|
if (draw.vertex_buffer == handle) {
|
|
|
|
draw.vertex_buffer = 0;
|
2015-08-06 04:22:06 +02:00
|
|
|
}
|
2017-11-25 21:54:35 +01:00
|
|
|
if (draw.uniform_buffer == handle) {
|
|
|
|
draw.uniform_buffer = 0;
|
2015-11-10 17:58:53 +01:00
|
|
|
}
|
2017-11-25 21:54:35 +01:00
|
|
|
return *this;
|
2015-08-06 04:22:06 +02:00
|
|
|
}
|
|
|
|
|
2017-11-25 21:54:35 +01:00
|
|
|
OpenGLState& OpenGLState::ResetVertexArray(GLuint handle) {
|
|
|
|
if (draw.vertex_array == handle) {
|
|
|
|
draw.vertex_array = 0;
|
2015-08-06 04:22:06 +02:00
|
|
|
}
|
2017-11-25 21:54:35 +01:00
|
|
|
return *this;
|
2015-08-06 04:22:06 +02:00
|
|
|
}
|
|
|
|
|
2017-11-25 21:54:35 +01:00
|
|
|
OpenGLState& OpenGLState::ResetFramebuffer(GLuint handle) {
|
|
|
|
if (draw.read_framebuffer == handle) {
|
|
|
|
draw.read_framebuffer = 0;
|
2016-04-17 00:57:57 +02:00
|
|
|
}
|
2017-11-25 21:54:35 +01:00
|
|
|
if (draw.draw_framebuffer == handle) {
|
|
|
|
draw.draw_framebuffer = 0;
|
2015-08-06 04:22:06 +02:00
|
|
|
}
|
2017-11-25 21:54:35 +01:00
|
|
|
return *this;
|
2015-08-06 04:22:06 +02:00
|
|
|
}
|