Working on the Player UI
This commit is contained in:
@ -20,7 +20,7 @@ set(SETTING_GAME_POKER 1)
|
|||||||
set(SETTING_GAME_DAWN 2)
|
set(SETTING_GAME_DAWN 2)
|
||||||
set(SETTING_GAME_SANDBOX 3)
|
set(SETTING_GAME_SANDBOX 3)
|
||||||
|
|
||||||
set(SETTING_GAME SETTING_GAME_SANDBOX)
|
set(SETTING_GAME SETTING_GAME_POKER)
|
||||||
set(SETTING_GAME_NAME "DawnGame")
|
set(SETTING_GAME_NAME "DawnGame")
|
||||||
|
|
||||||
################################## Targets #####################################
|
################################## Targets #####################################
|
||||||
|
@ -48,6 +48,8 @@
|
|||||||
#include "game/poker/pokergameassets.h"
|
#include "game/poker/pokergameassets.h"
|
||||||
#include "game/poker/pokerworld.h"
|
#include "game/poker/pokerworld.h"
|
||||||
|
|
||||||
|
#include "game/sandbox/sandboxscene.h"
|
||||||
|
|
||||||
// Player Input
|
// Player Input
|
||||||
#include "input/input.h"
|
#include "input/input.h"
|
||||||
|
|
||||||
|
@ -8,24 +8,28 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "../libs.h"
|
#include "../libs.h"
|
||||||
#include "../util/dynarray.h"
|
#include "../util/dynarray.h"
|
||||||
#include "../game/game.h"
|
#include "../engine/engine.h"
|
||||||
#include "framebuffer.h"
|
#include "framebuffer.h"
|
||||||
#include "shader.h"
|
#include "shader.h"
|
||||||
|
#include "primitive.h"
|
||||||
|
|
||||||
typedef struct _renderpass_t renderpass_t;
|
typedef struct {
|
||||||
typedef struct _renderlist_t renderlist_t;
|
framebuffer_t frame;
|
||||||
|
|
||||||
typedef void renderitem_t(
|
|
||||||
renderlist_t *list, renderpass_t *pass, game_t *game, int32_t i
|
|
||||||
);
|
|
||||||
|
|
||||||
typedef struct _renderpass_t {
|
|
||||||
framebuffer_t framebuffer;
|
|
||||||
shader_t *shader;
|
shader_t *shader;
|
||||||
} renderpass_t;
|
} renderpass_t;
|
||||||
|
|
||||||
typedef struct _renderlist_t {
|
typedef struct {
|
||||||
int32_t width;
|
framebuffer_t frame;
|
||||||
int32_t height;
|
primitive_t quad;
|
||||||
|
|
||||||
dynarray_t passes;
|
dynarray_t passes;
|
||||||
} renderlist_t;
|
void *user;
|
||||||
|
} renderlist_t;
|
||||||
|
|
||||||
|
typedef void renderitemcallback_t(
|
||||||
|
renderlist_t *list, renderpass_t *pass, engine_t *engine, int32_t i
|
||||||
|
);
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
renderitemcallback_t *onRender;
|
||||||
|
} renderitem_t;
|
@ -12,6 +12,14 @@
|
|||||||
#include "../../../display/framebuffer.h"
|
#include "../../../display/framebuffer.h"
|
||||||
#include "../../../display/camera.h"
|
#include "../../../display/camera.h"
|
||||||
|
|
||||||
|
#define POKER_PLAYER_UI_IMAGE_SIZE 64
|
||||||
|
#define POKER_PLAYER_UI_IMAGE_RESOLUTION POKER_PLAYER_UI_IMAGE_SIZE * 2
|
||||||
|
#define POKER_PLAYER_UI_IMAGE_DIST 0.8f
|
||||||
|
#define POKER_PLAYER_UI_IMAGE_Y 0.1f
|
||||||
|
#define POKER_PLAYER_UI_PADDING 8
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
label_t label;
|
label_t label;
|
||||||
|
framebuffer_t frame;
|
||||||
|
primitive_t quad;
|
||||||
} pokerplayerui_t;
|
} pokerplayerui_t;
|
@ -11,7 +11,14 @@
|
|||||||
#include "../../display/shader.h"
|
#include "../../display/shader.h"
|
||||||
#include "../../display/font.h"
|
#include "../../display/font.h"
|
||||||
#include "../../display/primitive.h"
|
#include "../../display/primitive.h"
|
||||||
|
#include "../../display/renderlist.h"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
camera_t camera;
|
camera_t camera;
|
||||||
|
renderlist_t list;
|
||||||
|
|
||||||
|
shader_t shader;
|
||||||
|
texture_t texture;
|
||||||
|
|
||||||
|
primitive_t cube;
|
||||||
} sandboxscene_t;
|
} sandboxscene_t;
|
@ -127,10 +127,9 @@ void glfwOnCursor(GLFWwindow *window, double x, double y) {
|
|||||||
|
|
||||||
|
|
||||||
inputsource_t glfwGetInputSourceForKey(int32_t key) {
|
inputsource_t glfwGetInputSourceForKey(int32_t key) {
|
||||||
// return (inputsource_t)((
|
return (inputsource_t)((
|
||||||
// key <= GLFW_KEY_GRAVE_ACCENT ? key - GLFW_KEY_SPACE :
|
key <= GLFW_KEY_GRAVE_ACCENT ? key - GLFW_KEY_SPACE :
|
||||||
// key <= GLFW_KEY_MENU ? key - GLFW_KEY_ESCAPE + GLFW_KEY_GRAVE_ACCENT :
|
key <= GLFW_KEY_MENU ? key - GLFW_KEY_ESCAPE + GLFW_KEY_GRAVE_ACCENT :
|
||||||
// key
|
key
|
||||||
// ) % INPUT_SOURCE_COUNT);
|
) % INPUT_SOURCE_COUNT);
|
||||||
return 0;
|
|
||||||
}
|
}
|
@ -19,7 +19,7 @@ void renderInit() {
|
|||||||
glDepthMask(GL_TRUE);
|
glDepthMask(GL_TRUE);
|
||||||
glDepthFunc(GL_LEQUAL);
|
glDepthFunc(GL_LEQUAL);
|
||||||
|
|
||||||
glClearColor(0,0,0, 1.0);
|
glClearColor(0,0,0, 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void renderFrameStart(render_t *render) {
|
void renderFrameStart(render_t *render) {
|
||||||
|
@ -8,36 +8,76 @@
|
|||||||
#include "renderlist.h"
|
#include "renderlist.h"
|
||||||
|
|
||||||
void renderListInit(renderlist_t *list, int32_t passes, int32_t width, int32_t height) {
|
void renderListInit(renderlist_t *list, int32_t passes, int32_t width, int32_t height) {
|
||||||
int32_t i;
|
frameBufferInit(&list->frame, width, height);
|
||||||
renderpass_t *pass;
|
quadInit(&list->quad, 0, 0,0,0,0, 1,1,1,1);
|
||||||
|
|
||||||
list->width = width;
|
|
||||||
list->height = height;
|
|
||||||
|
|
||||||
dynArrayInit(&list->passes, sizeof(renderpass_t), passes);
|
dynArrayInit(&list->passes, sizeof(renderpass_t), passes);
|
||||||
|
|
||||||
for(i = 0; i < passes; i++) {
|
|
||||||
pass = (renderpass_t *)dynArrayGet(&list->passes, i);
|
|
||||||
frameBufferInit(&pass->framebuffer, width, height);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void renderListRenderPass(renderlist_t *list, game_t *game, int32_t pass, dynarray_t *items, int32_t itemCount) {
|
renderpass_t * renderListGetPass(renderlist_t *list, int32_t pass) {
|
||||||
|
return (renderpass_t *)dynArrayGet(&list->passes, pass);
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t renderPassAdd(renderlist_t *list) {
|
||||||
|
int32_t i = dynArrayAdd(&list->passes);
|
||||||
|
renderpass_t *pass = renderListGetPass(list, i);
|
||||||
|
|
||||||
|
frameBufferInit(&pass->frame,
|
||||||
|
list->frame.texture.width, list->frame.texture.height
|
||||||
|
);
|
||||||
|
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
void renderListRenderPass(
|
||||||
|
renderlist_t *list, engine_t *engine,
|
||||||
|
camera_t *camera, int32_t pass, dynarray_t *items
|
||||||
|
) {
|
||||||
int32_t i;
|
int32_t i;
|
||||||
renderpass_t *renderPass;
|
renderpass_t *renderPass;
|
||||||
renderitem_t *item;
|
renderitem_t *item;
|
||||||
|
|
||||||
renderPass = (renderpass_t *)dynArrayGet(&list->passes, pass);
|
renderPass = renderListGetPass(list, pass);
|
||||||
|
|
||||||
// Bind the shader.
|
// Bind the shader.
|
||||||
frameBufferUse(&renderPass->framebuffer, true);
|
frameBufferUse(&renderPass->frame, true);
|
||||||
shaderUse(renderPass->shader);
|
shaderUse(renderPass->shader);
|
||||||
|
|
||||||
// "Uniforms"
|
// "Uniforms"
|
||||||
|
shaderUseCamera(renderPass->shader, camera);
|
||||||
|
|
||||||
// Render list
|
// Render list
|
||||||
for(i = 0; i < itemCount; i++) {
|
for(i = 0; i < items->length; i++) {
|
||||||
item = (renderitem_t *)dynArrayGet(items, i);
|
item = (renderitem_t *)dynArrayGet(items, i);
|
||||||
item(list, renderPass, game, i);
|
item->onRender(list, renderPass, engine, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
frameBufferUnbind(&engine->render, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void renderListRender(renderlist_t *list, engine_t *engine, shader_t *shader) {
|
||||||
|
camera_t camera;
|
||||||
|
int32_t i;
|
||||||
|
renderpass_t *pass;
|
||||||
|
|
||||||
|
// Setup the camera
|
||||||
|
cameraLookAt(&camera, 0,0,1, 0,0,0);
|
||||||
|
cameraOrtho(&camera, 0,1, 0,1, 0.5f, 1.5f);
|
||||||
|
|
||||||
|
// Bind the framebuffer
|
||||||
|
frameBufferUse(&list->frame, false);
|
||||||
|
|
||||||
|
// Set the shader
|
||||||
|
shaderUse(shader);
|
||||||
|
shaderUsePosition(shader, 0,0,0, 0,0,0);
|
||||||
|
shaderUseCamera(shader, &camera);
|
||||||
|
|
||||||
|
// Render each pass.
|
||||||
|
for(i = 0; i < list->passes.length; i++) {
|
||||||
|
pass = renderListGetPass(list, i);
|
||||||
|
shaderUseTexture(shader, &pass->frame.texture);
|
||||||
|
primitiveDraw(&list->quad, 0, -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unbind the framebuffer.
|
||||||
|
frameBufferUnbind(&engine->render, false);
|
||||||
}
|
}
|
@ -7,10 +7,20 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <dawn/dawn.h>
|
#include <dawn/dawn.h>
|
||||||
|
#include "../game/game.h"
|
||||||
#include "framebuffer.h"
|
#include "framebuffer.h"
|
||||||
#include "primitive.h"
|
#include "primitive.h"
|
||||||
#include "shader.h"
|
#include "shader.h"
|
||||||
|
#include "camera.h"
|
||||||
#include "primitives/quad.h"
|
#include "primitives/quad.h"
|
||||||
#include "../util/dynarray.h"
|
#include "../util/dynarray.h"
|
||||||
|
|
||||||
void renderListInit(renderlist_t *renderList, int32_t passes);
|
void renderListInit(renderlist_t *list, int32_t passes, int32_t width, int32_t height);
|
||||||
|
renderpass_t * renderListGetPass(renderlist_t *list, int32_t pass);
|
||||||
|
int32_t renderPassAdd(renderlist_t *list);
|
||||||
|
void renderListRenderPass(
|
||||||
|
renderlist_t *list, engine_t *engine,
|
||||||
|
camera_t *camera, int32_t pass, dynarray_t *items
|
||||||
|
);
|
||||||
|
|
||||||
|
void renderListRender(renderlist_t *list, engine_t *engine, shader_t *shader);
|
@ -20,7 +20,10 @@ void engineUpdateStart(engine_t *engine, game_t *game, float delta) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool engineUpdateEnd(engine_t *engine, game_t *game) {
|
bool engineUpdateEnd(engine_t *engine, game_t *game) {
|
||||||
if(inputIsPressed(&engine->input, INPUT_NULL)) return false;
|
if(inputIsPressed(&engine->input, INPUT_NULL)) {
|
||||||
|
printf("Game exit requested\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ bool gameUpdate(game_t *game, float platformDelta) {
|
|||||||
void gameDispose(game_t *game) {
|
void gameDispose(game_t *game) {
|
||||||
// Cleanup the game
|
// Cleanup the game
|
||||||
#if SETTING_GAME == SETTING_GAME_POKER
|
#if SETTING_GAME == SETTING_GAME_POKER
|
||||||
pokerGameDispose(game);
|
pokerGameDispose(&game->pokerGame);
|
||||||
#elif SETTING_GAME == SETTING_GAME_DAWN
|
#elif SETTING_GAME == SETTING_GAME_DAWN
|
||||||
dawnGameDispose(game);
|
dawnGameDispose(game);
|
||||||
#elif SETTING_GAME == SETTING_GAME_SANDBOX
|
#elif SETTING_GAME == SETTING_GAME_SANDBOX
|
||||||
|
@ -31,10 +31,13 @@ bool pokerGameInit(pokergame_t *game) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void pokerGameUpdate(pokergame_t *game, engine_t *engine) {
|
void pokerGameUpdate(pokergame_t *game, engine_t *engine) {
|
||||||
|
|
||||||
// Update the VN Engine.
|
// Update the VN Engine.
|
||||||
vnSceneUpdate(&game->scene, engine);
|
vnSceneUpdate(&game->scene, engine);
|
||||||
|
|
||||||
|
// Update the UI
|
||||||
|
pokerUiUpdate(game, engine);
|
||||||
|
|
||||||
|
|
||||||
// Bind the shader.
|
// Bind the shader.
|
||||||
shaderUse(&game->assets.shader);
|
shaderUse(&game->assets.shader);
|
||||||
|
|
||||||
|
@ -32,12 +32,7 @@ void pokerWorldInit(pokergame_t *game) {
|
|||||||
|
|
||||||
void pokerWorldLookAtPlayer(vnscene_t *scene, uint8_t playerIndex) {
|
void pokerWorldLookAtPlayer(vnscene_t *scene, uint8_t playerIndex) {
|
||||||
uint8_t seat;
|
uint8_t seat;
|
||||||
seat = (
|
seat = pokerGameSeatFromIndex(playerIndex);
|
||||||
playerIndex == POKER_DEALER_INDEX ?
|
|
||||||
POKER_GAME_SEAT_DEALER :
|
|
||||||
POKER_GAME_SEAT_FOR_PLAYER(playerIndex)
|
|
||||||
);
|
|
||||||
|
|
||||||
scene->cameraLookX = POKER_WORLD_SEAT_POSITION_X(seat);
|
scene->cameraLookX = POKER_WORLD_SEAT_POSITION_X(seat);
|
||||||
scene->cameraLookZ = POKER_WORLD_SEAT_POSITION_Z(seat);
|
scene->cameraLookZ = POKER_WORLD_SEAT_POSITION_Z(seat);
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,55 @@
|
|||||||
|
|
||||||
void pokerPlayerUiInit(pokerplayerui_t *ui) {
|
void pokerPlayerUiInit(pokerplayerui_t *ui) {
|
||||||
labelInit(&ui->label);
|
labelInit(&ui->label);
|
||||||
|
|
||||||
|
frameBufferInit(&ui->frame,
|
||||||
|
POKER_PLAYER_UI_IMAGE_RESOLUTION, POKER_PLAYER_UI_IMAGE_RESOLUTION
|
||||||
|
);
|
||||||
|
|
||||||
|
quadInit(&ui->quad, 0,
|
||||||
|
0, 0, 0, 1,
|
||||||
|
POKER_PLAYER_UI_IMAGE_SIZE, POKER_PLAYER_UI_IMAGE_SIZE, 1, 0
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void pokerPlayerUiUpdate(
|
||||||
|
pokerplayerui_t *ui, pokergame_t *game, shader_t *shader, int32_t playerIndex,
|
||||||
|
engine_t *engine
|
||||||
|
) {
|
||||||
|
|
||||||
|
camera_t camera;
|
||||||
|
uint8_t seat;
|
||||||
|
float x, y, z;
|
||||||
|
|
||||||
|
// Bind the frame buffer
|
||||||
|
frameBufferUse(&ui->frame, true);
|
||||||
|
|
||||||
|
// Set up the camera perspective
|
||||||
|
cameraPerspective(&camera, 45,
|
||||||
|
(float)POKER_PLAYER_UI_IMAGE_SIZE / (float)POKER_PLAYER_UI_IMAGE_SIZE,
|
||||||
|
0.03f, 10.0f
|
||||||
|
);
|
||||||
|
|
||||||
|
// Locate the XYZ position of the camera to look at the player
|
||||||
|
seat = pokerGameSeatFromIndex(playerIndex);
|
||||||
|
x = POKER_WORLD_SEAT_POSITION_X(seat);
|
||||||
|
y = POKER_PLAYER_UI_IMAGE_Y;
|
||||||
|
z = POKER_WORLD_SEAT_POSITION_Z(seat);
|
||||||
|
|
||||||
|
// Actually look at the player, we need to get close.
|
||||||
|
cameraLookAt(&camera,
|
||||||
|
x * POKER_PLAYER_UI_IMAGE_DIST, y, z * POKER_PLAYER_UI_IMAGE_DIST,
|
||||||
|
x, y, z
|
||||||
|
);
|
||||||
|
|
||||||
|
// Render the VN character
|
||||||
|
shaderUse(shader);
|
||||||
|
shaderUseCamera(shader, &camera);
|
||||||
|
shaderUsePosition(shader, 0,0,0, 0,0,0);
|
||||||
|
vnCharacterRender(game->scene.characters + playerIndex, shader);
|
||||||
|
|
||||||
|
// Unbind the frame buffer.
|
||||||
|
frameBufferUnbind(&engine->render, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void pokerPlayerUiRender(
|
void pokerPlayerUiRender(
|
||||||
@ -22,13 +71,20 @@ void pokerPlayerUiRender(
|
|||||||
scale = fontGetScale(FONT_SIZE_DEFAULT);
|
scale = fontGetScale(FONT_SIZE_DEFAULT);
|
||||||
player = game->poker.players + playerIndex;
|
player = game->poker.players + playerIndex;
|
||||||
|
|
||||||
|
// Render Face
|
||||||
|
shaderUseTexture(shader, &ui->frame.texture);
|
||||||
|
shaderUsePosition(shader, x - POKER_PLAYER_UI_IMAGE_SIZE,y,0, 0,0,0);
|
||||||
|
primitiveDraw(&ui->quad, 0, -1);
|
||||||
|
|
||||||
|
// Move everything left a bit.
|
||||||
|
x -= POKER_PLAYER_UI_IMAGE_SIZE + POKER_PLAYER_UI_PADDING;
|
||||||
|
y += (POKER_PLAYER_UI_IMAGE_SIZE - (FONT_LINE_HEIGHT * scale * 2)) / 2.0f;
|
||||||
|
|
||||||
// Render chips
|
// Render chips
|
||||||
sprintf(buffer, "$%i", player->chips);
|
sprintf(buffer, "$%i", player->chips);
|
||||||
labelSetText(&ui->label, font, buffer);
|
labelSetText(&ui->label, font, buffer);
|
||||||
labelRender(&ui->label, shader, x - ui->label.info.width, y);
|
labelRender(&ui->label, shader, x - ui->label.info.width, y);
|
||||||
|
|
||||||
// Render Face
|
|
||||||
|
|
||||||
// Render state
|
// Render state
|
||||||
if(player->state & POKER_PLAYER_STATE_OUT) {
|
if(player->state & POKER_PLAYER_STATE_OUT) {
|
||||||
sprintf(buffer, "Out");
|
sprintf(buffer, "Out");
|
||||||
@ -48,5 +104,7 @@ void pokerPlayerUiRender(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void pokerPlayerUiDispose(pokerplayerui_t *ui) {
|
void pokerPlayerUiDispose(pokerplayerui_t *ui) {
|
||||||
|
primitiveDispose(&ui->quad);
|
||||||
|
frameBufferDispose(&ui->frame);
|
||||||
labelDispose(&ui->label);
|
labelDispose(&ui->label);
|
||||||
}
|
}
|
@ -10,11 +10,19 @@
|
|||||||
#include "../../../ui/label.h"
|
#include "../../../ui/label.h"
|
||||||
#include "../../../ui/image.h"
|
#include "../../../ui/image.h"
|
||||||
#include "../../../display/framebuffer.h"
|
#include "../../../display/framebuffer.h"
|
||||||
|
#include "../../../display/primitive.h"
|
||||||
|
#include "../../../display/primitives/quad.h"
|
||||||
|
#include "../../../display/primitives/cube.h"
|
||||||
#include "../../../display/camera.h"
|
#include "../../../display/camera.h"
|
||||||
|
#include "../../../vn/vncharacter.h"
|
||||||
|
|
||||||
void pokerPlayerUiInit(pokerplayerui_t *ui);
|
void pokerPlayerUiInit(pokerplayerui_t *ui);
|
||||||
|
|
||||||
|
void pokerPlayerUiUpdate(
|
||||||
|
pokerplayerui_t *ui, pokergame_t *game, shader_t *shader, int32_t playerIndex,
|
||||||
|
engine_t *engine
|
||||||
|
);
|
||||||
|
|
||||||
void pokerPlayerUiRender(
|
void pokerPlayerUiRender(
|
||||||
pokerplayerui_t *ui, pokergame_t *game, shader_t *shader, font_t *font,
|
pokerplayerui_t *ui, pokergame_t *game, shader_t *shader, font_t *font,
|
||||||
int32_t playerIndex, float x, float y
|
int32_t playerIndex, float x, float y
|
||||||
|
@ -15,6 +15,17 @@ void pokerUiInit(pokergame_t *pokerGame) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void pokerUiUpdate(pokergame_t *pokerGame, engine_t *engine) {
|
||||||
|
uint8_t i;
|
||||||
|
pokerplayerui_t *ui;
|
||||||
|
|
||||||
|
for(i = 0; i < POKER_PLAYER_COUNT; i++) {
|
||||||
|
ui = pokerGame->ui.player + i;
|
||||||
|
|
||||||
|
pokerPlayerUiUpdate(ui, pokerGame, &pokerGame->assets.shader, i, engine);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void pokerUiRender(pokergame_t *pokerGame, engine_t *engine) {
|
void pokerUiRender(pokergame_t *pokerGame, engine_t *engine) {
|
||||||
uint8_t i;
|
uint8_t i;
|
||||||
pokerplayerui_t *ui;
|
pokerplayerui_t *ui;
|
||||||
|
@ -17,6 +17,14 @@
|
|||||||
*/
|
*/
|
||||||
void pokerUiInit(pokergame_t *pokerGame);
|
void pokerUiInit(pokergame_t *pokerGame);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the Poker Game UI.
|
||||||
|
*
|
||||||
|
* @param pokerGame Game to update.
|
||||||
|
* @param engine Engine to use for updating.
|
||||||
|
*/
|
||||||
|
void pokerUiUpdate(pokergame_t *pokerGame, engine_t *engine);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Render the Poker Game UI.
|
* Render the Poker Game UI.
|
||||||
*
|
*
|
||||||
|
@ -7,13 +7,50 @@
|
|||||||
|
|
||||||
#include "sandboxscene.h"
|
#include "sandboxscene.h"
|
||||||
|
|
||||||
|
void renderTest(renderlist_t *list, renderpass_t *pass, engine_t *engine, int32_t i) {
|
||||||
|
sandboxscene_t *scene;
|
||||||
|
scene = (sandboxscene_t *)list->user;
|
||||||
|
|
||||||
|
shaderUsePosition(pass->shader, 0, 0, 0, engine->time.current, engine->time.current, 0);
|
||||||
|
shaderUseTexture(pass->shader, &scene->texture);
|
||||||
|
primitiveDraw(&scene->cube, 0, -1);
|
||||||
|
}
|
||||||
|
|
||||||
bool sandboxSceneInit(sandboxscene_t *game) {
|
bool sandboxSceneInit(sandboxscene_t *game) {
|
||||||
printf("Sandbox init\n");
|
int32_t passIndex;
|
||||||
|
renderpass_t *pass;
|
||||||
|
|
||||||
|
// Load assets
|
||||||
|
assetTextureLoad(&game->texture, "test_texture.png");
|
||||||
|
assetShaderLoad(&game->shader, "shaders/textured.vert", "shaders/textured.frag");
|
||||||
|
cubeInit(&game->cube, 1.0f, 1.0f, 1.0f);
|
||||||
|
|
||||||
|
// Initialize list
|
||||||
|
renderListInit(&game->list, 1, 400, 400);
|
||||||
|
game->list.user = game;
|
||||||
|
|
||||||
|
// Set up the pass
|
||||||
|
passIndex = renderPassAdd(&game->list);
|
||||||
|
pass = renderListGetPass(&game->list, passIndex);
|
||||||
|
pass->shader = &game->shader;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void sandboxSceneUpdate(sandboxscene_t *game, engine_t *engine) {
|
void sandboxSceneUpdate(sandboxscene_t *game, engine_t *engine) {
|
||||||
|
dynarray_t items;
|
||||||
|
renderitem_t *item;
|
||||||
|
dynArrayInit(&items, sizeof(renderitem_t), 1);
|
||||||
|
item = (renderitem_t *)dynArrayGet(&items, dynArrayAdd(&items));
|
||||||
|
item->onRender= &renderTest;
|
||||||
|
|
||||||
|
cameraLookAt(&game->camera, 3,3,3, 0,0,0);
|
||||||
|
cameraPerspective(&game->camera, 75, 16.0f/9.0f, 0.3f, 100.0f);
|
||||||
|
|
||||||
|
renderListRenderPass(&game->list, engine, &game->camera, 0, &items);
|
||||||
|
renderListRender(&game->list, engine, &game->shader);
|
||||||
|
|
||||||
|
dynArrayDispose(&items);
|
||||||
}
|
}
|
||||||
|
|
||||||
void sandboxSceneDispose(sandboxscene_t *game) {
|
void sandboxSceneDispose(sandboxscene_t *game) {
|
||||||
|
@ -12,6 +12,9 @@
|
|||||||
#include "../../display/font.h"
|
#include "../../display/font.h"
|
||||||
#include "../../display/primitive.h"
|
#include "../../display/primitive.h"
|
||||||
#include "../../display/primitives/quad.h"
|
#include "../../display/primitives/quad.h"
|
||||||
|
#include "../../display/primitives/cube.h"
|
||||||
|
#include "../../display/renderlist.h"
|
||||||
|
#include "../../file/asset.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize the sandbox scene test game.
|
* Initialize the sandbox scene test game.
|
||||||
|
@ -29,6 +29,12 @@ int32_t dynArrayPush(dynarray_t *array, void *data) {
|
|||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t dynArrayAdd(dynarray_t *array) {
|
||||||
|
int32_t i = array->length;
|
||||||
|
array->length++;
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
void dynArrayPop(dynarray_t *array) {
|
void dynArrayPop(dynarray_t *array) {
|
||||||
array->length -= 1;
|
array->length -= 1;
|
||||||
}
|
}
|
||||||
|
@ -48,6 +48,14 @@ void dynArraySet(dynarray_t *array, int32_t i, void *data);
|
|||||||
*/
|
*/
|
||||||
int32_t dynArrayPush(dynarray_t *array, void *data);
|
int32_t dynArrayPush(dynarray_t *array, void *data);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new element in the array for you to use.
|
||||||
|
*
|
||||||
|
* @param array Array to add to.
|
||||||
|
* @return The index that the item was added to.
|
||||||
|
*/
|
||||||
|
int32_t dynArrayAdd(dynarray_t *array);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* "Pops" (Removes) the last element from the array.
|
* "Pops" (Removes) the last element from the array.
|
||||||
*
|
*
|
||||||
|
@ -151,7 +151,6 @@ void vnCharacterRender(vncharacter_t *character, shader_t *shader) {
|
|||||||
character->pitch, character->yaw, character->roll,
|
character->pitch, character->yaw, character->roll,
|
||||||
character->scaleX, character->scaleY, 1
|
character->scaleX, character->scaleY, 1
|
||||||
);
|
);
|
||||||
|
|
||||||
shaderUseTexture(shader, character->texture);
|
shaderUseTexture(shader, character->texture);
|
||||||
primitiveDraw(&character->primitive, 0, -1);
|
primitiveDraw(&character->primitive, 0, -1);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user