replaced all crappy spaces with proper tabs
kept this in its own changeset so it doesn't interfere with real changes git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1334 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
parent
8431753ba3
commit
2f2fc5d4fa
56 changed files with 8094 additions and 8094 deletions
|
@ -1,27 +1,27 @@
|
|||
/*
|
||||
* DSFML - SFML Library wrapper for the D programming language.
|
||||
* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com)
|
||||
* Copyright (C) 2010 Andreas Hollandt
|
||||
* DSFML - SFML Library wrapper for the D programming language.
|
||||
* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com)
|
||||
* Copyright (C) 2010 Andreas Hollandt
|
||||
*
|
||||
* This software is provided 'as-is', without any express or
|
||||
* implied warranty. In no event will the authors be held
|
||||
* liable for any damages arising from the use of this software.
|
||||
* This software is provided 'as-is', without any express or
|
||||
* implied warranty. In no event will the authors be held
|
||||
* liable for any damages arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute
|
||||
* it freely, subject to the following restrictions:
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute
|
||||
* it freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented;
|
||||
* you must not claim that you wrote the original software.
|
||||
* If you use this software in a product, an acknowledgment
|
||||
* in the product documentation would be appreciated but
|
||||
* is not required.
|
||||
* 1. The origin of this software must not be misrepresented;
|
||||
* you must not claim that you wrote the original software.
|
||||
* If you use this software in a product, an acknowledgment
|
||||
* in the product documentation would be appreciated but
|
||||
* is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such,
|
||||
* and must not be misrepresented as being the original software.
|
||||
* 2. Altered source versions must be plainly marked as such,
|
||||
* and must not be misrepresented as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any
|
||||
* source distribution.
|
||||
* 3. This notice may not be removed or altered from any
|
||||
* source distribution.
|
||||
*/
|
||||
|
||||
module dsfml.graphics.shader;
|
||||
|
@ -35,100 +35,100 @@ import dsfml.system.stringutil;
|
|||
|
||||
|
||||
/**
|
||||
* Define loading methods for effect
|
||||
* Define loading methods for effect
|
||||
*/
|
||||
enum LoadingType
|
||||
{
|
||||
FROMFILE, /// string represents a file path
|
||||
FROMSTRING /// string represents effect code
|
||||
FROMFILE, /// string represents a file path
|
||||
FROMSTRING /// string represents effect code
|
||||
}
|
||||
|
||||
/**
|
||||
* Shader is used to apply a post effect to a window
|
||||
* Shader is used to apply a post effect to a window
|
||||
*
|
||||
* See_Also:
|
||||
* $(LINK2 http://www.sfml-dev.org/tutorials/graphics-postfx.php, SFML post FX tutorial) from more informations about Post effects and GLSL fragment shaders syntax.
|
||||
* See_Also:
|
||||
* $(LINK2 http://www.sfml-dev.org/tutorials/graphics-postfx.php, SFML post FX tutorial) from more informations about Post effects and GLSL fragment shaders syntax.
|
||||
*/
|
||||
class Shader : DSFMLObject
|
||||
{
|
||||
/**
|
||||
* construct the effect
|
||||
*
|
||||
* Params:
|
||||
* effect = Path of a file or string containing the effect.
|
||||
* type = type of the effect (default is FROMFILE)
|
||||
*/
|
||||
this(string effect, LoadingType type = LoadingType.FROMFILE)
|
||||
/**
|
||||
* construct the effect
|
||||
*
|
||||
* Params:
|
||||
* effect = Path of a file or string containing the effect.
|
||||
* type = type of the effect (default is FROMFILE)
|
||||
*/
|
||||
this(string effect, LoadingType type = LoadingType.FROMFILE)
|
||||
{
|
||||
if (effect is null || effect.length == 0)
|
||||
throw new LoadingException("LoadingException : Effect is invalid.");
|
||||
|
||||
if (type == LoadingType.FROMFILE)
|
||||
super(sfShader_CreateFromFile(toStringz(effect)));
|
||||
else
|
||||
super(sfShader_CreateFromMemory(toStringz(effect)));
|
||||
if (effect is null || effect.length == 0)
|
||||
throw new LoadingException("LoadingException : Effect is invalid.");
|
||||
|
||||
if (type == LoadingType.FROMFILE)
|
||||
super(sfShader_CreateFromFile(toStringz(effect)));
|
||||
else
|
||||
super(sfShader_CreateFromMemory(toStringz(effect)));
|
||||
}
|
||||
|
||||
override void dispose()
|
||||
override void dispose()
|
||||
{
|
||||
sfShader_Destroy(m_ptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change parameters of the effect
|
||||
*
|
||||
* Params:
|
||||
* name = Parameter name in the effect
|
||||
*/
|
||||
void setParameter(string name, float x)
|
||||
/**
|
||||
* Change parameters of the effect
|
||||
*
|
||||
* Params:
|
||||
* name = Parameter name in the effect
|
||||
*/
|
||||
void setParameter(string name, float x)
|
||||
{
|
||||
sfShader_SetParameter1(m_ptr, toStringz(name), x);
|
||||
}
|
||||
|
||||
/**
|
||||
* ditto
|
||||
*/
|
||||
void setParameter(string name, float x, float y)
|
||||
/**
|
||||
* ditto
|
||||
*/
|
||||
void setParameter(string name, float x, float y)
|
||||
{
|
||||
sfShader_SetParameter2(m_ptr, toStringz(name), x, y);
|
||||
}
|
||||
|
||||
/**
|
||||
* ditto
|
||||
*/
|
||||
void setParameter(string name, float x, float y, float z)
|
||||
/**
|
||||
* ditto
|
||||
*/
|
||||
void setParameter(string name, float x, float y, float z)
|
||||
{
|
||||
sfShader_SetParameter3(m_ptr, toStringz(name), x, y, z);
|
||||
}
|
||||
|
||||
/**
|
||||
* ditto
|
||||
*/
|
||||
void setParameter(string name, float x, float y, float z, float w)
|
||||
/**
|
||||
* ditto
|
||||
*/
|
||||
void setParameter(string name, float x, float y, float z, float w)
|
||||
{
|
||||
sfShader_SetParameter4(m_ptr, toStringz(name), x, y, z, w);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a texture parameter
|
||||
*
|
||||
* Params:
|
||||
* name = Texture name in the effect
|
||||
* texture = Image to set (pass NULL to use content of current framebuffer)
|
||||
*/
|
||||
void setTexture(string name, Image texture)
|
||||
/**
|
||||
* Set a texture parameter
|
||||
*
|
||||
* Params:
|
||||
* name = Texture name in the effect
|
||||
* texture = Image to set (pass NULL to use content of current framebuffer)
|
||||
*/
|
||||
void setTexture(string name, Image texture)
|
||||
{
|
||||
m_texture = texture;
|
||||
m_texture = texture;
|
||||
sfShader_SetTexture(m_ptr, toStringz(name), texture is null ? null : texture.getNativePointer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tell whether or not the system supports shaders
|
||||
*
|
||||
* Returns:
|
||||
* True if the system can use shaders
|
||||
*/
|
||||
static bool isAvailable()
|
||||
/**
|
||||
* Tell whether or not the system supports shaders
|
||||
*
|
||||
* Returns:
|
||||
* True if the system can use shaders
|
||||
*/
|
||||
static bool isAvailable()
|
||||
{
|
||||
return cast(bool)sfShader_IsAvailable();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue