FS#25 - Change sf::PostFx to a more general purpose pixel shader class (sf::Shader)
Updated the PostFx sample, renamed to Shader Renamed all the static X::CanUseX() functions to X::IsAvailable() to make the API more consistent Moved .def files from /build/VC200X to /src in CSFML Minors fixes in CSFML git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1258 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
parent
63e07cec84
commit
d7bd00afc0
125 changed files with 1606 additions and 2348 deletions
|
@ -31,10 +31,12 @@
|
|||
|
||||
#include <SFML/Window.h>
|
||||
#include <SFML/Graphics/Color.h>
|
||||
#include <SFML/Graphics/Font.h>
|
||||
#include <SFML/Graphics/Image.h>
|
||||
#include <SFML/Graphics/PostFX.h>
|
||||
#include <SFML/Graphics/Rect.h>
|
||||
#include <SFML/Graphics/RenderWindow.h>
|
||||
#include <SFML/Graphics/RenderImage.h>
|
||||
#include <SFML/Graphics/Shader.h>
|
||||
#include <SFML/Graphics/Shape.h>
|
||||
#include <SFML/Graphics/Sprite.h>
|
||||
#include <SFML/Graphics/String.h>
|
||||
|
|
|
@ -112,15 +112,26 @@ CSFML_API void sfRenderImage_Display(sfRenderImage* renderImage);
|
|||
////////////////////////////////////////////////////////////
|
||||
/// Draw something on a renderimage
|
||||
///
|
||||
/// \param renderImage : Renderimage to draw in
|
||||
/// \param postFX / sprite / string / shape : Object to draw
|
||||
/// \param renderImage : Renderimage to draw in
|
||||
/// \param sprite / string / shape : Object to draw
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
CSFML_API void sfRenderImage_DrawPostFX(sfRenderImage* renderImage, sfPostFX* postFX);
|
||||
CSFML_API void sfRenderImage_DrawSprite(sfRenderImage* renderImage, sfSprite* sprite);
|
||||
CSFML_API void sfRenderImage_DrawShape (sfRenderImage* renderImage, sfShape* shape);
|
||||
CSFML_API void sfRenderImage_DrawString(sfRenderImage* renderImage, sfString* string);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Draw something on a renderimage with a shader
|
||||
///
|
||||
/// \param renderImage : Renderimage to draw in
|
||||
/// \param sprite / string / shape : Object to draw
|
||||
/// \param shader : Shader to use
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
CSFML_API void sfRenderImage_DrawSpriteWithShader(sfRenderImage* renderImage, sfSprite* sprite, sfShader* shader);
|
||||
CSFML_API void sfRenderImage_DrawShapeWithShader (sfRenderImage* renderImage, sfShape* shape, sfShader* shader);
|
||||
CSFML_API void sfRenderImage_DrawStringWithShader(sfRenderImage* renderImage, sfString* string, sfShader* shader);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Clear the renderimage with the given color
|
||||
///
|
||||
|
@ -199,7 +210,7 @@ CSFML_API sfImage* sfRenderImage_GetImage(sfRenderImage* renderImage);
|
|||
/// \return sfTrue if the RenderImage class can be used
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
CSFML_API sfBool sfRenderImage_CanUseRenderImage();
|
||||
CSFML_API sfBool sfRenderImage_IsAvailable();
|
||||
|
||||
|
||||
#endif // SFML_RENDERIMAGE_H
|
||||
|
|
|
@ -292,15 +292,26 @@ CSFML_API void sfRenderWindow_SetJoystickThreshold(sfRenderWindow* renderWindow,
|
|||
////////////////////////////////////////////////////////////
|
||||
/// Draw something on a renderwindow
|
||||
///
|
||||
/// \param renderWindow : Renderwindow to draw in
|
||||
/// \param postFX / sprite / string / shape : Object to draw
|
||||
/// \param renderWindow : Renderwindow to draw in
|
||||
/// \param sprite / string / shape : Object to draw
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
CSFML_API void sfRenderWindow_DrawPostFX(sfRenderWindow* renderWindow, sfPostFX* postFX);
|
||||
CSFML_API void sfRenderWindow_DrawSprite(sfRenderWindow* renderWindow, sfSprite* sprite);
|
||||
CSFML_API void sfRenderWindow_DrawShape (sfRenderWindow* renderWindow, sfShape* shape);
|
||||
CSFML_API void sfRenderWindow_DrawString(sfRenderWindow* renderWindow, sfString* string);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Draw something on a renderwindow with a shader
|
||||
///
|
||||
/// \param renderWindow : Renderwindow to draw in
|
||||
/// \param sprite / string / shape : Object to draw
|
||||
/// \param shader : Shader to use
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
CSFML_API void sfRenderWindow_DrawSpriteWithShader(sfRenderWindow* renderWindow, sfSprite* sprite, sfShader* shader);
|
||||
CSFML_API void sfRenderWindow_DrawShapeWithShader (sfRenderWindow* renderWindow, sfShape* shape, sfShader* shader);
|
||||
CSFML_API void sfRenderWindow_DrawStringWithShader(sfRenderWindow* renderWindow, sfString* string, sfShader* shader);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Clear the screen with the given color
|
||||
///
|
||||
|
|
|
@ -22,8 +22,8 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef SFML_POSTFX_H
|
||||
#define SFML_POSTFX_H
|
||||
#ifndef SFML_SHADER_H
|
||||
#define SFML_SHADER_H
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Headers
|
||||
|
@ -33,90 +33,106 @@
|
|||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Create a new post-fx from a file
|
||||
/// Create a new shader from a file
|
||||
///
|
||||
/// \param filename : File to load
|
||||
///
|
||||
/// \return A new sfPostFX object, or NULL if it failed
|
||||
/// \return A new sfShader object, or NULL if it failed
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
CSFML_API sfPostFX* sfPostFX_CreateFromFile(const char* Filename);
|
||||
CSFML_API sfShader* sfShader_CreateFromFile(const char* Filename);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Create a new post-fx from an effect source code
|
||||
/// Create a new shader from an effect source code
|
||||
///
|
||||
/// \param effect : Source code of the effect
|
||||
///
|
||||
/// \return A new sfPostFX object, or NULL if it failed
|
||||
/// \return A new sfShader object, or NULL if it failed
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
CSFML_API sfPostFX* sfPostFX_CreateFromMemory(const char* effect);
|
||||
CSFML_API sfShader* sfShader_CreateFromMemory(const char* effect);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Destroy an existing post-fx
|
||||
/// Destroy an existing shader
|
||||
///
|
||||
/// \param postFX : PostFX to delete
|
||||
/// \param shader : Shader to delete
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
CSFML_API void sfPostFX_Destroy(sfPostFX* postFX);
|
||||
CSFML_API void sfShader_Destroy(sfShader* shader);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Change a parameter of a post-fx (1 float)
|
||||
/// Change a parameter of a shader (1 float)
|
||||
///
|
||||
/// \param postFX : Post-effect to modify
|
||||
/// \param shader : Shader to modify
|
||||
/// \param name : Parameter name in the effect
|
||||
/// \param x : Value to assign
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
CSFML_API void sfPostFX_SetParameter1(sfPostFX* postFX, const char* name, float x);
|
||||
CSFML_API void sfShader_SetParameter1(sfShader* shader, const char* name, float x);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Change a parameter of a post-fx (2 floats)
|
||||
/// Change a parameter of a shader (2 floats)
|
||||
///
|
||||
/// \param postFX : Post-effect to modify
|
||||
/// \param shader : Shader to modify
|
||||
/// \param name : Parameter name in the effect
|
||||
/// \param x, y : Values to assign
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
CSFML_API void sfPostFX_SetParameter2(sfPostFX* postFX, const char* name, float x, float y);
|
||||
CSFML_API void sfShader_SetParameter2(sfShader* shader, const char* name, float x, float y);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Change a parameter of a post-fx (3 floats)
|
||||
/// Change a parameter of a shader (3 floats)
|
||||
///
|
||||
/// \param postFX : Post-effect to modify
|
||||
/// \param shader : Shader to modify
|
||||
/// \param name : Parameter name in the effect
|
||||
/// \param x, y, z : Values to assign
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
CSFML_API void sfPostFX_SetParameter3(sfPostFX* postFX, const char* name, float x, float y, float z);
|
||||
CSFML_API void sfShader_SetParameter3(sfShader* shader, const char* name, float x, float y, float z);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Change a parameter of a post-fx (4 floats)
|
||||
/// Change a parameter of a shader (4 floats)
|
||||
///
|
||||
/// \param postFX : Post-effect to modify
|
||||
/// \param shader : Shader to modify
|
||||
/// \param name : Parameter name in the effect
|
||||
/// \param x, y, z, w : Values to assign
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
CSFML_API void sfPostFX_SetParameter4(sfPostFX* postFX, const char* name, float x, float y, float z, float w);
|
||||
CSFML_API void sfShader_SetParameter4(sfShader* shader, const char* name, float x, float y, float z, float w);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Set a texture parameter in a post-fx
|
||||
/// Set a texture parameter in a shader
|
||||
///
|
||||
/// \param postFX : Post-effect to modify
|
||||
/// \param shader : Shader to modify
|
||||
/// \param name : Texture name in the effect
|
||||
/// \param texture : Image to set (pass NULL to use content of current framebuffer)
|
||||
/// \param texture : Image to set (pass NULL to use the texture of the object being drawn)
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
CSFML_API void sfPostFX_SetTexture(sfPostFX* postFX, const char* name, sfImage* texture);
|
||||
CSFML_API void sfShader_SetTexture(sfShader* shader, const char* name, sfImage* texture);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Tell whether or not the system supports post-effects
|
||||
/// Bind a shader for rendering
|
||||
///
|
||||
/// \return sfTrue if the system can use post-effects
|
||||
/// \param shader : Shader to bind
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
CSFML_API sfBool sfPostFX_CanUsePostFX();
|
||||
CSFML_API void sfShader_Bind(sfShader* shader);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Unbind a shader
|
||||
///
|
||||
/// \param shader : Shader to unbind
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
CSFML_API void sfShader_Unbind(sfShader* shader);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Tell whether or not the system supports shaders
|
||||
///
|
||||
/// \return sfTrue if the system can use shaders
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
CSFML_API sfBool sfShader_IsAvailable();
|
||||
|
||||
|
||||
#endif // SFML_POSTFX_H
|
||||
#endif // SFML_SHADER_H
|
|
@ -28,7 +28,7 @@
|
|||
|
||||
typedef struct sfFont sfFont;
|
||||
typedef struct sfImage sfImage;
|
||||
typedef struct sfPostFX sfPostFX;
|
||||
typedef struct sfShader sfShader;
|
||||
typedef struct sfRenderImage sfRenderImage;
|
||||
typedef struct sfRenderWindow sfRenderWindow;
|
||||
typedef struct sfShape sfShape;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue