aboutsummaryrefslogtreecommitdiff
path: root/src/client/lua_api/video
diff options
context:
space:
mode:
authorAlexander Pickering <alex@cogarr.net>2018-10-31 12:39:50 -0400
committerAlexander Pickering <alex@cogarr.net>2018-10-31 12:39:50 -0400
commit6df9cb0de3e457788808b485b8b34bd8f0d6e42b (patch)
treede15337ea18f28f8643aedabfe2c34448a1b45fe /src/client/lua_api/video
parent133e620665037ea2b66da65c67716b290711bfde (diff)
downloadbrokengine-6df9cb0de3e457788808b485b8b34bd8f0d6e42b.tar.gz
brokengine-6df9cb0de3e457788808b485b8b34bd8f0d6e42b.tar.bz2
brokengine-6df9cb0de3e457788808b485b8b34bd8f0d6e42b.zip
Added more documentation
Added documentation for luadoc for * io.* * phys.* * video.*
Diffstat (limited to 'src/client/lua_api/video')
-rw-r--r--src/client/lua_api/video/iimage.cpp52
1 files changed, 49 insertions, 3 deletions
diff --git a/src/client/lua_api/video/iimage.cpp b/src/client/lua_api/video/iimage.cpp
index 86d984e..6fbf6c5 100644
--- a/src/client/lua_api/video/iimage.cpp
+++ b/src/client/lua_api/video/iimage.cpp
@@ -4,12 +4,24 @@
#include <shared/lua_api/common.hpp>
+/***
+@module video
+*/
+
using namespace irr;
using namespace video;
extern IrrlichtDevice* device;
extern IVideoDriver* driver;
+/***
+Creates a new irrlicht image.
+A newly created image will be fully white by default.
+@function newiimage(format, size)
+@tparam enum_color_format format The format for the image
+@tparam vec2d size The size of the image
+@treturn iimage The image
+*/
//newiimage(ECOLOR_FORMAT,{width,height}) -> {image}
int newiimage(lua_State* L){
//printf("Attempting to create new iimage\n");
@@ -28,23 +40,43 @@ int newiimage(lua_State* L){
return 1;
}
+/***
+Creates a new irrlicht image.
+Creates a new irrlicht image from a file. The format and width/height will be
+taken from the image file.
+@function newiimagefromfile(path)
+@tparam string path The file path of the image file
+@treturn iimage The loaded image
+*/
//newiimagefromfile("/path/to/file") -> {image}
int newiimagefromfile(lua_State* L){
- //printf("Creating new iimage from file");
+ printf("Creating new iimage from file");
const char* strpath = lua_tostring(L,-1);
lua_pop(L,1);
int numloaders = driver->getImageLoaderCount();
bool hasloaded = false;
IImage* img = NULL;
+ printf("About to create and open file\n");
+ io::IReadFile *f = device->getFileSystem()->createAndOpenFile(strpath);
+ if(!f){
+ lua_pushstring(L,"Failed to open file: ");
+ lua_pushstring(L,strpath);
+ lua_concat(L,2);
+ lua_error(L);
+ }
+ printf("Opened file\n");
for(int j = 0; j < numloaders; j++){
IImageLoader* loader = driver->getImageLoader(j);
- io::IReadFile* f = device->getFileSystem()->createAndOpenFile(strpath);
if(!loader->isALoadableFileExtension(strpath))
continue;
if(!loader->isALoadableFileFormat(f))
continue;
+ f->seek(0,false);
hasloaded = true;
+ printf("Found a loader, about to load\n");
img = loader->loadImage(f);
+ printf("Done loading\n");
+ f->drop();
}
if(!hasloaded){
lua_pushstring(L,"Failed to load file, no image loader for this type.");
@@ -54,15 +86,23 @@ int newiimagefromfile(lua_State* L){
lua_pushstring(L,"Failed to load image");
lua_error(L);
}
+ printf("Successfully loaded\n");
lua_newtable(L);
lua_pushlightuserdata(L,img);
lua_setfield(L,-2,"image");
luaL_getmetatable(L,"iimage");
lua_setmetatable(L,-2);
- //printf("IImage made, returning!");
+ printf("IImage made, returning!");
return 1;
}
+/***
+Sets the color of an image at a particular pixel.
+@function iimage:setpixel(position,color,shouldblend)
+@tparam vec2i position The position of the pixel to change colors
+@tparam color color The color to change the pixel to
+@tparam boolean shouldblend Should this pixel blend into it's neighbors?
+*/
//setpixel({self},{x,y},{r,g,b,a},bool_shouldblend)
int setiimagepixel(lua_State* L){
bool sb = lua_toboolean(L,-1);//{ud_iimage},{x,y},{r,g,b,a},bool_shouldblend
@@ -78,6 +118,12 @@ int setiimagepixel(lua_State* L){
return 0;
}
+/***
+Returns the color at a position in the image.
+@function iimage:getpixel(position)
+@tparam vec2i position The position of the pixel to return
+@treturn color The color of the image at the position
+*/
//getpixel({self},{x,y})
int getiimagepixel(lua_State* L){
long x,y;