Browse Source

WIP

pull/202/head
Squareys 10 years ago committed by Jonathan Hale
parent
commit
707f277366
  1. 20
      src/Magnum/Test/ContextTest.cpp
  2. 15
      src/Magnum/Vk/Context.cpp
  3. 1
      src/Magnum/Vk/Context.h

20
src/Magnum/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,21 +34,26 @@ namespace Magnum { namespace Test {
struct ContextTest: TestSuite::Tester { struct ContextTest: TestSuite::Tester {
explicit ContextTest(); explicit ContextTest();
void debugFlag(); void createAndDestroy();
void flag();
void result();
}; };
ContextTest::ContextTest() { ContextTest::ContextTest() {
addTests({&ContextTest::debugFlag}); addTests({&ContextTest::createAndDestroy,
&ContextTest::flag,
&ContextTest::result});
} }
void ContextTest::debugFlag() { void ContextTest::createAndDestroy() {
#ifdef MAGNUM_TARGET_WEBGL Vk::Context c{{}};
CORRADE_SKIP("No context flags on Emscripten yet."); CORRADE_COMPARE(c.version(), Vk::Version::Vulkan_1_0);
#else }
void ContextTest::flag() {
std::ostringstream out; std::ostringstream out;
Debug(&out) << Context::Flag::Debug << Context::Flag(0xdead); Debug(&out) << Context::Flag::Debug << Context::Flag(0xdead);
CORRADE_COMPARE(out.str(), "Context::Flag::Debug Context::Flag(0xdead)\n"); CORRADE_COMPARE(out.str(), "Context::Flag::Debug Context::Flag(0xdead)\n");
#endif
} }
}} }}

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);
}} }}

Loading…
Cancel
Save