From 88a59374bca37567803bcc4c56942af39ad1c34d Mon Sep 17 00:00:00 2001 From: Zachariah Brown Date: Tue, 31 Mar 2015 08:14:32 -0400 Subject: [PATCH] Added support for context creation flags and texture/shader native handles --- include/SFML/Graphics/Shader.h | 14 ++++++++++++++ include/SFML/Graphics/Texture.h | 14 ++++++++++++++ include/SFML/Window/Window.h | 13 +++++++++++++ src/SFML/Graphics/RenderWindow.cpp | 4 ++++ src/SFML/Graphics/Shader.cpp | 7 +++++++ src/SFML/Graphics/Texture.cpp | 7 +++++++ src/SFML/Window/Window.cpp | 4 ++++ 7 files changed, 63 insertions(+) diff --git a/include/SFML/Graphics/Shader.h b/include/SFML/Graphics/Shader.h index 0a9746a..7172c51 100644 --- a/include/SFML/Graphics/Shader.h +++ b/include/SFML/Graphics/Shader.h @@ -349,6 +349,20 @@ CSFML_GRAPHICS_API void sfShader_setTextureParameter(sfShader* shader, const cha //////////////////////////////////////////////////////////// CSFML_GRAPHICS_API void sfShader_setCurrentTextureParameter(sfShader* shader, const char* name); +//////////////////////////////////////////////////////////// +/// \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. +/// +/// \param shader Shader object +/// +/// \return OpenGL handle of the shader or 0 if not yet loaded +/// +//////////////////////////////////////////////////////////// +CSFML_GRAPHICS_API unsigned int sfShader_getNativeHandle(const sfShader* shader); + //////////////////////////////////////////////////////////// /// \brief Bind a shader for rendering (activate it) /// diff --git a/include/SFML/Graphics/Texture.h b/include/SFML/Graphics/Texture.h index 395cf61..4f4f094 100644 --- a/include/SFML/Graphics/Texture.h +++ b/include/SFML/Graphics/Texture.h @@ -229,6 +229,20 @@ CSFML_GRAPHICS_API void sfTexture_setRepeated(sfTexture* texture, sfBool repeate //////////////////////////////////////////////////////////// CSFML_GRAPHICS_API sfBool sfTexture_isRepeated(const sfTexture* texture); +//////////////////////////////////////////////////////////// +/// \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. +/// +/// \param texture The texture object +/// +/// \return OpenGL handle of the texture or 0 if not yet created +/// +//////////////////////////////////////////////////////////// +CSFML_GRAPHICS_API unsigned int sfTexture_getNativeHandle(const sfTexture* texture); + //////////////////////////////////////////////////////////// /// \brief Bind a texture for rendering /// diff --git a/include/SFML/Window/Window.h b/include/SFML/Window/Window.h index b4d23b1..8ccdb0c 100644 --- a/include/SFML/Window/Window.h +++ b/include/SFML/Window/Window.h @@ -51,6 +51,18 @@ typedef enum } sfWindowStyle; +//////////////////////////////////////////////////////////// +/// \brief Enumeration of the context attribute flags +/// +//////////////////////////////////////////////////////////// +typedef enum +{ + sfContextDefault = 0, ///< Non-debug, compatibility context (this and the core attribute are mutually exclusive) + sfContextCore = 1 << 0, ///< Core attribute + sfContextDebug = 1 << 2 ///< Debug attribute +} sfContextAttribute; + + //////////////////////////////////////////////////////////// /// \brief Structure defining the window's creation settings /// @@ -62,6 +74,7 @@ typedef struct unsigned int antialiasingLevel; ///< Level of antialiasing unsigned int majorVersion; ///< Major number of the context version to create unsigned int minorVersion; ///< Minor number of the context version to create + sfUint32 attributeFlags; ///< The attribute flags to create the context with } sfContextSettings; diff --git a/src/SFML/Graphics/RenderWindow.cpp b/src/SFML/Graphics/RenderWindow.cpp index 61d8636..a72e528 100644 --- a/src/SFML/Graphics/RenderWindow.cpp +++ b/src/SFML/Graphics/RenderWindow.cpp @@ -56,6 +56,7 @@ sfRenderWindow* sfRenderWindow_create(sfVideoMode mode, const char* title, sfUin params.antialiasingLevel = settings->antialiasingLevel; params.majorVersion = settings->majorVersion; params.minorVersion = settings->minorVersion; + params.attributeFlags = settings->attributeFlags; } // Create the window @@ -82,6 +83,7 @@ sfRenderWindow* sfRenderWindow_createUnicode(sfVideoMode mode, const sfUint32* t params.antialiasingLevel = settings->antialiasingLevel; params.majorVersion = settings->majorVersion; params.minorVersion = settings->minorVersion; + params.attributeFlags = settings->attributeFlags; } // Create the window @@ -106,6 +108,7 @@ sfRenderWindow* sfRenderWindow_createFromHandle(sfWindowHandle handle, const sfC params.antialiasingLevel = settings->antialiasingLevel; params.majorVersion = settings->majorVersion; params.minorVersion = settings->minorVersion; + params.attributeFlags = settings->attributeFlags; } // Create the window @@ -151,6 +154,7 @@ sfContextSettings sfRenderWindow_getSettings(const sfRenderWindow* renderWindow) settings.antialiasingLevel = params.antialiasingLevel; settings.majorVersion = params.majorVersion; settings.minorVersion = params.minorVersion; + settings.attributeFlags = params.attributeFlags; return settings; } diff --git a/src/SFML/Graphics/Shader.cpp b/src/SFML/Graphics/Shader.cpp index 604b36b..e90da6d 100644 --- a/src/SFML/Graphics/Shader.cpp +++ b/src/SFML/Graphics/Shader.cpp @@ -217,6 +217,13 @@ void sfShader_setCurrentTextureParameter(sfShader* shader, const char* name) } +//////////////////////////////////////////////////////////// +unsigned int sfShader_getNativeHandle(const sfShader* shader) +{ + CSFML_CALL_RETURN(shader, getNativeHandle(), 0); +} + + //////////////////////////////////////////////////////////// void sfShader_bind(const sfShader* shader) { diff --git a/src/SFML/Graphics/Texture.cpp b/src/SFML/Graphics/Texture.cpp index 72b2bde..efe328f 100644 --- a/src/SFML/Graphics/Texture.cpp +++ b/src/SFML/Graphics/Texture.cpp @@ -242,6 +242,13 @@ sfBool sfTexture_isRepeated(const sfTexture* texture) } +//////////////////////////////////////////////////////////// +unsigned int sfTexture_getNativeHandle(const sfTexture* texture) +{ + CSFML_CALL_PTR_RETURN(texture, getNativeHandle(), 0); +} + + //////////////////////////////////////////////////////////// void sfTexture_bind(const sfTexture* texture) { diff --git a/src/SFML/Window/Window.cpp b/src/SFML/Window/Window.cpp index 28bc4b1..6507a3d 100644 --- a/src/SFML/Window/Window.cpp +++ b/src/SFML/Window/Window.cpp @@ -46,6 +46,7 @@ sfWindow* sfWindow_create(sfVideoMode mode, const char* title, sfUint32 style, c params.antialiasingLevel = settings->antialiasingLevel; params.majorVersion = settings->majorVersion; params.minorVersion = settings->minorVersion; + params.attributeFlags = settings->attributeFlags; } // Create the window @@ -70,6 +71,7 @@ sfWindow* sfWindow_createUnicode(sfVideoMode mode, const sfUint32* title, sfUint params.antialiasingLevel = settings->antialiasingLevel; params.majorVersion = settings->majorVersion; params.minorVersion = settings->minorVersion; + params.attributeFlags = settings->attributeFlags; } // Create the window @@ -92,6 +94,7 @@ sfWindow* sfWindow_createFromHandle(sfWindowHandle handle, const sfContextSettin params.antialiasingLevel = settings->antialiasingLevel; params.majorVersion = settings->majorVersion; params.minorVersion = settings->minorVersion; + params.attributeFlags = settings->attributeFlags; } // Create the window @@ -134,6 +137,7 @@ sfContextSettings sfWindow_getSettings(const sfWindow* window) settings.antialiasingLevel = params.antialiasingLevel; settings.majorVersion = params.majorVersion; settings.minorVersion = params.minorVersion; + settings.attributeFlags = params.attributeFlags; return settings; }