Decreased GL,GLFW presence out of Window module
This commit is contained in:
parent
086f04af39
commit
1d9fc44482
@ -68,7 +68,7 @@ bool _load_font(Assets* assets, const std::string& filename, const std::string&
|
||||
}
|
||||
pages.push_back(texture);
|
||||
}
|
||||
Font* font = new Font(pages);
|
||||
Font* font = new Font(pages, pages[0]->height / 16);
|
||||
assets->store(font, name);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
#include "Texture.h"
|
||||
#include "Batch2D.h"
|
||||
|
||||
Font::Font(std::vector<Texture*> pages) : pages(pages) {
|
||||
Font::Font(std::vector<Texture*> pages, int lineHeight) : lineHeight_(lineHeight), pages(pages) {
|
||||
}
|
||||
|
||||
Font::~Font(){
|
||||
@ -26,6 +26,9 @@ Font::~Font(){
|
||||
// return 7;
|
||||
// }
|
||||
|
||||
int Font::lineHeight() const {
|
||||
return lineHeight_;
|
||||
}
|
||||
|
||||
bool Font::isPrintableChar(int c) {
|
||||
switch (c){
|
||||
@ -42,6 +45,10 @@ bool Font::isPrintableChar(int c) {
|
||||
|
||||
#define RES 16
|
||||
|
||||
int Font::calcWidth(std::wstring text) {
|
||||
return text.length() * 8;
|
||||
}
|
||||
|
||||
void Font::draw(Batch2D* batch, std::wstring text, int x, int y) {
|
||||
draw(batch, text, x, y, STYLE_NONE);
|
||||
}
|
||||
|
||||
@ -12,11 +12,14 @@ class Batch2D;
|
||||
#define STYLE_OUTLINE 2
|
||||
|
||||
class Font {
|
||||
int lineHeight_;
|
||||
public:
|
||||
std::vector<Texture*> pages;
|
||||
Font(std::vector<Texture*> pages);
|
||||
Font(std::vector<Texture*> pages, int lineHeight);
|
||||
~Font();
|
||||
|
||||
int lineHeight() const;
|
||||
int calcWidth(std::wstring text);
|
||||
// int getGlyphWidth(char c);
|
||||
bool isPrintableChar(int c);
|
||||
void draw(Batch2D* batch, std::wstring text, int x, int y);
|
||||
|
||||
@ -2,10 +2,6 @@
|
||||
#include <cmath>
|
||||
#include <stdint.h>
|
||||
|
||||
#define GLEW_STATIC
|
||||
#include <GL/glew.h>
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <ctime>
|
||||
@ -22,6 +18,7 @@
|
||||
#include "window/Window.h"
|
||||
#include "window/Events.h"
|
||||
#include "window/Camera.h"
|
||||
#include "window/input.h"
|
||||
#include "audio/Audio.h"
|
||||
#include "voxels/Chunk.h"
|
||||
#include "voxels/Chunks.h"
|
||||
@ -117,25 +114,22 @@ Engine::Engine(const EngineSettings& settings) {
|
||||
|
||||
void Engine::updateTimers() {
|
||||
frame++;
|
||||
float currentTime = glfwGetTime();
|
||||
float currentTime = Window::time();
|
||||
delta = currentTime - lastTime;
|
||||
lastTime = currentTime;
|
||||
}
|
||||
|
||||
void Engine::updateHotkeys() {
|
||||
if (Events::jpressed(GLFW_KEY_ESCAPE)) {
|
||||
Window::setShouldClose(true);
|
||||
}
|
||||
if (Events::jpressed(GLFW_KEY_TAB) || Events::jpressed(GLFW_KEY_E)) {
|
||||
if (Events::jpressed(keycode::TAB)) {
|
||||
Events::toggleCursor();
|
||||
}
|
||||
if (Events::jpressed(GLFW_KEY_O)) {
|
||||
if (Events::jpressed(keycode::O)) {
|
||||
occlusion = !occlusion;
|
||||
}
|
||||
if (Events::jpressed(GLFW_KEY_F3)) {
|
||||
if (Events::jpressed(keycode::F3)) {
|
||||
level->player->debug = !level->player->debug;
|
||||
}
|
||||
if (Events::jpressed(GLFW_KEY_F5)) {
|
||||
if (Events::jpressed(keycode::F5)) {
|
||||
for (uint i = 0; i < level->chunks->volume; i++) {
|
||||
shared_ptr<Chunk> chunk = level->chunks->chunks[i];
|
||||
if (chunk != nullptr && chunk->isReady()) {
|
||||
@ -150,7 +144,7 @@ void Engine::mainloop() {
|
||||
std::cout << "-- preparing systems" << std::endl;
|
||||
WorldRenderer worldRenderer(level, assets);
|
||||
HudRenderer hud(assets);
|
||||
lastTime = glfwGetTime();
|
||||
lastTime = Window::time();
|
||||
|
||||
Window::swapInterval(1);
|
||||
while (!Window::isShouldClose()){
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
#include <iostream>
|
||||
#include "Window.h"
|
||||
#include "Events.h"
|
||||
|
||||
#define GLEW_STATIC
|
||||
#include <GL/glew.h>
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
@ -168,3 +170,7 @@ void Window::swapBuffers(){
|
||||
glfwSwapBuffers(window);
|
||||
Window::resetScissor();
|
||||
}
|
||||
|
||||
double Window::time() {
|
||||
return glfwGetTime();
|
||||
}
|
||||
@ -29,6 +29,8 @@ public:
|
||||
static void pushScissor(glm::vec4 area);
|
||||
static void popScissor();
|
||||
static void resetScissor();
|
||||
|
||||
static double time();
|
||||
};
|
||||
|
||||
#endif /* WINDOW_WINDOW_H_ */
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user