Skip to content

Commit 4082613

Browse files
Fixed no Vulakn and no OpenGL modes on Linux
1 parent 802c487 commit 4082613

3 files changed

Lines changed: 40 additions & 6 deletions

File tree

SampleBase/src/Linux/SampleAppLinux.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222
*/
2323

2424
#include "SampleApp.h"
25-
#include "ImGuiImplLinuxXCB.h"
25+
#if VULKAN_SUPPORTED
26+
# include "ImGuiImplLinuxXCB.h"
27+
#endif
2628
#include "ImGuiImplLinuxX11.h"
2729

2830
namespace Diligent

Tutorials/Tutorial00_HelloLinux/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ set_target_properties(Tutorial00_HelloLinux PROPERTIES
1818
CXX_EXTENSIONS OFF
1919
)
2020

21-
target_link_libraries(Tutorial00_HelloLinux PRIVATE GL X11 Diligent-GraphicsEngineOpenGL-shared)
21+
if(OPENGL_SUPPORTED)
22+
target_link_libraries(Tutorial00_HelloLinux PRIVATE Diligent-GraphicsEngineOpenGL-shared GL X11)
23+
endif()
2224

2325
if(VULKAN_SUPPORTED)
2426
target_link_libraries(Tutorial00_HelloLinux PRIVATE Diligent-GraphicsEngineVk-shared xcb)

Tutorials/Tutorial00_HelloLinux/src/Tutorial00_HelloLinux.cpp

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,9 @@ struct xcb_size_hints_t
8686
# define GL_SUPPORTED 1
8787
#endif
8888

89-
#include "Graphics/GraphicsEngineOpenGL/interface/EngineFactoryOpenGL.h"
89+
#if OPENGL_SUPPORTED
90+
# include "Graphics/GraphicsEngineOpenGL/interface/EngineFactoryOpenGL.h"
91+
#endif
9092

9193
#if VULKAN_SUPPORTED
9294
# include "Graphics/GraphicsEngineVulkan/interface/EngineFactoryVk.h"
@@ -189,6 +191,7 @@ class Tutorial00App
189191
m_pImmediateContext->Flush();
190192
}
191193

194+
#if OPENGL_SUPPORTED
192195
bool OnGLContextCreated(Display* display, Window NativeWindowHandle)
193196
{
194197
SwapChainDesc SCDesc;
@@ -204,6 +207,7 @@ class Tutorial00App
204207

205208
return true;
206209
}
210+
#endif
207211

208212
#if VULKAN_SUPPORTED
209213
bool InitVulkan(XCBInfo& xcbInfo)
@@ -479,6 +483,7 @@ int xcb_main()
479483

480484
#endif
481485

486+
#if OPENGL_SUPPORTED
482487
int x_main()
483488
{
484489
std::unique_ptr<Tutorial00App> TheApp(new Tutorial00App);
@@ -640,13 +645,20 @@ int x_main()
640645

641646
return 0;
642647
}
648+
#endif
643649

644650
int main(int argc, char** argv)
645651
{
646-
DeviceType DevType = DeviceType::OpenGL;
652+
DeviceType DevType = DeviceType::Undefined;
647653

648-
#ifdef VULKAN_SUPPORTED
654+
#if VULKAN_SUPPORTED
649655
DevType = DeviceType::Vulkan;
656+
#elif OPENGL_SUPPORTED
657+
DevType = DeviceType::OpenGL;
658+
#else
659+
# error No supported backends
660+
#endif
661+
650662
if (argc > 1)
651663
{
652664
const auto* Key = "-mode ";
@@ -656,11 +668,21 @@ int main(int argc, char** argv)
656668
pos += strlen(Key);
657669
if (strcasecmp(pos, "GL") == 0)
658670
{
671+
#if OPENGL_SUPPORTED
659672
DevType = DeviceType::OpenGL;
673+
#else
674+
std::cerr << "OpenGL is not supported";
675+
return -1;
676+
#endif
660677
}
661678
else if (strcasecmp(pos, "VK") == 0)
662679
{
680+
#if VULKAN_SUPPORTED
663681
DevType = DeviceType::Vulkan;
682+
#else
683+
std::cerr << "Vulkan is not supported";
684+
return -1;
685+
#endif
664686
}
665687
else
666688
{
@@ -670,11 +692,19 @@ int main(int argc, char** argv)
670692
}
671693
}
672694

695+
#if VULKAN_SUPPORTED
673696
if (DevType == DeviceType::Vulkan)
674697
{
675698
return xcb_main();
676699
}
677700
#endif
678701

679-
return x_main();
702+
#if OPENGL_SUPPORTED
703+
if (DevType == DeviceType::OpenGL)
704+
{
705+
return x_main();
706+
}
707+
#endif
708+
709+
return -1;
680710
}

0 commit comments

Comments
 (0)