-
Notifications
You must be signed in to change notification settings - Fork 725
Headless and GLFW Windows #491
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
TomAtkinsonArm
merged 11 commits into
KhronosGroup:framework/v2.0
from
TomAtkinsonArm:windows
Nov 21, 2022
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
f79c46c
window interface
TomAtkinsonArm f7b7a7c
headless window
TomAtkinsonArm a79bd93
GLFW window
TomAtkinsonArm bdccff0
add VKB_TEST_GLFW
TomAtkinsonArm accee16
fix glfw errors
TomAtkinsonArm 66f9459
add samples_launcher window improvements
TomAtkinsonArm 3d9a6ba
STD Filesystem VFS (#495)
TomAtkinsonArm 2dab118
GLFW window
TomAtkinsonArm d67767d
add VKB_TEST_GLFW
TomAtkinsonArm 4943efa
directly create a surface
TomAtkinsonArm 037e925
Direct to Display
TomAtkinsonArm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# Copyright (c) 2022, Arm Limited and Contributors | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# Licensed under the Apache License, Version 2.0 the "License"; | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
vkb__register_component( | ||
NAME window_headers | ||
LINK_LIBS | ||
vkb__events | ||
volk | ||
INCLUDE_DIRS | ||
${CMAKE_CURRENT_SOURCE_DIR}/include | ||
) | ||
|
||
# headless window | ||
vkb__register_component( | ||
NAME headless_window | ||
SRC | ||
src/headless.cpp | ||
LINK_LIBS | ||
vkb__window_headers | ||
) | ||
|
||
vkb__register_tests( | ||
NAME headless_window_tests | ||
SRC | ||
tests/headless.test.cpp | ||
LIBS | ||
vkb__headless_window | ||
) | ||
|
||
if(DIRECT_TO_DISPLAY) | ||
# Direct to display can only use specific windows. windows past this point are not compatible | ||
return() | ||
endif() | ||
|
||
# glfw window | ||
vkb__register_component( | ||
NAME glfw_window | ||
SRC | ||
src/glfw.cpp | ||
LINK_LIBS | ||
vkb__window_headers | ||
glfw | ||
) | ||
|
||
option(VKB_TEST_GLFW "Enable GLFW Tests" OFF) | ||
|
||
if(VKB_TEST_GLFW) | ||
vkb__register_tests( | ||
NAME glfw_window_test | ||
SRC | ||
tests/glfw.test.cpp | ||
LIBS | ||
vkb__glfw_window | ||
) | ||
endif() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* Copyright (c) 2022, Arm Limited and Contributors | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* Licensed under the Apache License, Version 2.0 the "License"; | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "components/events/event_types.hpp" | ||
#include <components/windows/window.hpp> | ||
|
||
struct GLFWwindow; | ||
|
||
namespace components | ||
{ | ||
namespace windows | ||
{ | ||
class GLFWCallbackHelper; | ||
|
||
class GLFWWindow : public Window | ||
{ | ||
friend class GLFWCallbackHelper; | ||
|
||
public: | ||
GLFWWindow(const std::string &title = "New Window", const Extent &initial_extent = {600, 600}); | ||
~GLFWWindow(); | ||
void set_extent(const Extent &extent) override; | ||
Extent extent() const override; | ||
void set_position(const Position &position) override; | ||
Position position() const override; | ||
float dpi_factor() const override; | ||
void set_title(const std::string &title) override; | ||
std::string_view title() const override; | ||
void update() override; | ||
void attach(events::EventBus &bus) override; | ||
|
||
VkResult create_surface(VkInstance instance, VkSurfaceKHR* surface) override; | ||
|
||
protected: | ||
std::string m_title; | ||
Extent m_extent; | ||
Position m_position; | ||
|
||
GLFWwindow *m_handle{nullptr}; | ||
std::unique_ptr<GLFWCallbackHelper> m_callback_helper{nullptr}; | ||
events::ChannelSenderPtr<PositionChangedEvent> m_position_sender{nullptr}; | ||
events::ChannelSenderPtr<ContentRectChangedEvent> m_content_rect_sender{nullptr}; | ||
events::ChannelSenderPtr<FocusChangedEvent> m_focus_sender{nullptr}; | ||
events::ChannelSenderPtr<ShouldCloseEvent> m_should_close_sender{nullptr}; | ||
|
||
events::ChannelSenderPtr<events::KeyEvent> m_key_sender{nullptr}; | ||
events::ChannelSenderPtr<events::CursorPositionEvent> m_cursor_position_sender{nullptr}; | ||
events::ChannelSenderPtr<events::TouchEvent> m_touch_sender{nullptr}; | ||
}; | ||
} // namespace windows | ||
} // namespace components |
58 changes: 58 additions & 0 deletions
58
components/windows/include/components/windows/headless.hpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* Copyright (c) 2022, Arm Limited and Contributors | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* Licensed under the Apache License, Version 2.0 the "License"; | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <components/windows/window.hpp> | ||
|
||
namespace components | ||
{ | ||
namespace windows | ||
{ | ||
class HeadlessWindow : public Window | ||
{ | ||
public: | ||
HeadlessWindow(const std::string &title = "New Window", const Extent &initial_extent = {600, 600}); | ||
~HeadlessWindow() = default; | ||
void set_extent(const Extent &extent) override; | ||
Extent extent() const override; | ||
void set_position(const Position &position) override; | ||
Position position() const override; | ||
float dpi_factor() const override; | ||
void set_title(const std::string &title) override; | ||
std::string_view title() const override; | ||
void update() override; | ||
void attach(events::EventBus &bus) override; | ||
|
||
VkResult create_surface(VkInstance instance, VkSurfaceKHR* surface) override; | ||
|
||
private: | ||
std::string m_title; | ||
|
||
bool m_extent_changed{false}; | ||
Extent m_extent{}; | ||
|
||
bool m_position_changed{false}; | ||
Position m_position{0, 0}; | ||
|
||
float m_dpi_factor{1.0f}; | ||
|
||
events::ChannelSenderPtr<PositionChangedEvent> m_position_sender{nullptr}; | ||
events::ChannelSenderPtr<ContentRectChangedEvent> m_content_rect_sender{nullptr}; | ||
}; | ||
} // namespace windows | ||
} // namespace components |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.