[Drape] Introduce developer sandbox app for rendering debugging and developement #10052
8
.github/workflows/linux-check.yaml
vendored
|
@ -61,6 +61,10 @@ jobs:
|
|||
libgl1-mesa-dev \
|
||||
libglvnd-dev \
|
||||
libharfbuzz-dev \
|
||||
libxrandr-dev \
|
||||
libxinerama-dev \
|
||||
libxcursor-dev \
|
||||
libxi-dev \
|
||||
qt6-base-dev \
|
||||
libqt6svg6-dev \
|
||||
qt6-positioning-dev \
|
||||
|
@ -128,6 +132,10 @@ jobs:
|
|||
libgl1-mesa-dev \
|
||||
libglvnd-dev \
|
||||
libharfbuzz-dev \
|
||||
libxrandr-dev \
|
||||
libxinerama-dev \
|
||||
libxcursor-dev \
|
||||
libxi-dev \
|
||||
qt6-base-dev \
|
||||
libqt6svg6-dev \
|
||||
qt6-positioning-dev \
|
||||
|
|
9
.gitmodules
vendored
|
@ -59,3 +59,12 @@
|
|||
[submodule "3party/utfcpp"]
|
||||
path = 3party/utfcpp
|
||||
url = https://github.com/nemtrif/utfcpp.git
|
||||
[submodule "3party/glfw"]
|
||||
path = 3party/glfw
|
||||
url = https://github.com/glfw/glfw.git
|
||||
[submodule "3party/CMake-MetalShaderSupport"]
|
||||
path = 3party/CMake-MetalShaderSupport
|
||||
url = https://github.com/dpogue/CMake-MetalShaderSupport.git
|
||||
[submodule "3party/imgui/imgui"]
|
||||
path = 3party/imgui/imgui
|
||||
url = https://github.com/ocornut/imgui
|
||||
|
|
1
3party/CMake-MetalShaderSupport
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit 989857d2e5e54869c35ad06fb21a67d12a2dbc67
|
|
@ -66,4 +66,19 @@ add_subdirectory(vulkan_wrapper)
|
|||
|
||||
if (PLATFORM_DESKTOP)
|
||||
add_subdirectory(libtess2)
|
||||
|
||||
set(GLFW_BUILD_DOCS OFF CACHE BOOL "")
|
||||
set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "")
|
||||
set(GLFW_BUILD_TESTS OFF CACHE BOOL "")
|
||||
set(GLFW_INSTALL OFF CACHE BOOL "")
|
||||
set(GLFW_VULKAN_STATIC OFF CACHE BOOL "")
|
||||
set(GLFW_BUILD_WAYLAND OFF CACHE BOOL "")
|
||||
# Disable ARC for glfw and re-enable after it because it's globally set in the root CMakeLists.txt
|
||||
set(CMAKE_OBJC_FLAGS "")
|
||||
add_subdirectory(glfw)
|
||||
set_target_properties(glfw PROPERTIES UNITY_BUILD OFF)
|
||||
set_target_properties(glfw PROPERTIES XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC NO)
|
||||
set(CMAKE_OBJC_FLAGS -fobjc-arc)
|
||||
|
||||
add_subdirectory(imgui)
|
||||
endif()
|
||||
|
|
1
3party/glfw
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit 21fea01161e0d6b70c0c5c1f52dc8e7a7df14a50
|
16
3party/imgui/CMakeLists.txt
Normal file
|
@ -0,0 +1,16 @@
|
|||
project(imgui)
|
||||
|
||||
set(SRC
|
||||
imgui/imgui_draw.cpp
|
||||
imgui/imgui_tables.cpp
|
||||
imgui/imgui_widgets.cpp
|
||||
imgui/imgui.cpp
|
||||
imgui/backends/imgui_impl_glfw.cpp
|
||||
)
|
||||
|
||||
add_library(${PROJECT_NAME} ${SRC})
|
||||
target_include_directories(${PROJECT_NAME}
|
||||
PRIVATE ${OMIM_ROOT}/3party/glfw/include
|
||||
PUBLIC ${OMIM_ROOT}/3party/imgui/imgui
|
||||
PUBLIC .
|
||||
)
|
1
3party/imgui/imgui
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit 6982ce43f5b143c5dce5fab0ce07dd4867b705ae
|
|
@ -90,6 +90,19 @@ else()
|
|||
message(FATAL_ERROR "Unsupported platform: ${CMAKE_SYSTEM_NAME}")
|
||||
endif()
|
||||
|
||||
if(${PLATFORM_MAC})
|
||||
set(XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC YES)
|
||||
|
||||
# Metal language support
|
||||
list(APPEND CMAKE_MODULE_PATH ${OMIM_ROOT}/3party/CMake-MetalShaderSupport/cmake)
|
||||
include(CheckLanguage)
|
||||
include(MetalShaderSupport)
|
||||
check_language(Metal)
|
||||
if(CMAKE_Metal_COMPILER)
|
||||
enable_language(Metal)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Sanitizer
|
||||
if (PLATFORM_DESKTOP)
|
||||
# https://clang.llvm.org/docs/UsersManual.html#controlling-code-generation
|
||||
|
@ -384,6 +397,7 @@ if (PLATFORM_DESKTOP)
|
|||
add_subdirectory(qt)
|
||||
omim_add_tool_subdirectory(skin_generator)
|
||||
endif()
|
||||
add_subdirectory(dev_sandbox)
|
||||
endif()
|
||||
|
||||
omim_add_test_subdirectory(qt_tstfrm)
|
||||
|
|
|
@ -155,6 +155,12 @@
|
|||
<li><a href="https://chromium.googlesource.com/chromium/src/courgette/">Chromium's Courgette</a>;
|
||||
<a href="#bsd3-license" class="license">BSD License</a></li>
|
||||
|
||||
<li><a href="https://github.com/dpogue/CMake-MetalShaderSupport">CMake Metal support files</a><br>
|
||||
© 2024 Darryl Pogue and Contributors;<a href="#cmake-support-license" class="license">License</a></li>
|
||||
|
||||
<li><a href="https://github.com/ocornut/imgui">Dear ImGui</a><br>
|
||||
© 2014-2025 Omar Cornut; <a href="#mit-license" class="license">MIT License</a></li>
|
||||
|
||||
<li><a href="https://libexpat.github.io">Expat</a><br>© 1998–2000 Thai Open Source Software Center Ltd and Clark Cooper,
|
||||
© 2001–2019 Expat maintainers; <a href="#mit-license" class="license">MIT License</a></li>
|
||||
|
||||
|
@ -164,6 +170,9 @@
|
|||
<li><a href="http://www.freetype.org">FreeType</a><br>
|
||||
© 2013 The FreeType Project; <a href="#freetype-license" class="license">FTL</a></li>
|
||||
|
||||
<li><a href="https://www.glfw.org/">GLFW</a><br>
|
||||
© 2002-2006 Marcus Geelnard;2006-2019 Camilla Löwy; <a href="#zlib-license" class="license">Zlib License</a></li>
|
||||
|
||||
<li><a href="http://www.g-truc.net/project-0016.html">GLM</a><br>
|
||||
© 2005–2014 G-Truc Creation; <a href="#mit-license" class="license">MIT License</a></li>
|
||||
|
||||
|
@ -1058,6 +1067,54 @@ of the copyright holder.</p>
|
|||
|
||||
</div>
|
||||
|
||||
<div class="section">
|
||||
|
||||
<h2 id="cmake-support-license">CMake Metal support files</h2>
|
||||
<p>Copyright 2024 Darryl Pogue and Contributors</p>
|
||||
<p>All rights reserved.</p>
|
||||
|
||||
<p>Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:</p>
|
||||
|
||||
<p>* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.</p>
|
||||
|
||||
<p>* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.</p>
|
||||
|
||||
<p>* Neither the name of Kitware, Inc. nor the names of Contributors may be used to endorse or promote products derived from this software without specific prior written permission.</p>
|
||||
|
||||
<p>THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</p>
|
||||
|
||||
<p>------------------------------------------------------------------------------</p>
|
||||
|
||||
<p>See version control history for details of individual contributions.</p>
|
||||
|
||||
<p>The above copyright and license notice applies to distributions of
|
||||
CMake in source and binary form. Third-party software packages supplied
|
||||
with CMake under compatible licenses provide their own copyright notices
|
||||
documented in corresponding subdirectories or source files.</p>
|
||||
|
||||
<p>------------------------------------------------------------------------------</p>
|
||||
|
||||
<p>CMake was initially developed by Kitware with the following sponsorship:</p>
|
||||
|
||||
<p>* National Library of Medicine at the National Institutes of Health as part of the Insight Segmentation and Registration Toolkit (ITK).</p>
|
||||
|
||||
<p>* US National Labs (Los Alamos, Livermore, Sandia) ASC Parallel Visualization Initiative.</p>
|
||||
|
||||
<p>* National Alliance for Medical Image Computing (NAMIC) is funded by the National Institutes of Health through the NIH Roadmap for Medical Research, Grant U54 EB005149.</p>
|
||||
|
||||
<p>* Kitware, Inc.</p>
|
||||
</div>
|
||||
|
||||
<div class="section">
|
||||
|
||||
<h2 id="freetype-license">The FreeType Project License</h2>
|
||||
|
|
134
dev_sandbox/CMakeLists.txt
Normal file
|
@ -0,0 +1,134 @@
|
|||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
project(dev_sandbox)
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
set(SRC
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
main.cpp
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
imgui_renderer.cpp
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
imgui_renderer.hpp
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
)
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
if (${PLATFORM_MAC})
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
append(SRC
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
main.mm
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
../iphone/Maps/Classes/MetalContextFactory.h
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
../iphone/Maps/Classes/MetalContextFactory.mm
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
)
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
file(GLOB_RECURSE SHADER_SOURCES_FILES ${OMIM_ROOT}/shaders/Metal/*.metal)
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
add_metal_shader_library(shaders_metal
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
${SHADER_SOURCES_FILES}
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
)
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
endif()
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
if (${PLATFORM_LINUX})
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
append(SRC
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
main_linux.cpp
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
)
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
endif()
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
omim_add_executable(${PROJECT_NAME} MACOSX_BUNDLE ${SRC})
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
target_link_libraries(${PROJECT_NAME}
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
generator # For borders::LoadBorders
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
map
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
gflags::gflags
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
glfw
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
imgui
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
)
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
# Installing Vulkan SDK is optional, however without it Vulkan dynamic libraries
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
# should be discovered via system paths and validation layers may not be available
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
find_package(Vulkan QUIET)
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
if (Vulkan_FOUND)
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
message(STATUS "Vulkan found")
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
target_link_libraries(${PROJECT_NAME} Vulkan::Vulkan)
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
endif()
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
if(PLATFORM_MAC)
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
target_embed_metal_shader_libraries(${PROJECT_NAME} shaders_metal)
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
endif()
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
target_compile_definitions(${PROJECT_NAME} PUBLIC GL_SILENCE_DEPRECATION)
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
if (PLATFORM_MAC)
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC YES)
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
endif()
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
if (PLATFORM_LINUX)
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
target_compile_definitions(${PROJECT_NAME} PRIVATE VK_USE_PLATFORM_XLIB_KHR)
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
endif()
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
target_include_directories(${PROJECT_NAME} PUBLIC ${OMIM_ROOT}/3party/glfw/include)
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
target_include_directories(${PROJECT_NAME} PUBLIC ${OMIM_ROOT}/3party/imgui)
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
set(BUNDLE_NAME "OMapsDevSandbox")
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
set(BUNDLE_DISPLAY_NAME "Organic Maps: Developer Sandbox")
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME ${BUNDLE_NAME})
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
set(BUNDLE_EXECUTABLE ${BUNDLE_NAME})
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
set(BUNDLE_FOLDER ${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}/${BUNDLE_NAME}.app)
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
set(RESOURCES_FOLDER ${BUNDLE_FOLDER}/Contents/Resources)
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
set(DATA_DIR ${OMIM_ROOT}/data)
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
execute_process(
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
COMMAND mkdir -p ${RESOURCES_FOLDER}/shaders_compiler
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
)
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
function(copy_resources)
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
foreach(file ${ARGN})
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
execute_process(
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
COMMAND cp -r ${DATA_DIR}/${file} ${RESOURCES_FOLDER}
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
)
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
endforeach()
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
endfunction()
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
copy_resources(
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
AndrewShkrob
commented
How about vulkan shaders folder? Is the app going to support Vulkan? How about vulkan shaders folder? Is the app going to support Vulkan?
![]() Good catch! Good catch!
|
||||
countries-strings
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
resources-default
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
resources-mdpi_light
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
resources-hdpi_light
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
resources-xhdpi_light
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
resources-xxhdpi_light
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
resources-xxxhdpi_light
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
resources-6plus_light
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
vulkan_shaders
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
categories.txt
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
categories_cuisines.txt
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
classificator.txt
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
colors.txt
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
countries.txt
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
drules_proto_default_light.bin
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
drules_proto_default_dark.bin
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
drules_proto_vehicle_light.bin
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
drules_proto_vehicle_dark.bin
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
editor.config
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
fonts_blacklist.txt
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
fonts_whitelist.txt
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
packed_polygons.bin
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
patterns.txt
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
transit_colors.txt
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
types.txt
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
unicode_blocks.txt
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
World.mwm
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
WorldCoasts.mwm
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
00_NotoNaskhArabic-Regular.ttf
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
00_NotoSansBengali-Regular.ttf
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
00_NotoSansHebrew-Regular.ttf
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
00_NotoSansMalayalam-Regular.ttf
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
00_NotoSansThai-Regular.ttf
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
00_NotoSerifDevanagari-Regular.ttf
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
01_dejavusans.ttf
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
02_droidsans-fallback.ttf
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
03_jomolhari-id-a3d.ttf
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
04_padauk.ttf
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
05_khmeros.ttf
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
06_code2000.ttf
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
07_roboto_medium.ttf
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
)
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
if (NOT PLATFORM_LINUX)
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
# On Linux, ICU data is loaded from the shared library.
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
copy_resources(icudt75l.dat)
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
||||
endif()
|
||||
AndrewShkrob
commented
Is it needed? Shaders compiler is used only in tests Is it needed? Shaders compiler is used only in tests
|
257
dev_sandbox/imgui_renderer.cpp
Normal file
|
@ -0,0 +1,257 @@
|
|||
#include "imgui_renderer.hpp"
|
||||
|
||||
#include "base/logging.hpp"
|
||||
#include "base/macros.hpp"
|
||||
|
||||
#include <drape_frontend/render_state_extension.hpp>
|
||||
|
||||
#include <shaders/program_manager.hpp>
|
||||
|
||||
#include <imgui/imgui.h>
|
||||
|
||||
#include <cstring>
|
||||
#include <limits>
|
||||
|
||||
ImguiRenderer::ImguiRenderer()
|
||||
: m_state(df::CreateRenderState(gpu::Program::ImGui, df::DepthLayer::GuiLayer))
|
||||
{
|
||||
m_state.SetDepthTestEnabled(false);
|
||||
m_state.SetBlending(dp::Blending(true));
|
||||
}
|
||||
|
||||
void ImguiRenderer::Render(ref_ptr<dp::GraphicsContext> context, ref_ptr<dp::TextureManager> textureManager,
|
||||
ref_ptr<gpu::ProgramManager> programManager)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_bufferMutex);
|
||||
size_t renderDataIndex = (m_updateIndex + 1) % m_uiDataBuffer.size();
|
||||
UiDataBuffer & dataBuffer = m_uiDataBuffer[renderDataIndex];
|
||||
|
||||
auto gpuProgram = programManager->GetProgram(m_state.GetProgram<gpu::Program>());
|
||||
|
||||
bool needUpdate = true;
|
||||
if (!m_mesh || dataBuffer.m_vertices.size() > m_vertexCount || dataBuffer.m_indices.size() > m_indexCount)
|
||||
{
|
||||
while (dataBuffer.m_vertices.size() > m_vertexCount)
|
||||
m_vertexCount *= 2;
|
||||
while (dataBuffer.m_indices.size() > m_indexCount)
|
||||
m_indexCount *= 2;
|
||||
m_indexCount = std::min(m_indexCount, static_cast<uint32_t>(std::numeric_limits<uint16_t>::max()));
|
||||
|
||||
dataBuffer.m_vertices.resize(m_vertexCount);
|
||||
dataBuffer.m_indices.resize(m_indexCount);
|
||||
|
||||
m_mesh = make_unique_dp<dp::MeshObject>(context, dp::MeshObject::DrawPrimitive::Triangles, "imGui");
|
||||
|
||||
m_mesh->SetBuffer(0, std::move(dataBuffer.m_vertices));
|
||||
m_mesh->SetAttribute("a_position", 0, 0 /* offset */, 2);
|
||||
m_mesh->SetAttribute("a_texCoords", 0, 2 * sizeof(float) /* offset */, 2);
|
||||
m_mesh->SetAttribute("a_color", 0, 4 * sizeof(float) /* offset */, 4);
|
||||
m_mesh->SetIndexBuffer(std::move(dataBuffer.m_indices));
|
||||
m_mesh->Build(context, gpuProgram);
|
||||
|
||||
dataBuffer.m_vertices.clear();
|
||||
dataBuffer.m_indices.clear();
|
||||
needUpdate = false;
|
||||
}
|
||||
|
||||
if (!m_texture)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_textureMutex);
|
||||
if (!m_textureData.empty())
|
||||
{
|
||||
m_texture = make_unique_dp<dp::StaticTexture>();
|
||||
m_texture->Create(context,
|
||||
dp::Texture::Params{
|
||||
.m_width = m_textureWidth,
|
||||
.m_height = m_textureHeight,
|
||||
.m_format = dp::TextureFormat::RGBA8,
|
||||
.m_allocator = textureManager->GetTextureAllocator(),
|
||||
},
|
||||
m_textureData.data());
|
||||
m_textureData.clear();
|
||||
m_state.SetColorTexture(make_ref(m_texture));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Can't render without texture.
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (dataBuffer.m_drawCalls.empty())
|
||||
return;
|
||||
|
||||
if (needUpdate && !dataBuffer.m_vertices.empty() && !dataBuffer.m_indices.empty())
|
||||
{
|
||||
m_mesh->UpdateBuffer(context, 0, dataBuffer.m_vertices);
|
||||
m_mesh->UpdateIndexBuffer(context, dataBuffer.m_indices);
|
||||
dataBuffer.m_vertices.clear();
|
||||
dataBuffer.m_indices.clear();
|
||||
}
|
||||
|
||||
gpu::ImGuiProgramParams const params{.m_projection = m_projection};
|
||||
context->PushDebugLabel("ImGui Rendering");
|
||||
m_mesh->Render(context, gpuProgram, m_state, programManager->GetParamsSetter(), params,
|
||||
[&, this]()
|
||||
{
|
||||
context->SetCullingEnabled(false);
|
||||
for (auto const & drawCall : dataBuffer.m_drawCalls)
|
||||
{
|
||||
uint32_t y = drawCall.clipRect.y;
|
||||
if (context->GetApiVersion() == dp::ApiVersion::OpenGLES3)
|
||||
y = dataBuffer.m_height - y - drawCall.clipRect.w;
|
||||
context->SetScissor(drawCall.clipRect.x, y, drawCall.clipRect.z, drawCall.clipRect.w);
|
||||
m_mesh->DrawPrimitivesSubsetIndexed(context, drawCall.indexCount, drawCall.startIndex);
|
||||
}
|
||||
context->SetCullingEnabled(true);
|
||||
context->SetScissor(0, 0, dataBuffer.m_width, dataBuffer.m_height);
|
||||
});
|
||||
context->PopDebugLabel();
|
||||
}
|
||||
|
||||
void ImguiRenderer::Update(std::function<void()> const & uiCallback)
|
||||
{
|
||||
CHECK(uiCallback, ());
|
||||
ImGuiIO & io = ImGui::GetIO();
|
||||
if (!io.Fonts->IsBuilt())
|
||||
io.Fonts->Build();
|
||||
if (!m_texture)
|
||||
UpdateTexture();
|
||||
|
||||
ImGui::NewFrame();
|
||||
uiCallback();
|
||||
ImGui::Render();
|
||||
UpdateBuffers();
|
||||
}
|
||||
|
||||
void ImguiRenderer::Reset()
|
||||
{
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_textureMutex);
|
||||
m_texture.reset();
|
||||
}
|
||||
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_bufferMutex);
|
||||
m_mesh.reset();
|
||||
}
|
||||
}
|
||||
|
||||
void ImguiRenderer::UpdateTexture()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_textureMutex);
|
||||
unsigned char * pixels;
|
||||
int width, height;
|
||||
ImGui::GetIO().Fonts->GetTexDataAsRGBA32(&pixels, &width, &height);
|
||||
|
||||
auto const sizeInBytes = width * height * sizeof(uint32_t);
|
||||
m_textureData.resize(sizeInBytes);
|
||||
memcpy(m_textureData.data(), pixels, sizeInBytes);
|
||||
m_textureWidth = static_cast<uint32_t>(width);
|
||||
m_textureHeight = static_cast<uint32_t>(height);
|
||||
}
|
||||
|
||||
void ImguiRenderer::UpdateBuffers()
|
||||
{
|
||||
UiDataBuffer & dataBuffer = m_uiDataBuffer[m_updateIndex];
|
||||
dataBuffer.m_drawCalls.clear();
|
||||
|
||||
ImDrawData * dd = ImGui::GetDrawData();
|
||||
auto const fbWidth = static_cast<int>(dd->DisplaySize.x * dd->FramebufferScale.x);
|
||||
auto const fbHeight = static_cast<int>(dd->DisplaySize.y * dd->FramebufferScale.y);
|
||||
if (fbWidth <= 0 || fbHeight <= 0 || dd->CmdListsCount == 0 || dd->TotalIdxCount == 0 || dd->TotalVtxCount == 0)
|
||||
return;
|
||||
dataBuffer.m_width = static_cast<uint32_t>(fbWidth);
|
||||
dataBuffer.m_height = static_cast<uint32_t>(fbHeight);
|
||||
|
||||
CHECK(dd->TotalVtxCount <= std::numeric_limits<uint16_t>::max(),
|
||||
("UI is so complex and now requires 32-bit indices. You need to improve dp::MeshObject or simplify UI"));
|
||||
|
||||
CHECK((ImGui::GetIO().BackendFlags & ImGuiBackendFlags_RendererHasVtxOffset) == 0, ());
|
||||
|
||||
dataBuffer.m_vertices.resize(dd->TotalVtxCount);
|
||||
dataBuffer.m_indices.resize(dd->TotalIdxCount);
|
||||
|
||||
int totalDrawCallsCount = 0;
|
||||
for (int i = 0; i < dd->CmdListsCount; ++i)
|
||||
totalDrawCallsCount += dd->CmdLists[i]->CmdBuffer.Size;
|
||||
dataBuffer.m_drawCalls.reserve(totalDrawCallsCount);
|
||||
|
||||
ImVec2 const clipOff = dd->DisplayPos;
|
||||
ImVec2 const clipScale = dd->FramebufferScale;
|
||||
|
||||
uint32_t vertexOffset = 0;
|
||||
uint32_t indexOffset = 0;
|
||||
for (int i = 0; i < dd->CmdListsCount; ++i)
|
||||
{
|
||||
ImDrawList const * cmdList = dd->CmdLists[i];
|
||||
for (int j = 0; j < cmdList->VtxBuffer.Size; ++j)
|
||||
{
|
||||
dp::Color color(cmdList->VtxBuffer.Data[j].col);
|
||||
dataBuffer.m_vertices[j + vertexOffset] = {
|
||||
.position = {cmdList->VtxBuffer.Data[j].pos.x, cmdList->VtxBuffer.Data[j].pos.y},
|
||||
.texCoords = {cmdList->VtxBuffer.Data[j].uv.x, cmdList->VtxBuffer.Data[j].uv.y},
|
||||
.color = {color.GetAlphaF(), color.GetBlueF(), color.GetGreenF(),
|
||||
color.GetRedF()} // Byte order is reversed in imGui
|
||||
};
|
||||
}
|
||||
|
||||
static_assert(sizeof(uint16_t) == sizeof(ImDrawIdx));
|
||||
memcpy(dataBuffer.m_indices.data() + indexOffset, cmdList->IdxBuffer.Data,
|
||||
cmdList->IdxBuffer.Size * sizeof(ImDrawIdx));
|
||||
for (int j = 0; j < cmdList->IdxBuffer.Size; ++j)
|
||||
{
|
||||
uint32_t indexValue = dataBuffer.m_indices[j + indexOffset];
|
||||
indexValue += vertexOffset;
|
||||
CHECK(indexValue <= std::numeric_limits<uint16_t>::max(), ());
|
||||
dataBuffer.m_indices[j + indexOffset] = static_cast<uint16_t>(indexValue);
|
||||
}
|
||||
|
||||
for (int cmdIndex = 0; cmdIndex < cmdList->CmdBuffer.Size; ++cmdIndex)
|
||||
{
|
||||
const ImDrawCmd cmd = cmdList->CmdBuffer[cmdIndex];
|
||||
ImVec2 clipMin((cmd.ClipRect.x - clipOff.x) * clipScale.x, (cmd.ClipRect.y - clipOff.y) * clipScale.y);
|
||||
ImVec2 clipMax((cmd.ClipRect.z - clipOff.x) * clipScale.x, (cmd.ClipRect.w - clipOff.y) * clipScale.y);
|
||||
if (clipMin.x < 0.0f)
|
||||
clipMin.x = 0.0f;
|
||||
if (clipMin.y < 0.0f)
|
||||
clipMin.y = 0.0f;
|
||||
if (clipMax.x > fbWidth)
|
||||
clipMax.x = static_cast<float>(fbWidth);
|
||||
if (clipMax.y > fbHeight)
|
||||
clipMax.y = static_cast<float>(fbHeight);
|
||||
if (clipMax.x <= clipMin.x || clipMax.y <= clipMin.y)
|
||||
continue;
|
||||
|
||||
dataBuffer.m_drawCalls.emplace_back(DrawCall{
|
||||
.indexCount = static_cast<uint32_t>(cmd.ElemCount),
|
||||
.startIndex = static_cast<uint32_t>(indexOffset + cmd.IdxOffset),
|
||||
.clipRect = {static_cast<uint32_t>(clipMin.x), static_cast<uint32_t>(clipMin.y),
|
||||
static_cast<uint32_t>(clipMax.x - clipMin.x), static_cast<uint32_t>(clipMax.y - clipMin.y)}});
|
||||
}
|
||||
|
||||
vertexOffset += static_cast<uint32_t>(cmdList->VtxBuffer.Size);
|
||||
indexOffset += static_cast<uint32_t>(cmdList->IdxBuffer.Size);
|
||||
}
|
||||
CHECK(vertexOffset == dataBuffer.m_vertices.size(), ());
|
||||
CHECK(indexOffset == dataBuffer.m_indices.size(), ());
|
||||
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_bufferMutex);
|
||||
|
||||
// Projection
|
||||
float const left = dd->DisplayPos.x;
|
||||
float const right = dd->DisplayPos.x + dd->DisplaySize.x;
|
||||
float const top = dd->DisplayPos.y;
|
||||
float const bottom = dd->DisplayPos.y + dd->DisplaySize.y;
|
||||
m_projection[0][0] = 2.0f / (right - left);
|
||||
m_projection[1][1] = 2.0f / (top - bottom);
|
||||
m_projection[2][2] = -1.0f;
|
||||
m_projection[3][3] = 1.0f;
|
||||
m_projection[0][3] = -(right + left) / (right - left);
|
||||
m_projection[1][3] = -(top + bottom) / (top - bottom);
|
||||
|
||||
// Swap buffers
|
||||
m_updateIndex = (m_updateIndex + 1) % m_uiDataBuffer.size();
|
||||
}
|
||||
}
|
72
dev_sandbox/imgui_renderer.hpp
Normal file
|
@ -0,0 +1,72 @@
|
|||
#pragma once
|
||||
|
||||
#include "drape/glsl_types.hpp"
|
||||
#include "drape/graphics_context.hpp"
|
||||
#include "drape/mesh_object.hpp"
|
||||
#include "drape/pointers.hpp"
|
||||
#include "drape/render_state.hpp"
|
||||
#include "drape/static_texture.hpp"
|
||||
#include "drape/texture_manager.hpp"
|
||||
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <functional>
|
||||
#include <mutex>
|
||||
#include <vector>
|
||||
|
||||
class ImguiRenderer
|
||||
{
|
||||
public:
|
||||
ImguiRenderer();
|
||||
void Render(ref_ptr<dp::GraphicsContext> context,
|
||||
ref_ptr<dp::TextureManager> textureManager,
|
||||
ref_ptr<gpu::ProgramManager> programManager);
|
||||
void Update(std::function<void()> const & uiCallback);
|
||||
void Reset();
|
||||
|
||||
private:
|
||||
void UpdateTexture();
|
||||
void UpdateBuffers();
|
||||
|
||||
struct ImguiVertex
|
||||
{
|
||||
glsl::vec2 position;
|
||||
glsl::vec2 texCoords;
|
||||
glsl::vec4 color;
|
||||
};
|
||||
static_assert(sizeof(ImguiVertex) == 2 * sizeof(glsl::vec4));
|
||||
|
||||
struct DrawCall
|
||||
{
|
||||
uint32_t indexCount = 0;
|
||||
uint32_t startIndex = 0;
|
||||
glsl::uvec4 clipRect{};
|
||||
};
|
||||
|
||||
drape_ptr<dp::MeshObject> m_mesh;
|
||||
uint32_t m_vertexCount = 2000;
|
||||
uint32_t m_indexCount = 3000;
|
||||
|
||||
drape_ptr<dp::StaticTexture> m_texture;
|
||||
std::vector<unsigned char> m_textureData;
|
||||
uint32_t m_textureWidth = 0;
|
||||
uint32_t m_textureHeight = 0;
|
||||
|
||||
dp::RenderState m_state;
|
||||
|
||||
struct UiDataBuffer
|
||||
{
|
||||
std::vector<ImguiVertex> m_vertices;
|
||||
std::vector<uint16_t> m_indices;
|
||||
std::vector<DrawCall> m_drawCalls;
|
||||
uint32_t m_width;
|
||||
uint32_t m_height;
|
||||
};
|
||||
std::array<UiDataBuffer, 2> m_uiDataBuffer;
|
||||
size_t m_updateIndex = 0;
|
||||
|
||||
glsl::mat4 m_projection;
|
||||
|
||||
std::mutex m_bufferMutex;
|
||||
std::mutex m_textureMutex;
|
||||
};
|
683
dev_sandbox/main.cpp
Normal file
|
@ -0,0 +1,683 @@
|
|||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
#include "dev_sandbox/imgui_renderer.hpp"
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
#include "map/framework.hpp"
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
#include "platform/platform.hpp"
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
#include "platform/settings.hpp"
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
#include "coding/reader.hpp"
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
#include "base/logging.hpp"
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
#include "base/macros.hpp"
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
#include "std/target_os.hpp"
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
#include <chrono>
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
#include <functional>
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
#include <mutex>
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
#include <optional>
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
#include <sstream>
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
#include <string>
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
#include <string_view>
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
#include <vector>
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
#include <gflags/gflags.h>
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
#if defined(OMIM_OS_WINDOWS)
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
#define GLFW_EXPOSE_NATIVE_WIN32
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
#elif defined(OMIM_OS_LINUX)
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
#define GLFW_EXPOSE_NATIVE_X11
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
#elif defined(OMIM_OS_MAC)
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
#define GLFW_EXPOSE_NATIVE_COCOA
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
#else
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
#error Unsupported plaform
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
#endif
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
#define GLFW_INCLUDE_NONE
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
#include <GLFW/glfw3.h>
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
#include <GLFW/glfw3native.h>
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
#include <imgui/backends/imgui_impl_glfw.h>
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
#include <imgui/imgui.h>
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
DEFINE_string(data_path, "", "Path to data directory.");
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
DEFINE_string(log_abort_level, base::ToString(base::GetDefaultLogAbortLevel()),
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
"Log messages severity that causes termination.");
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
DEFINE_string(resources_path, "", "Path to resources directory.");
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
DEFINE_string(lang, "", "Device language.");
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
#if defined(OMIM_OS_MAC) || defined(OMIM_OS_LINUX)
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
drape_ptr<dp::GraphicsContextFactory> CreateContextFactory(GLFWwindow * window, dp::ApiVersion api, m2::PointU size);
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
void PrepareDestroyContextFactory(ref_ptr<dp::GraphicsContextFactory> contextFactory);
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
void OnCreateDrapeEngine(GLFWwindow * window, dp::ApiVersion api, ref_ptr<dp::GraphicsContextFactory> contextFactory);
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
void UpdateContentScale(GLFWwindow * window, float scale);
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
void UpdateSize(ref_ptr<dp::GraphicsContextFactory> contextFactory, int w, int h);
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
#endif
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
#if defined(OMIM_OS_LINUX)
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
// Workaround for storage::Status compilation issue:
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
// /usr/include/X11/Xlib.h:83:16: note: expanded from macro 'Status'
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
#undef Status
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
#endif
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
namespace
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
{
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
bool ValidateLogAbortLevel(char const * flagname, std::string const & value)
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
{
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
if (auto level = base::FromString(value); !level)
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
{
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
std::cerr << "Invalid value for --" << flagname << ": " << value << ", must be one of: ";
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
auto const & names = base::GetLogLevelNames();
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
for (size_t i = 0; i < names.size(); ++i)
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
{
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
if (i != 0)
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
std::cerr << ", ";
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
std::cerr << names[i];
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
}
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
std::cerr << '\n';
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
return false;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
}
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
return true;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
}
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
bool const g_logAbortLevelDummy = gflags::RegisterFlagValidator(&FLAGS_log_abort_level, &ValidateLogAbortLevel);
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
void errorCallback(int error, char const * description) { LOG(LERROR, ("GLFW (", error, "):", description)); }
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
struct WindowHandlers
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
{
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
std::function<void(int w, int h)> onResize;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
std::function<void(double x, double y, int button, int action, int mods)> onMouseButton;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
std::function<void(double x, double y)> onMouseMove;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
std::function<void(double x, double y, double xOffset, double yOffset)> onScroll;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
std::function<void(int key, int scancode, int action, int mods)> onKeyboardButton;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
std::function<void(float xscale, float yscale)> onContentScale;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
} handlers;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
df::Touch GetTouch(double x, double y)
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
{
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
return df::Touch{.m_location = m2::PointF(static_cast<float>(x), static_cast<float>(y)), .m_id = 0};
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
}
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
df::Touch GetSymmetricalTouch(Framework & framework, df::Touch const & touch)
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
{
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
m2::PointD const pixelCenter = framework.GetVisiblePixelCenter();
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
m2::PointD const symmetricalLocation = pixelCenter + pixelCenter - m2::PointD(touch.m_location);
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
df::Touch result;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
result.m_id = touch.m_id + 1;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
result.m_location = symmetricalLocation;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
return result;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
}
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
df::TouchEvent GetTouchEvent(Framework & framework, double x, double y, int mods, df::TouchEvent::ETouchType type)
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
{
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
df::TouchEvent event;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
event.SetTouchType(type);
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
event.SetFirstTouch(GetTouch(x, y));
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
if (mods & GLFW_MOD_SUPER)
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
event.SetSecondTouch(GetSymmetricalTouch(framework, event.GetFirstTouch()));
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
return event;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
}
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
void FormatMapSize(uint64_t sizeInBytes, std::string & units, size_t & sizeToDownload)
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
{
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
int const mbInBytes = 1024 * 1024;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
int const kbInBytes = 1024;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
if (sizeInBytes > mbInBytes)
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
{
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
sizeToDownload = (sizeInBytes + mbInBytes - 1) / mbInBytes;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
units = "MB";
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
}
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
else if (sizeInBytes > kbInBytes)
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
{
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
sizeToDownload = (sizeInBytes + kbInBytes - 1) / kbInBytes;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
units = "KB";
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
}
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
else
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
{
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
sizeToDownload = sizeInBytes;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
units = "B";
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
}
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
}
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
std::string_view GetMyPoisitionText(location::EMyPositionMode mode)
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
{
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
switch(mode)
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
{
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
case location::EMyPositionMode::PendingPosition: return "Pending";
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
case location::EMyPositionMode::NotFollowNoPosition: return "No position";
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
case location::EMyPositionMode::NotFollow: return "Not follow";
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
case location::EMyPositionMode::Follow: return "Follow";
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
case location::EMyPositionMode::FollowAndRotate: return "Follow and Rotate";
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
}
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
return "";
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
}
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
dp::ApiVersion GetApiVersion(char const * apiLabel)
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
{
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
std::string_view v(apiLabel);
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
if (v == "Metal") return dp::ApiVersion::Metal;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
if (v == "Vulkan") return dp::ApiVersion::Vulkan;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
if (v == "OpenGL") return dp::ApiVersion::OpenGLES3;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
return dp::ApiVersion::Invalid;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
}
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
#if defined(OMIM_OS_LINUX)
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
class LinuxGuiThread : public base::TaskLoop
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
{
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
public:
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
PushResult Push(Task && task) override
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
{
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
m_tasks.emplace_back(std::move(task));
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
return {true, base::TaskLoop::kNoId};
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
}
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
PushResult Push(Task const & task) override
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
{
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
m_tasks.emplace_back(task);
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
return {true, base::TaskLoop::kNoId};
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
}
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
void ExecuteTasks()
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
{
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
for (auto & task : m_tasks)
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
task();
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
m_tasks.clear();
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
}
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
private:
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
std::vector<Task> m_tasks;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
std::mutex m_mutex;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
};
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
#endif
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
} // namespace
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
int main(int argc, char * argv[])
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
{
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
// Our double parsing code (base/string_utils.hpp) needs dots as a floating point delimiters, not commas.
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
// TODO: Refactor our doubles parsing code to use locale-independent delimiters.
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
// For example, https://github.com/google/double-conversion can be used.
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
// See http://dbaron.org/log/20121222-locale for more details.
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
(void)::setenv("LC_NUMERIC", "C", 1);
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
Platform & platform = GetPlatform();
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
LOG(LINFO, ("Organic Maps: Developer Sandbox", platform.Version(), "detected CPU cores:", platform.CpuCores()));
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
gflags::SetUsageMessage("Developer Sandbox.");
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
gflags::SetVersionString(platform.Version());
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
if (!FLAGS_resources_path.empty())
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
platform.SetResourceDir(FLAGS_resources_path);
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
if (!FLAGS_data_path.empty())
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
platform.SetWritableDirForTests(FLAGS_data_path);
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
if (auto const logLevel = base::FromString(FLAGS_log_abort_level); logLevel)
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
base::g_LogAbortLevel = *logLevel;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
else
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
LOG(LCRITICAL, ("Invalid log level:", FLAGS_log_abort_level));
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
#if defined(OMIM_OS_LINUX)
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
auto guiThread = std::make_unique<LinuxGuiThread>();
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
auto guiThreadPtr = guiThread.get();
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
platform.SetGuiThread(std::move(guiThread));
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
#endif
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
// Init GLFW.
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
glfwSetErrorCallback(errorCallback);
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
if (!glfwInit())
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
{
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
return -1;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
}
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
#if defined(OMIM_OS_WINDOWS)
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
glfwWindowHint(GLFW_SCALE_TO_MONITOR, GLFW_TRUE);
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
#endif
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
auto monitor = glfwGetPrimaryMonitor();
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
auto mode = glfwGetVideoMode(monitor);
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
GLFWwindow * window =
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
glfwCreateWindow(mode->width, mode->height, "Organic Maps: Developer Sandbox", nullptr, nullptr);
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
int fbWidth = 0, fbHeight = 0;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
glfwGetFramebufferSize(window, &fbWidth, &fbHeight);
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
float xs = 1.0f, ys = 1.0f;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
glfwGetWindowContentScale(window, &xs, &ys);
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
float visualScale = std::max(xs, ys);
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
glfwSetGamma(monitor, 1.0f);
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
IMGUI_CHECKVERSION();
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
ImGui::CreateContext();
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
ImGui::GetIO().ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
ImGui::StyleColorsClassic();
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
glfwMaximizeWindow(window);
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
platform.SetupMeasurementSystem();
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
bool outvalue;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
if (!settings::Get(settings::kDeveloperMode, outvalue))
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
settings::Set(settings::kDeveloperMode, true);
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
if (!FLAGS_lang.empty())
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
(void)::setenv("LANGUAGE", FLAGS_lang.c_str(), 1);
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
FrameworkParams frameworkParams;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
Framework framework(frameworkParams);
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
ImguiRenderer imguiRenderer;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
Framework::DrapeCreationParams drapeParams{
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
#if defined(OMIM_OS_MAC)
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
.m_apiVersion = dp::ApiVersion::Metal,
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
#else
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
.m_apiVersion = dp::ApiVersion::Vulkan,
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
#endif
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
.m_visualScale = visualScale,
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
.m_surfaceWidth = fbWidth,
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
.m_surfaceHeight = fbHeight,
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
.m_renderInjectionHandler = [&](ref_ptr<dp::GraphicsContext> context,
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
ref_ptr<dp::TextureManager> textureManager,
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
ref_ptr<gpu::ProgramManager> programManager,
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
bool shutdown)
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
{
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
if (shutdown)
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
imguiRenderer.Reset();
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
else
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
imguiRenderer.Render(context, textureManager, programManager);
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
}};
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
gui::Skin guiSkin(gui::ResolveGuiSkinFile("default"), visualScale);
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
guiSkin.Resize(fbWidth, fbHeight);
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
guiSkin.ForEach([&](gui::EWidget widget, gui::Position const & pos) { drapeParams.m_widgetsInitInfo[widget] = pos; });
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
drapeParams.m_widgetsInitInfo[gui::WIDGET_SCALE_FPS_LABEL] = gui::Position(dp::LeftTop);
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
drape_ptr<dp::GraphicsContextFactory> contextFactory;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
auto CreateDrapeEngine = [&](dp::ApiVersion version)
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
{
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
drapeParams.m_apiVersion = version;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
drapeParams.m_visualScale = visualScale;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
drapeParams.m_surfaceWidth = fbWidth;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
drapeParams.m_surfaceHeight = fbHeight;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
contextFactory = CreateContextFactory(window, drapeParams.m_apiVersion,
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
m2::PointU(static_cast<uint32_t>(drapeParams.m_surfaceWidth),
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
static_cast<uint32_t>(drapeParams.m_surfaceHeight)));
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
auto params = drapeParams;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
framework.CreateDrapeEngine(make_ref(contextFactory), std::move(params));
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
OnCreateDrapeEngine(window, version, make_ref(contextFactory));
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
framework.SetRenderingEnabled(nullptr);
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
};
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
CreateDrapeEngine(drapeParams.m_apiVersion);
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
auto DestroyDrapeEngine = [&]()
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
{
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
framework.SetRenderingDisabled(true);
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
framework.DestroyDrapeEngine();
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
PrepareDestroyContextFactory(make_ref(contextFactory));
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
contextFactory.reset();
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
};
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
// Process resizing.
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
handlers.onResize = [&](int w, int h)
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
{
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
fbWidth = w;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
fbHeight = h;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
if (fbWidth > 0 && fbHeight > 0)
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
{
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
UpdateSize(make_ref(contextFactory), fbWidth, fbHeight);
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
framework.OnSize(fbWidth, fbHeight);
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
guiSkin.Resize(w, h);
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
gui::TWidgetsLayoutInfo layout;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
guiSkin.ForEach([&layout](gui::EWidget w, gui::Position const & pos) { layout[w] = pos.m_pixelPivot; });
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
framework.SetWidgetLayout(std::move(layout));
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
framework.MakeFrameActive();
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
}
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
};
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
glfwSetFramebufferSizeCallback(window, [](GLFWwindow * wnd, int w, int h) { handlers.onResize(w, h); });
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
// Process change content scale.
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
handlers.onContentScale = [&](float xscale, float yscale)
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
{
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
visualScale = std::max(xscale, yscale);
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
framework.UpdateVisualScale(visualScale);
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
int w = 0, h = 0;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
glfwGetWindowSize(window, &w, &h);
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
#if defined(OMIM_OS_MAC)
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
w *= xscale;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
h *= yscale;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
#endif
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
if (w != fbWidth || h != fbHeight)
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
{
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
#if defined(OMIM_OS_MAC)
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
UpdateContentScale(window, xscale);
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
#endif
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
fbWidth = w;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
fbHeight = h;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
UpdateSize(make_ref(contextFactory), fbWidth, fbHeight);
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
framework.OnSize(fbWidth, fbHeight);
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
}
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
};
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
glfwSetWindowContentScaleCallback(window, [](GLFWwindow *, float xscale, float yscale)
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
{
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
handlers.onContentScale(xscale, yscale);
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
});
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
// Location handler
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
std::optional<ms::LatLon> lastLatLon;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
bool bearingEnabled = false;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
float bearing = 0.0f;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
auto setUserLocation = [&]()
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
{
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
if (lastLatLon)
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
{
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
framework.OnLocationUpdate(
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
location::GpsInfo{.m_source = location::EUser,
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
.m_timestamp = static_cast<double>(std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
std::chrono::system_clock::now().time_since_epoch())
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
.count()) /
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
1000,
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
.m_latitude = lastLatLon->m_lat,
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
.m_longitude = lastLatLon->m_lon,
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
.m_horizontalAccuracy = 10,
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
.m_bearing = bearingEnabled ? bearing : -1.0f});
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
if (bearingEnabled)
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
{
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
framework.OnCompassUpdate(location::CompassInfo{.m_bearing = base::DegToRad(bearing)});
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
}
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
}
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
};
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
// Download maps handler
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
std::string downloadButtonLabel;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
std::string retryButtonLabel;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
std::string downloadStatusLabel;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
storage::CountryId lastCountry;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
auto const onCountryChanged = [&](storage::CountryId const & countryId)
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
{
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
downloadButtonLabel.clear();
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
retryButtonLabel.clear();
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
downloadStatusLabel.clear();
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
lastCountry = countryId;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
// Called by Framework in World zoom level.
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
if (countryId.empty())
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
return;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
auto const & storage = framework.GetStorage();
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
auto status = storage.CountryStatusEx(countryId);
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
auto const & countryName = countryId;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
if (status == storage::Status::NotDownloaded)
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
{
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
std::string units;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
size_t sizeToDownload = 0;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
FormatMapSize(storage.CountrySizeInBytes(countryId).second, units, sizeToDownload);
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
std::stringstream str;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
str << "Download (" << countryName << ") " << sizeToDownload << units;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
downloadButtonLabel = str.str();
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
}
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
else if (status == storage::Status::InQueue)
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
{
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
std::stringstream str;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
str << countryName << " is waiting for downloading";
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
downloadStatusLabel = str.str();
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
}
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
else if (status != storage::Status::Downloading && status != storage::Status::OnDisk &&
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
status != storage::Status::OnDiskOutOfDate)
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
{
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
std::stringstream str;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
str << "Retry to download " << countryName;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
retryButtonLabel = str.str();
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
}
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
};
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
framework.SetCurrentCountryChangedListener(onCountryChanged);
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
framework.GetStorage().Subscribe(
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
[&](storage::CountryId const & countryId)
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
{
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
// Storage also calls notifications for parents, but we are interested in leafs only.
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
if (framework.GetStorage().IsLeaf(countryId))
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
onCountryChanged(countryId);
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
},
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
[&](storage::CountryId const & countryId, downloader::Progress const & progress)
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
{
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
std::stringstream str;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
str << "Downloading (" << countryId << ") " << (progress.m_bytesDownloaded * 100 / progress.m_bytesTotal)
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
<< "%";
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
downloadStatusLabel = str.str();
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
framework.MakeFrameActive();
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
});
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
// Handle mouse buttons.
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
bool touchActive = false;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
int touchMods = 0;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
bool setUpLocationByLeftClick = false;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
handlers.onMouseButton = [&](double x, double y, int button, int action, int mods)
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
{
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
#if defined(OMIM_OS_LINUX)
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
ImGui::GetIO().MousePos = ImVec2(x / visualScale, y / visualScale);
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
#endif
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
if (ImGui::GetIO().WantCaptureMouse)
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
{
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
framework.MakeFrameActive();
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
return;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
}
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
#if defined(OMIM_OS_MAC)
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
x *= visualScale;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
y *= visualScale;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
#endif
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
lastLatLon = mercator::ToLatLon(framework.PtoG(m2::PointD(x, y)));
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
if (setUpLocationByLeftClick)
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
{
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
setUserLocation();
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
return;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
}
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
if (button == GLFW_MOUSE_BUTTON_LEFT && action == GLFW_PRESS)
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
{
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
framework.TouchEvent(GetTouchEvent(framework, x, y, mods, df::TouchEvent::TOUCH_DOWN));
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
touchActive = true;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
touchMods = mods;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
}
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
if (touchActive && action == GLFW_RELEASE)
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
{
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
framework.TouchEvent(GetTouchEvent(framework, x, y, 0, df::TouchEvent::TOUCH_UP));
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
touchActive = false;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
touchMods = 0;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
}
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
};
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
glfwSetMouseButtonCallback(window,
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
[](GLFWwindow * wnd, int button, int action, int mods)
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
{
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
double x, y;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
glfwGetCursorPos(wnd, &x, &y);
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
handlers.onMouseButton(x, y, button, action, mods);
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
});
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
// Handle mouse moving.
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
handlers.onMouseMove = [&](double x, double y)
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
{
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
#if defined(OMIM_OS_LINUX)
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
ImGui::GetIO().MousePos = ImVec2(x / visualScale, y / visualScale);
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
#endif
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
if (ImGui::GetIO().WantCaptureMouse)
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
framework.MakeFrameActive();
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
if (touchActive)
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
{
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
#if defined(OMIM_OS_MAC)
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
x *= visualScale;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
y *= visualScale;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
#endif
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
framework.TouchEvent(
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
GetTouchEvent(framework, x, y, touchMods, df::TouchEvent::TOUCH_MOVE));
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
}
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
};
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
glfwSetCursorPosCallback(window, [](GLFWwindow *, double x, double y)
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
{
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
handlers.onMouseMove(x, y);
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
});
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
// Handle scroll.
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
handlers.onScroll = [&](double x, double y, double xOffset, double yOffset)
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
{
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
#if defined(OMIM_OS_LINUX)
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
ImGui::GetIO().MousePos = ImVec2(x / visualScale, y / visualScale);
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
#endif
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
if (ImGui::GetIO().WantCaptureMouse)
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
{
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
framework.MakeFrameActive();
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
return;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
}
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
#if defined(OMIM_OS_MAC)
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
x *= visualScale;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
y *= visualScale;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
#endif
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
![]() This stuff here and above is a bit mind-blowing :) Why do we multiply coordinates on Mac and divide on Linux. This stuff here and above is a bit mind-blowing :) Why do we multiply coordinates on Mac and divide on Linux.
![]() Unfortunately, OS are not consistent in terms of visual scale in glfw library (possibly it's native behaviour on this OS). macOS returns width/height in the same units regardless of screen scaling, while on Linux it returns width/height premultiplied to display scaling. Unfortunately, OS are not consistent in terms of visual scale in glfw library (possibly it's native behaviour on this OS). macOS returns width/height in the same units regardless of screen scaling, while on Linux it returns width/height premultiplied to display scaling.
|
||||
constexpr double kSensitivity = 0.01;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
double const factor = yOffset * kSensitivity;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
framework.Scale(exp(factor), m2::PointD(x, y), false);
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
};
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
glfwSetScrollCallback(window,
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
[](GLFWwindow * wnd, double xoffset, double yoffset)
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
{
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
double x, y;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
glfwGetCursorPos(wnd, &x, &y);
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
handlers.onScroll(x, y, xoffset, yoffset);
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
});
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
// Keys.
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
handlers.onKeyboardButton = [&](int key, int scancode, int action, int mods) {};
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
glfwSetKeyCallback(window, [](GLFWwindow *, int key, int scancode, int action, int mods)
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
{
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
handlers.onKeyboardButton(key, scancode, action, mods);
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
});
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
// imGui UI
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
bool enableDebugRectRendering = false;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
bool enableAA = false;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
auto imGuiUI = [&]()
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
{
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
ImGui::SetNextWindowPos(ImVec2(5, 20), ImGuiCond_Appearing);
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
ImGui::Begin("Controls", nullptr, ImGuiWindowFlags_AlwaysAutoResize);
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
// Drape controls
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
char const * apiLabels[] = {
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
#if defined(OMIM_OS_MAC)
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
"Metal",
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
"Vulkan",
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
"OpenGL"
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
#elif defined(OMIM_OS_LINUX)
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
"Vulkan",
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
"OpenGL"
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
#endif
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
};
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
static int currentAPI = 0;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
if (ImGui::Combo("API", ¤tAPI, apiLabels, IM_ARRAYSIZE(apiLabels)))
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
{
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
auto const apiVersion = GetApiVersion(apiLabels[currentAPI]);
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
if (framework.GetDrapeEngine()->GetApiVersion() != apiVersion)
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
{
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
DestroyDrapeEngine();
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
CreateDrapeEngine(apiVersion);
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
}
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
}
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
if (ImGui::Checkbox("Debug rect rendering", &enableDebugRectRendering))
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
framework.EnableDebugRectRendering(enableDebugRectRendering);
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
if (ImGui::Checkbox("Antialiasing", &enableAA))
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
framework.GetDrapeEngine()->SetPosteffectEnabled(df::PostprocessRenderer::Antialiasing, enableAA);
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
ImGui::NewLine();
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
ImGui::Separator();
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
ImGui::NewLine();
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
// Map controls
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
if (ImGui::Button("Scale +"))
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
framework.Scale(Framework::SCALE_MAG, true);
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
ImGui::SameLine();
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
if (ImGui::Button("Scale -"))
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
framework.Scale(Framework::SCALE_MIN, true);
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
ImGui::Checkbox("Set up location by left click", &setUpLocationByLeftClick);
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
if (setUpLocationByLeftClick)
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
{
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
if (ImGui::Checkbox("Bearing", &bearingEnabled))
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
setUserLocation();
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
ImGui::SameLine();
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
if (ImGui::SliderFloat(" ", &bearing, 0.0f, 360.0f, "%.1f"))
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
setUserLocation();
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
}
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
ImGui::Text("My positon mode: %s", GetMyPoisitionText(framework.GetMyPositionMode()).data());
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
if (ImGui::Button("Next Position Mode"))
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
framework.SwitchMyPositionNextMode();
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
ImGui::NewLine();
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
ImGui::Separator();
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
ImGui::NewLine();
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
// No downloading on Linux at the moment, need to implement http_thread without Qt.
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
#if !defined(OMIM_OS_LINUX)
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
// Download controls
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
if (!downloadButtonLabel.empty())
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
{
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
if (ImGui::Button(downloadButtonLabel.c_str()))
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
framework.GetStorage().DownloadNode(lastCountry);
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
}
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
if (!retryButtonLabel.empty())
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
{
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
if (ImGui::Button(retryButtonLabel.c_str()))
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
framework.GetStorage().RetryDownloadNode(lastCountry);
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
}
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
if (!downloadStatusLabel.empty())
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
ImGui::Text("%s", downloadStatusLabel.c_str());
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
if (!downloadButtonLabel.empty() || !retryButtonLabel.empty() || !downloadStatusLabel.empty())
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
{
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
ImGui::NewLine();
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
ImGui::Separator();
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
ImGui::NewLine();
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
}
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
#endif
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
ImGui::End();
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
};
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
ImGui_ImplGlfw_InitForOther(window, true);
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
// Main loop.
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
while (!glfwWindowShouldClose(window))
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
{
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
glfwPollEvents();
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
#if defined(OMIM_OS_LINUX)
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
guiThreadPtr->ExecuteTasks();
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
#endif
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
// Render imGui UI
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
ImGui_ImplGlfw_NewFrame();
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
#if defined(OMIM_OS_LINUX)
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
// Apply correct visual scale on Linux
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
// In glfw for Linux, window size and framebuffer size are the same,
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
// even if visual scale is not 1.0. It's different from behaviour on Mac.
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
io.DisplaySize = ImVec2(fbWidth / visualScale, fbHeight / visualScale);
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
io.DisplayFramebufferScale = ImVec2(visualScale, visualScale);
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
double mouseX, mouseY;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
glfwGetCursorPos(window, &mouseX, &mouseY);
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
io.AddMousePosEvent((float)mouseX / visualScale, (float)mouseY / visualScale);
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
#endif
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
io.IniFilename = nullptr;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
imguiRenderer.Update(imGuiUI);
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(1000 / 30));
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
}
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
framework.EnterBackground();
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
DestroyDrapeEngine();
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
ImGui_ImplGlfw_Shutdown();
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
ImGui::DestroyContext();
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
glfwDestroyWindow(window);
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
glfwTerminate();
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
return 0;
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
||||
}
|
||||
![]() nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many. nit: I'd prefer to make one Window or App instance here that holds all these callbacks. To have one global object instead of many.
|
370
dev_sandbox/main.mm
Normal file
|
@ -0,0 +1,370 @@
|
|||
#include "iphone/Maps/Classes/MetalContextFactory.h"
|
||||
|
||||
#include "drape/gl_functions.hpp"
|
||||
#include "drape/oglcontext.hpp"
|
||||
#include "drape/metal/metal_base_context.hpp"
|
||||
#include "drape/vulkan/vulkan_context_factory.hpp"
|
||||
|
||||
#define GLFW_INCLUDE_NONE
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
#if __APPLE__
|
||||
#define GLFW_EXPOSE_NATIVE_COCOA
|
||||
#else
|
||||
#error Unsupported OS
|
||||
#endif
|
||||
#include <GLFW/glfw3native.h>
|
||||
|
||||
#import <AppKit/NSOpenGL.h>
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import <Metal/Metal.h>
|
||||
#import <QuartzCore/CAMetalLayer.h>
|
||||
|
||||
#include <vulkan/vulkan_macos.h>
|
||||
|
||||
#include <atomic>
|
||||
#include <memory>
|
||||
|
||||
class MacOSVulkanContextFactory : public dp::vulkan::VulkanContextFactory
|
||||
{
|
||||
public:
|
||||
MacOSVulkanContextFactory()
|
||||
: dp::vulkan::VulkanContextFactory(1, 33, false) {}
|
||||
|
||||
void SetSurface(CAMetalLayer *layer)
|
||||
{
|
||||
VkMacOSSurfaceCreateInfoMVK createInfo = {
|
||||
.sType = VK_STRUCTURE_TYPE_MACOS_SURFACE_CREATE_INFO_MVK,
|
||||
.flags = 0,
|
||||
.pView = static_cast<const void *>(CFBridgingRetain(layer)),
|
||||
};
|
||||
|
||||
VkResult statusCode;
|
||||
CHECK(vkCreateMacOSSurfaceMVK, ());
|
||||
statusCode = vkCreateMacOSSurfaceMVK(m_vulkanInstance, &createInfo, nullptr,
|
||||
&m_surface);
|
||||
if (statusCode != VK_SUCCESS)
|
||||
{
|
||||
LOG_ERROR_VK_CALL(vkCreateMacOSSurfaceMVK, statusCode);
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t const renderingQueueIndex = m_drawContext->GetRenderingQueueFamilyIndex();
|
||||
VkBool32 supportsPresent;
|
||||
statusCode = vkGetPhysicalDeviceSurfaceSupportKHR(m_gpu, renderingQueueIndex, m_surface, &supportsPresent);
|
||||
if (statusCode != VK_SUCCESS)
|
||||
{
|
||||
LOG_ERROR_VK_CALL(vkGetPhysicalDeviceSurfaceSupportKHR, statusCode);
|
||||
return;
|
||||
}
|
||||
CHECK_EQUAL(supportsPresent, VK_TRUE, ());
|
||||
|
||||
CHECK(QuerySurfaceSize(), ());
|
||||
|
||||
if (m_drawContext)
|
||||
m_drawContext->SetSurface(m_surface, m_surfaceFormat, m_surfaceCapabilities);
|
||||
}
|
||||
|
||||
void ResetSurface()
|
||||
{
|
||||
if (m_drawContext)
|
||||
m_drawContext->ResetSurface(false);
|
||||
|
||||
vkDestroySurfaceKHR(m_vulkanInstance, m_surface, nullptr);
|
||||
}
|
||||
};
|
||||
|
||||
class MacGLContext : public dp::OGLContext
|
||||
{
|
||||
public:
|
||||
MacGLContext(MacGLContext * contextToShareWith)
|
||||
: m_viewSet(false)
|
||||
{
|
||||
NSOpenGLPixelFormatAttribute attributes[] = {
|
||||
NSOpenGLPFAAccelerated,
|
||||
NSOpenGLPFAOpenGLProfile,
|
||||
NSOpenGLProfileVersion4_1Core,
|
||||
NSOpenGLPFADoubleBuffer,
|
||||
NSOpenGLPFAColorSize,
|
||||
24,
|
||||
NSOpenGLPFAAlphaSize,
|
||||
8,
|
||||
NSOpenGLPFADepthSize,
|
||||
24,
|
||||
NSOpenGLPFAStencilSize,
|
||||
8,
|
||||
0
|
||||
};
|
||||
m_pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:attributes];
|
||||
CHECK(m_pixelFormat, ("Pixel format is not found"));
|
||||
m_context = [[NSOpenGLContext alloc] initWithFormat:m_pixelFormat
|
||||
shareContext:(contextToShareWith ? contextToShareWith->m_context : nil)];
|
||||
int interval = 1;
|
||||
[m_context getValues:&interval forParameter:NSOpenGLContextParameterSwapInterval];
|
||||
}
|
||||
|
||||
~MacGLContext()
|
||||
{
|
||||
@autoreleasepool {
|
||||
[m_context clearDrawable];
|
||||
m_pixelFormat = nil;
|
||||
m_context = nil;
|
||||
}
|
||||
}
|
||||
|
||||
bool BeginRendering() override { return m_viewSet; }
|
||||
|
||||
void Present() override
|
||||
{
|
||||
if (m_viewSet)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_updateSizeMutex);
|
||||
[m_context flushBuffer];
|
||||
}
|
||||
}
|
||||
|
||||
void MakeCurrent() override
|
||||
{
|
||||
[m_context makeCurrentContext];
|
||||
}
|
||||
|
||||
void DoneCurrent() override
|
||||
{
|
||||
[NSOpenGLContext clearCurrentContext];
|
||||
}
|
||||
|
||||
void SetFramebuffer(ref_ptr<dp::BaseFramebuffer> framebuffer) override
|
||||
{
|
||||
if (framebuffer)
|
||||
framebuffer->Bind();
|
||||
else
|
||||
GLFunctions::glBindFramebuffer(0);
|
||||
}
|
||||
|
||||
void SetView(NSView* view)
|
||||
{
|
||||
[m_context setView: view];
|
||||
[m_context update];
|
||||
m_viewSet = true;
|
||||
}
|
||||
|
||||
void UpdateSize(int w, int h)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_updateSizeMutex);
|
||||
[m_context update];
|
||||
}
|
||||
|
||||
private:
|
||||
NSOpenGLPixelFormat * m_pixelFormat = nil;
|
||||
NSOpenGLContext* m_context = nil;
|
||||
std::atomic<bool> m_viewSet;
|
||||
|
||||
std::mutex m_updateSizeMutex;
|
||||
};
|
||||
|
||||
class MacGLContextFactory: public dp::GraphicsContextFactory
|
||||
{
|
||||
public:
|
||||
dp::GraphicsContext * GetDrawContext() override
|
||||
{
|
||||
bool needNotify = false;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_contextAccess);
|
||||
if (m_drawContext == nullptr)
|
||||
{
|
||||
m_drawContext = std::make_unique<MacGLContext>(m_uploadContext.get());
|
||||
needNotify = true;
|
||||
}
|
||||
}
|
||||
if (needNotify)
|
||||
NotifyView();
|
||||
|
||||
std::lock_guard<std::mutex> lock(m_contextAccess);
|
||||
return m_drawContext.get();
|
||||
}
|
||||
|
||||
dp::GraphicsContext * GetResourcesUploadContext() override
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_contextAccess);
|
||||
if (m_uploadContext == nullptr)
|
||||
m_uploadContext = std::make_unique<MacGLContext>(m_drawContext.get());
|
||||
return m_uploadContext.get();
|
||||
}
|
||||
|
||||
void WaitForInitialization(dp::GraphicsContext *) override
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(m_initializationMutex);
|
||||
if (m_isInitialized)
|
||||
return;
|
||||
|
||||
m_initializationCounter++;
|
||||
if (m_initializationCounter >= kGLThreadsCount)
|
||||
{
|
||||
m_isInitialized = true;
|
||||
m_initializationCondition.notify_all();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_initializationCondition.wait(lock, [this] { return m_isInitialized; });
|
||||
}
|
||||
}
|
||||
|
||||
bool IsDrawContextCreated() const override
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_contextAccess);
|
||||
return m_drawContext != nullptr;
|
||||
}
|
||||
|
||||
bool IsUploadContextCreated() const override
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_contextAccess);
|
||||
return m_uploadContext != nullptr;
|
||||
}
|
||||
|
||||
void SetView(NSView* view)
|
||||
{
|
||||
bool needWait;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_contextAccess);
|
||||
needWait = (m_drawContext == nullptr);
|
||||
}
|
||||
if (needWait)
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(m_viewSetMutex);
|
||||
m_viewSetCondition.wait(lock, [this] { return m_viewSet; });
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> lock(m_contextAccess);
|
||||
CHECK(m_drawContext, ());
|
||||
m_drawContext->SetView(view);
|
||||
}
|
||||
|
||||
void UpdateSize(int w, int h)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_contextAccess);
|
||||
if (m_drawContext)
|
||||
m_drawContext->UpdateSize(w, h);
|
||||
}
|
||||
|
||||
private:
|
||||
void NotifyView()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_viewSetMutex);
|
||||
m_viewSet = true;
|
||||
m_viewSetCondition.notify_all();
|
||||
}
|
||||
|
||||
static size_t constexpr kGLThreadsCount = 2;
|
||||
|
||||
std::unique_ptr<MacGLContext> m_drawContext;
|
||||
std::unique_ptr<MacGLContext> m_uploadContext;
|
||||
|
||||
mutable std::mutex m_contextAccess;
|
||||
|
||||
bool m_isInitialized = false;
|
||||
size_t m_initializationCounter = 0;
|
||||
std::condition_variable m_initializationCondition;
|
||||
std::mutex m_initializationMutex;
|
||||
|
||||
bool m_viewSet = false;
|
||||
std::condition_variable m_viewSetCondition;
|
||||
std::mutex m_viewSetMutex;
|
||||
};
|
||||
|
||||
drape_ptr<dp::GraphicsContextFactory> CreateContextFactory(GLFWwindow *window, dp::ApiVersion api, m2::PointU size)
|
||||
{
|
||||
if (api == dp::ApiVersion::Metal)
|
||||
{
|
||||
CAMetalLayer *layer = [CAMetalLayer layer];
|
||||
layer.device = MTLCreateSystemDefaultDevice();
|
||||
layer.opaque = YES;
|
||||
layer.displaySyncEnabled = YES;
|
||||
|
||||
NSWindow *nswindow = glfwGetCocoaWindow(window);
|
||||
NSScreen *screen = [NSScreen mainScreen];
|
||||
CGFloat factor = [screen backingScaleFactor];
|
||||
layer.contentsScale = factor;
|
||||
nswindow.contentView.layer = layer;
|
||||
nswindow.contentView.wantsLayer = YES;
|
||||
|
||||
return make_unique_dp<MetalContextFactory>(layer, size);
|
||||
}
|
||||
|
||||
if (api == dp::ApiVersion::Vulkan)
|
||||
{
|
||||
CAMetalLayer *layer = [CAMetalLayer layer];
|
||||
layer.device = MTLCreateSystemDefaultDevice();
|
||||
layer.opaque = YES;
|
||||
layer.displaySyncEnabled = YES;
|
||||
|
||||
NSWindow *nswindow = glfwGetCocoaWindow(window);
|
||||
NSScreen *screen = [NSScreen mainScreen];
|
||||
CGFloat factor = [screen backingScaleFactor];
|
||||
layer.contentsScale = factor;
|
||||
nswindow.contentView.layer = layer;
|
||||
nswindow.contentView.wantsLayer = YES;
|
||||
|
||||
auto contextFactory = make_unique_dp<MacOSVulkanContextFactory>();
|
||||
contextFactory->SetSurface(layer);
|
||||
return contextFactory;
|
||||
}
|
||||
|
||||
if (api == dp::ApiVersion::OpenGLES3)
|
||||
{
|
||||
NSWindow *nswindow = glfwGetCocoaWindow(window);
|
||||
[nswindow.contentView setWantsBestResolutionOpenGLSurface:YES];
|
||||
return make_unique_dp<MacGLContextFactory>();
|
||||
}
|
||||
|
||||
ASSERT(false, ("API is not available yet"));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void OnCreateDrapeEngine(GLFWwindow *window, dp::ApiVersion api,
|
||||
ref_ptr<dp::GraphicsContextFactory> contextFactory)
|
||||
{
|
||||
if (api == dp::ApiVersion::OpenGLES3)
|
||||
{
|
||||
NSWindow *nswindow = glfwGetCocoaWindow(window);
|
||||
ref_ptr<MacGLContextFactory> macosContextFactory = contextFactory;
|
||||
macosContextFactory->SetView(nswindow.contentView);
|
||||
}
|
||||
}
|
||||
|
||||
void PrepareDestroyContextFactory(ref_ptr<dp::GraphicsContextFactory> contextFactory)
|
||||
{
|
||||
auto const api = contextFactory->GetDrawContext()->GetApiVersion();
|
||||
if (api == dp::ApiVersion::Metal || api == dp::ApiVersion::OpenGLES3)
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
else if (api == dp::ApiVersion::Vulkan)
|
||||
{
|
||||
ref_ptr<MacOSVulkanContextFactory> macosContextFactory = contextFactory;
|
||||
macosContextFactory->ResetSurface();
|
||||
}
|
||||
else
|
||||
{
|
||||
ASSERT(false, ("API is not available yet"));
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateContentScale(GLFWwindow *window, float scale)
|
||||
{
|
||||
NSWindow *nswindow = glfwGetCocoaWindow(window);
|
||||
if (nswindow.contentView.layer)
|
||||
nswindow.contentView.layer.contentsScale = scale;
|
||||
}
|
||||
|
||||
void UpdateSize(ref_ptr<dp::GraphicsContextFactory> contextFactory, int w, int h)
|
||||
{
|
||||
if (!contextFactory || !contextFactory->GetDrawContext())
|
||||
return;
|
||||
|
||||
auto const api = contextFactory->GetDrawContext()->GetApiVersion();
|
||||
if (api == dp::ApiVersion::OpenGLES3)
|
||||
{
|
||||
ref_ptr<MacGLContextFactory> macosContextFactory = contextFactory;
|
||||
macosContextFactory->UpdateSize(w, h);
|
||||
}
|
||||
}
|
411
dev_sandbox/main_linux.cpp
Normal file
|
@ -0,0 +1,411 @@
|
|||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
#include "std/target_os.hpp"
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
#if !defined(OMIM_OS_LINUX)
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
#error Unsupported OS
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
#endif
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
#define GLFW_INCLUDE_NONE
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
#include <GLFW/glfw3.h>
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
#define GLFW_EXPOSE_NATIVE_X11
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
#include <GLFW/glfw3native.h>
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
#include <dlfcn.h>
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
#include <X11/X.h>
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
#include <vulkan_wrapper.h>
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
#include <vulkan/vulkan_xlib.h>
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
// Workaround for TestFunction::Always compilation issue:
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
// /usr/include/X11/X.h:441:33: note: expanded from macro 'Always'
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
#undef Always
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
// Workaround for storage::Status compilation issue:
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
// /usr/include/X11/Xlib.h:83:16: note: expanded from macro 'Status'
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
#undef Status
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
#include "drape/vulkan/vulkan_context_factory.hpp"
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
#include "drape/gl_functions.hpp"
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
#include "drape/gl_includes.hpp"
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
#include "drape/oglcontext.hpp"
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
#include <array>
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
#include <atomic>
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
#include <memory>
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
class LinuxVulkanContextFactory : public dp::vulkan::VulkanContextFactory
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
{
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
public:
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
LinuxVulkanContextFactory() : dp::vulkan::VulkanContextFactory(1, 33, false) {}
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
void SetSurface(Display * display, Window window)
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
{
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
VkXlibSurfaceCreateInfoKHR const createInfo = {
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
.sType = VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR,
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
.pNext = nullptr,
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
.flags = 0,
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
.dpy = display,
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
.window = window,
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
};
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
VkResult statusCode;
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
CHECK(vkCreateXlibSurfaceKHR, ());
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
statusCode = vkCreateXlibSurfaceKHR(m_vulkanInstance, &createInfo, nullptr, &m_surface);
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
if (statusCode != VK_SUCCESS)
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
{
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
LOG_ERROR_VK_CALL(vkCreateXlibSurfaceKHR, statusCode);
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
return;
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
}
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
uint32_t const renderingQueueIndex = m_drawContext->GetRenderingQueueFamilyIndex();
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
VkBool32 supportsPresent;
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
statusCode = vkGetPhysicalDeviceSurfaceSupportKHR(m_gpu, renderingQueueIndex, m_surface, &supportsPresent);
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
if (statusCode != VK_SUCCESS)
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
{
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
LOG_ERROR_VK_CALL(vkGetPhysicalDeviceSurfaceSupportKHR, statusCode);
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
return;
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
}
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
CHECK_EQUAL(supportsPresent, VK_TRUE, ());
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
CHECK(QuerySurfaceSize(), ());
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
if (m_drawContext)
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
m_drawContext->SetSurface(m_surface, m_surfaceFormat, m_surfaceCapabilities);
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
}
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
void ResetSurface()
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
{
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
if (m_drawContext)
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
m_drawContext->ResetSurface(false);
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
vkDestroySurfaceKHR(m_vulkanInstance, m_surface, nullptr);
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
}
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
};
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
// Based on: https://github.com/glfw/glfw/blob/master/src/glx_context.c
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
#define GLX_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
#define GLX_CONTEXT_PROFILE_MASK_ARB 0x9126
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
#define GLX_CONTEXT_MAJOR_VERSION_ARB 0x2091
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
#define GLX_CONTEXT_MINOR_VERSION_ARB 0x2092
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
#define GLX_PBUFFER_HEIGHT 0x8040
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
#define GLX_PBUFFER_WIDTH 0x8041
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
#define GLX_DOUBLEBUFFER 5
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
#define GLX_DRAWABLE_TYPE 0x8010
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
#define GLX_RENDER_TYPE 0x8011
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
#define GLX_WINDOW_BIT 0x00000001
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
#define GLX_PBUFFER_BIT 0x00000004
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
#define GLX_RGBA_BIT 0x00000001
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
#define GLX_RED_SIZE 8
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
#define GLX_GREEN_SIZE 9
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
#define GLX_BLUE_SIZE 10
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
#define GLX_ALPHA_SIZE 11
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
#define GLX_DEPTH_SIZE 12
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
#define GLX_STENCIL_SIZE 13
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
typedef XID GLXDrawable;
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
typedef struct __GLXcontext * GLXContext;
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
typedef XID GLXPbuffer;
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
typedef struct __GLXFBConfig * GLXFBConfig;
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
typedef void (*__GLXextproc)(void);
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
typedef __GLXextproc (*PFNGLXGETPROCADDRESSPROC)(const GLubyte * procName);
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
typedef int (*PFNXFREE)(void *);
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
typedef GLXFBConfig * (*PFNGLXCHOOSEFBCONFIGPROC)(Display *, int, const int *, int *);
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
typedef GLXContext (*PFNGLXCREATECONTEXTATTRIBSARB)(Display *, GLXFBConfig, GLXContext, Bool, const int *);
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
typedef void (*PFNGLXDESTROYCONTEXT)(Display *, GLXContext);
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
typedef GLXPbuffer (*PFNGLXCREATEPBUFFERPROC)(Display *, GLXFBConfig, const int *);
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
typedef void (*PFNGLXDESTROYPBUFFER)(Display *, GLXPbuffer);
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
typedef Bool (*PFNGLXMAKECURRENTPROC)(Display *, GLXDrawable, GLXContext);
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
typedef void (*PFNGLXSWAPBUFFERSPROC)(Display *, GLXDrawable);
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
struct GLXFunctions
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
{
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
GLXFunctions()
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
{
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
std::array<char const *, 3> libs = {
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
"libGLX.so.0",
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
"libGL.so.1",
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
"libGL.so",
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
};
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
for (char const * lib : libs)
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
{
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
m_module = dlopen(lib, RTLD_LAZY | RTLD_LOCAL);
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
if (m_module)
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
{
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
break;
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
}
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
}
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
CHECK(m_module != nullptr, ("Failed to initialize GLX"));
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
XFree = loadFunction<PFNXFREE>("XFree");
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
glXGetProcAddress = loadFunction<PFNGLXGETPROCADDRESSPROC>("glXGetProcAddress");
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
glXGetProcAddressARB = loadFunction<PFNGLXGETPROCADDRESSPROC>("glXGetProcAddressARB");
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
glXChooseFBConfig = loadGlxFunction<PFNGLXCHOOSEFBCONFIGPROC>("glXChooseFBConfig");
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
glXCreateContextAttribsARB = loadGlxFunction<PFNGLXCREATECONTEXTATTRIBSARB>("glXCreateContextAttribsARB");
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
glXDestroyContext = loadGlxFunction<PFNGLXDESTROYCONTEXT>("glXDestroyContext");
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
glXCreatePbuffer = loadGlxFunction<PFNGLXCREATEPBUFFERPROC>("glXCreatePbuffer");
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
glXDestroyPbuffer = loadGlxFunction<PFNGLXDESTROYPBUFFER>("glXDestroyPbuffer");
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
glXMakeCurrent = loadGlxFunction<PFNGLXMAKECURRENTPROC>("glXMakeCurrent");
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
glXSwapBuffers = loadGlxFunction<PFNGLXSWAPBUFFERSPROC>("glXSwapBuffers");
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
}
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
~GLXFunctions()
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
{
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
if (m_module)
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
{
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
dlclose(m_module);
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
}
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
}
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
PFNXFREE XFree = nullptr;
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
PFNGLXGETPROCADDRESSPROC glXGetProcAddress = nullptr;
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
PFNGLXGETPROCADDRESSPROC glXGetProcAddressARB = nullptr;
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
PFNGLXCHOOSEFBCONFIGPROC glXChooseFBConfig = nullptr;
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
PFNGLXCREATECONTEXTATTRIBSARB glXCreateContextAttribsARB = nullptr;
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
PFNGLXDESTROYCONTEXT glXDestroyContext = nullptr;
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
PFNGLXCREATEPBUFFERPROC glXCreatePbuffer = nullptr;
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
PFNGLXDESTROYPBUFFER glXDestroyPbuffer = nullptr;
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
PFNGLXMAKECURRENTPROC glXMakeCurrent = nullptr;
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
PFNGLXSWAPBUFFERSPROC glXSwapBuffers = nullptr;
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
private:
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
template <typename T>
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
T loadFunction(char const * func)
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
{
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
auto f = reinterpret_cast<T>(dlsym(m_module, func));
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
ASSERT(f, ("Failed to initialize GLX:", func, "is not found"));
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
return f;
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
}
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
template <typename T>
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
T loadGlxFunction(char const * func)
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
{
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
if (auto f = reinterpret_cast<T>(glXGetProcAddress(reinterpret_cast<GLubyte const *>(func))))
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
return f;
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
if (auto f = reinterpret_cast<T>(glXGetProcAddressARB(reinterpret_cast<GLubyte const *>(func))))
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
return f;
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
return loadFunction<T>(func);
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
}
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
void * m_module = nullptr;
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
};
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
class LinuxGLContext : public dp::OGLContext
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
{
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
public:
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
LinuxGLContext(GLXFunctions const & glx, Display * display, Window window, LinuxGLContext * contextToShareWith,
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
bool usePixelBuffer)
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
: m_glx(glx), m_display(display), m_window(window)
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
{
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
int visualAttribs[] = {
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
GLX_DOUBLEBUFFER, True,
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
GLX_RENDER_TYPE, GLX_RGBA_BIT,
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
GLX_DRAWABLE_TYPE, (usePixelBuffer ? GLX_PBUFFER_BIT : GLX_WINDOW_BIT),
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
GLX_RED_SIZE, 8,
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
GLX_GREEN_SIZE, 8,
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
GLX_BLUE_SIZE, 8,
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
GLX_ALPHA_SIZE, 8,
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
GLX_DEPTH_SIZE, 24,
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
GLX_STENCIL_SIZE, 8,
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
None
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
};
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
int contextAttribs[] = {
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_CORE_PROFILE_BIT_ARB,
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
GLX_CONTEXT_MAJOR_VERSION_ARB, 4,
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
GLX_CONTEXT_MINOR_VERSION_ARB, 1,
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
None};
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
int fbcount = 0;
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
if (GLXFBConfig * config = m_glx.glXChooseFBConfig(display, DefaultScreen(display), visualAttribs, &fbcount))
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
{
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
m_context =
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
m_glx.glXCreateContextAttribsARB(display, config[0], contextToShareWith ? contextToShareWith->m_context : 0, True, contextAttribs);
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
CHECK(m_context != nullptr, ("Failed to create GLX context"));
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
if (usePixelBuffer)
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
{
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
int pbufferAttribs[] = {GLX_PBUFFER_WIDTH, 1, GLX_PBUFFER_HEIGHT, 1, None};
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
m_pixelBufferHandle = m_glx.glXCreatePbuffer(display, config[0], pbufferAttribs);
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
CHECK(m_pixelBufferHandle != 0, ("Failed to create GLX pbuffer"));
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
}
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
m_glx.XFree(config);
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
}
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
}
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
~LinuxGLContext() override
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
{
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
if (m_pixelBufferHandle)
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
{
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
m_glx.glXDestroyPbuffer(m_display, m_pixelBufferHandle);
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
m_pixelBufferHandle = 0;
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
}
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
if (m_context)
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
{
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
m_glx.glXDestroyContext(m_display, m_context);
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
m_context = nullptr;
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
}
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
}
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
void Present() override
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
{
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
if (!m_pixelBufferHandle)
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
m_glx.glXSwapBuffers(m_display, m_window);
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
}
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
void MakeCurrent() override
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
{
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
if (!m_glx.glXMakeCurrent(m_display, m_pixelBufferHandle ? m_pixelBufferHandle : m_window, m_context))
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
LOG(LERROR, ("MakeCurrent(): glXMakeCurrent failed"));
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
}
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
void DoneCurrent() override
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
{
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
if (!m_glx.glXMakeCurrent(m_display, None, nullptr))
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
LOG(LERROR, ("DoneCurrent(): glXMakeCurrent failed"));
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
}
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
void SetFramebuffer(ref_ptr<dp::BaseFramebuffer> framebuffer) override
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
{
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
if (framebuffer)
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
framebuffer->Bind();
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
else
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
GLFunctions::glBindFramebuffer(0);
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
}
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
private:
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
GLXFunctions const & m_glx;
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
Display * m_display = nullptr;
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
Window m_window = 0;
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
GLXDrawable m_pixelBufferHandle = 0;
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
GLXContext m_context = nullptr;
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
};
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
class LinuxContextFactory : public dp::GraphicsContextFactory
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
{
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
public:
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
LinuxContextFactory(Display * display, Window window) : m_display(display), m_window(window) {}
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
dp::GraphicsContext * GetDrawContext() override
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
{
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
std::lock_guard<std::mutex> lock(m_contextAccess);
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
if (m_drawContext == nullptr)
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
m_drawContext = std::make_unique<LinuxGLContext>(m_glx, m_display, m_window, m_uploadContext.get(), false);
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
return m_drawContext.get();
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
}
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
dp::GraphicsContext * GetResourcesUploadContext() override
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
{
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
std::lock_guard<std::mutex> lock(m_contextAccess);
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
if (m_uploadContext == nullptr)
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
m_uploadContext = std::make_unique<LinuxGLContext>(m_glx, m_display, 0, m_drawContext.get(), true);
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
return m_uploadContext.get();
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
}
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
void WaitForInitialization(dp::GraphicsContext *) override
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
{
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
std::unique_lock<std::mutex> lock(m_initializationMutex);
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
if (m_isInitialized)
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
return;
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
m_initializationCounter++;
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
if (m_initializationCounter >= kGLThreadsCount)
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
{
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
m_isInitialized = true;
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
m_initializationCondition.notify_all();
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
}
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
else
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
{
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
m_initializationCondition.wait(lock, [this] { return m_isInitialized; });
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
}
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
}
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
bool IsDrawContextCreated() const override
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
{
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
std::lock_guard<std::mutex> lock(m_contextAccess);
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
return m_drawContext != nullptr;
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
}
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
bool IsUploadContextCreated() const override
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
{
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
std::lock_guard<std::mutex> lock(m_contextAccess);
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
return m_uploadContext != nullptr;
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
}
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
private:
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
static size_t constexpr kGLThreadsCount = 2;
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
GLXFunctions m_glx;
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
Display * m_display = nullptr;
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
Window m_window = 0;
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
std::unique_ptr<LinuxGLContext> m_drawContext;
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
std::unique_ptr<LinuxGLContext> m_uploadContext;
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
mutable std::mutex m_contextAccess;
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
bool m_isInitialized = false;
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
size_t m_initializationCounter = 0;
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
std::condition_variable m_initializationCondition;
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
std::mutex m_initializationMutex;
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
};
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
drape_ptr<dp::GraphicsContextFactory> CreateContextFactory(GLFWwindow * window, dp::ApiVersion api, m2::PointU size)
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
{
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
if (api == dp::ApiVersion::Vulkan)
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
{
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
auto contextFactory = make_unique_dp<LinuxVulkanContextFactory>();
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
contextFactory->SetSurface(glfwGetX11Display(), glfwGetX11Window(window));
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
return contextFactory;
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
}
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
if (api == dp::ApiVersion::OpenGLES3)
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
{
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
return make_unique_dp<LinuxContextFactory>(glfwGetX11Display(), glfwGetX11Window(window));
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
}
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
ASSERT(false, ("API is not available yet"));
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
return nullptr;
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
}
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
void OnCreateDrapeEngine(GLFWwindow * window, dp::ApiVersion api, ref_ptr<dp::GraphicsContextFactory> contextFactory)
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
{
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
// Do nothing
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
}
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
void PrepareDestroyContextFactory(ref_ptr<dp::GraphicsContextFactory> contextFactory)
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
{
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
auto const api = contextFactory->GetDrawContext()->GetApiVersion();
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
if (api == dp::ApiVersion::OpenGLES3)
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
{
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
// Do nothing
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
}
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
else if (api == dp::ApiVersion::Vulkan)
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
{
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
ref_ptr<LinuxVulkanContextFactory> linuxContextFactory = contextFactory;
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
linuxContextFactory->ResetSurface();
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
}
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
else
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
{
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
ASSERT(false, ("API is not available yet"));
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
}
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
}
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
void UpdateContentScale(GLFWwindow * window, float scale)
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
{
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
// Do nothing
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
}
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
void UpdateSize(ref_ptr<dp::GraphicsContextFactory> contextFactory, int w, int h)
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
{
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
// Do nothing
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
||||
}
|
||||
![]() nit: I suppose static is redundant here nit: I suppose static is redundant here
|
|
@ -115,6 +115,10 @@ sudo apt update && sudo apt install -y \
|
|||
libqt6positioning6-plugins \
|
||||
libqt6positioning6 \
|
||||
libsqlite3-dev \
|
||||
libxrandr-dev \
|
||||
libxinerama-dev \
|
||||
libxcursor-dev \
|
||||
libxi-dev \
|
||||
zlib1g-dev
|
||||
```
|
||||
|
||||
|
|
|
@ -84,6 +84,7 @@ Automatically [generated](TRANSLATIONS.md#technical-details):
|
|||
- `cmake/` - CMake helper files.
|
||||
- `coding/` - I/O classes and data processing.
|
||||
- `descriptions/` -
|
||||
- `dev_sandbox/` - developer tool for debugging rendering.
|
||||
- `drape_frontend/` - scene and resource manager for the Drape library.
|
||||
- `drape/` - the new graphics library core.
|
||||
- `editor/` - built-in OSM data editor.
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include <functional>
|
||||
#include <string>
|
||||
#include <variant>
|
||||
#include <vector>
|
||||
|
||||
namespace osm
|
||||
|
|
10
shaders/GL/imgui.fsh.glsl
Normal file
|
@ -0,0 +1,10 @@
|
|||
varying vec2 v_texCoords;
|
||||
varying vec4 v_color;
|
||||
|
||||
uniform sampler2D u_colorTex;
|
||||
|
||||
void main()
|
||||
{
|
||||
LOW_P vec4 color = texture2D(u_colorTex, v_texCoords);
|
||||
gl_FragColor = color * v_color;
|
||||
}
|
19
shaders/GL/imgui.vsh.glsl
Normal file
|
@ -0,0 +1,19 @@
|
|||
attribute vec2 a_position;
|
||||
attribute vec2 a_texCoords;
|
||||
attribute vec4 a_color;
|
||||
|
||||
varying vec2 v_texCoords;
|
||||
varying vec4 v_color;
|
||||
|
||||
uniform mat4 u_projection;
|
||||
|
||||
void main()
|
||||
{
|
||||
v_texCoords = a_texCoords;
|
||||
v_color = a_color;
|
||||
gl_Position = vec4(a_position, 0, 1) * u_projection;
|
||||
#ifdef VULKAN
|
||||
gl_Position.y = -gl_Position.y;
|
||||
gl_Position.z = (gl_Position.z + gl_Position.w) * 0.5;
|
||||
#endif
|
||||
}
|
|
@ -53,3 +53,4 @@ TrafficCircle traffic_circle.vsh.glsl traffic_circle.fsh.glsl
|
|||
SmaaEdges smaa_edges.vsh.glsl smaa_edges.fsh.glsl
|
||||
SmaaBlendingWeight smaa_blending_weight.vsh.glsl smaa_blending_weight.fsh.glsl
|
||||
SmaaFinal smaa_final.vsh.glsl smaa_final.fsh.glsl
|
||||
ImGui imgui.vsh.glsl imgui.fsh.glsl
|
||||
|
|
39
shaders/Metal/imgui.metal
Normal file
|
@ -0,0 +1,39 @@
|
|||
#include <metal_stdlib>
|
||||
#include <simd/simd.h>
|
||||
using namespace metal;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float2 a_position [[attribute(0)]];
|
||||
float2 a_texCoords [[attribute(1)]];
|
||||
float4 a_color [[attribute(2)]];
|
||||
} Vertex_T;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float4 position [[position]];
|
||||
float2 texCoords;
|
||||
float4 color;
|
||||
} Fragment_T;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float4x4 u_projection;
|
||||
} Uniforms_T;
|
||||
|
||||
vertex Fragment_T vsImGui(const Vertex_T in [[stage_in]],
|
||||
constant Uniforms_T & uniforms [[buffer(1)]])
|
||||
{
|
||||
Fragment_T out;
|
||||
out.position = float4(in.a_position, 0.0, 1.0) * uniforms.u_projection;
|
||||
out.texCoords = in.a_texCoords;
|
||||
out.color = in.a_color;
|
||||
return out;
|
||||
}
|
||||
|
||||
fragment float4 fsImGui(const Fragment_T in [[stage_in]],
|
||||
texture2d<float> u_colorTex [[texture(0)]],
|
||||
sampler u_colorTexSampler [[sampler(0)]])
|
||||
{
|
||||
return in.color * u_colorTex.sample(u_colorTexSampler, in.texCoords);
|
||||
}
|
|
@ -230,4 +230,14 @@ void GLProgramParamsSetter::Apply(ref_ptr<dp::GraphicsContext> context,
|
|||
|
||||
Parameter::CheckApply(guard, "u_framebufferMetrics", params.m_framebufferMetrics);
|
||||
}
|
||||
|
||||
void GLProgramParamsSetter::Apply(ref_ptr<dp::GraphicsContext> context,
|
||||
ref_ptr<dp::GpuProgram> program,
|
||||
ImGuiProgramParams const & params)
|
||||
{
|
||||
UNUSED_VALUE(context);
|
||||
UniformsGuard guard(program, params);
|
||||
|
||||
Parameter::CheckApply(guard, "u_projection", params.m_projection);
|
||||
}
|
||||
} // namespace gpu
|
||||
|
|
|
@ -29,5 +29,7 @@ public:
|
|||
ref_ptr<dp::GpuProgram> program, ScreenQuadProgramParams const & params) override;
|
||||
void Apply(ref_ptr<dp::GraphicsContext> context,
|
||||
ref_ptr<dp::GpuProgram> program, SMAAProgramParams const & params) override;
|
||||
void Apply(ref_ptr<dp::GraphicsContext> context,
|
||||
ref_ptr<dp::GpuProgram> program, ImGuiProgramParams const & params) override;
|
||||
};
|
||||
} // namespace gpu
|
||||
|
|
|
@ -31,6 +31,8 @@ public:
|
|||
ScreenQuadProgramParams const & params) override;
|
||||
void Apply(ref_ptr<dp::GraphicsContext> context, ref_ptr<dp::GpuProgram> program,
|
||||
SMAAProgramParams const & params) override;
|
||||
void Apply(ref_ptr<dp::GraphicsContext> context, ref_ptr<dp::GpuProgram> program,
|
||||
ImGuiProgramParams const & params) override;
|
||||
};
|
||||
} // namespace metal
|
||||
} // namespace gpu
|
||||
|
|
|
@ -101,5 +101,12 @@ void MetalProgramParamsSetter::Apply(ref_ptr<dp::GraphicsContext> context,
|
|||
{
|
||||
ApplyBytes(context, program, params);
|
||||
}
|
||||
|
||||
void MetalProgramParamsSetter::Apply(ref_ptr<dp::GraphicsContext> context,
|
||||
ref_ptr<dp::GpuProgram> program,
|
||||
ImGuiProgramParams const & params)
|
||||
{
|
||||
ApplyBytes(context, program, params);
|
||||
}
|
||||
} // namespace metal
|
||||
} // namespace gpu
|
||||
|
|
|
@ -102,6 +102,7 @@ std::array<ProgramInfo, static_cast<size_t>(Program::ProgramsCount)> const kMeta
|
|||
ProgramInfo("vsSmaaEdges", "fsSmaaEdges", {{0, 1}}), // SmaaEdges
|
||||
ProgramInfo("vsSmaaBlendingWeight", "fsSmaaBlendingWeight", {{0, 1}}), // SmaaBlendingWeight
|
||||
ProgramInfo("vsSmaaFinal", "fsSmaaFinal", {{0, 1}}), // SmaaFinal
|
||||
ProgramInfo("vsImGui", "fsImGui", {{0, 2}}), // ImGui
|
||||
}};
|
||||
|
||||
MTLVertexFormat GetFormatByDataType(MTLDataType dataType)
|
||||
|
|
|
@ -18,6 +18,7 @@ void ProgramParams::Init()
|
|||
DebugRectProgramParams::BindPrograms(m_boundParams);
|
||||
ScreenQuadProgramParams::BindPrograms(m_boundParams);
|
||||
SMAAProgramParams::BindPrograms(m_boundParams);
|
||||
ImGuiProgramParams::BindPrograms(m_boundParams);
|
||||
}
|
||||
|
||||
// static
|
||||
|
|
|
@ -222,6 +222,14 @@ struct ALIGNMENT SMAAProgramParams
|
|||
Program::SmaaFinal)
|
||||
};
|
||||
|
||||
struct ALIGNMENT ImGuiProgramParams
|
||||
{
|
||||
glsl::mat4 m_projection;
|
||||
|
||||
BIND_PROGRAMS(ImGuiProgramParams,
|
||||
Program::ImGui)
|
||||
};
|
||||
|
||||
#undef ALIGNMENT
|
||||
|
||||
class ProgramParamsSetter
|
||||
|
@ -248,5 +256,7 @@ public:
|
|||
ref_ptr<dp::GpuProgram> program, ScreenQuadProgramParams const & params) = 0;
|
||||
virtual void Apply(ref_ptr<dp::GraphicsContext> context,
|
||||
ref_ptr<dp::GpuProgram> program, SMAAProgramParams const & params) = 0;
|
||||
virtual void Apply(ref_ptr<dp::GraphicsContext> context,
|
||||
ref_ptr<dp::GpuProgram> program, ImGuiProgramParams const & params) = 0;
|
||||
};
|
||||
} // namespace gpu
|
||||
|
|
|
@ -65,6 +65,7 @@ enum class Program
|
|||
SmaaEdges,
|
||||
SmaaBlendingWeight,
|
||||
SmaaFinal,
|
||||
ImGui,
|
||||
|
||||
ProgramsCount
|
||||
};
|
||||
|
@ -128,6 +129,7 @@ inline std::string DebugPrint(Program p)
|
|||
case Program::SmaaEdges: return "SmaaEdges";
|
||||
case Program::SmaaBlendingWeight: return "SmaaBlendingWeight";
|
||||
case Program::SmaaFinal: return "SmaaFinal";
|
||||
case Program::ImGui: return "ImGui";
|
||||
|
||||
case Program::ProgramsCount:
|
||||
CHECK(false, ("Try to output ProgramsCount"));
|
||||
|
|
|
@ -229,5 +229,12 @@ void VulkanProgramParamsSetter::Apply(ref_ptr<dp::GraphicsContext> context,
|
|||
{
|
||||
ApplyImpl(context, program, params);
|
||||
}
|
||||
|
||||
void VulkanProgramParamsSetter::Apply(ref_ptr<dp::GraphicsContext> context,
|
||||
ref_ptr<dp::GpuProgram> program,
|
||||
ImGuiProgramParams const & params)
|
||||
{
|
||||
ApplyImpl(context, program, params);
|
||||
}
|
||||
} // namespace vulkan
|
||||
} // namespace gpu
|
||||
|
|
|
@ -55,6 +55,8 @@ public:
|
|||
ScreenQuadProgramParams const & params) override;
|
||||
void Apply(ref_ptr<dp::GraphicsContext> context, ref_ptr<dp::GpuProgram> program,
|
||||
SMAAProgramParams const & params) override;
|
||||
void Apply(ref_ptr<dp::GraphicsContext> context, ref_ptr<dp::GpuProgram> program,
|
||||
ImGuiProgramParams const & params) override;
|
||||
|
||||
private:
|
||||
template<typename T>
|
||||
|
|
Is it needed? Shaders compiler is used only in tests