Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
VkCV Framework
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Vulkan2021
VkCV Framework
Commits
c6d9823c
Commit
c6d9823c
authored
3 years ago
by
Sebastian Gaida
Browse files
Options
Downloads
Patches
Plain Diff
[
#89
] create get focussed window function
parent
e8406a9d
No related branches found
No related tags found
1 merge request
!90
Resolve "Mehrere Fenster, Abhängigkeiten von Core zu Fenster+Swapchain etc"
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/vkcv/Window.hpp
+15
-7
15 additions, 7 deletions
include/vkcv/Window.hpp
src/vkcv/Window.cpp
+33
-20
33 additions, 20 deletions
src/vkcv/Window.cpp
with
48 additions
and
27 deletions
include/vkcv/Window.hpp
+
15
−
7
View file @
c6d9823c
#pragma once
#pragma once
/**
* @authors Sebastian Gaida
* @file src/vkcv/Window.hpp
* @brief Window class to handle a basic rendering surface and input
*/
#define NOMINMAX
#define NOMINMAX
#include
<algorithm>
#include
<algorithm>
...
@@ -16,11 +11,12 @@ struct GLFWwindow;
...
@@ -16,11 +11,12 @@ struct GLFWwindow;
namespace
vkcv
{
namespace
vkcv
{
class
Window
{
class
Window
{
friend
class
WindowManager
;
private:
private:
std
::
string
m_title
;
std
::
string
m_title
;
bool
m_resizable
;
bool
m_resizable
;
GLFWwindow
*
m_window
;
GLFWwindow
*
m_window
;
public:
public:
/**
/**
* creates an uninitialized #Window
* creates an uninitialized #Window
...
@@ -60,6 +56,13 @@ namespace vkcv {
...
@@ -60,6 +56,13 @@ namespace vkcv {
[[
nodiscard
]]
[[
nodiscard
]]
bool
isOpen
()
const
;
bool
isOpen
()
const
;
/**
* gets the currently focused window and returns it
* only accessible to WindowManager
* @return
*/
static
Window
&
getFocusedWindow
();
/**
/**
* polls all events on the GLFWwindow
* polls all events on the GLFWwindow
*/
*/
...
@@ -115,7 +118,12 @@ namespace vkcv {
...
@@ -115,7 +118,12 @@ namespace vkcv {
* Destructor of #Window, terminates GLFW
* Destructor of #Window, terminates GLFW
*/
*/
virtual
~
Window
();
virtual
~
Window
();
/**
* destroys the window
*/
void
destroyWindow
();
/**
/**
* gets the windows framebuffer size
* gets the windows framebuffer size
* @param width
* @param width
...
...
This diff is collapsed.
Click to expand it.
src/vkcv/Window.cpp
+
33
−
20
View file @
c6d9823c
/**
* @authors Sebastian Gaida
* @file src/vkcv/Window.cpp
* @brief Window class to handle a basic rendering surface and input
*/
#include
<thread>
#include
<thread>
#include
<vector>
#include
<vector>
...
@@ -63,20 +58,7 @@ namespace vkcv {
...
@@ -63,20 +58,7 @@ namespace vkcv {
static
std
::
vector
<
GLFWwindow
*>
s_Windows
;
static
std
::
vector
<
GLFWwindow
*>
s_Windows
;
void
Window_onGamepadEvent
(
int
gamepadIndex
)
{
void
Window_onGamepadEvent
(
int
gamepadIndex
)
{
size_t
activeWindowIndex
=
std
::
find_if
(
Window
::
getFocusedWindow
().
e_gamepad
(
gamepadIndex
);
s_Windows
.
begin
(),
s_Windows
.
end
(),
[](
GLFWwindow
*
window
){
return
glfwGetWindowAttrib
(
window
,
GLFW_FOCUSED
);}
)
-
s_Windows
.
begin
();
// fixes index getting out of bounds (e.g. if there is no focused window)
activeWindowIndex
*=
(
activeWindowIndex
<
s_Windows
.
size
());
auto
window
=
static_cast
<
Window
*>
(
glfwGetWindowUserPointer
(
s_Windows
[
activeWindowIndex
]));
if
(
window
!=
nullptr
)
{
window
->
e_gamepad
(
gamepadIndex
);
}
}
}
static
GLFWwindow
*
createGLFWWindow
(
const
char
*
windowTitle
,
int
width
,
int
height
,
bool
resizable
)
{
static
GLFWwindow
*
createGLFWWindow
(
const
char
*
windowTitle
,
int
width
,
int
height
,
bool
resizable
)
{
...
@@ -162,6 +144,21 @@ namespace vkcv {
...
@@ -162,6 +144,21 @@ namespace vkcv {
glfwTerminate
();
glfwTerminate
();
}
}
}
}
void
Window
::
destroyWindow
()
{
Window
::
e_mouseButton
.
unlock
();
Window
::
e_mouseMove
.
unlock
();
Window
::
e_mouseScroll
.
unlock
();
Window
::
e_resize
.
unlock
();
Window
::
e_key
.
unlock
();
Window
::
e_char
.
unlock
();
Window
::
e_gamepad
.
unlock
();
if
(
m_window
)
{
s_Windows
.
erase
(
std
::
find
(
s_Windows
.
begin
(),
s_Windows
.
end
(),
m_window
));
glfwDestroyWindow
(
m_window
);
}
}
Window
::
Window
(
const
Window
&
other
)
:
Window
::
Window
(
const
Window
&
other
)
:
m_title
(
other
.
getTitle
()),
m_title
(
other
.
getTitle
()),
...
@@ -291,5 +288,21 @@ namespace vkcv {
...
@@ -291,5 +288,21 @@ namespace vkcv {
height
=
0
;
height
=
0
;
}
}
}
}
Window
&
Window
::
getFocusedWindow
()
{
static
Window
defaultWindow
;
auto
activeWindowIterator
=
std
::
find_if
(
s_Windows
.
begin
(),
s_Windows
.
end
(),
[](
GLFWwindow
*
window
)
{
return
glfwGetWindowAttrib
(
window
,
GLFW_FOCUSED
);
}
);
if
(
activeWindowIterator
==
s_Windows
.
end
()
)
{
return
defaultWindow
;
}
Window
&
window
=
*
static_cast
<
Window
*>
(
glfwGetWindowUserPointer
(
*
activeWindowIterator
));
return
window
;
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment