Dawn/src/game/sandbox/sandboxscene.c

97 lines
2.0 KiB
C

/**
* Copyright (c) 2021 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#include "sandboxscene.h"
menuv2_t menu;
void gridTest(
void *user, int32_t i,
float screenWidth, float screenHeight,
float x, float y,
float width, float height
) {
sandboxscene_t *game = (sandboxscene_t *)user;
game->items[i].x = x;
game->items[i].y = y;
game->items[i].width = width;
game->items[i].height = height;
}
bool sandboxSceneInit(sandboxscene_t *game) {
menu2Init(&menu);
gridAddBreakpoint(&menu.grid, -1, 3, 1, 0, 0);
gridchild_t *child = gridAddChild(&menu.grid);
gridChildAddBreakpoint(child, 0,0, 1,1);
child = gridAddChild(&menu.grid);
gridChildAddBreakpoint(child, 0,1, 1,1);
child = gridAddChild(&menu.grid);
gridChildAddBreakpoint(child, 0,2, 1,1);
assetTextureLoad(&game->texture, "test_texture.png");
assetShaderLoad(&game->shader,
"shaders/textured.vert", "shaders/textured.frag"
);
quadInit(&game->primitive, 0,
0,0,0,0,
1,1,1,1
);
return true;
}
void sandboxSceneUpdate(sandboxscene_t *game, engine_t *engine) {
cameraLookAt(&game->camera,
0, 0, 10,
0, 0, 0
);
cameraOrtho(&game->camera,
0, engine->render.width,
engine->render.height, 0,
0.01f, 1000.0f
);
shaderUse(&game->shader);
shaderUseCamera(&game->shader, &game->camera);
shaderUseTexture(&game->shader, &game->texture);
menu2Update(&menu, engine);
gridSetSize(&menu.grid,
engine->render.width, engine->render.height,
engine->render.width, engine->render.height,
0, 0
);
// gridSetSize(&grid,
// engine->render.width, engine->render.height,
// engine->render.width, engine->render.height,
// 0, 0
// );
for(uint8_t i = 0; i < GRID_BRUH_COUNT; i++) {
gridbruh_t *b = game->items + i;
shaderUsePositionAndScale(&game->shader,
b->x, b->y, 0,
0, 0, 0,
b->width, b->height, 1
);
primitiveDraw(&game->primitive, 0, -1);
}
}
void sandboxSceneDispose(sandboxscene_t *game) {
}