///////////////////////////////////////////////////////
| 571 | |
| 572 | //////////////////////////////////////////////////////////// |
| 573 | void RenderTarget::resetGLStates() |
| 574 | { |
| 575 | // Check here to make sure a context change does not happen after activate(true) |
| 576 | const bool shaderAvailable = Shader::isAvailable(); |
| 577 | const bool vertexBufferAvailable = VertexBuffer::isAvailable(); |
| 578 | |
| 579 | // Workaround for states not being properly reset on |
| 580 | // macOS unless a context switch really takes place |
| 581 | #if defined(SFML_SYSTEM_MACOS) |
| 582 | if (!setActive(false)) |
| 583 | { |
| 584 | err() << "Failed to set render target inactive" << std::endl; |
| 585 | } |
| 586 | #endif |
| 587 | |
| 588 | if (RenderTargetImpl::isActive(m_id) || setActive(true)) |
| 589 | { |
| 590 | // Make sure that extensions are initialized |
| 591 | priv::ensureExtensionsInit(); |
| 592 | |
| 593 | // Make sure that the texture unit which is active is the number 0 |
| 594 | if (GLEXT_multitexture) |
| 595 | { |
| 596 | glCheck(GLEXT_glClientActiveTexture(GLEXT_GL_TEXTURE0)); |
| 597 | glCheck(GLEXT_glActiveTexture(GLEXT_GL_TEXTURE0)); |
| 598 | } |
| 599 | |
| 600 | // Define the default OpenGL states |
| 601 | glCheck(glDisable(GL_CULL_FACE)); |
| 602 | glCheck(glDisable(GL_LIGHTING)); |
| 603 | glCheck(glDisable(GL_STENCIL_TEST)); |
| 604 | glCheck(glDisable(GL_DEPTH_TEST)); |
| 605 | glCheck(glDisable(GL_ALPHA_TEST)); |
| 606 | glCheck(glDisable(GL_SCISSOR_TEST)); |
| 607 | glCheck(glEnable(GL_TEXTURE_2D)); |
| 608 | glCheck(glEnable(GL_BLEND)); |
| 609 | glCheck(glMatrixMode(GL_MODELVIEW)); |
| 610 | glCheck(glLoadIdentity()); |
| 611 | glCheck(glEnableClientState(GL_VERTEX_ARRAY)); |
| 612 | glCheck(glEnableClientState(GL_COLOR_ARRAY)); |
| 613 | glCheck(glEnableClientState(GL_TEXTURE_COORD_ARRAY)); |
| 614 | glCheck(glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE)); |
| 615 | m_cache.scissorEnabled = false; |
| 616 | m_cache.stencilEnabled = false; |
| 617 | m_cache.glStatesSet = true; |
| 618 | |
| 619 | // Apply the default SFML states |
| 620 | applyBlendMode(BlendAlpha); |
| 621 | applyStencilMode(StencilMode()); |
| 622 | applyTexture(nullptr); |
| 623 | if (shaderAvailable) |
| 624 | applyShader(nullptr); |
| 625 | |
| 626 | if (vertexBufferAvailable) |
| 627 | glCheck(VertexBuffer::bind(nullptr)); |
| 628 | |
| 629 | m_cache.texCoordsArrayEnabled = true; |
| 630 |
nothing calls this directly
no test coverage detected