Dawn/src/dawnpokergame/game/DawnPokerGame.cpp

58 lines
1.5 KiB
C++

// Copyright (c) 2022 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "DawnPokerGame.hpp"
#include "event/Event.hpp"
using namespace Dawn;
DawnGame::DawnGame(DawnHost &host) :
host(host),
renderManager(*this)
{
}
int32_t DawnGame::init() {
this->renderManager.init();
this->scene = std::make_shared<Scene>(*this);
auto cameraObject = this->scene->createSceneItem();
auto camera = cameraObject->addComponent<Camera>();
camera->lookAt(glm::vec3(5, 5, 5), glm::vec3(0, 0, 0));
auto cubeObject = this->scene->createSceneItem();
auto cubeMeshRenderer = cubeObject->addComponent<MeshRenderer>();
auto cubeMaterial = cubeObject->addComponent<Material>();
cubeMeshRenderer->mesh = std::make_shared<Mesh>();
cubeMeshRenderer->mesh->createBuffers(QUAD_VERTICE_COUNT, QUAD_INDICE_COUNT);
QuadMesh::bufferQuadMeshWithZ(
*cubeMeshRenderer->mesh,
glm::vec2(-1, -1), glm::vec2(0, 0),
glm::vec2(1, 1), glm::vec2(1, 1),
0, 0, 0
);
auto testTexture = std::make_shared<Texture>();
testTexture->setSize(2, 2);
struct Color colors[4] = {
COLOR_RED, COLOR_GREEN, COLOR_BLUE, COLOR_WHITE
};
testTexture->buffer(colors);
cubeMaterial->textureValues[cubeMaterial->getShader()->getParameterByName("u_Text")] = testTexture;
return DAWN_GAME_INIT_RESULT_SUCCESS;
}
int32_t DawnGame::update(float_t delta) {
if(this->scene != nullptr) this->scene->update();
this->renderManager.update();
return DAWN_GAME_UPDATE_RESULT_SUCCESS;
}
DawnGame::~DawnGame() {
}