diff --git a/README.md b/README.md index 422c044..7e0b781 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,7 @@ http://kelvinshadewing.net/dl/brux-nightly.zip * Fixed chance of non-string-convertable type being passed incorrectly in `jsonWrite()` * Added `choose()` * Added pseudo typecasting functions `int()`, `float()`, `str()`, `char()`, and `bool()` + * Added `getDrawTarget()` * **0.2.10** * Remove std namespace diff --git a/docs/graphics.md b/docs/graphics.md index fbe4f0c..bab8af8 100644 --- a/docs/graphics.md +++ b/docs/graphics.md @@ -13,6 +13,10 @@ Set an image to be drawn to when using drawing functions. When set to 0, it draws directly to the screen. It can be loaded with `loadImage` or created with `newTexture`. +* **`getDrawTarget()`** + + Returns the ID of the current texture being drawn to; 0 if drawing directly to the screen. + * **`drawImage( image, x, y )`** Draws a full image at `x`,`y`. diff --git a/rte/binds.cpp b/rte/binds.cpp index 83d0bfb..dc8496b 100644 --- a/rte/binds.cpp +++ b/rte/binds.cpp @@ -272,10 +272,17 @@ SQInteger sqSetDrawTarget(HSQUIRRELVM v) { sq_getinteger(v, 2, &tex); xySetDrawTarget(tex); + gvDrawTarget = tex; return 0; }; +SQInteger sqGetDrawTarget(HSQUIRRELVM v) { + sq_pushinteger(v, gvDrawTarget); + + return 1; +}; + SQInteger sqResetDrawTarget(HSQUIRRELVM v) { xyResetDrawTarget(); diff --git a/rte/binds.h b/rte/binds.h index b8311a3..03d6eef 100644 --- a/rte/binds.h +++ b/rte/binds.h @@ -44,6 +44,7 @@ SQInteger sqIsDir(HSQUIRRELVM v); SQInteger sqWait(HSQUIRRELVM v); SQInteger sqClearScreen(HSQUIRRELVM v); SQInteger sqSetDrawTarget(HSQUIRRELVM v); +SQInteger sqGetDrawTarget(HSQUIRRELVM v); SQInteger sqDrawImage(HSQUIRRELVM v); SQInteger sqSetDrawColor(HSQUIRRELVM v); SQInteger sqSetBackgroundColor(HSQUIRRELVM v); diff --git a/rte/global.cpp b/rte/global.cpp index 13c1a7c..56ee9ee 100644 --- a/rte/global.cpp +++ b/rte/global.cpp @@ -51,6 +51,7 @@ std::string gvInputString; int gvMixChannels; int gvVolumeMusic = 128; int gvVolumeSound = 128; +int gvDrawTarget = 0; //Gamepad SDL_Joystick* gvGamepad[8] = {0}; diff --git a/rte/global.h b/rte/global.h index a386381..1ea8005 100644 --- a/rte/global.h +++ b/rte/global.h @@ -52,6 +52,7 @@ extern std::string gvInputString; extern int gvMixChannels; extern int gvVolumeMusic; extern int gvVolumeSound; +extern int gvDrawTarget; //Gamepad extern SDL_Joystick* gvGamepad[8]; diff --git a/rte/main.cpp b/rte/main.cpp index ccb9401..e0da453 100644 --- a/rte/main.cpp +++ b/rte/main.cpp @@ -298,6 +298,7 @@ void xyBindAllFunctions(HSQUIRRELVM v) { //Graphics xyPrint(0, "Embedding graphics..."); xyBindFunc(v, sqSetDrawTarget, "setDrawTarget", 2, ".n"); //Doc'd + xyBindFunc(v, sqGetDrawTarget, "getDrawTarget"); //Doc'd xyBindFunc(v, sqClearScreen, "clearScreen"); //Doc'd xyBindFunc(v, sqResetDrawTarget, "resetDrawTarget"); xyBindFunc(v, sqDrawImage, "drawImage", 4, ".n|bn|bn|b"); //Doc'd