Skip to content

Commit cfb5d39

Browse files
Move surfaceId to the RuntimeView itself
We still need to hook up the surfaceIds to ACTUALLY do something tho
1 parent a3133f7 commit cfb5d39

3 files changed

Lines changed: 7 additions & 9 deletions

File tree

src/runner.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1304,6 +1304,7 @@ static void initRoom(Runner* runner, int32_t roomIndex) {
13041304
copyRoomViewToRuntimeView(roomView, &runner->views[vi]);
13051305
initDefaultCameraFromRoomView(&runner->defaultCameras[vi], roomView);
13061306
runner->views[vi].cameraId = (int32_t) vi;
1307+
runner->views[vi].surfaceId = -1;
13071308
}
13081309

13091310
// Reset tile layer state for the new room
@@ -1868,9 +1869,6 @@ Runner* Runner_create(DataWin* dataWin, VMContext* vm, Renderer* renderer, FileS
18681869
runner->keyboard = RunnerKeyboard_create();
18691870
runner->gamepads = RunnerGamepad_create();
18701871
runner->mouse = RunnerMouse_create();
1871-
repeat(8, i) {
1872-
runner->viewSurfaceIds[i] = -1;
1873-
}
18741872
runner->appSurfaceEnabled = true;
18751873
runner->appSurfaceAutoDraw = true;
18761874
runner->usingAppSurface = true;
@@ -2421,7 +2419,7 @@ void Runner_getMouseRoomPosition(Runner* runner, GMLReal* outX, GMLReal* outY) {
24212419
if (viewsEnabled) {
24222420
repeat(MAX_VIEWS, vi) {
24232421
RuntimeView* v = &runner->views[vi];
2424-
if (!v->enabled || runner->viewSurfaceIds[vi] != -1) continue;
2422+
if (!v->enabled || v->surfaceId != -1) continue;
24252423
screenViewCount++;
24262424
lastScreenViewIndex = (int32_t) vi;
24272425
int32_t portX = (int32_t) ((float) v->portX * displayScaleX + 0.5f);

src/runner.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ typedef struct {
140140
int32_t portWidth;
141141
int32_t portHeight;
142142
int32_t cameraId;
143+
int32_t surfaceId;
143144
} RuntimeView;
144145

145146
typedef struct {
@@ -480,7 +481,6 @@ struct Runner {
480481
int32_t viewportY; // Y offset in window (letterboxing)
481482
int32_t viewportW; // Scaled game width in window
482483
int32_t viewportH; // Scaled game height in window
483-
int32_t viewSurfaceIds[8]; // view_surface_id per view, -1 = default (render to screen), else surface index
484484
struct { char* key; int value; }* disabledObjects; // stb_ds string hashmap, nullptr = no filtering
485485
struct { int key; Instance* value; }* instancesById;
486486
bool forceDrawDepth;

src/vm_builtins.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -798,7 +798,7 @@ RValue VMBuiltins_getVariable(VMContext* ctx, int16_t builtinVarId, const char*
798798
return RValue_makeReal(0.0);
799799
}
800800
case BUILTIN_VAR_VIEW_SURFACE_ID:
801-
if (arrayIndex >= 0 && MAX_VIEWS > arrayIndex) return RValue_makeReal((GMLReal) runner->viewSurfaceIds[arrayIndex]);
801+
if (arrayIndex >= 0 && MAX_VIEWS > arrayIndex) return RValue_makeReal((GMLReal) runner->views[arrayIndex].surfaceId);
802802
return RValue_makeReal(-1.0);
803803

804804
// Background properties
@@ -1444,7 +1444,7 @@ void VMBuiltins_setVariable(VMContext* ctx, int16_t builtinVarId, const char* na
14441444
return;
14451445
}
14461446
case BUILTIN_VAR_VIEW_SURFACE_ID:
1447-
if (arrayIndex >= 0 && MAX_VIEWS > arrayIndex) runner->viewSurfaceIds[arrayIndex] = RValue_toInt32(val);
1447+
if (arrayIndex >= 0 && MAX_VIEWS > arrayIndex) runner->views[arrayIndex].surfaceId = RValue_toInt32(val);
14481448
return;
14491449

14501450
// Background properties
@@ -3099,7 +3099,7 @@ static RValue builtin_view_get_surface_id(VMContext* ctx, RValue* args, int32_t
30993099
Runner* runner = ctx->runner;
31003100
int32_t viewIndex = RValue_toInt32(args[0]);
31013101
if (viewIndex >= 0 && MAX_VIEWS > viewIndex) {
3102-
return RValue_makeReal(runner->viewSurfaceIds[viewIndex]);
3102+
return RValue_makeReal(runner->views[viewIndex].surfaceId);
31033103
}
31043104
return RValue_makeReal(-1);
31053105
}
@@ -3159,7 +3159,7 @@ static RValue builtin_view_set_surface_id(VMContext* ctx, RValue* args, int32_t
31593159
Runner* runner = ctx->runner;
31603160
int32_t viewIndex = RValue_toInt32(args[0]);
31613161
if (viewIndex >= 0 && MAX_VIEWS > viewIndex) {
3162-
runner->viewSurfaceIds[viewIndex] = RValue_toInt32(args[1]);
3162+
runner->views[viewIndex].surfaceId = RValue_toInt32(args[1]);
31633163
}
31643164
return RValue_makeUndefined();
31653165
}

0 commit comments

Comments
 (0)