gl_state.cpp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574
  1. // Copyright 2015 Citra Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #include <iterator>
  5. #include <glad/glad.h>
  6. #include "common/assert.h"
  7. #include "common/logging/log.h"
  8. #include "video_core/renderer_opengl/gl_state.h"
  9. namespace OpenGL {
  10. OpenGLState OpenGLState::cur_state;
  11. bool OpenGLState::s_rgb_used;
  12. OpenGLState::OpenGLState() {
  13. // These all match default OpenGL values
  14. geometry_shaders.enabled = false;
  15. framebuffer_srgb.enabled = false;
  16. multisample_control.alpha_to_coverage = false;
  17. multisample_control.alpha_to_one = false;
  18. cull.enabled = false;
  19. cull.mode = GL_BACK;
  20. cull.front_face = GL_CCW;
  21. depth.test_enabled = false;
  22. depth.test_func = GL_LESS;
  23. depth.write_mask = GL_TRUE;
  24. primitive_restart.enabled = false;
  25. primitive_restart.index = 0;
  26. for (auto& item : color_mask) {
  27. item.red_enabled = GL_TRUE;
  28. item.green_enabled = GL_TRUE;
  29. item.blue_enabled = GL_TRUE;
  30. item.alpha_enabled = GL_TRUE;
  31. }
  32. stencil.test_enabled = false;
  33. auto reset_stencil = [](auto& config) {
  34. config.test_func = GL_ALWAYS;
  35. config.test_ref = 0;
  36. config.test_mask = 0xFFFFFFFF;
  37. config.write_mask = 0xFFFFFFFF;
  38. config.action_depth_fail = GL_KEEP;
  39. config.action_depth_pass = GL_KEEP;
  40. config.action_stencil_fail = GL_KEEP;
  41. };
  42. reset_stencil(stencil.front);
  43. reset_stencil(stencil.back);
  44. for (auto& item : viewports) {
  45. item.x = 0;
  46. item.y = 0;
  47. item.width = 0;
  48. item.height = 0;
  49. item.depth_range_near = 0.0f;
  50. item.depth_range_far = 1.0f;
  51. item.scissor.enabled = false;
  52. item.scissor.x = 0;
  53. item.scissor.y = 0;
  54. item.scissor.width = 0;
  55. item.scissor.height = 0;
  56. }
  57. for (auto& item : blend) {
  58. item.enabled = true;
  59. item.rgb_equation = GL_FUNC_ADD;
  60. item.a_equation = GL_FUNC_ADD;
  61. item.src_rgb_func = GL_ONE;
  62. item.dst_rgb_func = GL_ZERO;
  63. item.src_a_func = GL_ONE;
  64. item.dst_a_func = GL_ZERO;
  65. }
  66. independant_blend.enabled = false;
  67. blend_color.red = 0.0f;
  68. blend_color.green = 0.0f;
  69. blend_color.blue = 0.0f;
  70. blend_color.alpha = 0.0f;
  71. logic_op.enabled = false;
  72. logic_op.operation = GL_COPY;
  73. for (auto& texture_unit : texture_units) {
  74. texture_unit.Reset();
  75. }
  76. draw.read_framebuffer = 0;
  77. draw.draw_framebuffer = 0;
  78. draw.vertex_array = 0;
  79. draw.vertex_buffer = 0;
  80. draw.uniform_buffer = 0;
  81. draw.shader_program = 0;
  82. draw.program_pipeline = 0;
  83. clip_distance = {};
  84. point.size = 1;
  85. fragment_color_clamp.enabled = false;
  86. }
  87. void OpenGLState::ApplyDefaultState() {
  88. glDisable(GL_FRAMEBUFFER_SRGB);
  89. glDisable(GL_CULL_FACE);
  90. glDisable(GL_DEPTH_TEST);
  91. glDisable(GL_PRIMITIVE_RESTART);
  92. glDisable(GL_STENCIL_TEST);
  93. glEnable(GL_BLEND);
  94. glDisable(GL_COLOR_LOGIC_OP);
  95. glDisable(GL_SCISSOR_TEST);
  96. }
  97. void OpenGLState::ApplySRgb() const {
  98. // sRGB
  99. if (framebuffer_srgb.enabled != cur_state.framebuffer_srgb.enabled) {
  100. if (framebuffer_srgb.enabled) {
  101. // Track if sRGB is used
  102. s_rgb_used = true;
  103. glEnable(GL_FRAMEBUFFER_SRGB);
  104. } else {
  105. glDisable(GL_FRAMEBUFFER_SRGB);
  106. }
  107. }
  108. }
  109. void OpenGLState::ApplyCulling() const {
  110. // Culling
  111. const bool cull_changed = cull.enabled != cur_state.cull.enabled;
  112. if (cull_changed) {
  113. if (cull.enabled) {
  114. glEnable(GL_CULL_FACE);
  115. } else {
  116. glDisable(GL_CULL_FACE);
  117. }
  118. }
  119. if (cull.enabled) {
  120. if (cull_changed || cull.mode != cur_state.cull.mode) {
  121. glCullFace(cull.mode);
  122. }
  123. if (cull_changed || cull.front_face != cur_state.cull.front_face) {
  124. glFrontFace(cull.front_face);
  125. }
  126. }
  127. }
  128. void OpenGLState::ApplyColorMask() const {
  129. if (GLAD_GL_ARB_viewport_array && independant_blend.enabled) {
  130. for (size_t i = 0; i < Tegra::Engines::Maxwell3D::Regs::NumRenderTargets; i++) {
  131. const auto& updated = color_mask[i];
  132. const auto& current = cur_state.color_mask[i];
  133. if (updated.red_enabled != current.red_enabled ||
  134. updated.green_enabled != current.green_enabled ||
  135. updated.blue_enabled != current.blue_enabled ||
  136. updated.alpha_enabled != current.alpha_enabled) {
  137. glColorMaski(static_cast<GLuint>(i), updated.red_enabled, updated.green_enabled,
  138. updated.blue_enabled, updated.alpha_enabled);
  139. }
  140. }
  141. } else {
  142. const auto& updated = color_mask[0];
  143. const auto& current = cur_state.color_mask[0];
  144. if (updated.red_enabled != current.red_enabled ||
  145. updated.green_enabled != current.green_enabled ||
  146. updated.blue_enabled != current.blue_enabled ||
  147. updated.alpha_enabled != current.alpha_enabled) {
  148. glColorMask(updated.red_enabled, updated.green_enabled, updated.blue_enabled,
  149. updated.alpha_enabled);
  150. }
  151. }
  152. }
  153. void OpenGLState::ApplyDepth() const {
  154. // Depth test
  155. const bool depth_test_changed = depth.test_enabled != cur_state.depth.test_enabled;
  156. if (depth_test_changed) {
  157. if (depth.test_enabled) {
  158. glEnable(GL_DEPTH_TEST);
  159. } else {
  160. glDisable(GL_DEPTH_TEST);
  161. }
  162. }
  163. if (depth.test_enabled &&
  164. (depth_test_changed || depth.test_func != cur_state.depth.test_func)) {
  165. glDepthFunc(depth.test_func);
  166. }
  167. // Depth mask
  168. if (depth.write_mask != cur_state.depth.write_mask) {
  169. glDepthMask(depth.write_mask);
  170. }
  171. }
  172. void OpenGLState::ApplyPrimitiveRestart() const {
  173. const bool primitive_restart_changed =
  174. primitive_restart.enabled != cur_state.primitive_restart.enabled;
  175. if (primitive_restart_changed) {
  176. if (primitive_restart.enabled) {
  177. glEnable(GL_PRIMITIVE_RESTART);
  178. } else {
  179. glDisable(GL_PRIMITIVE_RESTART);
  180. }
  181. }
  182. if (primitive_restart_changed ||
  183. (primitive_restart.enabled &&
  184. primitive_restart.index != cur_state.primitive_restart.index)) {
  185. glPrimitiveRestartIndex(primitive_restart.index);
  186. }
  187. }
  188. void OpenGLState::ApplyStencilTest() const {
  189. const bool stencil_test_changed = stencil.test_enabled != cur_state.stencil.test_enabled;
  190. if (stencil_test_changed) {
  191. if (stencil.test_enabled) {
  192. glEnable(GL_STENCIL_TEST);
  193. } else {
  194. glDisable(GL_STENCIL_TEST);
  195. }
  196. }
  197. if (stencil.test_enabled) {
  198. auto config_stencil = [stencil_test_changed](GLenum face, const auto& config,
  199. const auto& prev_config) {
  200. if (stencil_test_changed || config.test_func != prev_config.test_func ||
  201. config.test_ref != prev_config.test_ref ||
  202. config.test_mask != prev_config.test_mask) {
  203. glStencilFuncSeparate(face, config.test_func, config.test_ref, config.test_mask);
  204. }
  205. if (stencil_test_changed || config.action_depth_fail != prev_config.action_depth_fail ||
  206. config.action_depth_pass != prev_config.action_depth_pass ||
  207. config.action_stencil_fail != prev_config.action_stencil_fail) {
  208. glStencilOpSeparate(face, config.action_stencil_fail, config.action_depth_fail,
  209. config.action_depth_pass);
  210. }
  211. if (config.write_mask != prev_config.write_mask) {
  212. glStencilMaskSeparate(face, config.write_mask);
  213. }
  214. };
  215. config_stencil(GL_FRONT, stencil.front, cur_state.stencil.front);
  216. config_stencil(GL_BACK, stencil.back, cur_state.stencil.back);
  217. }
  218. }
  219. void OpenGLState::ApplyViewport() const {
  220. if (GLAD_GL_ARB_viewport_array && geometry_shaders.enabled) {
  221. for (GLuint i = 0; i < static_cast<GLuint>(Tegra::Engines::Maxwell3D::Regs::NumViewports);
  222. i++) {
  223. const auto& current = cur_state.viewports[i];
  224. const auto& updated = viewports[i];
  225. if (updated.x != current.x || updated.y != current.y ||
  226. updated.width != current.width || updated.height != current.height) {
  227. glViewportIndexedf(i, updated.x, updated.y, updated.width, updated.height);
  228. }
  229. if (updated.depth_range_near != current.depth_range_near ||
  230. updated.depth_range_far != current.depth_range_far) {
  231. glDepthRangeIndexed(i, updated.depth_range_near, updated.depth_range_far);
  232. }
  233. const bool scissor_changed = updated.scissor.enabled != current.scissor.enabled;
  234. if (scissor_changed) {
  235. if (updated.scissor.enabled) {
  236. glEnablei(GL_SCISSOR_TEST, i);
  237. } else {
  238. glDisablei(GL_SCISSOR_TEST, i);
  239. }
  240. }
  241. if (updated.scissor.enabled &&
  242. (scissor_changed || updated.scissor.x != current.scissor.x ||
  243. updated.scissor.y != current.scissor.y ||
  244. updated.scissor.width != current.scissor.width ||
  245. updated.scissor.height != current.scissor.height)) {
  246. glScissorIndexed(i, updated.scissor.x, updated.scissor.y, updated.scissor.width,
  247. updated.scissor.height);
  248. }
  249. }
  250. } else {
  251. const auto& current = cur_state.viewports[0];
  252. const auto& updated = viewports[0];
  253. if (updated.x != current.x || updated.y != current.y || updated.width != current.width ||
  254. updated.height != current.height) {
  255. glViewport(static_cast<GLint>(updated.x), static_cast<GLint>(updated.y),
  256. static_cast<GLsizei>(updated.width), static_cast<GLsizei>(updated.height));
  257. }
  258. if (updated.depth_range_near != current.depth_range_near ||
  259. updated.depth_range_far != current.depth_range_far) {
  260. glDepthRange(updated.depth_range_near, updated.depth_range_far);
  261. }
  262. const bool scissor_changed = updated.scissor.enabled != current.scissor.enabled;
  263. if (scissor_changed) {
  264. if (updated.scissor.enabled) {
  265. glEnable(GL_SCISSOR_TEST);
  266. } else {
  267. glDisable(GL_SCISSOR_TEST);
  268. }
  269. }
  270. if (updated.scissor.enabled && (scissor_changed || updated.scissor.x != current.scissor.x ||
  271. updated.scissor.y != current.scissor.y ||
  272. updated.scissor.width != current.scissor.width ||
  273. updated.scissor.height != current.scissor.height)) {
  274. glScissor(updated.scissor.x, updated.scissor.y, updated.scissor.width,
  275. updated.scissor.height);
  276. }
  277. }
  278. }
  279. void OpenGLState::ApplyGlobalBlending() const {
  280. const Blend& current = cur_state.blend[0];
  281. const Blend& updated = blend[0];
  282. const bool blend_changed = updated.enabled != current.enabled;
  283. if (blend_changed) {
  284. if (updated.enabled) {
  285. glEnable(GL_BLEND);
  286. } else {
  287. glDisable(GL_BLEND);
  288. }
  289. }
  290. if (!updated.enabled) {
  291. return;
  292. }
  293. if (blend_changed || updated.src_rgb_func != current.src_rgb_func ||
  294. updated.dst_rgb_func != current.dst_rgb_func || updated.src_a_func != current.src_a_func ||
  295. updated.dst_a_func != current.dst_a_func) {
  296. glBlendFuncSeparate(updated.src_rgb_func, updated.dst_rgb_func, updated.src_a_func,
  297. updated.dst_a_func);
  298. }
  299. if (blend_changed || updated.rgb_equation != current.rgb_equation ||
  300. updated.a_equation != current.a_equation) {
  301. glBlendEquationSeparate(updated.rgb_equation, updated.a_equation);
  302. }
  303. }
  304. void OpenGLState::ApplyTargetBlending(std::size_t target, bool force) const {
  305. const Blend& updated = blend[target];
  306. const Blend& current = cur_state.blend[target];
  307. const bool blend_changed = updated.enabled != current.enabled || force;
  308. if (blend_changed) {
  309. if (updated.enabled) {
  310. glEnablei(GL_BLEND, static_cast<GLuint>(target));
  311. } else {
  312. glDisablei(GL_BLEND, static_cast<GLuint>(target));
  313. }
  314. }
  315. if (!updated.enabled) {
  316. return;
  317. }
  318. if (blend_changed || updated.src_rgb_func != current.src_rgb_func ||
  319. updated.dst_rgb_func != current.dst_rgb_func || updated.src_a_func != current.src_a_func ||
  320. updated.dst_a_func != current.dst_a_func) {
  321. glBlendFuncSeparatei(static_cast<GLuint>(target), updated.src_rgb_func,
  322. updated.dst_rgb_func, updated.src_a_func, updated.dst_a_func);
  323. }
  324. if (blend_changed || updated.rgb_equation != current.rgb_equation ||
  325. updated.a_equation != current.a_equation) {
  326. glBlendEquationSeparatei(static_cast<GLuint>(target), updated.rgb_equation,
  327. updated.a_equation);
  328. }
  329. }
  330. void OpenGLState::ApplyBlending() const {
  331. if (independant_blend.enabled) {
  332. for (size_t i = 0; i < Tegra::Engines::Maxwell3D::Regs::NumRenderTargets; i++) {
  333. ApplyTargetBlending(i,
  334. independant_blend.enabled != cur_state.independant_blend.enabled);
  335. }
  336. } else {
  337. ApplyGlobalBlending();
  338. }
  339. if (blend_color.red != cur_state.blend_color.red ||
  340. blend_color.green != cur_state.blend_color.green ||
  341. blend_color.blue != cur_state.blend_color.blue ||
  342. blend_color.alpha != cur_state.blend_color.alpha) {
  343. glBlendColor(blend_color.red, blend_color.green, blend_color.blue, blend_color.alpha);
  344. }
  345. }
  346. void OpenGLState::ApplyLogicOp() const {
  347. const bool logic_op_changed = logic_op.enabled != cur_state.logic_op.enabled;
  348. if (logic_op_changed) {
  349. if (logic_op.enabled) {
  350. glEnable(GL_COLOR_LOGIC_OP);
  351. } else {
  352. glDisable(GL_COLOR_LOGIC_OP);
  353. }
  354. }
  355. if (logic_op.enabled &&
  356. (logic_op_changed || logic_op.operation != cur_state.logic_op.operation)) {
  357. glLogicOp(logic_op.operation);
  358. }
  359. }
  360. void OpenGLState::ApplyTextures() const {
  361. for (std::size_t i = 0; i < std::size(texture_units); ++i) {
  362. const auto& texture_unit = texture_units[i];
  363. const auto& cur_state_texture_unit = cur_state.texture_units[i];
  364. if (texture_unit.texture != cur_state_texture_unit.texture) {
  365. glActiveTexture(TextureUnits::MaxwellTexture(static_cast<int>(i)).Enum());
  366. glBindTexture(texture_unit.target, texture_unit.texture);
  367. }
  368. // Update the texture swizzle
  369. if (texture_unit.swizzle.r != cur_state_texture_unit.swizzle.r ||
  370. texture_unit.swizzle.g != cur_state_texture_unit.swizzle.g ||
  371. texture_unit.swizzle.b != cur_state_texture_unit.swizzle.b ||
  372. texture_unit.swizzle.a != cur_state_texture_unit.swizzle.a) {
  373. std::array<GLint, 4> mask = {texture_unit.swizzle.r, texture_unit.swizzle.g,
  374. texture_unit.swizzle.b, texture_unit.swizzle.a};
  375. glTexParameteriv(texture_unit.target, GL_TEXTURE_SWIZZLE_RGBA, mask.data());
  376. }
  377. }
  378. }
  379. void OpenGLState::ApplySamplers() const {
  380. bool has_delta{};
  381. std::size_t first{}, last{};
  382. std::array<GLuint, Tegra::Engines::Maxwell3D::Regs::NumTextureSamplers> samplers;
  383. for (std::size_t i = 0; i < std::size(samplers); ++i) {
  384. samplers[i] = texture_units[i].sampler;
  385. if (samplers[i] != cur_state.texture_units[i].sampler) {
  386. if (!has_delta) {
  387. first = i;
  388. has_delta = true;
  389. }
  390. last = i;
  391. }
  392. }
  393. if (has_delta) {
  394. glBindSamplers(static_cast<GLuint>(first), static_cast<GLsizei>(last - first + 1),
  395. samplers.data());
  396. }
  397. }
  398. void OpenGLState::ApplyFramebufferState() const {
  399. // Framebuffer
  400. if (draw.read_framebuffer != cur_state.draw.read_framebuffer) {
  401. glBindFramebuffer(GL_READ_FRAMEBUFFER, draw.read_framebuffer);
  402. }
  403. if (draw.draw_framebuffer != cur_state.draw.draw_framebuffer) {
  404. glBindFramebuffer(GL_DRAW_FRAMEBUFFER, draw.draw_framebuffer);
  405. }
  406. }
  407. void OpenGLState::ApplyVertexBufferState() const {
  408. // Vertex array
  409. if (draw.vertex_array != cur_state.draw.vertex_array) {
  410. glBindVertexArray(draw.vertex_array);
  411. }
  412. // Vertex buffer
  413. if (draw.vertex_buffer != cur_state.draw.vertex_buffer) {
  414. glBindBuffer(GL_ARRAY_BUFFER, draw.vertex_buffer);
  415. }
  416. }
  417. void OpenGLState::Apply() const {
  418. ApplyFramebufferState();
  419. ApplyVertexBufferState();
  420. // Uniform buffer
  421. if (draw.uniform_buffer != cur_state.draw.uniform_buffer) {
  422. glBindBuffer(GL_UNIFORM_BUFFER, draw.uniform_buffer);
  423. }
  424. // Shader program
  425. if (draw.shader_program != cur_state.draw.shader_program) {
  426. glUseProgram(draw.shader_program);
  427. }
  428. // Program pipeline
  429. if (draw.program_pipeline != cur_state.draw.program_pipeline) {
  430. glBindProgramPipeline(draw.program_pipeline);
  431. }
  432. // Clip distance
  433. for (std::size_t i = 0; i < clip_distance.size(); ++i) {
  434. if (clip_distance[i] != cur_state.clip_distance[i]) {
  435. if (clip_distance[i]) {
  436. glEnable(GL_CLIP_DISTANCE0 + static_cast<GLenum>(i));
  437. } else {
  438. glDisable(GL_CLIP_DISTANCE0 + static_cast<GLenum>(i));
  439. }
  440. }
  441. }
  442. // Point
  443. if (point.size != cur_state.point.size) {
  444. glPointSize(point.size);
  445. }
  446. if (GLAD_GL_ARB_color_buffer_float) {
  447. if (fragment_color_clamp.enabled != cur_state.fragment_color_clamp.enabled) {
  448. glClampColor(GL_CLAMP_FRAGMENT_COLOR_ARB,
  449. fragment_color_clamp.enabled ? GL_TRUE : GL_FALSE);
  450. }
  451. }
  452. if (multisample_control.alpha_to_coverage != cur_state.multisample_control.alpha_to_coverage) {
  453. if (multisample_control.alpha_to_coverage) {
  454. glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE);
  455. } else {
  456. glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE);
  457. }
  458. }
  459. if (multisample_control.alpha_to_one != cur_state.multisample_control.alpha_to_one) {
  460. if (multisample_control.alpha_to_one) {
  461. glEnable(GL_SAMPLE_ALPHA_TO_ONE);
  462. } else {
  463. glDisable(GL_SAMPLE_ALPHA_TO_ONE);
  464. }
  465. }
  466. ApplyColorMask();
  467. ApplyViewport();
  468. ApplyStencilTest();
  469. ApplySRgb();
  470. ApplyCulling();
  471. ApplyDepth();
  472. ApplyPrimitiveRestart();
  473. ApplyBlending();
  474. ApplyLogicOp();
  475. ApplyTextures();
  476. ApplySamplers();
  477. cur_state = *this;
  478. }
  479. OpenGLState& OpenGLState::UnbindTexture(GLuint handle) {
  480. for (auto& unit : texture_units) {
  481. if (unit.texture == handle) {
  482. unit.Unbind();
  483. }
  484. }
  485. return *this;
  486. }
  487. OpenGLState& OpenGLState::ResetSampler(GLuint handle) {
  488. for (auto& unit : texture_units) {
  489. if (unit.sampler == handle) {
  490. unit.sampler = 0;
  491. }
  492. }
  493. return *this;
  494. }
  495. OpenGLState& OpenGLState::ResetProgram(GLuint handle) {
  496. if (draw.shader_program == handle) {
  497. draw.shader_program = 0;
  498. }
  499. return *this;
  500. }
  501. OpenGLState& OpenGLState::ResetPipeline(GLuint handle) {
  502. if (draw.program_pipeline == handle) {
  503. draw.program_pipeline = 0;
  504. }
  505. return *this;
  506. }
  507. OpenGLState& OpenGLState::ResetBuffer(GLuint handle) {
  508. if (draw.vertex_buffer == handle) {
  509. draw.vertex_buffer = 0;
  510. }
  511. if (draw.uniform_buffer == handle) {
  512. draw.uniform_buffer = 0;
  513. }
  514. return *this;
  515. }
  516. OpenGLState& OpenGLState::ResetVertexArray(GLuint handle) {
  517. if (draw.vertex_array == handle) {
  518. draw.vertex_array = 0;
  519. }
  520. return *this;
  521. }
  522. OpenGLState& OpenGLState::ResetFramebuffer(GLuint handle) {
  523. if (draw.read_framebuffer == handle) {
  524. draw.read_framebuffer = 0;
  525. }
  526. if (draw.draw_framebuffer == handle) {
  527. draw.draw_framebuffer = 0;
  528. }
  529. return *this;
  530. }
  531. } // namespace OpenGL