Visual Computing Library
All Classes Functions Variables Typedefs Enumerations Friends Modules Pages Concepts
imgui_shaders.h
1/*****************************************************************************
2 * VCLib *
3 * Visual Computing Library *
4 * *
5 * Copyright(C) 2021-2025 *
6 * Visual Computing Lab *
7 * ISTI - Italian National Research Council *
8 * *
9 * All rights reserved. *
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the Mozilla Public License Version 2.0 as published *
13 * by the Mozilla Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 * This program is distributed in the hope that it will be useful, *
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
19 * Mozilla Public License Version 2.0 *
20 * (https://www.mozilla.org/en-US/MPL/2.0/) for more details. *
21 ****************************************************************************/
22
23#ifndef VCL_BGFX_IMGUI_IMGUI_SHADERS_H
24#define VCL_BGFX_IMGUI_IMGUI_SHADERS_H
25
26#include <vclib/bgfx/programs/load_program.h>
27
28#include <bgfx_imgui/fs_imgui_image.sc.glsl.bin.h>
29#include <bgfx_imgui/vs_imgui_image.sc.glsl.bin.h>
30#include <bgfx_imgui/fs_ocornut_imgui.sc.glsl.bin.h>
31#include <bgfx_imgui/vs_ocornut_imgui.sc.glsl.bin.h>
32
33#include <bgfx_imgui/fs_imgui_image.sc.essl.bin.h>
34#include <bgfx_imgui/vs_imgui_image.sc.essl.bin.h>
35#include <bgfx_imgui/fs_ocornut_imgui.sc.essl.bin.h>
36#include <bgfx_imgui/vs_ocornut_imgui.sc.essl.bin.h>
37
38#include <bgfx_imgui/fs_imgui_image.sc.spv.bin.h>
39#include <bgfx_imgui/vs_imgui_image.sc.spv.bin.h>
40#include <bgfx_imgui/fs_ocornut_imgui.sc.spv.bin.h>
41#include <bgfx_imgui/vs_ocornut_imgui.sc.spv.bin.h>
42
43#ifdef _WIN32
44#include <bgfx_imgui/fs_imgui_image.sc.dx11.bin.h>
45#include <bgfx_imgui/vs_imgui_image.sc.dx11.bin.h>
46#include <bgfx_imgui/fs_ocornut_imgui.sc.dx11.bin.h>
47#include <bgfx_imgui/vs_ocornut_imgui.sc.dx11.bin.h>
48#endif // defined(_WIN32)
49#ifdef __APPLE__
50#include <bgfx_imgui/fs_imgui_image.sc.mtl.bin.h>
51#include <bgfx_imgui/vs_imgui_image.sc.mtl.bin.h>
52#include <bgfx_imgui/fs_ocornut_imgui.sc.mtl.bin.h>
53#include <bgfx_imgui/vs_ocornut_imgui.sc.mtl.bin.h>
54#endif // __APPLE__
55
56namespace vcl {
57
59{
60 enum Enum {ORCONUT_IMGUI, IMGUI_IMAGE};
61};
62
63namespace detail {
64
65bgfx::EmbeddedShader::Data vertOrconutImgui(bgfx::RendererType::Enum type)
66{
67 switch (type) {
68 case bgfx::RendererType::OpenGLES:
69 return {type, vs_ocornut_imgui_essl, sizeof(vs_ocornut_imgui_essl)};
70 case bgfx::RendererType::OpenGL:
71 return {type, vs_ocornut_imgui_glsl, sizeof(vs_ocornut_imgui_glsl)};
72 case bgfx::RendererType::Vulkan:
73 return {type, vs_ocornut_imgui_spv, sizeof(vs_ocornut_imgui_spv)};
74#ifdef _WIN32
75 case bgfx::RendererType::Direct3D11:
76 return {type, vs_ocornut_imgui_dx11, sizeof(vs_ocornut_imgui_dx11)};
77 case bgfx::RendererType::Direct3D12:
78 // TODO
79#endif
80#ifdef __APPLE__
81 case bgfx::RendererType::Metal:
82 return {type, vs_ocornut_imgui_mtl, sizeof(vs_ocornut_imgui_mtl)};
83#endif
84 default: return {type, nullptr, 0};
85 }
86}
87
88bgfx::EmbeddedShader::Data fragOrconutImgui(bgfx::RendererType::Enum type)
89{
90 switch (type) {
91 case bgfx::RendererType::OpenGLES:
92 return {type, fs_ocornut_imgui_essl, sizeof(fs_ocornut_imgui_essl)};
93 case bgfx::RendererType::OpenGL:
94 return {type, fs_ocornut_imgui_glsl, sizeof(fs_ocornut_imgui_glsl)};
95 case bgfx::RendererType::Vulkan:
96 return {type, fs_ocornut_imgui_spv, sizeof(fs_ocornut_imgui_spv)};
97#ifdef _WIN32
98 case bgfx::RendererType::Direct3D11:
99 return {type, fs_ocornut_imgui_dx11, sizeof(fs_ocornut_imgui_dx11)};
100 case bgfx::RendererType::Direct3D12:
101 // TODO
102#endif
103#ifdef __APPLE__
104 case bgfx::RendererType::Metal:
105 return {type, fs_ocornut_imgui_mtl, sizeof(fs_ocornut_imgui_mtl)};
106#endif
107 default: return {type, nullptr, 0};
108 }
109}
110
111bgfx::ProgramHandle loadOrconutImgui(bgfx::RendererType::Enum type)
112{
113 return vcl::createProgram(
114 vcl::loadShader(vertOrconutImgui(type)),
115 vcl::loadShader(fragOrconutImgui(type)));
116}
117
118bgfx::EmbeddedShader::Data vertImguiImage(bgfx::RendererType::Enum type)
119{
120 switch (type) {
121 case bgfx::RendererType::OpenGLES:
122 return {type, vs_imgui_image_essl, sizeof(vs_imgui_image_essl)};
123 case bgfx::RendererType::OpenGL:
124 return {type, vs_imgui_image_glsl, sizeof(vs_imgui_image_glsl)};
125 case bgfx::RendererType::Vulkan:
126 return {type, vs_imgui_image_spv, sizeof(vs_imgui_image_spv)};
127#ifdef _WIN32
128 case bgfx::RendererType::Direct3D11:
129 return {type, vs_imgui_image_dx11, sizeof(vs_imgui_image_dx11)};
130 case bgfx::RendererType::Direct3D12:
131 // TODO
132#endif
133#ifdef __APPLE__
134 case bgfx::RendererType::Metal:
135 return {type, vs_imgui_image_mtl, sizeof(vs_imgui_image_mtl)};
136#endif
137 default: return {type, nullptr, 0};
138 }
139}
140
141bgfx::EmbeddedShader::Data fragImguiImage(bgfx::RendererType::Enum type)
142{
143 switch (type) {
144 case bgfx::RendererType::OpenGLES:
145 return {type, fs_imgui_image_essl, sizeof(fs_imgui_image_essl)};
146 case bgfx::RendererType::OpenGL:
147 return {type, fs_imgui_image_glsl, sizeof(fs_imgui_image_glsl)};
148 case bgfx::RendererType::Vulkan:
149 return {type, fs_imgui_image_spv, sizeof(fs_imgui_image_spv)};
150#ifdef _WIN32
151 case bgfx::RendererType::Direct3D11:
152 return {type, fs_imgui_image_dx11, sizeof(fs_imgui_image_dx11)};
153 case bgfx::RendererType::Direct3D12:
154 // TODO
155#endif
156#ifdef __APPLE__
157 case bgfx::RendererType::Metal:
158 return {type, fs_imgui_image_mtl, sizeof(fs_imgui_image_mtl)};
159#endif
160 default: return {type, nullptr, 0};
161 }
162}
163
164bgfx::ProgramHandle loadImguiImage(bgfx::RendererType::Enum type)
165{
166 return vcl::createProgram(
167 vcl::loadShader(vertImguiImage(type)),
168 vcl::loadShader(fragImguiImage(type)));
169}
170
171} // namespace detail
172
173bgfx::ProgramHandle loadProgram(ImGuiShaders::Enum program, bgfx::RendererType::Enum type)
174{
175 switch (program) {
176 case ImGuiShaders::ORCONUT_IMGUI:
177 return detail::loadOrconutImgui(type);
178 case ImGuiShaders::IMGUI_IMAGE:
179 return detail::loadImguiImage(type);
180 default: return BGFX_INVALID_HANDLE;
181 }
182}
183
184} // namespace vcl
185
186#endif // VCL_BGFX_IMGUI_IMGUI_SHADERS_H
A class representing a line segment in n-dimensional space. The class is parameterized by a PointConc...
Definition segment.h:43
Definition imgui_shaders.h:59