Main.cpp 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. // Engine includes
  4. #include "BsApplication.h"
  5. #include "Resources/BsResources.h"
  6. #include "Resources/BsBuiltinResources.h"
  7. #include "Importer/BsImporter.h"
  8. #include "Importer/BsTextureImportOptions.h"
  9. #include "Importer/BsMeshImportOptions.h"
  10. #include "Material/BsMaterial.h"
  11. #include "Material/BsShader.h"
  12. #include "Input/BsVirtualInput.h"
  13. #include "Components/BsCCamera.h"
  14. #include "Components/BsCRenderable.h"
  15. #include "Components/BsCLight.h"
  16. #include "GUI/BsCGUIWidget.h"
  17. #include "GUI/BsGUILayoutX.h"
  18. #include "GUI/BsGUILayoutY.h"
  19. #include "GUI/BsGUIPanel.h"
  20. #include "GUI/BsGUISpace.h"
  21. #include "GUI/BsGUILabel.h"
  22. #include "GUI/BsGUIButton.h"
  23. #include "GUI/BsGUIListBox.h"
  24. #include "GUI/BsProfilerOverlay.h"
  25. #include "RenderAPI/BsRenderAPI.h"
  26. #include "RenderAPI/BsRenderWindow.h"
  27. #include "Scene/BsSceneObject.h"
  28. #include "BsEngineConfig.h"
  29. #if BS_PLATFORM == BS_PLATFORM_WIN32
  30. #include <windows.h>
  31. #endif
  32. // Example includes
  33. #include "CameraFlyer.h"
  34. namespace bs
  35. {
  36. UINT32 windowResWidth = 1280;
  37. UINT32 windowResHeight = 720;
  38. /** Imports all of our assets and prepares GameObject that handle the example logic. */
  39. void setUpExample();
  40. /** Import mesh/texture/GPU programs used by the example. */
  41. void loadAssets(HMesh& model, HTexture& texture, HShader& shader);
  42. /** Create a material used by our example model. */
  43. HMaterial createMaterial(const HTexture& texture, const HShader& shader);
  44. /** Set up example scene objects. */
  45. void setUp3DScene(const HMesh& mesh, const HMaterial& material);
  46. /** Set up example GUI. */
  47. void setUpGUI();
  48. /** Set up input configuration and callbacks. */
  49. void setUpInput();
  50. /** Toggles the primary window between full-screen and windowed mode. */
  51. void toggleFullscreen();
  52. /** Called whenever the main render window is resized. */
  53. void renderWindowResized();
  54. /** Called when the selected video mode changes in the video mode list box. */
  55. void videoModeChanged(UINT32 idx, bool enabled);
  56. /** Triggered whenever a virtual button is released. */
  57. void buttonUp(const VirtualButton& button, UINT32 deviceIdx);
  58. }
  59. using namespace bs;
  60. /** Main entry point into the application. */
  61. #if BS_PLATFORM == BS_PLATFORM_WIN32
  62. int CALLBACK WinMain(
  63. _In_ HINSTANCE hInstance,
  64. _In_ HINSTANCE hPrevInstance,
  65. _In_ LPSTR lpCmdLine,
  66. _In_ int nCmdShow
  67. )
  68. #else
  69. int main()
  70. #endif
  71. {
  72. // Descriptor used for initializing the engine
  73. START_UP_DESC startUpDesc;
  74. // Use default values as specified by the build system
  75. startUpDesc.renderAPI = BS_RENDER_API_MODULE;
  76. startUpDesc.renderer = BS_RENDERER_MODULE;
  77. startUpDesc.audio = BS_AUDIO_MODULE;
  78. startUpDesc.physics = BS_PHYSICS_MODULE;
  79. // Descriptor used for initializing the primary application window.
  80. startUpDesc.primaryWindowDesc.videoMode = VideoMode(windowResWidth, windowResHeight);
  81. startUpDesc.primaryWindowDesc.title = "Banshee Example App";
  82. startUpDesc.primaryWindowDesc.fullscreen = false;
  83. startUpDesc.primaryWindowDesc.depthBuffer = false;
  84. // List of importer plugins we plan on using for importing various resources
  85. startUpDesc.importers.push_back("BansheeFreeImgImporter"); // For importing textures
  86. startUpDesc.importers.push_back("BansheeFBXImporter"); // For importing meshes
  87. startUpDesc.importers.push_back("BansheeFontImporter"); // For importing fonts
  88. startUpDesc.importers.push_back("BansheeSL"); // For importing shaders
  89. // Initializes the application with systems and primary window as defined above
  90. Application::startUp(startUpDesc);
  91. // Imports all of ours assets and prepares GameObjects that handle the example logic.
  92. setUpExample();
  93. // Runs the main loop that does most of the work. This method will exit when user closes the main
  94. // window or exits in some other way.
  95. Application::instance().runMainLoop();
  96. Application::shutDown();
  97. return 0;
  98. }
  99. namespace bs
  100. {
  101. Path dataPath = Paths::getRuntimeDataPath();
  102. Path exampleModelPath = dataPath + "Examples/Dragon.fbx";
  103. Path exampleTexturePath = dataPath + "Examples/Dragon.tga";
  104. Path exampleShaderPath = dataPath + "Examples/Example.bsl";
  105. GUIButton* toggleFullscreenButton = nullptr;
  106. bool fullscreen = false;
  107. const VideoMode* selectedVideoMode = nullptr;
  108. Vector<const VideoMode*> videoModes;
  109. HCamera sceneCamera;
  110. HProfilerOverlay profilerOverlay;
  111. VirtualButton toggleCPUProfilerBtn;
  112. VirtualButton toggleGPUProfilerBtn;
  113. bool cpuProfilerActive = false;
  114. bool gpuProfilerActive = false;
  115. void setUpExample()
  116. {
  117. HMesh exampleModel;
  118. HTexture exampleTexture;
  119. HShader exampleShader;
  120. loadAssets(exampleModel, exampleTexture, exampleShader);
  121. HMaterial exampleMaterial = createMaterial(exampleTexture, exampleShader);
  122. setUp3DScene(exampleModel, exampleMaterial);
  123. setUpGUI();
  124. setUpInput();
  125. }
  126. /**
  127. * Load the required resources. First try to load a pre-processed version of the resources. If they don't exist import
  128. * resources from the source formats into engine format, and save them for next time.
  129. */
  130. void loadAssets(HMesh& model, HTexture& texture, HShader& shader)
  131. {
  132. // Set up paths to pre-processed versions of example resources.
  133. Path exampleModelAssetPath = exampleModelPath;
  134. Path exampleTextureAssetPath = exampleTexturePath;
  135. Path exampleShaderAssetPath = exampleShaderPath;
  136. exampleModelAssetPath.setExtension(exampleModelAssetPath.getExtension() + ".asset");
  137. exampleTextureAssetPath.setExtension(exampleTextureAssetPath.getExtension() + ".asset");
  138. exampleShaderAssetPath.setExtension(exampleShaderAssetPath.getExtension() + ".asset");
  139. // Load an FBX mesh.
  140. model = gResources().load<Mesh>(exampleModelAssetPath);
  141. if(model == nullptr) // Mesh file doesn't exist, import from the source file.
  142. {
  143. // When importing you may specify optional import options that control how is the asset imported.
  144. SPtr<ImportOptions> meshImportOptions = Importer::instance().createImportOptions(exampleModelPath);
  145. // rtti_is_of_type checks if the import options are of valid type, in case the provided path is pointing to a
  146. // non-mesh resource. This is similar to dynamic_cast but uses Banshee internal RTTI system for type checking.
  147. if (rtti_is_of_type<MeshImportOptions>(meshImportOptions))
  148. {
  149. MeshImportOptions* importOptions = static_cast<MeshImportOptions*>(meshImportOptions.get());
  150. // Ensures we can save the mesh contents
  151. importOptions->setCPUCached(true);
  152. }
  153. model = gImporter().import<Mesh>(exampleModelPath, meshImportOptions);
  154. // Save for later use, so we don't have to import on the next run.
  155. gResources().save(model, exampleModelAssetPath, true);
  156. }
  157. // Load an TGA texture.
  158. texture = gResources().load<Texture>(exampleTextureAssetPath);
  159. if (texture == nullptr) // Texture file doesn't exist, import from the source file.
  160. {
  161. // When importing you may specify optional import options that control how is the asset imported.
  162. SPtr<ImportOptions> textureImportOptions = Importer::instance().createImportOptions(exampleTexturePath);
  163. // rtti_is_of_type checks if the import options are of valid type, in case the provided path is pointing to a
  164. // non-texture resource. This is similar to dynamic_cast but uses Banshee internal RTTI system for type checking.
  165. if (rtti_is_of_type<TextureImportOptions>(textureImportOptions))
  166. {
  167. TextureImportOptions* importOptions = static_cast<TextureImportOptions*>(textureImportOptions.get());
  168. // We want maximum number of mipmaps to be generated
  169. importOptions->setGenerateMipmaps(true);
  170. // The texture is in sRGB space
  171. importOptions->setSRGB(true);
  172. // Ensures we can save the texture contents
  173. importOptions->setCPUCached(true);
  174. }
  175. // Import texture with specified import options
  176. texture = gImporter().import<Texture>(exampleTexturePath, textureImportOptions);
  177. // Save for later use, so we don't have to import on the next run.
  178. gResources().save(texture, exampleTextureAssetPath, true);
  179. }
  180. // Load a shader.
  181. shader = gResources().load<Shader>(exampleShaderAssetPath);
  182. if (shader == nullptr) // Mesh file doesn't exist, import from the source file.
  183. {
  184. shader = gImporter().import<Shader>(exampleShaderPath);
  185. // Save for later use, so we don't have to import on the next run.
  186. gResources().save(shader, exampleShaderAssetPath, true);
  187. }
  188. }
  189. /** Create a material using the provided shader, and assign the provided texture to it. */
  190. HMaterial createMaterial(const HTexture& texture, const HShader& shader)
  191. {
  192. // Create a material with the provided shader.
  193. HMaterial exampleMaterial = Material::create(shader);
  194. // And set the texture to be used by the "tex" shader parameter. We leave the "samp"
  195. // parameter at its defaults. These parameters are defined in the shader (.bsl) file.
  196. exampleMaterial->setTexture("tex", texture);
  197. return exampleMaterial;
  198. }
  199. /** Set up the 3D object used by the example, and the camera to view the world through. */
  200. void setUp3DScene(const HMesh& mesh, const HMaterial& material)
  201. {
  202. /************************************************************************/
  203. /* SCENE OBJECT */
  204. /************************************************************************/
  205. // Now we create a scene object that has a position, orientation, scale and optionally
  206. // components to govern its logic. In this particular case we are creating a SceneObject
  207. // with a Renderable component which will render a mesh at the position of the scene object
  208. // with the provided material.
  209. // Create new scene object at (0, 0, 0)
  210. HSceneObject dragonSO = SceneObject::create("Dragon");
  211. // Attach the Renderable component and hook up the mesh we imported earlier,
  212. // and the material we created in the previous section.
  213. HRenderable renderable = dragonSO->addComponent<CRenderable>();
  214. renderable->setMesh(mesh);
  215. renderable->setMaterial(material);
  216. /************************************************************************/
  217. /* LIGHTS */
  218. /************************************************************************/
  219. // Add a couple of lights so that our object isn't completely in the dark.
  220. HSceneObject lightASO = SceneObject::create("Light A");
  221. HSceneObject lightBSO = SceneObject::create("Light B");
  222. lightASO->setPosition(Vector3(0, 50, 0));
  223. lightBSO->setPosition(Vector3(-130, 140, 450));
  224. HLight lightA = lightASO->addComponent<CLight>();
  225. HLight lightB = lightBSO->addComponent<CLight>();
  226. // Disable physically based attentuation because we want to set our own range
  227. lightA->setUseAutoAttenuation(false);
  228. lightB->setUseAutoAttenuation(false);
  229. lightA->setAttenuationRadius(500.0f);
  230. lightB->setAttenuationRadius(300.0f);
  231. lightA->setIntensity(10000.0f);
  232. lightB->setIntensity(10000.0f);
  233. /************************************************************************/
  234. /* CAMERA */
  235. /************************************************************************/
  236. // In order something to render on screen we need at least one camera.
  237. // Like before, we create a new scene object at (0, 0, 0).
  238. HSceneObject sceneCameraSO = SceneObject::create("SceneCamera");
  239. // Get the primary render window we need for creating the camera. Additionally
  240. // hook up a callback so we are notified when user resizes the window.
  241. SPtr<RenderWindow> window = gApplication().getPrimaryWindow();
  242. window->onResized.connect(&renderWindowResized);
  243. // Add a Camera component that will output whatever it sees into that window
  244. // (You could also use a render texture or another window you created).
  245. sceneCamera = sceneCameraSO->addComponent<CCamera>(window);
  246. // Set up camera component properties
  247. // Priority determines in what order are cameras rendered in case multiple cameras render to the same render target.
  248. // We raise the priority slightly because later in code we have defined a GUI camera that we want to render second.
  249. sceneCamera->setPriority(1);
  250. // Set closest distance that is visible. Anything below that is clipped.
  251. sceneCamera->setNearClipDistance(5);
  252. // Set farthest distance that is visible. Anything above that is clipped.
  253. sceneCamera->setFarClipDistance(10000);
  254. // Set aspect ratio depending on the current resolution
  255. sceneCamera->setAspectRatio(windowResWidth / (float)windowResHeight);
  256. // Add a CameraFlyer component that allows us to move the camera. See CameraFlyer for more information.
  257. sceneCameraSO->addComponent<CameraFlyer>();
  258. // Position and orient the camera scene object
  259. sceneCameraSO->setPosition(Vector3(-130.0f, 140.0f, 650.0f));
  260. sceneCameraSO->lookAt(Vector3(0, 0, 0));
  261. }
  262. /** Register mouse and keyboard inputs that will be used for controlling the camera. */
  263. void setUpInput()
  264. {
  265. // Register input configuration
  266. // Banshee allows you to use VirtualInput system which will map input device buttons
  267. // and axes to arbitrary names, which allows you to change input buttons without affecting
  268. // the code that uses it, since the code is only aware of the virtual names.
  269. // If you want more direct input, see Input class.
  270. auto inputConfig = VirtualInput::instance().getConfiguration();
  271. // Camera controls for buttons (digital 0-1 input, e.g. keyboard or gamepad button)
  272. inputConfig->registerButton("Forward", BC_W);
  273. inputConfig->registerButton("Back", BC_S);
  274. inputConfig->registerButton("Left", BC_A);
  275. inputConfig->registerButton("Right", BC_D);
  276. inputConfig->registerButton("Forward", BC_UP);
  277. inputConfig->registerButton("Back", BC_BACK);
  278. inputConfig->registerButton("Left", BC_LEFT);
  279. inputConfig->registerButton("Right", BC_RIGHT);
  280. inputConfig->registerButton("FastMove", BC_LSHIFT);
  281. inputConfig->registerButton("RotateCam", BC_MOUSE_RIGHT);
  282. // Camera controls for axes (analog input, e.g. mouse or gamepad thumbstick)
  283. // These return values in [-1.0, 1.0] range.
  284. inputConfig->registerAxis("Horizontal", VIRTUAL_AXIS_DESC((UINT32)InputAxis::MouseX));
  285. inputConfig->registerAxis("Vertical", VIRTUAL_AXIS_DESC((UINT32)InputAxis::MouseY));
  286. // Controls that toggle the profiler overlays
  287. inputConfig->registerButton("CPUProfilerOverlay", BC_F1);
  288. inputConfig->registerButton("GPUProfilerOverlay", BC_F2);
  289. // Cache the profiler overlay buttons so when a button is pressed we can quickly
  290. // use these to determine its the one we want
  291. toggleCPUProfilerBtn = VirtualButton("CPUProfilerOverlay");
  292. toggleGPUProfilerBtn = VirtualButton("GPUProfilerOverlay");
  293. // Hook up a callback that gets triggered whenever a virtual button is released
  294. VirtualInput::instance().onButtonUp.connect(&buttonUp);
  295. }
  296. /** Set up graphical user interface used by the example. */
  297. void setUpGUI()
  298. {
  299. // Create a scene object that will contain GUI components
  300. HSceneObject guiSO = SceneObject::create("Example");
  301. // Get the primary render window we need for creating the camera.
  302. SPtr<RenderWindow> window = gApplication().getPrimaryWindow();
  303. // First we want another camera that is responsible for rendering GUI
  304. HCamera guiCamera = guiSO->addComponent<CCamera>(window);
  305. // Notify the renderer that the camera will only be used for overlays (e.g. GUI) so it can optimize its usage
  306. SPtr<RenderSettings> settings = guiCamera->getRenderSettings();
  307. settings->overlayOnly = true;
  308. // Set up GUI camera properties.
  309. // We don't care about aspect ratio for GUI camera.
  310. guiCamera->setAspectRatio(1.0f);
  311. // This camera should ignore any Renderable objects in the scene
  312. guiCamera->setLayers(0);
  313. // Don't clear this camera as that would clear anything the main camera has rendered.
  314. guiCamera->getViewport()->setRequiresClear(false, false, false);
  315. // Add a GUIWidget, the top-level GUI component, parent to all GUI elements. GUI widgets
  316. // require you to specify a viewport that they will output rendered GUI elements to.
  317. HGUIWidget gui = guiSO->addComponent<CGUIWidget>(guiCamera);
  318. // Depth allows you to control how is a GUI widget rendered in relation to other widgets
  319. // Lower depth means the widget will be rendered in front of those with higher. In this case we just
  320. // make the depth mid-range as there are no other widgets.
  321. gui->setDepth(128);
  322. // GUI skin defines how are all child elements of the GUI widget renderered. It contains all their styles
  323. // and default layout properties. We use the default skin that comes built into Banshee.
  324. gui->setSkin(BuiltinResources::instance().getGUISkin());
  325. // Get the primary GUI panel that stretches over the entire window and add to it a vertical layout
  326. // that will be using for vertically positioning messages about toggling profiler overlay.
  327. GUILayout* bottomLayout = gui->getPanel()->addNewElement<GUILayoutY>();
  328. // Add a flexible space that fills up any remaining area in the layout, making the two labels above be aligned
  329. // to the bottom of the GUI widget (and the screen).
  330. bottomLayout->addNewElement<GUIFlexibleSpace>();
  331. // Add a couple of labels to the layout with the needed messages. Labels expect a HString object that
  332. // maps into a string table and allows for easily localization.
  333. bottomLayout->addElement(GUILabel::create(HString(L"Press F1 to toggle CPU profiler overlay")));
  334. bottomLayout->addElement(GUILabel::create(HString(L"Press F2 to toggle GPU profiler overlay")));
  335. // Create a GUI panel that is used for displaying resolution and fullscreen options.
  336. GUILayout* rightLayout = gui->getPanel()->addNewElement<GUILayoutX>();
  337. // We want all the GUI elements be right aligned, so we add a flexible space first.
  338. rightLayout->addNewElement<GUIFlexibleSpace>();
  339. // And we want the elements to be vertically placed, top to bottom
  340. GUILayout* elemLayout = rightLayout->addNewElement<GUILayoutY>();
  341. // Leave 30 pixels to the right free
  342. rightLayout->addNewElement<GUIFixedSpace>(30);
  343. // Add a button that will trigger a callback when clicked
  344. toggleFullscreenButton = GUIButton::create(HString(L"Toggle fullscreen"));
  345. toggleFullscreenButton->onClick.connect(&toggleFullscreen);
  346. elemLayout->addElement(toggleFullscreenButton);
  347. // Add a profiler overlay object that is responsible for displaying CPU and GPU profiling GUI
  348. profilerOverlay = guiSO->addComponent<CProfilerOverlay>(guiCamera->_getCamera());
  349. // Set up video mode list box
  350. // First get a list of output devices
  351. const VideoModeInfo& videoModeInfo = RenderAPI::getVideoModeInfo();
  352. // Get video mode info for the primary monitor
  353. const VideoOutputInfo& primaryMonitorInfo = videoModeInfo.getOutputInfo(0);
  354. // Make the current desktop mode the default video mode
  355. selectedVideoMode = &primaryMonitorInfo.getDesktopVideoMode();
  356. // Create list box elements for each available video mode
  357. UINT32 numVideoModes = primaryMonitorInfo.getNumVideoModes();
  358. Vector<HString> videoModeLabels(numVideoModes);
  359. UINT32 selectedVideoModeIdx = 0;
  360. for (UINT32 i = 0; i < numVideoModes; i++)
  361. {
  362. const VideoMode& curVideoMode = primaryMonitorInfo.getVideoMode(i);
  363. HString videoModeLabel(L"{0} x {1} at {2}Hz");
  364. videoModeLabel.setParameter(0, toWString(curVideoMode.getWidth()));
  365. videoModeLabel.setParameter(1, toWString(curVideoMode.getHeight()));
  366. videoModeLabel.setParameter(2, toWString(Math::roundToInt(curVideoMode.getRefreshRate())));
  367. videoModeLabels[i] = videoModeLabel;
  368. videoModes.push_back(&curVideoMode);
  369. if (curVideoMode == *selectedVideoMode)
  370. selectedVideoModeIdx = i;
  371. }
  372. // Create the list box
  373. GUIListBox* videoModeListBox = GUIListBox::create(videoModeLabels);
  374. elemLayout->addElement(videoModeListBox);
  375. // Select the default (desktop) video mode
  376. videoModeListBox->selectElement(selectedVideoModeIdx);
  377. // Set up a callback to be notified when video mode changes
  378. videoModeListBox->onSelectionToggled.connect(&videoModeChanged);
  379. }
  380. /** Callback method that toggles between fullscreen and windowed modes. */
  381. void toggleFullscreen()
  382. {
  383. SPtr<RenderWindow> window = gApplication().getPrimaryWindow();
  384. if (fullscreen)
  385. window->setWindowed(windowResWidth, windowResHeight);
  386. else
  387. window->setFullscreen(*selectedVideoMode);
  388. fullscreen = !fullscreen;
  389. }
  390. /** Callback triggered wheneve the user resizes the example window. */
  391. void renderWindowResized()
  392. {
  393. SPtr<RenderWindow> window = gApplication().getPrimaryWindow();
  394. const RenderWindowProperties& rwProps = window->getProperties();
  395. if (!fullscreen)
  396. {
  397. windowResWidth = rwProps.width;
  398. windowResHeight = rwProps.height;
  399. }
  400. sceneCamera->setAspectRatio(rwProps.width / (float)rwProps.height);
  401. }
  402. /** Callback triggered when the user selects a new video mode from the GUI drop down element. */
  403. void videoModeChanged(UINT32 idx, bool enabled)
  404. {
  405. if (!enabled)
  406. return;
  407. selectedVideoMode = videoModes[idx];
  408. if (fullscreen)
  409. {
  410. SPtr<RenderWindow> window = gApplication().getPrimaryWindow();
  411. window->setFullscreen(*selectedVideoMode);
  412. }
  413. }
  414. /** Callback triggered when a user hits a button. */
  415. void buttonUp(const VirtualButton& button, UINT32 deviceIdx)
  416. {
  417. // Check if the pressed button is one of the either buttons we defined in "setUpExample", and toggle profiler
  418. // overlays accordingly. Device index is ignored for now, as it is assumed the user is using a single keyboard,
  419. // but if you wanted support for multiple gamepads you would check deviceIdx.
  420. if (button == toggleCPUProfilerBtn)
  421. {
  422. if (cpuProfilerActive)
  423. {
  424. profilerOverlay->hide();
  425. cpuProfilerActive = false;
  426. }
  427. else
  428. {
  429. profilerOverlay->show(ProfilerOverlayType::CPUSamples);
  430. cpuProfilerActive = true;
  431. gpuProfilerActive = false;
  432. }
  433. }
  434. else if (button == toggleGPUProfilerBtn)
  435. {
  436. if (gpuProfilerActive)
  437. {
  438. profilerOverlay->hide();
  439. gpuProfilerActive = false;
  440. }
  441. else
  442. {
  443. profilerOverlay->show(ProfilerOverlayType::GPUSamples);
  444. gpuProfilerActive = true;
  445. cpuProfilerActive = false;
  446. }
  447. }
  448. }
  449. }