From 1c3425744b405213335d40e08cc58d1ffcdd2302 Mon Sep 17 00:00:00 2001 From: binary1248 Date: Fri, 15 Aug 2014 07:13:32 +0200 Subject: [PATCH] Implemented methods to retrieve the OpenGL handles from sf::Texture and sf::Shader. --- include/SFML/Graphics/Shader.hpp | 12 ++++++++++++ include/SFML/Graphics/Texture.hpp | 12 ++++++++++++ src/SFML/Graphics/Shader.cpp | 7 +++++++ src/SFML/Graphics/Texture.cpp | 7 +++++++ 4 files changed, 38 insertions(+) diff --git a/include/SFML/Graphics/Shader.hpp b/include/SFML/Graphics/Shader.hpp index 028dd7270e..b042248386 100644 --- a/include/SFML/Graphics/Shader.hpp +++ b/include/SFML/Graphics/Shader.hpp @@ -456,6 +456,18 @@ public : //////////////////////////////////////////////////////////// void setParameter(const std::string& name, CurrentTextureType); + //////////////////////////////////////////////////////////// + /// \brief Get the underlying OpenGL handle of the shader. + /// + /// You shouldn't need to use this function, unless you have + /// very specific stuff to implement that SFML doesn't support, + /// or implement a temporary workaround until a bug is fixed. + /// + /// \return OpenGL handle of the shader or 0 if not yet loaded + /// + //////////////////////////////////////////////////////////// + unsigned int getNativeHandle() const; + //////////////////////////////////////////////////////////// /// \brief Bind a shader for rendering /// diff --git a/include/SFML/Graphics/Texture.hpp b/include/SFML/Graphics/Texture.hpp index 8fde8ec0af..5e7c37aa96 100644 --- a/include/SFML/Graphics/Texture.hpp +++ b/include/SFML/Graphics/Texture.hpp @@ -420,6 +420,18 @@ public : //////////////////////////////////////////////////////////// Texture& operator =(const Texture& right); + //////////////////////////////////////////////////////////// + /// \brief Get the underlying OpenGL handle of the texture. + /// + /// You shouldn't need to use this function, unless you have + /// very specific stuff to implement that SFML doesn't support, + /// or implement a temporary workaround until a bug is fixed. + /// + /// \return OpenGL handle of the texture or 0 if not yet created + /// + //////////////////////////////////////////////////////////// + unsigned int getNativeHandle() const; + //////////////////////////////////////////////////////////// /// \brief Bind a texture for rendering /// diff --git a/src/SFML/Graphics/Shader.cpp b/src/SFML/Graphics/Shader.cpp index 91c5f716e6..442658e271 100644 --- a/src/SFML/Graphics/Shader.cpp +++ b/src/SFML/Graphics/Shader.cpp @@ -458,6 +458,13 @@ void Shader::setParameter(const std::string& name, CurrentTextureType) } +//////////////////////////////////////////////////////////// +unsigned int Shader::getNativeHandle() const +{ + return m_shaderProgram; +} + + //////////////////////////////////////////////////////////// void Shader::bind(const Shader* shader) { diff --git a/src/SFML/Graphics/Texture.cpp b/src/SFML/Graphics/Texture.cpp index a0d0cfa4d7..dd4baa86c2 100644 --- a/src/SFML/Graphics/Texture.cpp +++ b/src/SFML/Graphics/Texture.cpp @@ -571,6 +571,13 @@ Texture& Texture::operator =(const Texture& right) } +//////////////////////////////////////////////////////////// +unsigned int Texture::getNativeHandle() const +{ + return m_texture; +} + + //////////////////////////////////////////////////////////// unsigned int Texture::getValidSize(unsigned int size) {