Skip to content
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

Win32_Window implmentation #11

Merged
merged 4 commits into from
Nov 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,12 @@ install_manifest.txt
*.exe
*.out
*.app

# Visual Studio files
*.sln
*.vcxproj
*.vcxproj.filters
*.vcxproj.user
.vs/
x64/
src/vsg/vsg.dir/
20 changes: 19 additions & 1 deletion include/vsg/viewer/Window.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI

</editor-fold> */

#include <any>

#include <vsg/vk/CommandBuffer.h>
#include <vsg/vk/CommandPool.h>
#include <vsg/vk/DeviceMemory.h>
Expand All @@ -28,8 +30,24 @@ namespace vsg
Window(const Window&) = delete;
Window& operator=(const Window&) = delete;

struct Traits
{
uint32_t x = 0;
uint32_t y = 0;
uint32_t width = 800;
uint32_t height = 600;
uint32_t screenNum = 0;

std::string title = "vsg window";
bool decoration = true;

Window* shareWindow = nullptr;
std::any nativeHandle = nullptr;
};

using Result = vsg::Result<Window, VkResult, VK_SUCCESS>;
static Result create(uint32_t width, uint32_t height, bool debugLayer = false, bool apiDumpLayer = false, Window* shareWindow = nullptr, AllocationCallbacks* allocator = nullptr);
static Result Window::create(uint32_t width, uint32_t height, bool debugLayer = false, bool apiDumpLayer = false, vsg::Window* shareWindow = nullptr, vsg::AllocationCallbacks* allocator = nullptr); // for backward compat
static Result create(const Traits& traits, bool debugLayer = false, bool apiDumpLayer = false, AllocationCallbacks* allocator = nullptr);

virtual bool valid() const { return false; }

Expand Down
29 changes: 29 additions & 0 deletions include/vsg/vk/Extensions.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#pragma once

/* <editor-fold desc="MIT License">

Copyright(c) 2018 Robert Osfield

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

</editor-fold> */

#include <vsg/vk/Instance.h>

namespace vsg
{
using ExtensionProperties = std::vector<VkExtensionProperties>;

extern VSG_DECLSPEC uint32_t getExtensionPropertiesCount();

extern VSG_DECLSPEC ExtensionProperties getExtensionProperties();

extern VSG_DECLSPEC bool isExtensionSupported(const char* extensionName);

extern VSG_DECLSPEC bool isExtensionListSupported(const Names& extensionList);

} // namespace vsg
22 changes: 20 additions & 2 deletions src/vsg/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ set(SOURCES
traversals/CullTraversal.cpp

viewer/GraphicsStage.cpp
viewer/GLFW_Window.cpp
viewer/Viewer.cpp
viewer/Window.cpp

Expand All @@ -59,6 +58,7 @@ set(SOURCES
vk/DescriptorSetLayout.cpp
vk/Device.cpp
vk/DeviceMemory.cpp
vk/Extensions.cpp
vk/Fence.cpp
vk/Framebuffer.cpp
vk/GraphicsPipeline.cpp
Expand All @@ -78,6 +78,14 @@ set(SOURCES
vk/Swapchain.cpp
)

# add platform specific Window implementation
if(WIN32)
set(SOURCES ${SOURCES} viewer/Win32_Window.cpp)
else()
set(SOURCES ${SOURCES} viewer/GLFW_Window.cpp)
endif()


add_library(vsg ${HEADERS} ${SOURCES})

if(MSVC)
Expand Down Expand Up @@ -133,7 +141,17 @@ set_property(TARGET vsg PROPERTY POSITION_INDEPENDENT_CODE ON)
set_property(TARGET vsg PROPERTY CXX_STANDARD 17)

target_include_directories(vsg PUBLIC $<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include> $<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include>)
target_link_libraries(vsg PUBLIC Vulkan::Vulkan PRIVATE glfw)

# set up library dependancies
set(LIBRARIES PUBLIC Vulkan::Vulkan)

if(WIN32)
set(LIBRARIES ${LIBRARIES})
else()
set(LIBRARIES ${LIBRARIES} PRIVATE glfw)
endif()

target_link_libraries(vsg ${LIBRARIES})

install(TARGETS vsg EXPORT vsgTargets
LIBRARY DESTINATION lib
Expand Down
Loading