Implement first menu (still not active)
This commit is contained in:
@@ -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