NoJobEngine
2.0.7
Toggle main menu visibility
Loading...
Searching...
No Matches
Window.cpp
Go to the documentation of this file.
1
#include "
Engine/Core/Window.h
"
2
#include "
Engine/Platform/OpenGL/OpenGLContext.h
"
3
#include <GLFW/glfw3.h>
4
#include <stdexcept>
5
6
namespace
NoJob
{
7
namespace
{ std::uint32_t s_WindowCount = 0; }
8
9
Window::Window
(
const
WindowProps
& props) {
10
if
(s_WindowCount == 0 && glfwInit() != GLFW_TRUE)
11
throw
std::runtime_error(
"NoJobEngine: GLFW initialization failed."
);
12
13
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
14
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 6);
15
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
16
17
m_Window = glfwCreateWindow(
18
static_cast<
int
>
(props.
Width
),
19
static_cast<
int
>
(props.
Height
),
20
props.
Title
.c_str(),
nullptr
,
nullptr
);
21
22
if
(!m_Window) {
23
if
(s_WindowCount == 0) glfwTerminate();
24
throw
std::runtime_error(
"NoJobEngine: window creation failed."
);
25
}
26
27
++s_WindowCount;
28
OpenGLContext::Init
(m_Window);
29
glfwSwapInterval(1);
30
}
31
32
Window::~Window
() {
33
if
(!m_Window)
return
;
34
glfwDestroyWindow(m_Window);
35
m_Window =
nullptr
;
36
if
(--s_WindowCount == 0) glfwTerminate();
37
}
38
39
bool
Window::ShouldClose
()
const
{
40
return
glfwWindowShouldClose(m_Window) == GLFW_TRUE;
41
}
42
void
Window::PollEvents
()
const
{ glfwPollEvents(); }
43
void
Window::SwapBuffers
()
const
{ glfwSwapBuffers(m_Window); }
44
}
OpenGLContext.h
OpenGLContext declarations for the OpenGL Backend subsystem.
Window.h
Window declarations for the Core subsystem.
NoJob::OpenGLContext::Init
static void Init(GLFWwindow *window)
Definition
OpenGLContext.cpp:8
NoJob::Window::SwapBuffers
void SwapBuffers() const
Definition
Window.cpp:43
NoJob::Window::PollEvents
void PollEvents() const
Definition
Window.cpp:42
NoJob::Window::~Window
~Window()
Definition
Window.cpp:32
NoJob::Window::Window
Window(const WindowProps &props)
Definition
Window.cpp:9
NoJob::Window::ShouldClose
bool ShouldClose() const
Definition
Window.cpp:39
NoJob
Definition
BTActionNode.h:13
NoJob::WindowProps
Definition
Window.h:12
NoJob::WindowProps::Height
std::uint32_t Height
Definition
Window.h:15
NoJob::WindowProps::Title
std::string Title
Definition
Window.h:13
NoJob::WindowProps::Width
std::uint32_t Width
Definition
Window.h:14
Engine
Core
Window.cpp
Generated by
1.18.0