88 lines
3.4 KiB
C
88 lines
3.4 KiB
C
/**
|
|
* Copyright (c) 2021 Dominic Masters
|
|
*
|
|
* This software is released under the MIT License.
|
|
* https://opensource.org/licenses/MIT
|
|
*/
|
|
#include "holdemgame.h"
|
|
|
|
holdemgame_t HOLDEM_GAME_STATE;
|
|
|
|
void holdemGameInit() {
|
|
int32_t lWidth, rWidth, height;
|
|
|
|
// Create the initial 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);
|
|
|
|
//TESTING
|
|
HOLDEM_GAME_STATE.cube = cubeCreate(1, 1, 1);
|
|
HOLDEM_GAME_STATE.texture = assetTextureLoad("bruh.png");
|
|
|
|
// Prepare match
|
|
holdemMatchInit(&HOLDEM_GAME_STATE.match);
|
|
}
|
|
|
|
void holdemGameUpdate() {
|
|
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) {
|
|
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, 0, lWidth, height, 1, 1, 0, 0);
|
|
quadBuffer(HOLDEM_GAME_STATE.quadRight, 0, 0, 0, 0, 0, rWidth, height, 1, 1, 0, 0);
|
|
}
|
|
|
|
// Render things on the left frame buffer
|
|
frameBufferUse(HOLDEM_GAME_STATE.frameLeft, true);
|
|
cameraPerspective(&HOLDEM_GAME_STATE.cameraLeft, 45,
|
|
((float)lWidth/height), 0.25f, 100.0f
|
|
);
|
|
cameraLookAt(&HOLDEM_GAME_STATE.cameraLeft, 5, 5, 5, 0, 0, 0);
|
|
shaderUseCamera(GAME_STATE.shaderWorld, &HOLDEM_GAME_STATE.cameraLeft);
|
|
|
|
shaderUseTexture(GAME_STATE.shaderWorld, HOLDEM_GAME_STATE.texture);
|
|
shaderUsePosition(GAME_STATE.shaderWorld, 0, 0, 0, TIME_STATE.current, TIME_STATE.current, 0);
|
|
primitiveDraw(HOLDEM_GAME_STATE.cube, 0, -1);
|
|
|
|
|
|
|
|
// Render things on the right frame buffer
|
|
frameBufferUse(HOLDEM_GAME_STATE.frameRight, true);
|
|
cameraPerspective(&HOLDEM_GAME_STATE.cameraRight, 45,
|
|
((float)rWidth/height), 0.25f, 100.0f
|
|
);
|
|
cameraLookAt(&HOLDEM_GAME_STATE.cameraRight, 2, 0, 2, 0, 0, 0);
|
|
shaderUseCamera(GAME_STATE.shaderWorld, &HOLDEM_GAME_STATE.cameraRight);
|
|
|
|
shaderUseTexture(GAME_STATE.shaderWorld, HOLDEM_GAME_STATE.texture);
|
|
shaderUsePosition(GAME_STATE.shaderWorld, 0, 0, 0, TIME_STATE.current, TIME_STATE.current, 0);
|
|
primitiveDraw(HOLDEM_GAME_STATE.cube, 0, -1);
|
|
|
|
|
|
|
|
// Finally, render the frame buffers to the back buffer.
|
|
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, lWidth, 0, 0, 0, 0, 0);
|
|
shaderUseTexture(GAME_STATE.shaderWorld, HOLDEM_GAME_STATE.frameRight->texture);
|
|
primitiveDraw(HOLDEM_GAME_STATE.quadRight, 0, -1);
|
|
} |