Sdk/Lua: Bind Texture class
This commit is contained in:
parent
0c6f7131a6
commit
4cd6bdd14a
|
|
@ -143,6 +143,24 @@ namespace Nz
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Queries arguments for Lua
|
||||||
|
* \return 1 in case of success
|
||||||
|
*
|
||||||
|
* \param instance Lua instance to interact with
|
||||||
|
* \param index Index type
|
||||||
|
* \param params Resulting parameters for an image
|
||||||
|
*/
|
||||||
|
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, ImageParams* params, TypeTag<ImageParams>)
|
||||||
|
{
|
||||||
|
instance.CheckType(index, Nz::LuaType_Table);
|
||||||
|
|
||||||
|
params->levelCount = instance.CheckField<Nz::UInt8>("LevelCount");
|
||||||
|
params->loadFormat = instance.CheckField<Nz::PixelFormatType>("LoadFormat");
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Queries arguments for Lua
|
* \brief Queries arguments for Lua
|
||||||
* \return 1 in case of success
|
* \return 1 in case of success
|
||||||
|
|
@ -614,6 +632,22 @@ namespace Nz
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Queries arguments for Lua
|
||||||
|
* \return 1 in case of success
|
||||||
|
*
|
||||||
|
* \param instance Lua instance to interact with
|
||||||
|
* \param index Index type
|
||||||
|
* \param fontRef Resulting reference to a font
|
||||||
|
*/
|
||||||
|
|
||||||
|
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, TextureRef* textureRef, TypeTag<TextureRef>)
|
||||||
|
{
|
||||||
|
*textureRef = *static_cast<TextureRef*>(instance.CheckUserdata(index, "Texture"));
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|
@ -630,6 +664,25 @@ namespace Nz
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Replies by value for Lua
|
||||||
|
* \return 1 in case of success
|
||||||
|
*
|
||||||
|
* \param instance Lua instance to interact with
|
||||||
|
* \param val Resulting color
|
||||||
|
*/
|
||||||
|
|
||||||
|
inline int LuaImplReplyVal(const LuaInstance& instance, Color&& val, TypeTag<Color>)
|
||||||
|
{
|
||||||
|
instance.PushTable();
|
||||||
|
instance.PushField("r", val.r);
|
||||||
|
instance.PushField("g", val.g);
|
||||||
|
instance.PushField("b", val.b);
|
||||||
|
instance.PushField("a", val.a);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Replies by value for Lua
|
* \brief Replies by value for Lua
|
||||||
* \return 1 in case of success
|
* \return 1 in case of success
|
||||||
|
|
@ -803,6 +856,20 @@ namespace Nz
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Replies by value for Lua
|
||||||
|
* \return 1 in case of success
|
||||||
|
*
|
||||||
|
* \param instance Lua instance to interact with
|
||||||
|
* \param handle Resulting texture
|
||||||
|
*/
|
||||||
|
|
||||||
|
inline int LuaImplReplyVal(const LuaInstance& instance, TextureRef&& handle, TypeTag<TextureRef>)
|
||||||
|
{
|
||||||
|
instance.PushInstance<TextureRef>("Texture", handle);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Replies by value for Lua
|
* \brief Replies by value for Lua
|
||||||
* \return 1 in case of success
|
* \return 1 in case of success
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ namespace Ndk
|
||||||
Nz::LuaClass<Nz::IpAddress> ipAddressClass;
|
Nz::LuaClass<Nz::IpAddress> ipAddressClass;
|
||||||
|
|
||||||
// Utility
|
// Utility
|
||||||
Nz::LuaClass<Nz::AbstractImage*> abstractImage;
|
Nz::LuaClass<Nz::AbstractImageRef> abstractImage;
|
||||||
Nz::LuaClass<Nz::FontRef> fontClass;
|
Nz::LuaClass<Nz::FontRef> fontClass;
|
||||||
Nz::LuaClass<Nz::Node> nodeClass;
|
Nz::LuaClass<Nz::Node> nodeClass;
|
||||||
|
|
||||||
|
|
@ -78,6 +78,9 @@ namespace Ndk
|
||||||
Nz::LuaClass<Nz::InstancedRenderableRef> instancedRenderable;
|
Nz::LuaClass<Nz::InstancedRenderableRef> instancedRenderable;
|
||||||
Nz::LuaClass<Nz::ModelRef> modelClass;
|
Nz::LuaClass<Nz::ModelRef> modelClass;
|
||||||
|
|
||||||
|
// Renderer
|
||||||
|
Nz::LuaClass<Nz::TextureRef> texture;
|
||||||
|
|
||||||
// SDK
|
// SDK
|
||||||
Nz::LuaClass<ConsoleHandle> consoleClass;
|
Nz::LuaClass<ConsoleHandle> consoleClass;
|
||||||
Nz::LuaClass<GraphicsComponentHandle> graphicsComponent;
|
Nz::LuaClass<GraphicsComponentHandle> graphicsComponent;
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,9 @@ namespace Ndk
|
||||||
instancedRenderable("InstancedRenderable"),
|
instancedRenderable("InstancedRenderable"),
|
||||||
modelClass("Model"),
|
modelClass("Model"),
|
||||||
|
|
||||||
|
// Renderer
|
||||||
|
texture("Texture"),
|
||||||
|
|
||||||
// SDK
|
// SDK
|
||||||
consoleClass("Console"),
|
consoleClass("Console"),
|
||||||
graphicsComponent("GraphicsComponent")
|
graphicsComponent("GraphicsComponent")
|
||||||
|
|
|
||||||
|
|
@ -10,9 +10,58 @@ namespace Ndk
|
||||||
/*!
|
/*!
|
||||||
* \brief Binds Renderer module to Lua
|
* \brief Binds Renderer module to Lua
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void LuaBinding::BindRenderer()
|
void LuaBinding::BindRenderer()
|
||||||
{
|
{
|
||||||
|
/*********************************** Nz::Texture ***********************************/
|
||||||
|
texture.Inherit<Nz::AbstractImageRef>(abstractImage, [] (Nz::TextureRef* texture) -> Nz::AbstractImageRef*
|
||||||
|
{
|
||||||
|
return reinterpret_cast<Nz::AbstractImageRef*>(texture); //TODO: Make a ObjectRefCast
|
||||||
|
});
|
||||||
|
|
||||||
|
texture.SetConstructor([] (Nz::LuaInstance& /*lua*/, Nz::TextureRef* texture, std::size_t /*argumentCount*/)
|
||||||
|
{
|
||||||
|
Nz::PlacementNew(texture, Nz::Texture::New());
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
|
texture.BindMethod("Create", &Nz::Texture::Create, static_cast<Nz::UInt8>(1), 1U);
|
||||||
|
texture.BindMethod("Destroy", &Nz::Texture::Destroy);
|
||||||
|
|
||||||
|
//texture.BindMethod("Download", &Nz::Texture::Download);
|
||||||
|
|
||||||
|
texture.BindMethod("EnableMipmapping", &Nz::Texture::EnableMipmapping);
|
||||||
|
texture.BindMethod("EnsureMipmapsUpdate", &Nz::Texture::EnsureMipmapsUpdate);
|
||||||
|
texture.BindMethod("HasMipmaps", &Nz::Texture::HasMipmaps);
|
||||||
|
texture.BindMethod("InvalidateMipmaps", &Nz::Texture::InvalidateMipmaps);
|
||||||
|
texture.BindMethod("IsValid", &Nz::Texture::IsValid);
|
||||||
|
|
||||||
|
texture.BindMethod("LoadFromFile", &Nz::Texture::LoadFromFile, true, Nz::ImageParams());
|
||||||
|
//bool LoadFromImage(const Image& image, bool generateMipmaps = true);
|
||||||
|
//bool LoadFromMemory(const void* data, std::size_t size, const ImageParams& params = ImageParams(), bool generateMipmaps = true);
|
||||||
|
//bool LoadFromStream(Stream& stream, const ImageParams& params = ImageParams(), bool generateMipmaps = true);
|
||||||
|
|
||||||
|
texture.BindMethod("LoadArrayFromFile", &Nz::Texture::LoadArrayFromFile, Nz::Vector2ui(2, 2), true, Nz::ImageParams());
|
||||||
|
//bool LoadArrayFromImage(const Image& image, bool generateMipmaps = true, const Vector2ui& atlasSize = Vector2ui(2, 2));
|
||||||
|
//bool LoadArrayFromMemory(const void* data, std::size_t size, const ImageParams& imageParams = ImageParams(), bool generateMipmaps = true, const Vector2ui& atlasSize = Vector2ui(2, 2));
|
||||||
|
//bool LoadArrayFromStream(Stream& stream, const ImageParams& imageParams = ImageParams(), bool generateMipmaps = true, const Vector2ui& atlasSize = Vector2ui(2, 2));
|
||||||
|
|
||||||
|
//bool LoadCubemapFromFile(const String& filePath, const ImageParams& imageParams = ImageParams(), bool generateMipmaps = true, const CubemapParams& cubemapParams = CubemapParams());
|
||||||
|
//bool LoadCubemapFromImage(const Image& image, bool generateMipmaps = true, const CubemapParams& params = CubemapParams());
|
||||||
|
//bool LoadCubemapFromMemory(const void* data, std::size_t size, const ImageParams& imageParams = ImageParams(), bool generateMipmaps = true, const CubemapParams& cubemapParams = CubemapParams());
|
||||||
|
//bool LoadCubemapFromStream(Stream& stream, const ImageParams& imageParams = ImageParams(), bool generateMipmaps = true, const CubemapParams& cubemapParams = CubemapParams());
|
||||||
|
|
||||||
|
texture.BindMethod("LoadFaceFromFile", &Nz::Texture::LoadFaceFromFile, Nz::ImageParams());
|
||||||
|
//bool LoadFaceFromMemory(CubemapFace face, const void* data, std::size_t size, const ImageParams& params = ImageParams());
|
||||||
|
//bool LoadFaceFromStream(CubemapFace face, Stream& stream, const ImageParams& params = ImageParams());
|
||||||
|
|
||||||
|
texture.BindMethod("SaveToFile", &Nz::Texture::SaveToFile, Nz::ImageParams());
|
||||||
|
//bool SaveToStream(Stream& stream, const String& format, const ImageParams& params = ImageParams());
|
||||||
|
|
||||||
|
texture.BindMethod("SetMipmapRange", &Nz::Texture::SetMipmapRange);
|
||||||
|
|
||||||
|
texture.BindStaticMethod("IsFormatSupported", &Nz::Texture::IsFormatSupported);
|
||||||
|
texture.BindStaticMethod("IsMipmappingSupported", &Nz::Texture::IsMipmappingSupported);
|
||||||
|
texture.BindStaticMethod("IsTypeSupported", &Nz::Texture::IsTypeSupported);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|
@ -20,8 +69,8 @@ namespace Ndk
|
||||||
*
|
*
|
||||||
* \param instance Lua instance that will interact with the Renderer classes
|
* \param instance Lua instance that will interact with the Renderer classes
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void LuaBinding::RegisterRenderer(Nz::LuaInstance& instance)
|
void LuaBinding::RegisterRenderer(Nz::LuaInstance& instance)
|
||||||
{
|
{
|
||||||
|
texture.Register(instance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue