Skip to content

Commit

Permalink
Merge pull request #39 from KelvinShadewing/unstable
Browse files Browse the repository at this point in the history
Add getDrawTarget
  • Loading branch information
KelvinShadewing committed Nov 28, 2022
2 parents 7a07c90 + cea6940 commit fd35048
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions docs/graphics.md
Expand Up @@ -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`.

* <a name="getDrawTarget"></a>**`getDrawTarget()`**

Returns the ID of the current texture being drawn to; 0 if drawing directly to the screen.

* <a name="drawImage"></a>**`drawImage( image, x, y )`**

Draws a full image at `x`,`y`.
Expand Down
7 changes: 7 additions & 0 deletions rte/binds.cpp
Expand Up @@ -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();

Expand Down
1 change: 1 addition & 0 deletions rte/binds.h
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions rte/global.cpp
Expand Up @@ -51,6 +51,7 @@ std::string gvInputString;
int gvMixChannels;
int gvVolumeMusic = 128;
int gvVolumeSound = 128;
int gvDrawTarget = 0;

//Gamepad
SDL_Joystick* gvGamepad[8] = {0};
Expand Down
1 change: 1 addition & 0 deletions rte/global.h
Expand Up @@ -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];
Expand Down
1 change: 1 addition & 0 deletions rte/main.cpp
Expand Up @@ -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
Expand Down

0 comments on commit fd35048

Please sign in to comment.