-
Notifications
You must be signed in to change notification settings - Fork 89
MacOS App: Integrated WebGPUView #263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| /* | ||
| * Copyright 2026 Diligent Graphics LLC | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| * | ||
| * In no event and under no legal theory, whether in tort (including negligence), | ||
| * contract, or otherwise, unless required by applicable law (such as deliberate | ||
| * and grossly negligent acts) or agreed to in writing, shall any Contributor be | ||
| * liable for any damages, including any direct, indirect, special, incidental, | ||
| * or consequential damages of any character arising as a result of this License or | ||
| * out of the use or inability to use the software (including but not limited to damages | ||
| * for loss of goodwill, work stoppage, computer failure or malfunction, or any and | ||
| * all other commercial damages or losses), even if such Contributor has been advised | ||
| * of the possibility of such damages. | ||
| */ | ||
|
|
||
| #pragma once | ||
|
|
||
| #define IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS | ||
| #define IMGUI_DEFINE_MATH_OPERATORS | ||
|
|
||
| namespace Diligent | ||
| { | ||
|
|
||
| #if PLATFORM_WIN32 | ||
| class WindowsFile; | ||
| using ImGuiFile = WindowsFile; | ||
| #elif PLATFORM_UNIVERSAL_WINDOWS | ||
| class WindowsStoreFile; | ||
| using ImGuiFile = WindowsStoreFile; | ||
| #elif PLATFORM_ANDROID | ||
| class AndroidFile; | ||
| using ImGuiFile = AndroidFile; | ||
| #else | ||
| class StandardFile; | ||
| using ImGuiFile = StandardFile; | ||
| #endif | ||
|
|
||
| } // namespace Diligent | ||
|
|
||
| using ImFileHandle = Diligent::ImGuiFile*; | ||
| using ImU64 = unsigned long long; | ||
|
|
||
| ImFileHandle ImFileOpen(const char* pFileName, const char* pMode); | ||
| bool ImFileClose(ImFileHandle pFile); | ||
| ImU64 ImFileGetSize(ImFileHandle pFile); | ||
| ImU64 ImFileRead(void* pData, ImU64 Size, ImU64 Count, ImFileHandle pFile); | ||
| ImU64 ImFileWrite(const void* pData, ImU64 Size, ImU64 Count, ImFileHandle pFile); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| /* | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ImGui changes seem to be unrelated to WebGPU on Mac?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Didn’t want to create a separate PR(we can use rebase instead squash). On macOS, ImGui runs into an issue when using
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This needs to be submitted separately - we need to merge this into development first and then try to build the main module to make sure all tests pass since it affects all platforms. |
||
| * Copyright 2026 Diligent Graphics LLC | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| * | ||
| * In no event and under no legal theory, whether in tort (including negligence), | ||
| * contract, or otherwise, unless required by applicable law (such as deliberate | ||
| * and grossly negligent acts) or agreed to in writing, shall any Contributor be | ||
| * liable for any damages, including any direct, indirect, special, incidental, | ||
| * or consequential damages of any character arising as a result of this License or | ||
| * out of the use or inability to use the software (including but not limited to damages | ||
| * for loss of goodwill, work stoppage, computer failure or malfunction, or any and | ||
| * all other commercial damages or losses), even if such Contributor has been advised | ||
| * of the possibility of such damages. | ||
| */ | ||
|
|
||
| #include "ImGuiDiligentConfig.h" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think ImGuiDiligentConfig.h is helpful (unless it needs to be included somewhere else). |
||
| #include "imgui.h" | ||
| #include "imgui_internal.h" | ||
| #include "FileSystem.hpp" | ||
|
|
||
| using namespace Diligent; | ||
|
|
||
| ImFileHandle ImFileOpen(const char* pFileName, const char* pMode) | ||
| { | ||
| EFileAccessMode AccessMode = EFileAccessMode::Read; | ||
| if (pMode) | ||
| { | ||
| switch (pMode[0]) | ||
| { | ||
| case 'w': AccessMode = (pMode[1] == '+') ? EFileAccessMode::OverwriteUpdate : EFileAccessMode::Overwrite; break; | ||
| case 'a': AccessMode = (pMode[1] == '+') ? EFileAccessMode::AppendUpdate : EFileAccessMode::Append; break; | ||
| case 'r': | ||
| default: AccessMode = (pMode[1] == '+') ? EFileAccessMode::ReadUpdate : EFileAccessMode::Read; break; | ||
| } | ||
| } | ||
|
|
||
| try | ||
| { | ||
| return static_cast<ImFileHandle>(FileSystem::OpenFile({pFileName, AccessMode})); | ||
| } | ||
| catch (...) | ||
| { | ||
| return nullptr; | ||
| } | ||
| } | ||
|
|
||
| bool ImFileClose(ImFileHandle pFile) | ||
| { | ||
| if (!pFile) | ||
| return false; | ||
| delete pFile; | ||
| return true; | ||
| } | ||
|
|
||
| ImU64 ImFileGetSize(ImFileHandle pFile) | ||
| { | ||
| if (!pFile) | ||
| return static_cast<ImU64>(-1); | ||
| return static_cast<ImU64>(pFile->GetSize()); | ||
| } | ||
|
|
||
| ImU64 ImFileRead(void* pData, ImU64 ElemSize, ImU64 ElemCount, ImFileHandle pFile) | ||
| { | ||
| if (!pFile) | ||
| return 0; | ||
| const size_t TotalSize = static_cast<size_t>(ElemSize * ElemCount); | ||
| return pFile->Read(pData, TotalSize) ? ElemCount : 0; | ||
| } | ||
|
|
||
| ImU64 ImFileWrite(const void* pData, ImU64 ElemSize, ImU64 ElemCount, ImFileHandle pFile) | ||
| { | ||
| if (!pFile) | ||
| return 0; | ||
| const size_t TotalSize = static_cast<size_t>(ElemSize * ElemCount); | ||
| return pFile->Write(pData, TotalSize) ? ElemCount : 0; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| /* Copyright 2026 Diligent Graphics LLC | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. | ||
| * | ||
| * In no event and under no legal theory, whether in tort (including negligence), | ||
| * contract, or otherwise, unless required by applicable law (such as deliberate | ||
| * and grossly negligent acts) or agreed to in writing, shall any Contributor be | ||
| * liable for any damages, including any direct, indirect, special, incidental, | ||
| * or consequential damages of any character arising as a result of this License or | ||
| * out of the use or inability to use the software (including but not limited to damages | ||
| * for loss of goodwill, work stoppage, computer failure or malfunction, or any and | ||
| * all other commercial damages or losses), even if such Contributor has been advised | ||
| * of the possibility of such damages. | ||
| */ | ||
|
|
||
| #import <AppKit/AppKit.h> | ||
|
|
||
| #include "ViewBase.h" | ||
|
|
||
| @interface WebGPUView : ViewBase | ||
|
|
||
| @end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is
CFilethat is exactly that.https://github.com/DiligentGraphics/DiligentCore/blob/ce4e9b10ee7c9c603882fb6b89d622f5a5941823/Platforms/interface/FileSystem.hpp#L62-L90