Browse Source

Vk: Continue context setup

Signed-off-by: Squareys <Squareys@googlemail.com>
pull/202/head
Squareys 10 years ago committed by Squareys
parent
commit
bdd3d9b66a
  1. 9
      src/Magnum/Platform/GlfwApplication.h
  2. 15
      src/Magnum/Vk/Context.cpp
  3. 1
      src/Magnum/Vk/Context.h
  4. 10
      src/Magnum/Vk/Test/ContextTest.cpp

9
src/Magnum/Platform/GlfwApplication.h

@ -220,6 +220,11 @@ class GlfwApplication {
glfwSetCursorPos(_window, Double(position.x()), Double(position.y())); glfwSetCursorPos(_window, Double(position.x()), Double(position.y()));
} }
#ifdef MAGNUM_TARGET_VULKAN
VkSurfaceKHR createVkSurface();
#endif
#ifdef DOXYGEN_GENERATING_OUTPUT #ifdef DOXYGEN_GENERATING_OUTPUT
protected: protected:
#else #else
@ -244,10 +249,6 @@ class GlfwApplication {
/*@}*/ /*@}*/
#ifdef MAGNUM_TARGET_VULKAN
VkSurfaceKHR createVkSurface();
#endif
private: private:
static void staticViewportEvent(GLFWwindow*, int w, int h) { static void staticViewportEvent(GLFWwindow*, int w, int h) {
_instance->viewportEvent({w, h}); _instance->viewportEvent({w, h});

15
src/Magnum/Vk/Context.cpp

@ -102,11 +102,13 @@ VkBool32 messageCallback(VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT
} }
bool Context::tryCreate() { bool Context::tryCreate() {
_version = Version::Vulkan_1_0;
VkApplicationInfo appInfo = {}; VkApplicationInfo appInfo = {};
appInfo.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; appInfo.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
appInfo.pApplicationName = "Vulkan Example"; appInfo.pApplicationName = "Vulkan Example";
appInfo.pEngineName = "Magnum"; appInfo.pEngineName = "Magnum";
appInfo.apiVersion = UnsignedInt(Version::Vulkan_1_0); appInfo.apiVersion = UnsignedInt(_version);
std::vector<const char*> enabledExtensions = { VK_KHR_SURFACE_EXTENSION_NAME }; std::vector<const char*> enabledExtensions = { VK_KHR_SURFACE_EXTENSION_NAME };
@ -204,4 +206,15 @@ Debug& operator<<(Debug& debug, Context::Flag value) {
return debug << "Context::Flag::(invalid)"; return debug << "Context::Flag::(invalid)";
} }
Debug& operator<<(Debug& debug, Version value) {
switch(value) {
#define _c(value) case Version::value: return debug << "Vk::Version::" #value;
_c(None)
_c(Vulkan_1_0)
#undef _c
}
return debug << "Vk::Version::(invalid)";
}
}} }}

1
src/Magnum/Vk/Context.h

@ -185,6 +185,7 @@ class MAGNUM_VK_EXPORT Context {
MAGNUM_VK_EXPORT Debug& operator<<(Debug& debug, Result value); MAGNUM_VK_EXPORT Debug& operator<<(Debug& debug, Result value);
MAGNUM_VK_EXPORT Debug& operator<<(Debug& debug, Context::Flag value); MAGNUM_VK_EXPORT Debug& operator<<(Debug& debug, Context::Flag value);
MAGNUM_VK_EXPORT Debug& operator<<(Debug& debug, Version value);
}} }}

10
src/Magnum/Vk/Test/ContextTest.cpp

@ -3,6 +3,7 @@
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016
Vladimír Vondruš <mosra@centrum.cz> Vladimír Vondruš <mosra@centrum.cz>
Copyright © 2016 Jonathan Hale <squareys@googlemail.com>
Permission is hereby granted, free of charge, to any person obtaining a Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"), copy of this software and associated documentation files (the "Software"),
@ -33,15 +34,22 @@ namespace Magnum { namespace Test {
struct ContextTest: TestSuite::Tester { struct ContextTest: TestSuite::Tester {
explicit ContextTest(); explicit ContextTest();
void createAndDestroy();
void flag(); void flag();
void result(); void result();
}; };
ContextTest::ContextTest() { ContextTest::ContextTest() {
addTests({&ContextTest::flag, addTests({&ContextTest::createAndDestroy,
&ContextTest::flag,
&ContextTest::result}); &ContextTest::result});
} }
void ContextTest::createAndDestroy() {
Vk::Context c{{}};
CORRADE_COMPARE(c.version(), Vk::Version::Vulkan_1_0);
}
void ContextTest::flag() { void ContextTest::flag() {
std::ostringstream out; std::ostringstream out;
Debug(&out) << Vk::Context::Flag::EnableValidation; Debug(&out) << Vk::Context::Flag::EnableValidation;

Loading…
Cancel
Save