Files
Webcam/include/modules/script_squirrel/legacy/texture_binding.cpp

159 lines
4.5 KiB
C++

/* -----------------------------------------------------------------------------
GSFramework
Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
----------------------------------------------------------------------------- */
#include "binding_helpers.h"
#include "core/render_data.h"
#include "core/graphic_resource_factory.h"
#include "picture/pict.h"
using namespace GS::Render;
using namespace GS::Script;
//------------------------------------------------------------------------------
SQInteger TextureSetWrapping(HSQUIRRELVM vm)
{
__SQ_GETSTART(3)
__SQ_GETSAFEPTR(t, Texture, typetag_Texture)
__SQ_GETBOOL(wrap_u)
__SQ_GETBOOL(wrap_v)
__SQ_GETEND
t->SetWrapping(wrap_u ? TextureParm::WrapRepeat : TextureParm::WrapClamp, wrap_v ? TextureParm::WrapRepeat : TextureParm::WrapClamp);
__SQ_RETURN
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
SQInteger TextureSetStreamState(HSQUIRRELVM vm)
{
__SQ_GETSTART(2)
__SQ_GETSAFEPTR(t, Texture, typetag_Texture)
__SQ_GETINT(stream_state)
__SQ_GETEND
__SQ_RETURN
}
SQInteger TextureRewindStream(HSQUIRRELVM vm)
{
__SQ_GETSINGLESAFEPTR(t, Texture, typetag_Texture)
__SQ_RETURN
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
SQInteger TextureGetWidth(HSQUIRRELVM vm)
{
__SQ_GETSINGLESAFEPTR(t, Texture, typetag_Texture)
__SQ_RETURNINT(t->GetWidth())
}
SQInteger TextureGetHeight(HSQUIRRELVM vm)
{
__SQ_GETSINGLESAFEPTR(t, Texture, typetag_Texture)
__SQ_RETURNINT(t->GetHeight())
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
SQInteger TextureUpdate(HSQUIRRELVM vm)
{
__SQ_GETSTART(2)
__SQ_GETSAFEPTR(t, Texture, typetag_Texture)
__SQ_GETSAFEPTR(p, GS::Picture, typetag_Picture)
__SQ_GETEND
//__SQ_RETURNBOOL(t->Create((const char *)p->GetData(), p->GetWidth(), p->GetHeight()))
t->Blit((const char *)p->GetData(), p->GetWidth(), p->GetHeight());
__SQ_RETURN
}
SQInteger TextureRelease(HSQUIRRELVM vm)
{
__SQ_GETSINGLESAFEPTR(t, Texture, typetag_Texture)
t->Free();
__SQ_RETURN
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void RegisterTextureBinding(HSQUIRRELVM vm)
{
/*#
Topic: Texture
Type: Texture
#*/
/*#
Section: TextureStream
Desc: Data streaming
#*/
/*#
Func: TextureSetStreamState
Proto: void:texture,StreamState state
Desc: Set the texture stream state.
#*/
sq_register(vm, TextureSetStreamState, "TextureSetStreamState", _SC(".xi"));
/*#
Func: TextureRewindStream
Proto: void:texture
Desc: Rewind texture stream.
#*/
sq_register(vm, TextureRewindStream, "TextureRewindStream", _SC(".x"));
/*#
Section: TextureSampling
Desc: Texture sampling
#*/
/*#
Func: TextureSetWrapping
Proto: void:Texture,bool wrap_u, bool wrap_v
Desc: Set the texture U and V wrap modes.
#*/
sq_register(vm, TextureSetWrapping, "TextureSetWrapping", _SC(".xbb"));
/*#
Section: TextureGeneric
Desc: Generic
#*/
/*#
Func: TextureGetWidth
Proto: int:texture
Desc: Return the texture width.
#*/
sq_register(vm, TextureGetWidth, "TextureGetWidth", _SC(".x"));
/*#
Func: TextureGetHeight
Proto: int:texture
Desc: Return the texture height.
#*/
sq_register(vm, TextureGetHeight, "TextureGetHeight", _SC(".x"));
/*#
Func: TextureUpdate
Proto: bool:Texture,Picture
Desc: Update the texture data from a picture object.
#*/
sq_register(vm, TextureUpdate, "TextureUpdate", _SC(".xx"));
/*#
Func: TextureRelease
Proto: void:Texture
Desc: Release the renderer data for a given texture. A subsequent call to TextureUpdate will then recreate the renderer object.
#*/
sq_register(vm, TextureRelease, "TextureRelease", _SC(".x"));
sq_pushroottable(vm);
/*#
Enum: StreamState
Values: StreamPlaying,StreamPaused
#*/
#if __ENABLE_DAV__
sq_pushstring(vm, "StreamPlaying", -1); sq_pushinteger(vm, TextureStreamInterface::Stream_Playing); sq_newslot(vm, -3, true);
sq_pushstring(vm, "StreamPaused", -1); sq_pushinteger(vm, TextureStreamInterface::Stream_Paused); sq_newslot(vm, -3, true);
#endif
sq_pushstring(vm, "NullTexture", -1); CObject::Push(vm, NULL, typetag_Texture); sq_newslot(vm, -3, true);
sq_pop(vm, 1);
}
//------------------------------------------------------------------------------