2021-09-13 15:53:43 +03:00
|
|
|
//
|
|
|
|
// Created by Иван Ильин on 14.01.2021.
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef ENGINE_SCREEN_H
|
|
|
|
#define ENGINE_SCREEN_H
|
|
|
|
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <map>
|
2021-10-31 11:39:08 +03:00
|
|
|
|
|
|
|
#include <SFML/Graphics.hpp>
|
|
|
|
|
|
|
|
#include "Triangle.h"
|
2021-09-13 15:53:43 +03:00
|
|
|
#include "utils/Time.h"
|
2021-10-16 20:22:55 +03:00
|
|
|
#include "Consts.h"
|
2021-10-22 19:42:32 +03:00
|
|
|
#include "Mesh.h"
|
|
|
|
#include "Camera.h"
|
2021-09-13 15:53:43 +03:00
|
|
|
|
2021-10-12 20:18:56 +03:00
|
|
|
class Screen final {
|
2021-09-13 15:53:43 +03:00
|
|
|
private:
|
2021-09-19 15:44:31 +03:00
|
|
|
std::string _title;
|
2021-09-13 15:53:43 +03:00
|
|
|
|
2021-09-19 11:25:10 +03:00
|
|
|
sf::Color _background;
|
2021-09-13 15:53:43 +03:00
|
|
|
|
2021-10-28 16:58:02 +03:00
|
|
|
const std::shared_ptr<sf::RenderWindow> _window = std::make_shared<sf::RenderWindow>();
|
2021-09-13 15:53:43 +03:00
|
|
|
public:
|
2021-10-31 11:39:08 +03:00
|
|
|
void open(int screenWidth = Consts::STANDARD_SCREEN_WIDTH, int screenHeight = Consts::STANDARD_SCREEN_HEIGHT,
|
|
|
|
const std::string &name = Consts::PROJECT_NAME, bool verticalSync = true,
|
|
|
|
sf::Color background = Consts::BACKGROUND_COLOR, sf::Uint32 style = sf::Style::Default);
|
2021-09-13 15:53:43 +03:00
|
|
|
|
|
|
|
void display();
|
2021-10-31 11:39:08 +03:00
|
|
|
|
2021-09-13 15:53:43 +03:00
|
|
|
void clear();
|
2021-10-31 11:39:08 +03:00
|
|
|
|
2021-10-22 19:42:32 +03:00
|
|
|
[[nodiscard]] bool hasFocus() const { return _window->hasFocus(); }
|
2021-09-13 15:53:43 +03:00
|
|
|
|
2021-10-31 11:39:08 +03:00
|
|
|
void drawTriangle(const Triangle &triangle);
|
|
|
|
|
|
|
|
void drawTetragon(const Vec2D &p1, const Vec2D &p2, const Vec2D &p3, const Vec2D &p4, sf::Color color);
|
|
|
|
|
|
|
|
void drawText(const std::string &string, const Vec2D &position, int size, sf::Color color);
|
|
|
|
|
|
|
|
void drawText(const sf::Text &text);
|
|
|
|
|
|
|
|
void drawSprite(const sf::Sprite &sprite);
|
|
|
|
|
|
|
|
void setTitle(const std::string &title);
|
2021-09-13 15:53:43 +03:00
|
|
|
|
2021-09-19 15:44:31 +03:00
|
|
|
[[nodiscard]] std::string title() const { return _title; };
|
2021-09-13 15:53:43 +03:00
|
|
|
|
|
|
|
bool isOpen();
|
|
|
|
|
2021-10-31 11:39:08 +03:00
|
|
|
[[nodiscard]] int width() const { return _window->getSize().x; }
|
|
|
|
|
|
|
|
[[nodiscard]] int height() const { return _window->getSize().y; }
|
2021-09-13 15:53:43 +03:00
|
|
|
|
|
|
|
void close();
|
|
|
|
|
2021-10-28 16:58:02 +03:00
|
|
|
void setMouseCursorVisible(bool visible);
|
2021-10-22 19:42:32 +03:00
|
|
|
|
|
|
|
// OpenGL functions
|
2021-10-31 11:39:08 +03:00
|
|
|
void glDrawMesh(GLfloat *geometry, GLfloat *view, GLfloat *model, size_t count);
|
|
|
|
|
2021-10-28 16:58:02 +03:00
|
|
|
[[nodiscard]] std::shared_ptr<sf::RenderWindow> renderWindow() { return _window; }
|
2021-11-05 21:28:04 +03:00
|
|
|
|
|
|
|
void pushGLStates() { _window->pushGLStates(); };
|
|
|
|
void popGLStates() { _window->popGLStates(); };
|
2021-09-13 15:53:43 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif //INC_3DZAVR_SCREEN_H
|