working on some render tools
This commit is contained in:
@ -34,6 +34,11 @@
|
|||||||
#define HOLDEM_GAME_CARD_HEIGHT 0.07
|
#define HOLDEM_GAME_CARD_HEIGHT 0.07
|
||||||
#define HOLDEM_GAME_CARD_DEPTH 0.001
|
#define HOLDEM_GAME_CARD_DEPTH 0.001
|
||||||
|
|
||||||
|
/** How many actions the queue can hold */
|
||||||
|
#define HOLDEM_GAME_ACTION_QUEUE_SIZE 12
|
||||||
|
|
||||||
|
/** How much data (in length of sizeof size_t) each action has available */
|
||||||
|
#define HOLDEM_GAME_ACTION_DATA_SIZE 256
|
||||||
|
|
||||||
/** Texas Hold'em Player State */
|
/** Texas Hold'em Player State */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@ -74,6 +79,16 @@ typedef struct {
|
|||||||
holdemplayer_t players[HOLDEM_PLAYER_COUNT];
|
holdemplayer_t players[HOLDEM_PLAYER_COUNT];
|
||||||
} holdemmatch_t;
|
} holdemmatch_t;
|
||||||
|
|
||||||
|
/** Callback for actions to use */
|
||||||
|
typedef void (*holdemActionCallback)(int32_t index, void *data);
|
||||||
|
|
||||||
|
/** Texas Hold'em Game action that can be queued and executed */
|
||||||
|
typedef struct {
|
||||||
|
holdemActionCallback init;
|
||||||
|
holdemActionCallback update;
|
||||||
|
holdemActionCallback dispose;
|
||||||
|
} holdemaction_t;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
holdemmatch_t match;
|
holdemmatch_t match;
|
||||||
|
|
||||||
@ -81,6 +96,11 @@ typedef struct {
|
|||||||
tileset_t *kagamiTileset;
|
tileset_t *kagamiTileset;
|
||||||
primitive_t *kagamiQuad;
|
primitive_t *kagamiQuad;
|
||||||
|
|
||||||
|
/** Action and Allocated Data Space */
|
||||||
|
holdemaction_t actionQueue[HOLDEM_GAME_ACTION_QUEUE_SIZE];
|
||||||
|
void *actionData[HOLDEM_GAME_ACTION_DATA_SIZE*HOLDEM_GAME_ACTION_QUEUE_SIZE];
|
||||||
|
|
||||||
|
/** Poker Table */
|
||||||
primitive_t *tablePrimitive;
|
primitive_t *tablePrimitive;
|
||||||
texture_t *tableTexture;
|
texture_t *tableTexture;
|
||||||
|
|
||||||
|
50
src/card/poker/action/action.c
Normal file
50
src/card/poker/action/action.c
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2021 Dominic Masters
|
||||||
|
*
|
||||||
|
* This software is released under the MIT License.
|
||||||
|
* https://opensource.org/licenses/MIT
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "action.h"
|
||||||
|
|
||||||
|
void holdemActionInit() {
|
||||||
|
// Free up all actions
|
||||||
|
memset(HOLDEM_GAME_STATE.actionQueue, (int32_t)NULL,
|
||||||
|
sizeof(holdemaction_t) * HOLDEM_GAME_ACTION_QUEUE_SIZE
|
||||||
|
);
|
||||||
|
|
||||||
|
// Free up all data
|
||||||
|
memset(HOLDEM_GAME_STATE.actionData, (int32_t)NULL, sizeof(void *) *
|
||||||
|
HOLDEM_GAME_ACTION_DATA_SIZE * HOLDEM_GAME_ACTION_QUEUE_SIZE
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void holdemActionAdd(holdemaction_t action) {
|
||||||
|
int32_t i = -1;
|
||||||
|
int32_t j = -1;
|
||||||
|
|
||||||
|
for(i = 0; i < HOLDEM_GAME_ACTION_QUEUE_SIZE; i++) {
|
||||||
|
if(HOLDEM_GAME_STATE.actionQueue[i].init != NULL) continue;
|
||||||
|
j = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
HOLDEM_GAME_STATE.actionQueue[j] = action;
|
||||||
|
action.init(j, HOLDEM_GAME_STATE.actionData + j);
|
||||||
|
}
|
||||||
|
|
||||||
|
void holdemActionUpdate() {
|
||||||
|
int32_t i;
|
||||||
|
for(i = 0; i < HOLDEM_GAME_ACTION_QUEUE_SIZE; i++) {
|
||||||
|
if(HOLDEM_GAME_STATE.actionQueue[i].update == NULL) continue;
|
||||||
|
HOLDEM_GAME_STATE.actionQueue[i].update(i, HOLDEM_GAME_STATE.actionData+i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void holdemActionDispose() {
|
||||||
|
int32_t i;
|
||||||
|
for(i = 0; i < HOLDEM_GAME_ACTION_QUEUE_SIZE; i++) {
|
||||||
|
if(HOLDEM_GAME_STATE.actionQueue[i].dispose == NULL) continue;
|
||||||
|
HOLDEM_GAME_STATE.actionQueue[i].dispose(i, HOLDEM_GAME_STATE.actionData+i);
|
||||||
|
}
|
||||||
|
}
|
32
src/card/poker/action/action.h
Normal file
32
src/card/poker/action/action.h
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2021 Dominic Masters
|
||||||
|
*
|
||||||
|
* This software is released under the MIT License.
|
||||||
|
* https://opensource.org/licenses/MIT
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include <dawn/dawn.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the action manager.
|
||||||
|
*/
|
||||||
|
void holdemActionInit();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds an action to the action queue.
|
||||||
|
*
|
||||||
|
* @param action Action to add to the queue.
|
||||||
|
*/
|
||||||
|
void holdemActionAdd(holdemaction_t action);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the action manager, which (in turn) updates all actions that are
|
||||||
|
* currently running.
|
||||||
|
*/
|
||||||
|
void holdemActionUpdate();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cleans up the action manager and all actions.
|
||||||
|
*/
|
||||||
|
void holdemActionDispose();
|
35
src/card/poker/action/start.c
Normal file
35
src/card/poker/action/start.c
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2021 Dominic Masters
|
||||||
|
*
|
||||||
|
* This software is released under the MIT License.
|
||||||
|
* https://opensource.org/licenses/MIT
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "start.h"
|
||||||
|
|
||||||
|
holdemaction_t actionStart() {
|
||||||
|
holdemaction_t action = {
|
||||||
|
.init = &actionStartInit,
|
||||||
|
.update = &actionStartUpdate,
|
||||||
|
.dispose = &actionStartDispose
|
||||||
|
};
|
||||||
|
|
||||||
|
return action;
|
||||||
|
}
|
||||||
|
|
||||||
|
void actionStartInit(int32_t index, void *data) {
|
||||||
|
// holdemactionstart_t *convData = data;
|
||||||
|
|
||||||
|
// Prepare the match
|
||||||
|
holdemMatchInit(&HOLDEM_GAME_STATE.match);
|
||||||
|
holdemRoundInit(&HOLDEM_GAME_STATE.match);
|
||||||
|
cardShuffle(HOLDEM_GAME_STATE.match.deck, HOLDEM_GAME_STATE.match.deckSize);
|
||||||
|
holdemFlop(&HOLDEM_GAME_STATE.match);
|
||||||
|
}
|
||||||
|
|
||||||
|
void actionStartUpdate(int32_t index, void *data) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void actionStartDispose(int32_t index, void *data) {
|
||||||
|
|
||||||
|
}
|
15
src/card/poker/action/start.h
Normal file
15
src/card/poker/action/start.h
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2021 Dominic Masters
|
||||||
|
*
|
||||||
|
* This software is released under the MIT License.
|
||||||
|
* https://opensource.org/licenses/MIT
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include <dawn/dawn.h>
|
||||||
|
|
||||||
|
holdemaction_t actionStart();
|
||||||
|
|
||||||
|
void actionStartInit(int32_t index, void *data);
|
||||||
|
void actionStartUpdate(int32_t index, void *data);
|
||||||
|
void actionStartDispose(int32_t index, void *data);
|
@ -9,144 +9,21 @@
|
|||||||
holdemgame_t HOLDEM_GAME_STATE;
|
holdemgame_t HOLDEM_GAME_STATE;
|
||||||
|
|
||||||
void holdemGameInit() {
|
void holdemGameInit() {
|
||||||
int32_t lWidth, rWidth, height;
|
// Prepare the renderer.
|
||||||
card_t card;
|
holdemRenderInit();
|
||||||
tilesetdiv_t *cardBack;
|
|
||||||
|
|
||||||
// Create the initial frame buffers
|
// Prepare the action manager
|
||||||
lWidth = HOLDEM_GAME_FRAME_LEFT_WIDTH, rWidth = HOLDEM_GAME_FRAME_RIGHT_WIDTH;
|
holdemActionInit();
|
||||||
height = HOLDEM_GAME_FRAME_HEIGHT;
|
|
||||||
HOLDEM_GAME_STATE.frameLeft = frameBufferCreate(lWidth, height);
|
|
||||||
HOLDEM_GAME_STATE.frameRight = frameBufferCreate(rWidth, height);
|
|
||||||
HOLDEM_GAME_STATE.quadLeft = quadCreate(0, 0, 0, 0, 0, lWidth, height, 1, 1);
|
|
||||||
HOLDEM_GAME_STATE.quadRight = quadCreate(0, 0, 0, 0, 0, rWidth, height, 1, 1);
|
|
||||||
|
|
||||||
// Font
|
// Start the first action
|
||||||
HOLDEM_GAME_STATE.fontTexture = assetTextureLoad("font.png");
|
holdemActionAdd(actionStart());
|
||||||
HOLDEM_GAME_STATE.fontTileset = tilesetCreate(20, 20,
|
|
||||||
HOLDEM_GAME_STATE.fontTexture->width,
|
|
||||||
HOLDEM_GAME_STATE.fontTexture->height,
|
|
||||||
1, 1, 1, 1
|
|
||||||
);
|
|
||||||
HOLDEM_GAME_STATE.fontBatch = spriteBatchCreate(1024);
|
|
||||||
|
|
||||||
// Poker Table
|
|
||||||
HOLDEM_GAME_STATE.tablePrimitive = pokerTableCreate();
|
|
||||||
HOLDEM_GAME_STATE.tableTexture = assetTextureLoad("pokertable.png");
|
|
||||||
|
|
||||||
// Kagami
|
|
||||||
HOLDEM_GAME_STATE.kagamiTexture = assetTextureLoad("kagami.png");
|
|
||||||
HOLDEM_GAME_STATE.kagamiTileset = tilesetCreate(3, 2,
|
|
||||||
HOLDEM_GAME_STATE.kagamiTexture->width,
|
|
||||||
HOLDEM_GAME_STATE.kagamiTexture->height,
|
|
||||||
0, 0, 0, 0
|
|
||||||
);
|
|
||||||
HOLDEM_GAME_STATE.kagamiQuad = quadCreate(0, 0, 0, 0, 0, 1, 1, 1, 1);
|
|
||||||
|
|
||||||
// Load Cards Texture
|
|
||||||
HOLDEM_GAME_STATE.cardTexture = assetTextureLoad("cards_normal.png");
|
|
||||||
HOLDEM_GAME_STATE.cardTileset = tilesetCreate(CARD_COUNT_PER_SUIT, 6,
|
|
||||||
HOLDEM_GAME_STATE.cardTexture->width, HOLDEM_GAME_STATE.cardTexture->height,
|
|
||||||
0, 0, 0, 0
|
|
||||||
);
|
|
||||||
|
|
||||||
// Cards Primitive
|
|
||||||
cardBack = HOLDEM_GAME_STATE.cardTileset->divisions+(
|
|
||||||
HOLDEM_GAME_STATE.cardTileset->columns * 4
|
|
||||||
);
|
|
||||||
HOLDEM_GAME_STATE.cardPrimitive = primitiveCreate(
|
|
||||||
QUAD_VERTICE_COUNT * 2, QUAD_INDICE_COUNT * 2
|
|
||||||
);
|
|
||||||
quadBuffer(HOLDEM_GAME_STATE.cardPrimitive, -HOLDEM_GAME_CARD_DEPTH,
|
|
||||||
-HOLDEM_GAME_CARD_WIDTH, -HOLDEM_GAME_CARD_HEIGHT,
|
|
||||||
cardBack->x0, cardBack->y1,
|
|
||||||
HOLDEM_GAME_CARD_WIDTH, HOLDEM_GAME_CARD_HEIGHT,
|
|
||||||
cardBack->x1, cardBack->y0,
|
|
||||||
QUAD_VERTICE_COUNT, QUAD_INDICE_COUNT
|
|
||||||
);
|
|
||||||
|
|
||||||
// Prepare match
|
|
||||||
holdemMatchInit(&HOLDEM_GAME_STATE.match);
|
|
||||||
holdemRoundInit(&HOLDEM_GAME_STATE.match);
|
|
||||||
cardShuffle(HOLDEM_GAME_STATE.match.deck, HOLDEM_GAME_STATE.match.deckSize);
|
|
||||||
holdemFlop(&HOLDEM_GAME_STATE.match);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void holdemGameUpdate() {
|
void holdemGameUpdate() {
|
||||||
int32_t lWidth, rWidth, height;
|
holdemActionUpdate();
|
||||||
|
holdemRender();
|
||||||
|
}
|
||||||
|
|
||||||
if(true) {
|
void holdemGameDispose() {
|
||||||
cameraPerspective(&HOLDEM_GAME_STATE.cameraLeft, 45,
|
holdemActionDispose();
|
||||||
((float)RENDER_STATE.width/(float)RENDER_STATE.height), 1.0f, 1000.0f
|
|
||||||
);
|
|
||||||
cameraLookAt(&HOLDEM_GAME_STATE.cameraLeft, 2, 2, 2, 0, 0, 0);
|
|
||||||
shaderUseCamera(GAME_STATE.shaderWorld, &HOLDEM_GAME_STATE.cameraLeft);
|
|
||||||
holdemRenderWorld();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Resize Frame buffers.
|
|
||||||
lWidth = HOLDEM_GAME_FRAME_LEFT_WIDTH, rWidth = HOLDEM_GAME_FRAME_RIGHT_WIDTH;
|
|
||||||
height = HOLDEM_GAME_FRAME_HEIGHT;
|
|
||||||
if(
|
|
||||||
HOLDEM_GAME_STATE.frameLeft->texture->width != lWidth ||
|
|
||||||
HOLDEM_GAME_STATE.frameLeft->texture->height != height
|
|
||||||
) {
|
|
||||||
frameBufferDispose(HOLDEM_GAME_STATE.frameLeft);
|
|
||||||
frameBufferDispose(HOLDEM_GAME_STATE.frameRight);
|
|
||||||
HOLDEM_GAME_STATE.frameLeft = frameBufferCreate(lWidth, height);
|
|
||||||
HOLDEM_GAME_STATE.frameRight = frameBufferCreate(rWidth, height);
|
|
||||||
quadBuffer(HOLDEM_GAME_STATE.quadLeft, 0,
|
|
||||||
0, 0, 0, 1,
|
|
||||||
lWidth, height, 1, 0,
|
|
||||||
0, 0
|
|
||||||
);
|
|
||||||
quadBuffer(HOLDEM_GAME_STATE.quadRight, 0,
|
|
||||||
0, 0, 0, 1,
|
|
||||||
rWidth, height, 1, 0,
|
|
||||||
0, 0
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Render things on the left frame buffer
|
|
||||||
glClearColor(0.3, 0, 0, 1);
|
|
||||||
frameBufferUse(HOLDEM_GAME_STATE.frameLeft, true);
|
|
||||||
cameraPerspective(&HOLDEM_GAME_STATE.cameraLeft, 45,
|
|
||||||
((float)lWidth/height), 1.0f, 1000.0f
|
|
||||||
);
|
|
||||||
cameraLookAt(&HOLDEM_GAME_STATE.cameraLeft, 2, 2, 2, 0, 0, 0);
|
|
||||||
shaderUseCamera(GAME_STATE.shaderWorld, &HOLDEM_GAME_STATE.cameraLeft);
|
|
||||||
holdemRenderWorld();
|
|
||||||
|
|
||||||
|
|
||||||
// Render things on the right frame buffer
|
|
||||||
glClearColor(0.3, 0.3, 0, 1);
|
|
||||||
frameBufferUse(HOLDEM_GAME_STATE.frameRight, true);
|
|
||||||
cameraPerspective(&HOLDEM_GAME_STATE.cameraRight, 45,
|
|
||||||
((float)rWidth/height), 0.25f, 100.0f
|
|
||||||
);
|
|
||||||
cameraLookAt(&HOLDEM_GAME_STATE.cameraRight, 0, 3, 3, 0, 0, 0);
|
|
||||||
shaderUseCamera(GAME_STATE.shaderWorld, &HOLDEM_GAME_STATE.cameraRight);
|
|
||||||
holdemRenderWorld();
|
|
||||||
|
|
||||||
|
|
||||||
// Finally, render the frame buffers to the back buffer.
|
|
||||||
glClearColor(0, 0, 0, 1);
|
|
||||||
frameBufferUse(NULL, true);
|
|
||||||
cameraOrtho(&GAME_STATE.cameraWorld, 0,
|
|
||||||
RENDER_STATE.width, RENDER_STATE.height, 1, 0, 1
|
|
||||||
);
|
|
||||||
cameraLookAt(&GAME_STATE.cameraWorld, 0, 0, 0.5f, 0, 0, 0);
|
|
||||||
shaderUseCamera(GAME_STATE.shaderWorld, &GAME_STATE.cameraWorld);
|
|
||||||
|
|
||||||
// L
|
|
||||||
shaderUsePosition(GAME_STATE.shaderWorld, 0, 0, 0, 0, 0, 0);
|
|
||||||
shaderUseTexture(GAME_STATE.shaderWorld, HOLDEM_GAME_STATE.frameLeft->texture);
|
|
||||||
primitiveDraw(HOLDEM_GAME_STATE.quadLeft, 0, -1);
|
|
||||||
// R
|
|
||||||
shaderUsePosition(GAME_STATE.shaderWorld,
|
|
||||||
RENDER_STATE.width-rWidth, 0, 0, 0, 0, 0
|
|
||||||
);
|
|
||||||
shaderUseTexture(GAME_STATE.shaderWorld, HOLDEM_GAME_STATE.frameRight->texture);
|
|
||||||
primitiveDraw(HOLDEM_GAME_STATE.quadRight, 0, -1);
|
|
||||||
}
|
}
|
@ -10,19 +10,22 @@
|
|||||||
#include "holdem.h"
|
#include "holdem.h"
|
||||||
#include "render/holdemrender.h"
|
#include "render/holdemrender.h"
|
||||||
#include "../card.h"
|
#include "../card.h"
|
||||||
#include "../../display/framebuffer.h"
|
|
||||||
#include "../../display/debug/position.h"
|
|
||||||
#include "../../display/primitive.h"
|
|
||||||
#include "../../display/shader.h"
|
|
||||||
#include "../../display/camera.h"
|
|
||||||
#include "../../display/primitives/cube.h"
|
|
||||||
#include "../../display/tileset.h"
|
|
||||||
#include "../../display/primitives/quad.h"
|
|
||||||
#include "../../file/asset.h"
|
#include "../../file/asset.h"
|
||||||
#include "../../display/gui/font.h"
|
#include "../../display/gui/font.h"
|
||||||
#include "model/pokertable.h"
|
#include "action/action.h"
|
||||||
|
#include "action/start.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the Texas Hold'em game
|
||||||
|
*/
|
||||||
void holdemGameInit();
|
void holdemGameInit();
|
||||||
|
|
||||||
void holdemGameUpdate();
|
/**
|
||||||
|
* Update the Texas Hold'em game.
|
||||||
|
*/
|
||||||
|
void holdemGameUpdate();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dispose the Texas Hold'em game.
|
||||||
|
*/
|
||||||
|
void holdemGameDispose();
|
@ -7,9 +7,159 @@
|
|||||||
|
|
||||||
#include "holdemrender.h"
|
#include "holdemrender.h"
|
||||||
|
|
||||||
|
void holdemRenderInit() {
|
||||||
|
int32_t lWidth, rWidth, height;
|
||||||
|
card_t card;
|
||||||
|
tilesetdiv_t *cardBack;
|
||||||
|
|
||||||
|
// Prepare the two frame buffers.
|
||||||
|
lWidth = HOLDEM_GAME_FRAME_LEFT_WIDTH, rWidth = HOLDEM_GAME_FRAME_RIGHT_WIDTH;
|
||||||
|
height = HOLDEM_GAME_FRAME_HEIGHT;
|
||||||
|
HOLDEM_GAME_STATE.frameLeft = frameBufferCreate(lWidth, height);
|
||||||
|
HOLDEM_GAME_STATE.frameRight = frameBufferCreate(rWidth, height);
|
||||||
|
HOLDEM_GAME_STATE.quadLeft = quadCreate(0, 0, 0, 0, 0, lWidth, height, 1, 1);
|
||||||
|
HOLDEM_GAME_STATE.quadRight = quadCreate(0, 0, 0, 0, 0, rWidth, height, 1, 1);
|
||||||
|
|
||||||
|
// Font
|
||||||
|
HOLDEM_GAME_STATE.fontTexture = assetTextureLoad("font.png");
|
||||||
|
HOLDEM_GAME_STATE.fontTileset = tilesetCreate(20, 20,
|
||||||
|
HOLDEM_GAME_STATE.fontTexture->width,
|
||||||
|
HOLDEM_GAME_STATE.fontTexture->height,
|
||||||
|
1, 1, 1, 1
|
||||||
|
);
|
||||||
|
HOLDEM_GAME_STATE.fontBatch = spriteBatchCreate(1024);
|
||||||
|
|
||||||
|
// Poker Table
|
||||||
|
HOLDEM_GAME_STATE.tablePrimitive = pokerTableCreate();
|
||||||
|
HOLDEM_GAME_STATE.tableTexture = assetTextureLoad("pokertable.png");
|
||||||
|
|
||||||
|
// Kagami
|
||||||
|
HOLDEM_GAME_STATE.kagamiTexture = assetTextureLoad("kagami.png");
|
||||||
|
HOLDEM_GAME_STATE.kagamiTileset = tilesetCreate(3, 2,
|
||||||
|
HOLDEM_GAME_STATE.kagamiTexture->width,
|
||||||
|
HOLDEM_GAME_STATE.kagamiTexture->height,
|
||||||
|
0, 0, 0, 0
|
||||||
|
);
|
||||||
|
HOLDEM_GAME_STATE.kagamiQuad = quadCreate(0, 0, 0, 0, 0, 1, 1, 1, 1);
|
||||||
|
|
||||||
|
// Load Cards Texture
|
||||||
|
HOLDEM_GAME_STATE.cardTexture = assetTextureLoad("cards_normal.png");
|
||||||
|
HOLDEM_GAME_STATE.cardTileset = tilesetCreate(CARD_COUNT_PER_SUIT, 6,
|
||||||
|
HOLDEM_GAME_STATE.cardTexture->width, HOLDEM_GAME_STATE.cardTexture->height,
|
||||||
|
0, 0, 0, 0
|
||||||
|
);
|
||||||
|
|
||||||
|
// Cards Primitive
|
||||||
|
cardBack = HOLDEM_GAME_STATE.cardTileset->divisions+(
|
||||||
|
HOLDEM_GAME_STATE.cardTileset->columns * 4
|
||||||
|
);
|
||||||
|
HOLDEM_GAME_STATE.cardPrimitive = primitiveCreate(
|
||||||
|
QUAD_VERTICE_COUNT * 2, QUAD_INDICE_COUNT * 2
|
||||||
|
);
|
||||||
|
quadBuffer(HOLDEM_GAME_STATE.cardPrimitive, -HOLDEM_GAME_CARD_DEPTH,
|
||||||
|
-HOLDEM_GAME_CARD_WIDTH, -HOLDEM_GAME_CARD_HEIGHT,
|
||||||
|
cardBack->x0, cardBack->y1,
|
||||||
|
HOLDEM_GAME_CARD_WIDTH, HOLDEM_GAME_CARD_HEIGHT,
|
||||||
|
cardBack->x1, cardBack->y0,
|
||||||
|
QUAD_VERTICE_COUNT, QUAD_INDICE_COUNT
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void holdemRender() {
|
||||||
|
int32_t lWidth, rWidth, height;
|
||||||
|
|
||||||
|
// Resize Frame buffers.
|
||||||
|
lWidth = HOLDEM_GAME_FRAME_LEFT_WIDTH, rWidth = HOLDEM_GAME_FRAME_RIGHT_WIDTH;
|
||||||
|
height = HOLDEM_GAME_FRAME_HEIGHT;
|
||||||
|
if(
|
||||||
|
HOLDEM_GAME_STATE.frameLeft->texture->width != lWidth ||
|
||||||
|
HOLDEM_GAME_STATE.frameLeft->texture->height != height
|
||||||
|
) {
|
||||||
|
frameBufferDispose(HOLDEM_GAME_STATE.frameLeft);
|
||||||
|
frameBufferDispose(HOLDEM_GAME_STATE.frameRight);
|
||||||
|
HOLDEM_GAME_STATE.frameLeft = frameBufferCreate(lWidth, height);
|
||||||
|
HOLDEM_GAME_STATE.frameRight = frameBufferCreate(rWidth, height);
|
||||||
|
quadBuffer(HOLDEM_GAME_STATE.quadLeft, 0,
|
||||||
|
0, 0, 0, 1,
|
||||||
|
lWidth, height, 1, 0,
|
||||||
|
0, 0
|
||||||
|
);
|
||||||
|
quadBuffer(HOLDEM_GAME_STATE.quadRight, 0,
|
||||||
|
0, 0, 0, 1,
|
||||||
|
rWidth, height, 1, 0,
|
||||||
|
0, 0
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Render things on the left frame buffer
|
||||||
|
glClearColor(0.3, 0, 0, 1);
|
||||||
|
frameBufferUse(HOLDEM_GAME_STATE.frameLeft, true);
|
||||||
|
cameraPerspective(&HOLDEM_GAME_STATE.cameraLeft, 25,
|
||||||
|
((float)lWidth/height), 0.2f, 1000.0f
|
||||||
|
);
|
||||||
|
// cameraLookAt(&HOLDEM_GAME_STATE.cameraLeft, 2, 2, 2, 0, 0, 0);
|
||||||
|
holdemLookHand(&HOLDEM_GAME_STATE.cameraLeft, 0x00);
|
||||||
|
shaderUseCamera(GAME_STATE.shaderWorld, &HOLDEM_GAME_STATE.cameraLeft);
|
||||||
|
holdemRenderWorld();
|
||||||
|
|
||||||
|
// Render things on the right frame buffer
|
||||||
|
glClearColor(0.3, 0.3, 0, 1);
|
||||||
|
frameBufferUse(HOLDEM_GAME_STATE.frameRight, true);
|
||||||
|
cameraPerspective(&HOLDEM_GAME_STATE.cameraRight, 45,
|
||||||
|
((float)rWidth/height), 0.25f, 100.0f
|
||||||
|
);
|
||||||
|
cameraLookAt(&HOLDEM_GAME_STATE.cameraRight, 0, 3, 3, 0, 0, 0);
|
||||||
|
shaderUseCamera(GAME_STATE.shaderWorld, &HOLDEM_GAME_STATE.cameraRight);
|
||||||
|
holdemRenderWorld();
|
||||||
|
|
||||||
|
// Finally, render the frame buffers to the back buffer.
|
||||||
|
glClearColor(0, 0, 0, 1);
|
||||||
|
frameBufferUse(NULL, true);
|
||||||
|
cameraOrtho(&GAME_STATE.cameraWorld, 0,
|
||||||
|
RENDER_STATE.width, RENDER_STATE.height, 1, 0, 1
|
||||||
|
);
|
||||||
|
cameraLookAt(&GAME_STATE.cameraWorld, 0, 0, 0.5f, 0, 0, 0);
|
||||||
|
shaderUseCamera(GAME_STATE.shaderWorld, &GAME_STATE.cameraWorld);
|
||||||
|
shaderUsePosition(GAME_STATE.shaderWorld,
|
||||||
|
0, 0, 0, 0, 0, 0
|
||||||
|
);
|
||||||
|
shaderUseTexture(GAME_STATE.shaderWorld, HOLDEM_GAME_STATE.frameLeft->texture);
|
||||||
|
primitiveDraw(HOLDEM_GAME_STATE.quadLeft, 0, -1);
|
||||||
|
shaderUsePosition(GAME_STATE.shaderWorld,
|
||||||
|
RENDER_STATE.width-rWidth, 0, 0, 0, 0, 0
|
||||||
|
);
|
||||||
|
shaderUseTexture(GAME_STATE.shaderWorld, HOLDEM_GAME_STATE.frameRight->texture);
|
||||||
|
primitiveDraw(HOLDEM_GAME_STATE.quadRight, 0, -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void holdemLookSeat(camera_t *camera, uint8_t seat) {
|
||||||
|
float x, z, angle;
|
||||||
|
|
||||||
|
angle = mathDeg2Rad(-45*seat);
|
||||||
|
x = sin(angle);
|
||||||
|
z = cos(angle);
|
||||||
|
cameraLookAt(&HOLDEM_GAME_STATE.cameraLeft,
|
||||||
|
x, 0.2, z,
|
||||||
|
-x, 0.2, -z
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void holdemLookHand(camera_t *camera, uint8_t seat) {
|
||||||
|
float x, lx, z, lz, angle, distance;
|
||||||
|
|
||||||
|
angle = mathDeg2Rad(-45*seat);
|
||||||
|
x = sin(angle);
|
||||||
|
z = cos(angle);
|
||||||
|
|
||||||
|
cameraLookAt(&HOLDEM_GAME_STATE.cameraLeft,
|
||||||
|
x*0.1, 0.8, z*0.1,
|
||||||
|
-x*0.5, 0.2, -z*0.5
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
void holdemRenderPlayer(float x, float y, float z, float yaw) {
|
void holdemRenderPlayer(float x, float y, float z, float yaw) {
|
||||||
float w, h;
|
float w, h;
|
||||||
w = 0.75, h = (
|
w = 0.6, h = (
|
||||||
(float)HOLDEM_GAME_STATE.kagamiTileset->divY /
|
(float)HOLDEM_GAME_STATE.kagamiTileset->divY /
|
||||||
(float)HOLDEM_GAME_STATE.kagamiTileset->divX
|
(float)HOLDEM_GAME_STATE.kagamiTileset->divX
|
||||||
) * w;
|
) * w;
|
||||||
@ -55,15 +205,15 @@ void holdemRenderWorld() {
|
|||||||
|
|
||||||
// Poker Table
|
// Poker Table
|
||||||
shaderUsePositionAndScale(GAME_STATE.shaderWorld,
|
shaderUsePositionAndScale(GAME_STATE.shaderWorld,
|
||||||
0, -0.01, 0.05,
|
0, -0.01, 0,
|
||||||
0, 0, 0,
|
0, 0, 0,
|
||||||
3.29, 3.29, 3.29
|
3.4, 3.4, 3.4
|
||||||
);
|
);
|
||||||
shaderUseTexture(GAME_STATE.shaderWorld, HOLDEM_GAME_STATE.tableTexture);
|
shaderUseTexture(GAME_STATE.shaderWorld, HOLDEM_GAME_STATE.tableTexture);
|
||||||
primitiveDraw(HOLDEM_GAME_STATE.tablePrimitive, 0, -1);
|
primitiveDraw(HOLDEM_GAME_STATE.tablePrimitive, 0, -1);
|
||||||
|
|
||||||
|
pitch = mathDeg2Rad(-90);
|
||||||
for(j = 0; j < HOLDEM_GAME_STATE.match.cardsFacing; j++) {
|
for(j = 0; j < HOLDEM_GAME_STATE.match.cardsFacing; j++) {
|
||||||
pitch = mathDeg2Rad(-90);
|
|
||||||
holdemRenderCard(HOLDEM_GAME_STATE.match.cards[j], j*0.2, 0, -0.2, pitch, 0, 0);
|
holdemRenderCard(HOLDEM_GAME_STATE.match.cards[j], j*0.2, 0, -0.2, pitch, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,10 +250,10 @@ void holdemRenderWorld() {
|
|||||||
spriteBatchDraw(HOLDEM_GAME_STATE.fontBatch, 0, -1);
|
spriteBatchDraw(HOLDEM_GAME_STATE.fontBatch, 0, -1);
|
||||||
|
|
||||||
// Draw the players
|
// Draw the players
|
||||||
float playerY = 0;
|
float playerY = 0.34;
|
||||||
holdemRenderPlayer(0, playerY, -1, 0);
|
holdemRenderPlayer(0, playerY, -1, 0);
|
||||||
holdemRenderPlayer(-1, playerY, -0, 90);
|
// holdemRenderPlayer(-1, playerY, -0, 90);
|
||||||
holdemRenderPlayer(-0.75, playerY, 0.75, -45);
|
// holdemRenderPlayer(-0.75, playerY, 0.75, -45);
|
||||||
holdemRenderPlayer(0.75, playerY, 0.75, 45);
|
// holdemRenderPlayer(0.75, playerY, 0.75, 45);
|
||||||
holdemRenderPlayer(1, playerY, 0, -90);
|
// holdemRenderPlayer(1, playerY, 0, -90);
|
||||||
}
|
}
|
||||||
|
@ -12,10 +12,30 @@
|
|||||||
#include "../../../display/primitives/quad.h"
|
#include "../../../display/primitives/quad.h"
|
||||||
#include "../../../display/spritebatch.h"
|
#include "../../../display/spritebatch.h"
|
||||||
#include "../../../display/gui/font.h"
|
#include "../../../display/gui/font.h"
|
||||||
|
#include "../../../display/framebuffer.h"
|
||||||
|
#include "../../../display/camera.h"
|
||||||
|
#include "../../../display/primitives/cube.h"
|
||||||
|
#include "../../../display/tileset.h"
|
||||||
#include "../../../util/math.h"
|
#include "../../../util/math.h"
|
||||||
|
#include "../model/pokertable.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepare the Hold'em Game Renderer.
|
||||||
|
*/
|
||||||
|
void holdemRenderInit();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Render the Texas Hold'em Game.
|
||||||
|
*/
|
||||||
|
void holdemRender();
|
||||||
|
|
||||||
|
void holdemLookSeat(camera_t *camera, uint8_t seat);
|
||||||
|
void holdemLookHand(camera_t *camera, uint8_t seat);
|
||||||
|
|
||||||
void holdemRenderPlayer(float x, float y, float z, float yaw);
|
void holdemRenderPlayer(float x, float y, float z, float yaw);
|
||||||
|
|
||||||
void holdemRenderCard(card_t card,
|
void holdemRenderCard(card_t card,
|
||||||
float x, float y, float z, float pitch, float yaw, float roll
|
float x, float y, float z, float pitch, float yaw, float roll
|
||||||
);
|
);
|
||||||
|
|
||||||
void holdemRenderWorld();
|
void holdemRenderWorld();
|
Reference in New Issue
Block a user