WIP Fullscreen Stuff (UI not scaling properly yet)

This commit is contained in:
2014-06-01 03:05:42 +02:00
parent a6906886f5
commit 72420d4248
6 changed files with 34 additions and 12 deletions
+6 -4
View File
@@ -25,16 +25,18 @@ public:
m_ResourceManager->RegisterType("Model", [rm](std::string resourceName) { return new Model(rm, *rm->Load<OBJ>("OBJ", resourceName)); });
m_ResourceManager->RegisterType("Texture", [](std::string resourceName) { return new Texture(resourceName); });
m_FrameStack = new GUI::Frame(m_EventBroker, m_ResourceManager);
m_FrameStack->Width = 1920;
m_FrameStack->Height = 1080;
m_Renderer = std::make_shared<Renderer>(m_ResourceManager);
m_Renderer->SetFullscreen(true);
m_Renderer->SetResolution(*static_cast<Rectangle*>(m_FrameStack));
m_Renderer->Initialize();
m_InputManager = std::make_shared<InputManager>(m_Renderer->GetWindow(), m_EventBroker);
m_FrameStack = new GUI::Frame(m_EventBroker, m_ResourceManager);
m_FrameStack->Width = 1280;
m_FrameStack->Height = 720;
new GUI::GameFrame(m_FrameStack, "GameFrame");
//m_World = std::make_shared<GameWorld>(m_EventBroker, m_ResourceManager);
//m_World->Initialize();
+4
View File
@@ -25,6 +25,9 @@ public:
Bottom
};
static const float BaseWidth = 1280.f;
static const float BaseHeight = 720.f;
// Set up a base frame with an event broker
Frame(std::shared_ptr<::EventBroker> eventBroker, std::shared_ptr<::ResourceManager> resourceManager)
: EventBroker(eventBroker)
@@ -180,6 +183,7 @@ protected:
std::string m_Name;
int m_Layer;
bool m_Hidden;
glm::vec2 Scale;
std::shared_ptr<Frame> m_Parent;
typedef std::multimap<std::string, std::shared_ptr<Frame>> Children_t; // name -> frame
+2 -2
View File
@@ -26,13 +26,13 @@ public:
{
vp1 = new Viewport(worldFrame, "Viewport1", m_World);
vp1->X = 0;
vp1->Width = 640;
vp1->Width = this->Width / 2.f;
//new PlayerHUD(vp1, "PlayerHUD", m_World, 1);
new VehicleSelection(vp1, "VehicleSelection", m_World, 1);
vp2 = new Viewport(worldFrame, "Viewport2", m_World);
vp2->X = vp1->Right();
vp2->Width = 640;
vp2->Width = this->Width / 2.f;
new PlayerHUD(vp2, "PlayerHUD", m_World, 2);
m_FreeCamViewport = new Viewport(worldFrame, "ViewportFreeCam", m_World);
+9 -5
View File
@@ -5,6 +5,9 @@ Renderer::Renderer(std::shared_ptr<::ResourceManager> resourceManager)
: ResourceManager(resourceManager)
{
m_VSync = false;
m_Fullscreen = false;
m_Width = 1280;
m_Height = 720;
#ifdef DEBUG
m_DrawNormals = false;
m_DrawWireframe = false;
@@ -38,11 +41,12 @@ void Renderer::Initialize()
}
// Create a window
m_Width = 1280;
m_Height = 720;
// Antialiasing
//glfwWindowHint(GLFW_SAMPLES, 16);
m_Window = glfwCreateWindow(m_Width, m_Height, "OpenGL", nullptr, nullptr);
GLFWmonitor* monitor = nullptr;
if (m_Fullscreen)
{
monitor = glfwGetPrimaryMonitor();
}
m_Window = glfwCreateWindow(m_Width, m_Height, "OpenGL", monitor, nullptr);
if (!m_Window)
{
LOG_ERROR("GLFW: Failed to create window");
+12
View File
@@ -43,6 +43,17 @@ public:
void UpdateCamera(int cameraIdentifier, glm::vec3 position, glm::quat orientation, float FOV, float nearClip, float farClip);
#pragma region NEWSTUFF
void SetResolution(const Rectangle &resolution)
{
m_Width = resolution.Width;
m_Height = resolution.Height;
}
void SetFullscreen(bool fullscreen)
{
m_Fullscreen = fullscreen;
}
void SetViewport(const Rectangle &viewport)
{
m_Viewport = viewport;
@@ -99,6 +110,7 @@ public:
private:
std::shared_ptr<::ResourceManager> ResourceManager;
bool m_Fullscreen;
int m_Width, m_Height;
struct Viewport