Working on Window
This commit is contained in:
@@ -1,26 +1,27 @@
|
|||||||
#include "Engine.hpp"
|
#include "Engine.hpp"
|
||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
|
|
||||||
void Engine::init() {
|
namespace DREAM {
|
||||||
|
void Engine::init() {
|
||||||
InitWindow(screenWidth, screenHeight, "DREAM Engine 0.0.1");
|
InitWindow(screenWidth, screenHeight, "DREAM Engine 0.0.1");
|
||||||
|
|
||||||
SetTargetFPS(165);
|
SetTargetFPS(165);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Engine::update(float deltaTime) {
|
void Engine::update(float deltaTime) {
|
||||||
deltaTime = GetFrameTime();
|
deltaTime = GetFrameTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Engine::draw() {
|
void Engine::draw() {
|
||||||
BeginDrawing();
|
BeginDrawing();
|
||||||
|
|
||||||
ClearBackground(BLACK);
|
ClearBackground(BLACK);
|
||||||
DrawText("fsdf", 10, 10, 16, WHITE);
|
DrawText("fsdf", 10, 10, 16, WHITE);
|
||||||
|
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Engine::run() {
|
void Engine::run() {
|
||||||
init();
|
init();
|
||||||
while (!WindowShouldClose()) {
|
while (!WindowShouldClose()) {
|
||||||
update(deltaTime);
|
update(deltaTime);
|
||||||
@@ -28,4 +29,5 @@ void Engine::run() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
CloseWindow();
|
CloseWindow();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,10 @@
|
|||||||
|
|
||||||
#include "../Game/src/Game.hpp"
|
#include "../Game/src/Game.hpp"
|
||||||
|
|
||||||
class Engine {
|
namespace DREAM {
|
||||||
private:
|
class Engine {
|
||||||
Game m_game;
|
private:
|
||||||
|
GamePlaceholder::Game m_game;
|
||||||
|
|
||||||
const int screenWidth = 1280;
|
const int screenWidth = 1280;
|
||||||
const int screenHeight = 720;
|
const int screenHeight = 720;
|
||||||
@@ -15,9 +16,10 @@ private:
|
|||||||
void update(float deltaTime);
|
void update(float deltaTime);
|
||||||
void draw();
|
void draw();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Engine() = default;
|
Engine() = default;
|
||||||
~Engine() = default;
|
~Engine() = default;
|
||||||
|
|
||||||
void run();
|
void run();
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|||||||
3
src/Engine/Window/Window.cpp
Normal file
3
src/Engine/Window/Window.cpp
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
namespace DREAM {
|
||||||
|
// TODO: Implement Window functions
|
||||||
|
}
|
||||||
41
src/Engine/Window/Window.hpp
Normal file
41
src/Engine/Window/Window.hpp
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace DREAM {
|
||||||
|
struct WindowConfig {
|
||||||
|
int m_width { 1280 };
|
||||||
|
int m_height { 720 };
|
||||||
|
|
||||||
|
bool m_Fullscreen { false };
|
||||||
|
bool m_vsync { false };
|
||||||
|
bool m_resizable { false } ;
|
||||||
|
};
|
||||||
|
|
||||||
|
namespace Window {
|
||||||
|
void init(WindowConfig& config);
|
||||||
|
|
||||||
|
void setWidth(int width);
|
||||||
|
void setHeight(int height);
|
||||||
|
|
||||||
|
void setSize(int width, int height);
|
||||||
|
void setFullscreen(bool enabled);
|
||||||
|
void toggleFullscreen();
|
||||||
|
|
||||||
|
void setTitle(const std::string& title);
|
||||||
|
void setPosition(int x, int y);
|
||||||
|
|
||||||
|
int getWidth();
|
||||||
|
int getHeight();
|
||||||
|
float getAspectRatio();
|
||||||
|
|
||||||
|
bool isFullscreen();
|
||||||
|
bool isVSyncEnabled();
|
||||||
|
bool isResizable();
|
||||||
|
|
||||||
|
int getMonitorIndex();
|
||||||
|
int getMonitorRefreshRate();
|
||||||
|
int getMonitorWidth();
|
||||||
|
int getMonitorHeight();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,12 +1,14 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
class Game {
|
namespace GamePlaceholder {
|
||||||
private:
|
class Game {
|
||||||
|
private:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Game() = default;
|
Game() = default;
|
||||||
~Game() = default;
|
~Game() = default;
|
||||||
|
|
||||||
void update();
|
void update();
|
||||||
void draw();
|
void draw();
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#include "Engine/Engine.hpp"
|
#include "Engine/Engine.hpp"
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
Engine engine;
|
DREAM::Engine engine;
|
||||||
engine.run();
|
engine.run();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user