Implement first menu (still not active)
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"loadingScreen": [
|
||||
{
|
||||
"unique_name": "widget0",
|
||||
"unique_name": "background",
|
||||
"position": [0.0, 0.0],
|
||||
"dimensions": [1.0, 1.0],
|
||||
"texture": "data/res/textures/loading.png"
|
||||
@@ -9,22 +9,22 @@
|
||||
],
|
||||
"mainMenuScreen": [
|
||||
{
|
||||
"unique_name": "widget1",
|
||||
"position": [0.5, 0.5],
|
||||
"dimensions": [0.25, 0.25],
|
||||
"texture": "data/res/textures/container.png"
|
||||
"unique_name": "exit",
|
||||
"position": [0.4, 0.2],
|
||||
"dimensions": [0.25, 0.10],
|
||||
"texture": "data/res/textures/exit.png"
|
||||
},
|
||||
{
|
||||
"unique_name": "widget2",
|
||||
"position": [0.75, 0.0],
|
||||
"dimensions": [0.25, 0.25],
|
||||
"texture": "data/res/textures/tex2.png"
|
||||
"unique_name": "play",
|
||||
"position": [0.4, 0.5],
|
||||
"dimensions": [0.25, 0.1],
|
||||
"texture": "data/res/textures/play.png"
|
||||
},
|
||||
{
|
||||
"unique_name": "widget3",
|
||||
"position": [0.05, 0.05],
|
||||
"dimensions": [0.35, 0.35],
|
||||
"texture": "data/res/textures/loading.png"
|
||||
"unique_name": "background",
|
||||
"position": [0.0, 0.0],
|
||||
"dimensions": [1.0, 1.0],
|
||||
"texture": "data/res/textures/mainMenu.png"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ Size=894,195
|
||||
Collapsed=0
|
||||
|
||||
[Window][Debug Utils]
|
||||
Pos=13,9
|
||||
Pos=14,9
|
||||
Size=791,379
|
||||
Collapsed=0
|
||||
|
||||
|
||||
@@ -42,6 +42,9 @@ Controller::Controller()
|
||||
menu->showScreenByName("loadingScreen");
|
||||
glfwSwapBuffers(gameWindow->getGLFWwindow());
|
||||
|
||||
// Show main menu when loading is finished...
|
||||
menu->showScreenByName("mainMenuScreen");
|
||||
|
||||
world = new World(shaderPrograms);
|
||||
|
||||
#ifdef _DEBUG
|
||||
@@ -128,23 +131,28 @@ void Controller::run()
|
||||
world->calculateShadows(getShaderProgramByName("directionalShadowDepthProgram"), getShaderProgramByName("pointShadowDepthProgram"));
|
||||
}
|
||||
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
menu->showScreenByName("mainMenuScreen");
|
||||
pp_framebuffer->bind();
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
camera->lookForward();
|
||||
camera->updateVPM();
|
||||
auto activeScreen = menu->getActiveScreen();
|
||||
if(activeScreen) {
|
||||
activeScreen->draw();
|
||||
} else {
|
||||
pp_framebuffer->bind();
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
world->getSkybox()->draw(camera->getView(), camera->getProj());
|
||||
world->draw(camera->getViewProj(), camera->getPosition());
|
||||
camera->lookForward();
|
||||
camera->updateVPM();
|
||||
|
||||
pp_framebuffer->unbind();
|
||||
pp_framebuffer->render();
|
||||
world->getSkybox()->draw(camera->getView(), camera->getProj());
|
||||
world->draw(camera->getViewProj(), camera->getPosition());
|
||||
|
||||
pp_framebuffer->unbind();
|
||||
pp_framebuffer->render();
|
||||
|
||||
#ifdef _DEBUG
|
||||
renderImGui(world, world->getPointLights()[0], &lightColor, &rotateEntity, &rotateLightSource, getShaderProgramByName("postProcessingProgram"), &intensity, &drawShadows);
|
||||
renderImGui(world, world->getPointLights()[0], &lightColor, &rotateEntity, &rotateLightSource, getShaderProgramByName("postProcessingProgram"), &intensity, &drawShadows);
|
||||
#endif
|
||||
}
|
||||
glfwSwapBuffers(gameWindow->getGLFWwindow());
|
||||
|
||||
// Update window size
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#include "Menu.h"
|
||||
#include "JsonParser.h"
|
||||
#include "eventActions.h"
|
||||
#include "helper.h"
|
||||
|
||||
#include <iostream>
|
||||
Menu::Menu(Framebuffer *p_framebuffer, ShaderProgram *p_shaderProgram) :
|
||||
framebuffer(p_framebuffer), shaderProgram(p_shaderProgram)
|
||||
@@ -27,6 +29,11 @@ Screen *Menu::getScreenByName(const char* unique_name)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Screen *Menu::getActiveScreen()
|
||||
{
|
||||
return activeScreen;
|
||||
}
|
||||
|
||||
void Menu::showScreenByName(const char *unique_name)
|
||||
{
|
||||
auto it = screens.begin();
|
||||
|
||||
@@ -15,6 +15,8 @@ public:
|
||||
Screen *getScreenByName(const char *unique_name);
|
||||
void showScreenByName(const char *unique_name);
|
||||
|
||||
Screen *getActiveScreen();
|
||||
|
||||
void resetActiveScreen();
|
||||
|
||||
void handleMouseButtonActionRegister(bool *mouseButtonActionRegister, Window* window);
|
||||
|
||||
@@ -10,13 +10,11 @@ Widget::Widget(std::string &name, Texture *texture, float p_x, float p_y, float
|
||||
{
|
||||
widgetTextures.push_back(texture);
|
||||
|
||||
const double ofst = 0.005;
|
||||
|
||||
double widgetVerticesData[12] = {
|
||||
2 * (x + w) - 1.0f + ofst, 2 * (y) - 1.0f - ofst, 0.0f, // Bottom right
|
||||
2 * (x) - 1.0f - ofst, 2 * (y + h) - 1.0f + ofst, 0.0f, // Top left
|
||||
2 * (x) - 1.0f - ofst, 2 * (y) - 1.0f - ofst, 0.0f, // Bottom left
|
||||
2 * (x + w) - 1.0f + ofst, 2 * (y + h) - 1.0f + ofst, 0.0f // Top right
|
||||
2 * (x + w) - 1.0f, 2 * (y) - 1.0f, 0.0f, // Bottom right
|
||||
2 * (x) - 1.0f, 2 * (y + h) - 1.0f, 0.0f, // Top left
|
||||
2 * (x) - 1.0f, 2 * (y) - 1.0f, 0.0f, // Bottom left
|
||||
2 * (x + w) - 1.0f, 2 * (y + h) - 1.0f, 0.0f // Top right
|
||||
};
|
||||
|
||||
unsigned int widgetIndicesData[6] = {
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
#ifdef __linux__
|
||||
#include <unistd.h>
|
||||
|
||||
Reference in New Issue
Block a user