/* -----------------------------------------------------------------------------
	GSFramework
	Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
----------------------------------------------------------------------------- */


		#include "binding_helpers.h"
		#include "core/render_data.h"

		using namespace GS::Render;
		using namespace GS::Script;


//------------------------------------------------------------------------------
SQInteger			MaterialShaderSetUniformValue(HSQUIRRELVM vm)
{
	__SQ_GETSTART(3)
	__SQ_GETSAFEPTR(shader, MaterialShader, typetag_MaterialShader)
	__SQ_GETSTRING(name)
	__SQ_GETVECTOR(value)
	bool r = shader->SetUserUniformValue(name, value);
	__SQ_GETEND
	__SQ_RETURNBOOL(r)
}
SQInteger			MaterialShaderSetUniformTexture(HSQUIRRELVM vm)
{
	__SQ_GETSTART(3)
	__SQ_GETSAFEPTR(shader, MaterialShader, typetag_MaterialShader)
	__SQ_GETSTRING(name)
	__SQ_GETSAFEPTRALLOWNULL(t, Texture, typetag_Texture)
	bool r = shader->SetUserUniformValue(name, t);
	__SQ_GETEND
	__SQ_RETURNBOOL(r)
}
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
void				RegisterMaterialShaderBinding(HSQUIRRELVM vm)
{
/*#
	Topic: Material Shader
	Type: MaterialShader
	Desc: A material shader holds all the variants of a shader required to render a material.
#*/

/*#
	Section: MaterialShaderGeneral
	Desc: General functions
#*/
	/*#
		Func: MaterialShaderSetUniformValue
		Proto: bool:MaterialShader shader,String name,Vector value
		Desc: Set uniform value in a material shader.
		Note: The value is always passed as a vector of 4 floats, if the uniform type is smaller than vec4 unused entries of the vector are ignored.
		Example:
local shader = MaterialGetShader(material)
// u_user_param is a float.
MaterialShaderSetUniformValue(shader, "u_user_param", Vector(1.0, 0.0, 0.0, 0.0))
	#*/
	sq_register(vm, MaterialShaderSetUniformValue, "MaterialShaderSetUniformValue", _SC(".xsx"));
	/*#
		Func: MaterialShaderSetUniformTexture
		Proto: bool:MaterialShader shader,String name,Texture texture
		Desc: Set uniform texture in a material shader.
		Example:
local shader = MaterialGetShader(material)
// u_user_tex is a Texture2D.
MaterialShaderSetUniformTexture(shader, "u_user_tex", ResourceFactoryLoadTexture(g_factory, "textures/texture.png"))
	#*/
	sq_register(vm, MaterialShaderSetUniformTexture, "MaterialShaderSetUniformTexture", _SC(".xsx"));
}
//------------------------------------------------------------------------------
