Testing some crap
This commit is contained in:
20
src/dawnosui/CMakeLists.txt
Normal file
20
src/dawnosui/CMakeLists.txt
Normal file
@ -0,0 +1,20 @@
|
||||
# Copyright (c) 2022 Dominic Masters
|
||||
#
|
||||
# This software is released under the MIT License.
|
||||
# https://opensource.org/licenses/MIT
|
||||
|
||||
# Set up the executable
|
||||
set(DAWN_TARGET_NAME "DawnOS" CACHE INTERNAL ${DAWN_CACHE_TARGET})
|
||||
|
||||
# Build Project
|
||||
add_executable(${DAWN_TARGET_NAME})
|
||||
|
||||
# Includes
|
||||
target_include_directories(${DAWN_TARGET_NAME}
|
||||
PUBLIC
|
||||
${CMAKE_CURRENT_LIST_DIR}
|
||||
)
|
||||
|
||||
# Subdirs
|
||||
add_subdirectory(game)
|
||||
add_subdirectory(display)
|
7
src/dawnosui/display/CMakeLists.txt
Normal file
7
src/dawnosui/display/CMakeLists.txt
Normal file
@ -0,0 +1,7 @@
|
||||
# Copyright (c) 2022 Dominic Masters
|
||||
#
|
||||
# This software is released under the MIT License.
|
||||
# https://opensource.org/licenses/MIT
|
||||
|
||||
# Subdirs
|
||||
add_subdirectory(shader)
|
6
src/dawnosui/display/shader/CMakeLists.txt
Normal file
6
src/dawnosui/display/shader/CMakeLists.txt
Normal file
@ -0,0 +1,6 @@
|
||||
# Copyright (c) 2022 Dominic Masters
|
||||
#
|
||||
# This software is released under the MIT License.
|
||||
# https://opensource.org/licenses/MIT
|
||||
|
||||
# Sources
|
94
src/dawnosui/display/shader/TestBackgroundShader.hpp
Normal file
94
src/dawnosui/display/shader/TestBackgroundShader.hpp
Normal file
@ -0,0 +1,94 @@
|
||||
// Copyright (c) 2022 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#pragma once
|
||||
#include "display/shader/Shader.hpp"
|
||||
#include "scene/components/Components.hpp"
|
||||
|
||||
namespace Dawn {
|
||||
class TestBackgroundShader : public Shader {
|
||||
public:
|
||||
shaderparameter_t paramProjection;
|
||||
shaderparameter_t paramView;
|
||||
shaderparameter_t paramTime;
|
||||
|
||||
std::map<shaderparameter_t, enum ShaderParameterType>
|
||||
getParameters() override {
|
||||
std::map<shaderparameter_t, enum ShaderParameterType> ps;
|
||||
ps[paramTime] = SHADER_PARAMETER_TYPE_FLOAT;
|
||||
return ps;
|
||||
}
|
||||
|
||||
void setDefaultParameters(Material &material) override {
|
||||
material.floatValues[this->paramTime] = 0.0f;
|
||||
}
|
||||
|
||||
void setGlobalParameters(glm::mat4 proj, glm::mat4 view) override {
|
||||
this->setMatrix(this->paramProjection, proj);
|
||||
this->setMatrix(this->paramView, view);
|
||||
}
|
||||
|
||||
void setMeshParameters(glm::mat4 transform) override {}
|
||||
|
||||
void bindTexture(
|
||||
shaderparameter_t param,
|
||||
Texture *texture
|
||||
) override {}
|
||||
|
||||
void compile() override {
|
||||
this->compileShader(R"GLSL(
|
||||
#version 330 core
|
||||
layout (location = 0) in vec3 aPos;
|
||||
layout (location = 1) in vec2 aTexCoord;
|
||||
|
||||
uniform mat4 u_Proj;
|
||||
uniform mat4 u_View;
|
||||
|
||||
out vec2 o_TextCoord;
|
||||
void main() {
|
||||
gl_Position = u_Proj * u_View * vec4(aPos, 1.0);
|
||||
o_TextCoord = vec2(aTexCoord.x, aTexCoord.y);
|
||||
}
|
||||
)GLSL", R"GLSL(
|
||||
#version 330 core
|
||||
out vec4 o_Color;
|
||||
in vec2 o_TextCoord;
|
||||
uniform float u_Time;
|
||||
|
||||
void main() {
|
||||
highp float tSpan = 4.0;
|
||||
highp float halfTSpan = tSpan / 2.0;
|
||||
highp float t = mod(u_Time, tSpan);
|
||||
if(t > halfTSpan) {
|
||||
t = halfTSpan + (halfTSpan - t);
|
||||
}
|
||||
t = t / halfTSpan;
|
||||
|
||||
highp float x = o_TextCoord.x;
|
||||
highp float y = o_TextCoord.y;
|
||||
float h = sin(x + u_Time) / 4 + 0.5;
|
||||
|
||||
highp float r = (0.6 + ((y * t) / 5.0));
|
||||
highp float g = 0.4 + ((x * t) / (10 + (t * 3)));
|
||||
highp float b = 0.8 + ((0.2 * t) - (x / 5));
|
||||
highp float global = 0.7 + ((0.1 + (y * 0.6)) / h / 4.0);
|
||||
|
||||
|
||||
o_Color = vec4(
|
||||
r * global,
|
||||
g * global,
|
||||
b * global,
|
||||
1.0
|
||||
);
|
||||
}
|
||||
)GLSL"
|
||||
);
|
||||
|
||||
this->paramProjection = this->getParameterByName("u_Proj");
|
||||
this->paramView = this->getParameterByName("u_View");
|
||||
this->paramTime = this->getParameterByName("u_Time");
|
||||
}
|
||||
};
|
||||
}
|
10
src/dawnosui/game/CMakeLists.txt
Normal file
10
src/dawnosui/game/CMakeLists.txt
Normal file
@ -0,0 +1,10 @@
|
||||
# Copyright (c) 2022 Dominic Masters
|
||||
#
|
||||
# This software is released under the MIT License.
|
||||
# https://opensource.org/licenses/MIT
|
||||
|
||||
# Sources
|
||||
target_sources(${DAWN_TARGET_NAME}
|
||||
PRIVATE
|
||||
DawnPokerGame.cpp
|
||||
)
|
69
src/dawnosui/game/DawnPokerGame.cpp
Normal file
69
src/dawnosui/game/DawnPokerGame.cpp
Normal file
@ -0,0 +1,69 @@
|
||||
// Copyright (c) 2022 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#include "DawnPokerGame.hpp"
|
||||
|
||||
using namespace Dawn;
|
||||
|
||||
std::shared_ptr<Material> material;
|
||||
std::shared_ptr<TestBackgroundShader> shader;
|
||||
|
||||
DawnGame::DawnGame(DawnHost &host) :
|
||||
host(host),
|
||||
renderManager(*this),
|
||||
inputManager(*this)
|
||||
{
|
||||
}
|
||||
|
||||
int32_t DawnGame::init() {
|
||||
this->assetManager.init();
|
||||
this->renderManager.init();
|
||||
|
||||
this->scene = std::make_shared<Scene>(*this);
|
||||
|
||||
auto cameraObject = this->scene->createSceneItem();
|
||||
auto camera = cameraObject->addComponent<Camera>();
|
||||
camera->type = CAMERA_TYPE_ORTHONOGRAPHIC;
|
||||
camera->orthoLeft = 0.0f;
|
||||
camera->orthoRight = 1.0f;
|
||||
camera->orthoTop = 0.0f;
|
||||
camera->orthoBottom = 1.0f;
|
||||
camera->transform.lookAt(glm::vec3(0, 0, 10), glm::vec3(0, 0, 0));
|
||||
// camera->transform.lookAt(glm::vec3(50, 50, 50), glm::vec3(0, 0, 0));
|
||||
|
||||
auto quad = this->scene->createSceneItem();
|
||||
auto meshRenderer = quad->addComponent<MeshRenderer>();
|
||||
meshRenderer->mesh = std::make_shared<Mesh>();
|
||||
meshRenderer->mesh->createBuffers(QUAD_VERTICE_COUNT, QUAD_INDICE_COUNT);
|
||||
QuadMesh::bufferQuadMesh(meshRenderer->mesh.get(),
|
||||
glm::vec2(0, 0), glm::vec2(0, 0),
|
||||
glm::vec2(1.0f, 1.0f), glm::vec2(1.0f, 1.0f),
|
||||
0, 0
|
||||
);
|
||||
|
||||
shader = std::make_shared<TestBackgroundShader>();
|
||||
shader->compile();
|
||||
material = quad->addComponent<Material>();
|
||||
material->setShader(shader);
|
||||
|
||||
return DAWN_GAME_INIT_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t DawnGame::update(float_t delta) {
|
||||
this->assetManager.update();
|
||||
this->inputManager.update();
|
||||
this->timeManager.update(delta);
|
||||
|
||||
if(this->scene != nullptr) this->scene->update();
|
||||
|
||||
material->floatValues[shader->paramTime] = this->timeManager.time;
|
||||
|
||||
this->renderManager.update();
|
||||
return DAWN_GAME_UPDATE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
DawnGame::~DawnGame() {
|
||||
|
||||
}
|
10
src/dawnosui/game/DawnPokerGame.hpp
Normal file
10
src/dawnosui/game/DawnPokerGame.hpp
Normal file
@ -0,0 +1,10 @@
|
||||
// Copyright (c) 2022 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#pragma once
|
||||
#include "game/DawnGame.hpp"
|
||||
#include "scene/components/Components.hpp"
|
||||
#include "display/mesh/QuadMesh.hpp"
|
||||
#include "display/shader/TestBackgroundShader.hpp"
|
9
src/dawnosui/input/InputBinds.hpp
Normal file
9
src/dawnosui/input/InputBinds.hpp
Normal file
@ -0,0 +1,9 @@
|
||||
// Copyright (c) 2022 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#pragma once
|
||||
#include "input/InputManager.hpp"
|
||||
|
||||
#define INPUT_BIND_ACCEPT ((inputbind_t)1)
|
Reference in New Issue
Block a user