├── .gitignore ├── .gitmodules ├── LICENSE ├── README.md ├── externals ├── GL │ ├── glcorearb.h │ ├── glext.h │ ├── glxext.h │ ├── wgl.h │ └── wglext.h ├── GLES │ ├── 1.0 │ │ └── gl.h │ ├── egl.h │ ├── gl.h │ ├── glext.h │ └── glplatform.h ├── GLES2 │ ├── gl2.h │ ├── gl2ext.h │ └── gl2platform.h ├── GLES3 │ ├── gl3.h │ ├── gl31.h │ ├── gl32.h │ └── gl3platform.h ├── GLSC │ ├── 1.0.1 │ │ └── gl.h │ └── 1.0 │ │ └── gl.h ├── GLSC2 │ ├── gl2platform.h │ ├── glsc2.h │ └── glsc2ext.h └── KHR │ └── khrplatform.h └── libs ├── config ├── CMakeLists.txt ├── CMakePresets.json ├── README.md ├── include │ └── hamon │ │ ├── config.hpp │ │ └── config │ │ ├── architecture.hpp │ │ ├── architecture │ │ ├── alpha.hpp │ │ ├── arm.hpp │ │ ├── blackfin.hpp │ │ ├── convex.hpp │ │ ├── ia64.hpp │ │ ├── m68k.hpp │ │ ├── mips.hpp │ │ ├── parisc.hpp │ │ ├── ppc.hpp │ │ ├── pyramid.hpp │ │ ├── rs6k.hpp │ │ ├── sparc.hpp │ │ ├── superh.hpp │ │ ├── sys370.hpp │ │ ├── sys390.hpp │ │ ├── x86.hpp │ │ └── z.hpp │ │ ├── compiler │ │ ├── apple_clang.hpp │ │ ├── clang.hpp │ │ ├── gcc.hpp │ │ └── msvc.hpp │ │ ├── platform │ │ ├── linux.hpp │ │ ├── macos.hpp │ │ └── win32.hpp │ │ ├── prefix.hpp │ │ ├── select_compiler_config.hpp │ │ ├── select_platform_config.hpp │ │ ├── select_stdlib_config.hpp │ │ ├── stdlib │ │ ├── dinkumware.hpp │ │ ├── libcpp.hpp │ │ └── libstdcpp3.hpp │ │ ├── suffix.hpp │ │ ├── suffix │ │ ├── alignas.hpp │ │ ├── alignof.hpp │ │ ├── carries_dependency.hpp │ │ ├── constexpr.hpp │ │ ├── current_function.hpp │ │ ├── deprecated.hpp │ │ ├── endian.hpp │ │ ├── extern_template.hpp │ │ ├── fallthrough.hpp │ │ ├── final.hpp │ │ ├── inline_var.hpp │ │ ├── likely.hpp │ │ ├── no_unique_address.hpp │ │ ├── nodiscard.hpp │ │ ├── noexcept.hpp │ │ ├── noreturn.hpp │ │ ├── override.hpp │ │ ├── pragma.hpp │ │ ├── unreachable.hpp │ │ └── warning.hpp │ │ └── user.hpp └── test │ ├── CMakeLists.txt │ └── src │ ├── unit_test_config.cpp │ ├── unit_test_config_alignas.cpp │ ├── unit_test_config_alignof.cpp │ ├── unit_test_config_carries_dependency.cpp │ ├── unit_test_config_constexpr.cpp │ ├── unit_test_config_current_function.cpp │ ├── unit_test_config_cxx11.cpp │ ├── unit_test_config_cxx14.cpp │ ├── unit_test_config_cxx17.cpp │ ├── unit_test_config_cxx20.cpp │ ├── unit_test_config_deprecated.cpp │ ├── unit_test_config_extern_template.cpp │ ├── unit_test_config_fallthrough.cpp │ ├── unit_test_config_final.cpp │ ├── unit_test_config_likely.cpp │ ├── unit_test_config_nodiscard.cpp │ ├── unit_test_config_noexcept.cpp │ ├── unit_test_config_noreturn.cpp │ └── unit_test_config_override.cpp ├── render ├── CMakeLists.txt ├── CMakePresets.json ├── README.md ├── include │ └── hamon │ │ ├── render.hpp │ │ └── render │ │ ├── blend_factor.hpp │ │ ├── blend_operation.hpp │ │ ├── blend_state.hpp │ │ ├── border_color.hpp │ │ ├── clear_value.hpp │ │ ├── color_write_mask.hpp │ │ ├── compare_operation.hpp │ │ ├── cull_mode.hpp │ │ ├── d3d │ │ ├── com_ptr.hpp │ │ ├── d3d11.hpp │ │ ├── d3d11shader.hpp │ │ ├── d3d12.hpp │ │ ├── d3d12shader.hpp │ │ ├── d3dcompiler.hpp │ │ ├── dxgi.hpp │ │ ├── dxgi_factory.hpp │ │ ├── dxgi_swap_chain.hpp │ │ └── throw_if_failed.hpp │ │ ├── d3d11 │ │ ├── blend_factor.hpp │ │ ├── blend_operation.hpp │ │ ├── blend_state.hpp │ │ ├── border_color.hpp │ │ ├── buffer.hpp │ │ ├── color_write_mask.hpp │ │ ├── compare_operation.hpp │ │ ├── constant_buffer.hpp │ │ ├── cull_mode.hpp │ │ ├── d3d11_renderer.hpp │ │ ├── depth_stencil_state.hpp │ │ ├── device.hpp │ │ ├── device_context.hpp │ │ ├── fill_mode.hpp │ │ ├── filter_mode.hpp │ │ ├── geometry.hpp │ │ ├── index_buffer.hpp │ │ ├── index_type.hpp │ │ ├── logic_operation.hpp │ │ ├── primitive_topology.hpp │ │ ├── program.hpp │ │ ├── rasterizer_state.hpp │ │ ├── render_target_view.hpp │ │ ├── resource_map.hpp │ │ ├── sampler.hpp │ │ ├── sampler_address_mode.hpp │ │ ├── shader.hpp │ │ ├── shader_reflection.hpp │ │ ├── stencil_operation.hpp │ │ ├── texture.hpp │ │ ├── texture_format.hpp │ │ └── vertex_buffer.hpp │ │ ├── d3d11_renderer.hpp │ │ ├── d3d12 │ │ ├── blend_factor.hpp │ │ ├── blend_operation.hpp │ │ ├── blend_state.hpp │ │ ├── border_color.hpp │ │ ├── color_write_mask.hpp │ │ ├── command_allocator.hpp │ │ ├── command_list.hpp │ │ ├── command_queue.hpp │ │ ├── compare_operation.hpp │ │ ├── constant_buffer.hpp │ │ ├── constant_buffer_descriptor.hpp │ │ ├── cull_mode.hpp │ │ ├── d3d12_renderer.hpp │ │ ├── depth_stencil_state.hpp │ │ ├── descriptor_heap.hpp │ │ ├── device.hpp │ │ ├── fence.hpp │ │ ├── fill_mode.hpp │ │ ├── filter_mode.hpp │ │ ├── geometry.hpp │ │ ├── index_buffer.hpp │ │ ├── index_type.hpp │ │ ├── input_layout.hpp │ │ ├── logic_operation.hpp │ │ ├── pipeline_state.hpp │ │ ├── primitive_topology.hpp │ │ ├── primitive_topology_type.hpp │ │ ├── program.hpp │ │ ├── rasterizer_state.hpp │ │ ├── render_target_view.hpp │ │ ├── resource.hpp │ │ ├── resource_map.hpp │ │ ├── root_signature.hpp │ │ ├── sampler.hpp │ │ ├── sampler_address_mode.hpp │ │ ├── sampler_descriptor.hpp │ │ ├── shader.hpp │ │ ├── shader_reflection.hpp │ │ ├── shader_visibility.hpp │ │ ├── stencil_operation.hpp │ │ ├── texture.hpp │ │ ├── texture_descriptor.hpp │ │ ├── texture_format.hpp │ │ └── vertex_buffer.hpp │ │ ├── d3d12_renderer.hpp │ │ ├── depth_stencil_state.hpp │ │ ├── detail │ │ ├── hash_combine.hpp │ │ ├── identifiable.hpp │ │ ├── identifier.hpp │ │ ├── index_array.hpp │ │ ├── pixels.hpp │ │ └── uniform.hpp │ │ ├── fill_mode.hpp │ │ ├── filter_mode.hpp │ │ ├── front_face.hpp │ │ ├── geometry.hpp │ │ ├── gl │ │ ├── blend_factor.hpp │ │ ├── blend_operation.hpp │ │ ├── blend_state.hpp │ │ ├── border_color.hpp │ │ ├── buffer.hpp │ │ ├── clear_value.hpp │ │ ├── compare_operation.hpp │ │ ├── context.hpp │ │ ├── cull_mode.hpp │ │ ├── depth_stencil_state.hpp │ │ ├── fill_mode.hpp │ │ ├── filter_mode.hpp │ │ ├── front_face.hpp │ │ ├── geometry.hpp │ │ ├── gl.hpp │ │ ├── gl_renderer.hpp │ │ ├── glext.hpp │ │ ├── index_buffer.hpp │ │ ├── index_type.hpp │ │ ├── logic_operation.hpp │ │ ├── primitive_topology.hpp │ │ ├── program.hpp │ │ ├── rasterizer_state.hpp │ │ ├── resource_map.hpp │ │ ├── sampler.hpp │ │ ├── sampler_address_mode.hpp │ │ ├── shader.hpp │ │ ├── shader_stage.hpp │ │ ├── stencil_operation.hpp │ │ ├── texture.hpp │ │ ├── type.hpp │ │ ├── uniform.hpp │ │ ├── uniform_block.hpp │ │ ├── vertex_array.hpp │ │ ├── vertex_buffer.hpp │ │ ├── viewport.hpp │ │ ├── wgl │ │ │ ├── context.hpp │ │ │ └── wglext.hpp │ │ └── x11 │ │ │ └── context.hpp │ │ ├── gl_renderer.hpp │ │ ├── index_type.hpp │ │ ├── logic_operation.hpp │ │ ├── mipmap_mode.hpp │ │ ├── primitive_topology.hpp │ │ ├── program.hpp │ │ ├── rasterizer_state.hpp │ │ ├── render_pass_state.hpp │ │ ├── render_state.hpp │ │ ├── renderer.hpp │ │ ├── sampler.hpp │ │ ├── sampler_address_mode.hpp │ │ ├── semantic.hpp │ │ ├── shader.hpp │ │ ├── shader_language.hpp │ │ ├── shader_stage.hpp │ │ ├── stencil_operation.hpp │ │ ├── texture.hpp │ │ ├── texture_format.hpp │ │ ├── type.hpp │ │ ├── uniforms.hpp │ │ ├── vertex_attribute.hpp │ │ ├── vertex_layout.hpp │ │ ├── viewport.hpp │ │ ├── vulkan │ │ ├── array_proxy.hpp │ │ ├── blend_factor.hpp │ │ ├── blend_operation.hpp │ │ ├── border_color.hpp │ │ ├── buffer.hpp │ │ ├── color_write_mask.hpp │ │ ├── combined_image_sampler_descriptor.hpp │ │ ├── command_buffer.hpp │ │ ├── command_pool.hpp │ │ ├── compare_operation.hpp │ │ ├── cull_mode.hpp │ │ ├── debug_report_callback.hpp │ │ ├── descriptor_pool.hpp │ │ ├── descriptor_set_layout.hpp │ │ ├── device.hpp │ │ ├── device_memory.hpp │ │ ├── fence.hpp │ │ ├── fill_mode.hpp │ │ ├── filter_mode.hpp │ │ ├── format.hpp │ │ ├── framebuffer.hpp │ │ ├── front_face.hpp │ │ ├── geometry.hpp │ │ ├── graphics_pipeline.hpp │ │ ├── image.hpp │ │ ├── image_view.hpp │ │ ├── index_buffer.hpp │ │ ├── index_type.hpp │ │ ├── instance.hpp │ │ ├── logic_operation.hpp │ │ ├── mipmap_mode.hpp │ │ ├── physical_device.hpp │ │ ├── pipeline_color_blend_state.hpp │ │ ├── pipeline_depth_stencil_state.hpp │ │ ├── pipeline_dynamic_state.hpp │ │ ├── pipeline_input_assembly_state.hpp │ │ ├── pipeline_layout.hpp │ │ ├── pipeline_multisample_state.hpp │ │ ├── pipeline_rasterization_state.hpp │ │ ├── pipeline_shader_stage.hpp │ │ ├── pipeline_vertex_input_state.hpp │ │ ├── pipeline_viewport_state.hpp │ │ ├── primitive_topology.hpp │ │ ├── program.hpp │ │ ├── queue.hpp │ │ ├── render_pass.hpp │ │ ├── resource.hpp │ │ ├── resource_map.hpp │ │ ├── sampler.hpp │ │ ├── sampler_address_mode.hpp │ │ ├── semaphore.hpp │ │ ├── shader.hpp │ │ ├── shader_module.hpp │ │ ├── shader_stage.hpp │ │ ├── spirv_program.hpp │ │ ├── spirv_reflection.hpp │ │ ├── spirv_shader.hpp │ │ ├── stencil_operation.hpp │ │ ├── surface.hpp │ │ ├── swapchain.hpp │ │ ├── texture.hpp │ │ ├── texture_format.hpp │ │ ├── throw_if_failed.hpp │ │ ├── uniform_buffer.hpp │ │ ├── uniform_buffer_descriptor.hpp │ │ ├── vertex_buffer.hpp │ │ ├── vulkan.hpp │ │ ├── vulkan_ext.hpp │ │ └── vulkan_renderer.hpp │ │ └── vulkan_renderer.hpp └── samples │ ├── CMakeLists.txt │ ├── clear │ ├── CMakeLists.txt │ └── sample_render_clear_main.cpp │ ├── color_write_mask │ ├── CMakeLists.txt │ └── sample_render_color_write_mask_main.cpp │ ├── cull_mode │ ├── CMakeLists.txt │ └── sample_render_cull_mode_main.cpp │ ├── fill_mode │ ├── CMakeLists.txt │ └── sample_render_fill_mode_main.cpp │ ├── indexed │ ├── CMakeLists.txt │ └── sample_render_indexed_main.cpp │ ├── primitive_topology │ ├── CMakeLists.txt │ └── sample_render_primitive_topology_main.cpp │ ├── texture │ ├── CMakeLists.txt │ └── sample_render_texture_main.cpp │ ├── triangle │ ├── CMakeLists.txt │ └── sample_render_triangle_main.cpp │ ├── uniform │ ├── CMakeLists.txt │ └── sample_render_uniform_main.cpp │ └── viewport │ ├── CMakeLists.txt │ └── sample_render_viewport_main.cpp ├── type_traits ├── CMakeLists.txt ├── CMakePresets.json ├── README.md ├── include │ └── hamon │ │ ├── type_traits.hpp │ │ └── type_traits │ │ ├── is_implicitly_constructible.hpp │ │ ├── is_implicitly_copy_constructible.hpp │ │ ├── is_implicitly_default_constructible.hpp │ │ └── is_implicitly_move_constructible.hpp └── test │ ├── CMakeLists.txt │ └── src │ ├── unit_test_type_traits_is_implicitly_constructible.cpp │ ├── unit_test_type_traits_is_implicitly_copy_constructible.cpp │ ├── unit_test_type_traits_is_implicitly_default_constructible.cpp │ └── unit_test_type_traits_is_implicitly_move_constructible.cpp └── window ├── CMakeLists.txt ├── CMakePresets.json ├── README.md ├── include └── hamon │ ├── window.hpp │ └── window │ ├── win32 │ ├── win32.hpp │ └── win32_window.hpp │ ├── window.hpp │ └── x11 │ └── x11_window.hpp └── samples ├── CMakeLists.txt └── window ├── CMakeLists.txt └── sample_window_window_main.cpp /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Compiled Dynamic libraries 15 | *.so 16 | *.dylib 17 | *.dll 18 | 19 | # Fortran module files 20 | *.mod 21 | *.smod 22 | 23 | # Compiled Static libraries 24 | *.lai 25 | *.la 26 | *.a 27 | *.lib 28 | 29 | # Executables 30 | *.exe 31 | *.out 32 | *.app 33 | 34 | # Visual Studio 2015/2017 cache/options directory 35 | .vs/ 36 | 37 | # Build Directory 38 | build/ 39 | 40 | # CMake 41 | CMakeUserPresets.json 42 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "externals/glslang"] 2 | path = externals/glslang 3 | url = https://github.com/KhronosGroup/glslang.git 4 | [submodule "externals/SPIRV-Cross"] 5 | path = externals/SPIRV-Cross 6 | url = https://github.com/KhronosGroup/SPIRV-Cross.git 7 | [submodule "externals/googletest"] 8 | path = externals/googletest 9 | url = https://github.com/google/googletest.git 10 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 shibainuudon 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shibainuudon/HamonEngine/d80f861c7fd4f4284e169712a1f267fec70bf3a7/README.md -------------------------------------------------------------------------------- /externals/GLES/egl.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright 2008-2020 The Khronos Group Inc. 3 | ** SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | /* 7 | * Skeleton egl.h to provide compatibility for early GLES 1.0 8 | * applications. Several early implementations included gl.h 9 | * in egl.h leading applications to include only egl.h 10 | */ 11 | 12 | #ifndef __legacy_egl_h_ 13 | #define __legacy_egl_h_ 14 | 15 | #include 16 | #include 17 | 18 | #endif /* __legacy_egl_h_ */ 19 | -------------------------------------------------------------------------------- /externals/GLES/glplatform.h: -------------------------------------------------------------------------------- 1 | #ifndef __glplatform_h_ 2 | #define __glplatform_h_ 3 | 4 | /* 5 | ** Copyright 2017-2020 The Khronos Group Inc. 6 | ** SPDX-License-Identifier: Apache-2.0 7 | */ 8 | 9 | /* Platform-specific types and definitions for OpenGL ES 1.X gl.h 10 | * 11 | * Adopters may modify khrplatform.h and this file to suit their platform. 12 | * Please contribute modifications back to Khronos as pull requests on the 13 | * public github repository: 14 | * https://github.com/KhronosGroup/OpenGL-Registry 15 | */ 16 | 17 | #include 18 | 19 | #ifndef GL_API 20 | #define GL_API KHRONOS_APICALL 21 | #endif 22 | 23 | #ifndef GL_APIENTRY 24 | #define GL_APIENTRY KHRONOS_APIENTRY 25 | #endif 26 | 27 | #endif /* __glplatform_h_ */ 28 | -------------------------------------------------------------------------------- /externals/GLES2/gl2platform.h: -------------------------------------------------------------------------------- 1 | #ifndef __gl2platform_h_ 2 | #define __gl2platform_h_ 3 | 4 | /* 5 | ** Copyright 2017-2020 The Khronos Group Inc. 6 | ** SPDX-License-Identifier: Apache-2.0 7 | */ 8 | 9 | /* Platform-specific types and definitions for OpenGL ES 2.X gl2.h 10 | * 11 | * Adopters may modify khrplatform.h and this file to suit their platform. 12 | * Please contribute modifications back to Khronos as pull requests on the 13 | * public github repository: 14 | * https://github.com/KhronosGroup/OpenGL-Registry 15 | */ 16 | 17 | #include 18 | 19 | #ifndef GL_APICALL 20 | #define GL_APICALL KHRONOS_APICALL 21 | #endif 22 | 23 | #ifndef GL_APIENTRY 24 | #define GL_APIENTRY KHRONOS_APIENTRY 25 | #endif 26 | 27 | #endif /* __gl2platform_h_ */ 28 | -------------------------------------------------------------------------------- /externals/GLES3/gl3platform.h: -------------------------------------------------------------------------------- 1 | #ifndef __gl3platform_h_ 2 | #define __gl3platform_h_ 3 | 4 | /* 5 | ** Copyright 2017-2020 The Khronos Group Inc. 6 | ** SPDX-License-Identifier: Apache-2.0 7 | */ 8 | 9 | /* Platform-specific types and definitions for OpenGL ES 3.X gl3.h 10 | * 11 | * Adopters may modify khrplatform.h and this file to suit their platform. 12 | * Please contribute modifications back to Khronos as pull requests on the 13 | * public github repository: 14 | * https://github.com/KhronosGroup/OpenGL-Registry 15 | */ 16 | 17 | #include 18 | 19 | #ifndef GL_APICALL 20 | #define GL_APICALL KHRONOS_APICALL 21 | #endif 22 | 23 | #ifndef GL_APIENTRY 24 | #define GL_APIENTRY KHRONOS_APIENTRY 25 | #endif 26 | 27 | #endif /* __gl3platform_h_ */ 28 | -------------------------------------------------------------------------------- /externals/GLSC2/gl2platform.h: -------------------------------------------------------------------------------- 1 | #ifndef __gl2platform_h_ 2 | #define __gl2platform_h_ 3 | 4 | /* 5 | ** Copyright 2017-2020 The Khronos Group Inc. 6 | ** SPDX-License-Identifier: Apache-2.0 7 | */ 8 | 9 | /* Platform-specific types and definitions for OpenGL SC 2.0 glsc2.h 10 | * 11 | * Adopters may modify khrplatform.h and this file to suit their platform. 12 | * Please contribute modifications back to Khronos as pull requests on the 13 | * public github repository: 14 | * https://github.com/KhronosGroup/OpenGL-Registry 15 | */ 16 | 17 | #include 18 | 19 | #ifndef GL_APICALL 20 | #define GL_APICALL KHRONOS_APICALL 21 | #endif 22 | 23 | #ifndef GL_APIENTRY 24 | #define GL_APIENTRY KHRONOS_APIENTRY 25 | #endif 26 | 27 | #endif /* __gl2platform_h_ */ 28 | -------------------------------------------------------------------------------- /libs/config/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | set(TARGET_NAME_BASE config) 4 | 5 | set(TARGET_NAME hamon_${TARGET_NAME_BASE}) 6 | set(TARGET_ALIAS_NAME Hamon::${TARGET_NAME_BASE}) 7 | 8 | if (TARGET ${TARGET_NAME}) 9 | RETURN() 10 | endif() 11 | 12 | project(${TARGET_NAME} LANGUAGES C CXX) 13 | 14 | add_library(${TARGET_NAME} INTERFACE) 15 | add_library(${TARGET_ALIAS_NAME} ALIAS ${TARGET_NAME}) 16 | 17 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 18 | set(CMAKE_CXX_EXTENSIONS OFF) 19 | 20 | target_include_directories(${TARGET_NAME} INTERFACE ${PROJECT_SOURCE_DIR}/include) 21 | 22 | if (MSVC) 23 | # /W4 (Warning Level) 24 | target_compile_options(${TARGET_NAME} INTERFACE /W4) 25 | 26 | # /WX (Treat all warnings as errors) 27 | target_compile_options(${TARGET_NAME} INTERFACE /WX) 28 | 29 | # /GR- (Disable Run-Time Type Information) 30 | target_compile_options(${TARGET_NAME} INTERFACE /GR-) 31 | 32 | # /MP (Build with Multiple Processes) 33 | if (NOT CMAKE_CXX_COMPILER_ID STREQUAL "Clang") 34 | target_compile_options(${TARGET_NAME} INTERFACE /MP) 35 | endif() 36 | 37 | elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") 38 | target_compile_options(${TARGET_NAME} INTERFACE -Wall -Wextra -Werror) 39 | 40 | elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") 41 | target_compile_options(${TARGET_NAME} INTERFACE -Wall -Wextra -Werror) 42 | 43 | endif() 44 | 45 | if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) 46 | add_subdirectory(test) 47 | endif() 48 | -------------------------------------------------------------------------------- /libs/config/README.md: -------------------------------------------------------------------------------- 1 | # Windowライブラリ 2 | -------------------------------------------------------------------------------- /libs/config/include/hamon/config.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file config.hpp 3 | * 4 | * @brief Config library 5 | */ 6 | 7 | #ifndef HAMON_CONFIG_HPP 8 | #define HAMON_CONFIG_HPP 9 | 10 | #include 11 | 12 | #if !defined(HAMON_USER_CONFIG) && !defined(HAMON_NO_USER_CONFIG) 13 | # define HAMON_USER_CONFIG 14 | #endif 15 | #if defined(HAMON_USER_CONFIG) 16 | # include HAMON_USER_CONFIG 17 | #endif 18 | 19 | #if !defined(HAMON_COMPILER_CONFIG) && !defined(HAMON_NO_COMPILER_CONFIG) && !defined(HAMON_NO_CONFIG) 20 | # include 21 | #endif 22 | #if defined(HAMON_COMPILER_CONFIG) 23 | # include HAMON_COMPILER_CONFIG 24 | #endif 25 | 26 | #if !defined(HAMON_STDLIB_CONFIG) && !defined(HAMON_NO_STDLIB_CONFIG) && !defined(HAMON_NO_CONFIG) && defined(__cplusplus) 27 | # include 28 | #endif 29 | #if defined(HAMON_STDLIB_CONFIG) 30 | # include HAMON_STDLIB_CONFIG 31 | #endif 32 | 33 | #if !defined(HAMON_PLATFORM_CONFIG) && !defined(HAMON_NO_PLATFORM_CONFIG) && !defined(HAMON_NO_CONFIG) 34 | # include 35 | #endif 36 | #if defined(HAMON_PLATFORM_CONFIG) 37 | # include HAMON_PLATFORM_CONFIG 38 | #endif 39 | 40 | #include 41 | #include 42 | 43 | #endif // HAMON_CONFIG_HPP 44 | -------------------------------------------------------------------------------- /libs/config/include/hamon/config/architecture.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file architecture.hpp 3 | * 4 | * @brief 5 | */ 6 | 7 | #ifndef HAMON_CONFIG_ARCHITECTURE_HPP 8 | #define HAMON_CONFIG_ARCHITECTURE_HPP 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | #endif // HAMON_CONFIG_ARCHITECTURE_HPP 29 | -------------------------------------------------------------------------------- /libs/config/include/hamon/config/architecture/alpha.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file alpha.hpp 3 | * 4 | * @brief HAMON_ARCHITECTURE_ALPHA を定義 5 | */ 6 | 7 | #ifndef HAMON_CONFIG_ARCHITECTURE_ALPHA_HPP 8 | #define HAMON_CONFIG_ARCHITECTURE_ALPHA_HPP 9 | 10 | #if defined(__alpha__) || defined(__alpha) || defined(_M_ALPHA) 11 | # define HAMON_ARCHITECTURE "alpha" 12 | # define HAMON_ARCHITECTURE_ALPHA 13 | #endif 14 | 15 | #endif // HAMON_CONFIG_ARCHITECTURE_ALPHA_HPP 16 | -------------------------------------------------------------------------------- /libs/config/include/hamon/config/architecture/arm.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file arm.hpp 3 | * 4 | * @brief HAMON_ARCHITECTURE_ARM を定義 5 | */ 6 | 7 | #ifndef HAMON_CONFIG_ARCHITECTURE_ARM_HPP 8 | #define HAMON_CONFIG_ARCHITECTURE_ARM_HPP 9 | 10 | #if defined(__arm__) || defined(__arm64) || defined(__thumb__) || \ 11 | defined(_M_ARM) || defined(_M_ARM64) || \ 12 | defined(__TARGET_ARCH_ARM) || defined(__TARGET_ARCH_THUMB) 13 | # define HAMON_ARCHITECTURE "arm" 14 | # define HAMON_ARCHITECTURE_ARM 15 | #endif 16 | 17 | #endif // HAMON_CONFIG_ARCHITECTURE_ARM_HPP 18 | -------------------------------------------------------------------------------- /libs/config/include/hamon/config/architecture/blackfin.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file blackfin.hpp 3 | * 4 | * @brief HAMON_ARCHITECTURE_BLACKFIN を定義 5 | */ 6 | 7 | #ifndef HAMON_CONFIG_ARCHITECTURE_BLACKFIN_HPP 8 | #define HAMON_CONFIG_ARCHITECTURE_BLACKFIN_HPP 9 | 10 | #if defined(__bfin__) || defined(__BFIN__) || \ 11 | defined(bfin) || defined(BFIN) 12 | # define HAMON_ARCHITECTURE "blackfin" 13 | # define HAMON_ARCHITECTURE_BLACKFIN 14 | #endif 15 | 16 | #endif // HAMON_CONFIG_ARCHITECTURE_BLACKFIN_HPP 17 | -------------------------------------------------------------------------------- /libs/config/include/hamon/config/architecture/convex.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file convex.hpp 3 | * 4 | * @brief HAMON_ARCHITECTURE_CONVEX を定義 5 | */ 6 | 7 | #ifndef HAMON_CONFIG_ARCHITECTURE_CONVEX_HPP 8 | #define HAMON_CONFIG_ARCHITECTURE_CONVEX_HPP 9 | 10 | #if defined(__convex__) 11 | # define HAMON_ARCHITECTURE "convex" 12 | # define HAMON_ARCHITECTURE_CONVEX 13 | #endif 14 | 15 | #endif // HAMON_CONFIG_ARCHITECTURE_CONVEX_HPP 16 | -------------------------------------------------------------------------------- /libs/config/include/hamon/config/architecture/ia64.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file ia64.hpp 3 | * 4 | * @brief HAMON_ARCHITECTURE_IA64 を定義 5 | */ 6 | 7 | #ifndef HAMON_CONFIG_ARCHITECTURE_IA64_HPP 8 | #define HAMON_CONFIG_ARCHITECTURE_IA64_HPP 9 | 10 | #if defined(__ia64__) || defined(_IA64) || \ 11 | defined(__IA64__) || defined(__ia64) || \ 12 | defined(_M_IA64) || defined(__itanium__) 13 | # define HAMON_ARCHITECTURE "ia64" 14 | # define HAMON_ARCHITECTURE_IA64 15 | #endif 16 | 17 | #endif // HAMON_CONFIG_ARCHITECTURE_IA64_HPP 18 | -------------------------------------------------------------------------------- /libs/config/include/hamon/config/architecture/m68k.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file m68k.hpp 3 | * 4 | * @brief HAMON_ARCHITECTURE_M68K を定義 5 | */ 6 | 7 | #ifndef HAMON_CONFIG_ARCHITECTURE_M68K_HPP 8 | #define HAMON_CONFIG_ARCHITECTURE_M68K_HPP 9 | 10 | #if defined(__m68k__) || defined(M68000) 11 | # define HAMON_ARCHITECTURE "m68k" 12 | # define HAMON_ARCHITECTURE_M68K 13 | #endif 14 | 15 | #endif // HAMON_CONFIG_ARCHITECTURE_M68K_HPP 16 | -------------------------------------------------------------------------------- /libs/config/include/hamon/config/architecture/mips.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file mips.hpp 3 | * 4 | * @brief HAMON_ARCHITECTURE_MIPS を定義 5 | */ 6 | 7 | #ifndef HAMON_CONFIG_ARCHITECTURE_MIPS_HPP 8 | #define HAMON_CONFIG_ARCHITECTURE_MIPS_HPP 9 | 10 | #if defined(__mips__) || defined(__mips) || \ 11 | defined(__MIPS__) 12 | # define HAMON_ARCHITECTURE "mips" 13 | # define HAMON_ARCHITECTURE_MIPS 14 | #endif 15 | 16 | #endif // HAMON_CONFIG_ARCHITECTURE_MIPS_HPP 17 | -------------------------------------------------------------------------------- /libs/config/include/hamon/config/architecture/parisc.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file parisc.hpp 3 | * 4 | * @brief HAMON_ARCHITECTURE_PARISC を定義 5 | */ 6 | 7 | #ifndef HAMON_CONFIG_ARCHITECTURE_PARISC_HPP 8 | #define HAMON_CONFIG_ARCHITECTURE_PARISC_HPP 9 | 10 | #if defined(__hppa__) || defined(__hppa) || defined(__HPPA__) 11 | # define HAMON_ARCHITECTURE "parisc" 12 | # define HAMON_ARCHITECTURE_PARISC 13 | #endif 14 | 15 | #endif // HAMON_CONFIG_ARCHITECTURE_PARISC_HPP 16 | -------------------------------------------------------------------------------- /libs/config/include/hamon/config/architecture/ppc.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file ppc.hpp 3 | * 4 | * @brief HAMON_ARCHITECTURE_PPC を定義 5 | */ 6 | 7 | #ifndef HAMON_CONFIG_ARCHITECTURE_PPC_HPP 8 | #define HAMON_CONFIG_ARCHITECTURE_PPC_HPP 9 | 10 | #if defined(__powerpc) || defined(__powerpc__) || \ 11 | defined(__POWERPC__) || defined(__ppc__) || \ 12 | defined(_M_PPC) || defined(_ARCH_PPC) || \ 13 | defined(__PPCGECKO__) || defined(__PPCBROADWAY__) || \ 14 | defined(_XENON) 15 | # define HAMON_ARCHITECTURE "ppc" 16 | # define HAMON_ARCHITECTURE_PPC 17 | #endif 18 | 19 | #endif // HAMON_CONFIG_ARCHITECTURE_PPC_HPP 20 | -------------------------------------------------------------------------------- /libs/config/include/hamon/config/architecture/pyramid.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file pyramid.hpp 3 | * 4 | * @brief HAMON_ARCHITECTURE_PYRAMID を定義 5 | */ 6 | 7 | #ifndef HAMON_CONFIG_ARCHITECTURE_PYRAMID_HPP 8 | #define HAMON_CONFIG_ARCHITECTURE_PYRAMID_HPP 9 | 10 | #if defined(pyr) 11 | # define HAMON_ARCHITECTURE "pyramid" 12 | # define HAMON_ARCHITECTURE_PYRAMID 13 | #endif 14 | 15 | #endif // HAMON_CONFIG_ARCHITECTURE_PYRAMID_HPP 16 | -------------------------------------------------------------------------------- /libs/config/include/hamon/config/architecture/rs6k.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file rs6k.hpp 3 | * 4 | * @brief HAMON_ARCHITECTURE_RS6000 を定義 5 | */ 6 | 7 | #ifndef HAMON_CONFIG_ARCHITECTURE_RS6K_HPP 8 | #define HAMON_CONFIG_ARCHITECTURE_RS6K_HPP 9 | 10 | #if defined(__THW_RS6000) || defined(_IBMR2) || \ 11 | defined(_POWER) || defined(_ARCH_PWR) || \ 12 | defined(_ARCH_PWR2) 13 | # define HAMON_ARCHITECTURE "rs6000" 14 | # define HAMON_ARCHITECTURE_RS6000 15 | #endif 16 | 17 | #endif // HAMON_CONFIG_ARCHITECTURE_RS6K_HPP 18 | -------------------------------------------------------------------------------- /libs/config/include/hamon/config/architecture/sparc.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file sparc.hpp 3 | * 4 | * @brief HAMON_ARCHITECTURE_SPARC を定義 5 | */ 6 | 7 | #ifndef HAMON_CONFIG_ARCHITECTURE_SPARC_HPP 8 | #define HAMON_CONFIG_ARCHITECTURE_SPARC_HPP 9 | 10 | #if defined(__sparc__) || defined(__sparc) 11 | # define HAMON_ARCHITECTURE "sparc" 12 | # define HAMON_ARCHITECTURE_SPARC 13 | #endif 14 | 15 | #endif // HAMON_CONFIG_ARCHITECTURE_SPARC_HPP 16 | -------------------------------------------------------------------------------- /libs/config/include/hamon/config/architecture/superh.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file superh.hpp 3 | * 4 | * @brief HAMON_ARCHITECTURE_SH を定義 5 | */ 6 | 7 | #ifndef HAMON_CONFIG_ARCHITECTURE_SUPERH_HPP 8 | #define HAMON_CONFIG_ARCHITECTURE_SUPERH_HPP 9 | 10 | #if defined(__sh__) 11 | # define HAMON_ARCHITECTURE "sh" 12 | # define HAMON_ARCHITECTURE_SH 13 | #endif 14 | 15 | #endif // HAMON_CONFIG_ARCHITECTURE_SUPERH_HPP 16 | -------------------------------------------------------------------------------- /libs/config/include/hamon/config/architecture/sys370.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file sys370.hpp 3 | * 4 | * @brief HAMON_ARCHITECTURE_SYS370 を定義 5 | */ 6 | 7 | #ifndef HAMON_CONFIG_ARCHITECTURE_SYS370_HPP 8 | #define HAMON_CONFIG_ARCHITECTURE_SYS370_HPP 9 | 10 | #if defined(__370__) || defined(__THW_370__) 11 | # define HAMON_ARCHITECTURE "sys370" 12 | # define HAMON_ARCHITECTURE_SYS370 13 | #endif 14 | 15 | #endif // HAMON_CONFIG_ARCHITECTURE_SYS370_HPP 16 | -------------------------------------------------------------------------------- /libs/config/include/hamon/config/architecture/sys390.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file sys390.hpp 3 | * 4 | * @brief HAMON_ARCHITECTURE_SYS390 を定義 5 | */ 6 | 7 | #ifndef HAMON_CONFIG_ARCHITECTURE_SYS390_HPP 8 | #define HAMON_CONFIG_ARCHITECTURE_SYS390_HPP 9 | 10 | #if defined(__s390__) || defined(__s390x__) 11 | # define HAMON_ARCHITECTURE "sys390" 12 | # define HAMON_ARCHITECTURE_SYS390 13 | #endif 14 | 15 | #endif // HAMON_CONFIG_ARCHITECTURE_SYS390_HPP 16 | -------------------------------------------------------------------------------- /libs/config/include/hamon/config/architecture/x86.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file x86.hpp 3 | * 4 | * @brief HAMON_ARCHITECTURE_X86 を定義 5 | */ 6 | 7 | #ifndef HAMON_CONFIG_ARCHITECTURE_X86_HPP 8 | #define HAMON_CONFIG_ARCHITECTURE_X86_HPP 9 | 10 | #if defined(i386) || defined(__i386__) || \ 11 | defined(__i486__) || defined(__i586__) || \ 12 | defined(__i686__) || defined(__i386) || \ 13 | defined(_M_IX86) || defined(_X86_) || \ 14 | defined(__INTEL__) || defined(__I86__) || \ 15 | defined(__THW_INTEL__) 16 | # define HAMON_ARCHITECTURE "x86_32" 17 | # define HAMON_ARCHITECTURE_X86_32 18 | #endif 19 | 20 | #if defined(__x86_64) || defined(__x86_64__) || \ 21 | defined(__amd64__) || defined(__amd64) || \ 22 | defined(_M_X64) 23 | # define HAMON_ARCHITECTURE "x86_64" 24 | # define HAMON_ARCHITECTURE_X86_64 25 | #endif 26 | 27 | #if defined(HAMON_ARCHITECTURE_X86_32) || defined(HAMON_ARCHITECTURE_X86_64) 28 | # define HAMON_ARCHITECTURE_X86 29 | #endif 30 | 31 | #endif // HAMON_CONFIG_ARCHITECTURE_X86_HPP 32 | -------------------------------------------------------------------------------- /libs/config/include/hamon/config/architecture/z.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file z.hpp 3 | * 4 | * @brief HAMON_ARCHITECTURE_Z を定義 5 | */ 6 | 7 | #ifndef HAMON_CONFIG_ARCHITECTURE_Z_HPP 8 | #define HAMON_CONFIG_ARCHITECTURE_Z_HPP 9 | 10 | #if defined(__SYSC_ZARCH__) 11 | # define HAMON_ARCHITECTURE "z" 12 | # define HAMON_ARCHITECTURE_Z 13 | #endif 14 | 15 | #endif // HAMON_CONFIG_ARCHITECTURE_Z_HPP 16 | -------------------------------------------------------------------------------- /libs/config/include/hamon/config/platform/linux.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file linux.hpp 3 | * 4 | * @brief 5 | */ 6 | 7 | #ifndef HAMON_CONFIG_PLATFORM_LINUX_HPP 8 | #define HAMON_CONFIG_PLATFORM_LINUX_HPP 9 | 10 | #define HAMON_PLATFORM "linux" 11 | #define HAMON_PLATFORM_LINUX 12 | 13 | #endif // HAMON_CONFIG_PLATFORM_LINUX_HPP 14 | -------------------------------------------------------------------------------- /libs/config/include/hamon/config/platform/macos.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file macos.hpp 3 | * 4 | * @brief 5 | */ 6 | 7 | #ifndef HAMON_CONFIG_PLATFORM_MACOS_HPP 8 | #define HAMON_CONFIG_PLATFORM_MACOS_HPP 9 | 10 | #define HAMON_PLATFORM "Mac OS" 11 | #define HAMON_PLATFORM_MACOS 12 | 13 | #endif // HAMON_CONFIG_PLATFORM_MACOS_HPP 14 | -------------------------------------------------------------------------------- /libs/config/include/hamon/config/platform/win32.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file win32.hpp 3 | * 4 | * @brief 5 | */ 6 | 7 | #ifndef HAMON_CONFIG_PLATFORM_WIN32_HPP 8 | #define HAMON_CONFIG_PLATFORM_WIN32_HPP 9 | 10 | #define HAMON_PLATFORM "Win32" 11 | #define HAMON_PLATFORM_WIN32 12 | 13 | #endif // HAMON_CONFIG_PLATFORM_WIN32_HPP 14 | -------------------------------------------------------------------------------- /libs/config/include/hamon/config/select_compiler_config.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file select_compiler_config.hpp 3 | * 4 | * @brief 5 | */ 6 | 7 | #ifndef HAMON_CONFIG_SELECT_COMPILER_CONFIG_HPP 8 | #define HAMON_CONFIG_SELECT_COMPILER_CONFIG_HPP 9 | 10 | #if defined(__clang__) && !defined(__CUDACC__) && !defined(__ibmxl__) 11 | // when using clang and cuda at same time, you want to appear as gcc 12 | // Clang C++ emulates GCC, so it has to appear early. 13 | 14 | # if defined(__APPLE__) 15 | # define HAMON_COMPILER_CONFIG "hamon/config/compiler/apple_clang.hpp" 16 | # else 17 | # define HAMON_COMPILER_CONFIG "hamon/config/compiler/clang.hpp" 18 | # endif 19 | 20 | #elif defined(__GNUC__) && !defined(__ibmxl__) 21 | // GNU C++: 22 | # define HAMON_COMPILER_CONFIG "hamon/config/compiler/gcc.hpp" 23 | 24 | #elif defined(_MSC_VER) 25 | // Microsoft Visual C++ 26 | # define HAMON_COMPILER_CONFIG "hamon/config/compiler/msvc.hpp" 27 | 28 | #else 29 | # error "Unknown compiler" 30 | 31 | #endif 32 | 33 | #endif // HAMON_CONFIG_SELECT_COMPILER_CONFIG_HPP 34 | -------------------------------------------------------------------------------- /libs/config/include/hamon/config/select_platform_config.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file select_platform_config.hpp 3 | * 4 | * @brief 5 | */ 6 | 7 | #ifndef HAMON_CONFIG_SELECT_PLATFORM_CONFIG_HPP 8 | #define HAMON_CONFIG_SELECT_PLATFORM_CONFIG_HPP 9 | 10 | #if (defined(linux) || defined(__linux) || defined(__linux__) || defined(__GNU__) || defined(__GLIBC__)) && !defined(_CRAYC) 11 | // linux 12 | # define HAMON_PLATFORM_CONFIG "hamon/config/platform/linux.hpp" 13 | 14 | #elif defined(_WIN32) || defined(__WIN32__) || defined(WIN32) 15 | // win32: 16 | # define HAMON_PLATFORM_CONFIG "hamon/config/platform/win32.hpp" 17 | 18 | #elif defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__) 19 | // MacOS 20 | # define HAMON_PLATFORM_CONFIG "hamon/config/platform/macos.hpp" 21 | 22 | #else 23 | # error "Unknown platform" 24 | 25 | #endif 26 | 27 | #endif // HAMON_CONFIG_SELECT_PLATFORM_CONFIG_HPP 28 | -------------------------------------------------------------------------------- /libs/config/include/hamon/config/select_stdlib_config.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file select_stdlib_config.hpp 3 | * 4 | * @brief 5 | */ 6 | 7 | #ifndef HAMON_CONFIG_SELECT_STDLIB_CONFIG_HPP 8 | #define HAMON_CONFIG_SELECT_STDLIB_CONFIG_HPP 9 | 10 | #ifdef __cplusplus 11 | # include 12 | #else 13 | # include 14 | #endif 15 | 16 | #if defined(_LIBCPP_VERSION) 17 | // libc++ 18 | # define HAMON_STDLIB_CONFIG "hamon/config/stdlib/libcpp.hpp" 19 | 20 | #elif defined(__GLIBCPP__) || defined(__GLIBCXX__) 21 | // GNU libstdc++ 3 22 | # define HAMON_STDLIB_CONFIG "hamon/config/stdlib/libstdcpp3.hpp" 23 | 24 | #elif (defined(_YVALS) && !defined(__IBMCPP__)) || defined(_CPPLIB_VER) 25 | // Dinkumware Library 26 | # define HAMON_STDLIB_CONFIG "hamon/config/stdlib/dinkumware.hpp" 27 | 28 | #else 29 | # error "Unknown standard library" 30 | 31 | #endif 32 | 33 | #endif // HAMON_CONFIG_SELECT_STDLIB_CONFIG_HPP 34 | -------------------------------------------------------------------------------- /libs/config/include/hamon/config/stdlib/dinkumware.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file dinkumware.hpp 3 | * 4 | * @brief 5 | */ 6 | 7 | #ifndef HAMON_CONFIG_STDLIB_DINKUMWARE_HPP 8 | #define HAMON_CONFIG_STDLIB_DINKUMWARE_HPP 9 | 10 | #define HAMON_STDLIB "Dinkumware" 11 | #define HAMON_STDLIB_DINKUMWARE 12 | 13 | #endif // HAMON_CONFIG_STDLIB_DINKUMWARE_HPP 14 | -------------------------------------------------------------------------------- /libs/config/include/hamon/config/stdlib/libcpp.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file libcpp.hpp 3 | * 4 | * @brief 5 | */ 6 | 7 | #ifndef HAMON_CONFIG_STDLIB_LIBCPP_HPP 8 | #define HAMON_CONFIG_STDLIB_LIBCPP_HPP 9 | 10 | #define HAMON_STDLIB "libcpp" 11 | #define HAMON_STDLIB_LIBCPP 12 | 13 | #endif // HAMON_CONFIG_STDLIB_LIBCPP_HPP 14 | -------------------------------------------------------------------------------- /libs/config/include/hamon/config/stdlib/libstdcpp3.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file libstdcpp3.hpp 3 | * 4 | * @brief 5 | */ 6 | 7 | #ifndef HAMON_CONFIG_STDLIB_LIBSTDCPP3_HPP 8 | #define HAMON_CONFIG_STDLIB_LIBSTDCPP3_HPP 9 | 10 | #define HAMON_STDLIB "libstdcpp3" 11 | #define HAMON_STDLIB_LIBSTDCPP3 12 | 13 | #endif // HAMON_CONFIG_STDLIB_LIBSTDCPP3_HPP 14 | -------------------------------------------------------------------------------- /libs/config/include/hamon/config/suffix.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file suffix.hpp 3 | * 4 | * @brief 5 | */ 6 | 7 | #ifndef HAMON_CONFIG_SUFFIX_HPP 8 | #define HAMON_CONFIG_SUFFIX_HPP 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | //#define HAMON_HEADER_ONLY 32 | 33 | #if defined(HAMON_HEADER_ONLY) 34 | # define HAMON_INLINE inline 35 | #else 36 | # define HAMON_INLINE 37 | #endif 38 | 39 | #endif // HAMON_CONFIG_SUFFIX_HPP 40 | -------------------------------------------------------------------------------- /libs/config/include/hamon/config/suffix/alignas.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file alignas.hpp 3 | * 4 | * @brief HAMON_ALIGNAS の定義 5 | */ 6 | 7 | #ifndef HAMON_CONFIG_SUFFIX_ALIGNAS_HPP 8 | #define HAMON_CONFIG_SUFFIX_ALIGNAS_HPP 9 | 10 | // 11 | // alignas workaround 12 | // 13 | #if !defined(HAMON_ALIGNAS) 14 | # if defined(HAMON_HAS_CXX11_ALIGNAS) 15 | # define HAMON_ALIGNAS(x) alignas(x) 16 | # define HAMON_ALIGNAS_TYPE(x) alignas(x) 17 | # elif defined(_MSC_VER) 18 | # define HAMON_ALIGNAS(x) __declspec(align(x)) 19 | # define HAMON_ALIGNAS_TYPE(x) __declspec(align(__alignof(x))) 20 | # elif defined(__GNUC__) 21 | # define HAMON_ALIGNAS(x) __attribute__((__aligned__(x))) 22 | # define HAMON_ALIGNAS_TYPE(x) __attribute__((__aligned__(__alignof__(x)))) 23 | # else 24 | # define HAMON_ALIGNAS(x) 25 | # define HAMON_ALIGNAS_TYPE(x) 26 | # define HAMON_NO_ALIGNAS 27 | # endif 28 | #endif 29 | 30 | #endif // HAMON_CONFIG_SUFFIX_ALIGNAS_HPP 31 | -------------------------------------------------------------------------------- /libs/config/include/hamon/config/suffix/alignof.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file alignof.hpp 3 | * 4 | * @brief HAMON_ALIGNOF の定義 5 | */ 6 | 7 | #ifndef HAMON_CONFIG_SUFFIX_ALIGNOF_HPP 8 | #define HAMON_CONFIG_SUFFIX_ALIGNOF_HPP 9 | 10 | // 11 | // alignof workaround 12 | // 13 | #if !defined(HAMON_ALIGNOF) 14 | # if defined(HAMON_HAS_CXX11_ALIGNOF) 15 | # define HAMON_ALIGNOF(type) alignof(type) 16 | # elif defined(_MSC_VER) 17 | # define HAMON_ALIGNOF(type) __alignof(type) 18 | # elif defined(__GNUC__) 19 | # define HAMON_ALIGNOF(type) __alignof__(type) 20 | # else 21 | # define HAMON_ALIGNOF(type) 22 | # define HAMON_NO_ALIGNOF 23 | # endif 24 | #endif 25 | 26 | #endif // HAMON_CONFIG_SUFFIX_ALIGNOF_HPP 27 | -------------------------------------------------------------------------------- /libs/config/include/hamon/config/suffix/carries_dependency.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file carries_dependency.hpp 3 | * 4 | * @brief HAMON_CARRIES_DEPENDENCY の定義 5 | */ 6 | 7 | #ifndef HAMON_CONFIG_SUFFIX_CARRIES_DEPENDENCY_HPP 8 | #define HAMON_CONFIG_SUFFIX_CARRIES_DEPENDENCY_HPP 9 | 10 | // 11 | // [[carries_dependency]] workaround 12 | // 13 | #if !defined(HAMON_CARRIES_DEPENDENCY) 14 | # if defined(HAMON_HAS_CXX11_CARRIES_DEPENDENCY) 15 | # define HAMON_CARRIES_DEPENDENCY [[carries_dependency]] 16 | # else 17 | # define HAMON_CARRIES_DEPENDENCY 18 | # define HAMON_NO_CARRIES_DEPENDENCY 19 | # endif 20 | #endif 21 | 22 | #endif // HAMON_CONFIG_SUFFIX_CARRIES_DEPENDENCY_HPP 23 | -------------------------------------------------------------------------------- /libs/config/include/hamon/config/suffix/current_function.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file current_function.hpp 3 | * 4 | * @brief HAMON_CURRENT_FUNCTION の定義 5 | */ 6 | 7 | #ifndef HAMON_CONFIG_SUFFIX_CURRENT_FUNCTION_HPP 8 | #define HAMON_CONFIG_SUFFIX_CURRENT_FUNCTION_HPP 9 | 10 | /** 11 | * @brief HAMON_CURRENT_FUNCTION 関数名を取得します 12 | */ 13 | 14 | #if defined(__GNUC__) || (defined(__MWERKS__) && (__MWERKS__ >= 0x3000)) || (defined(__ICC) && (__ICC >= 600)) || defined(__ghs__) 15 | 16 | # define HAMON_CURRENT_FUNCTION __PRETTY_FUNCTION__ 17 | 18 | #elif defined(__DMC__) && (__DMC__ >= 0x810) 19 | 20 | # define HAMON_CURRENT_FUNCTION __PRETTY_FUNCTION__ 21 | 22 | #elif defined(__FUNCSIG__) 23 | 24 | # define HAMON_CURRENT_FUNCTION __FUNCSIG__ 25 | 26 | #elif (defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 600)) || (defined(__IBMCPP__) && (__IBMCPP__ >= 500)) 27 | 28 | # define HAMON_CURRENT_FUNCTION __FUNCTION__ 29 | 30 | #elif defined(__BORLANDC__) && (__BORLANDC__ >= 0x550) 31 | 32 | # define HAMON_CURRENT_FUNCTION __FUNC__ 33 | 34 | #elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901) 35 | 36 | # define HAMON_CURRENT_FUNCTION __func__ 37 | 38 | #elif defined(__cplusplus) && (__cplusplus >= 201103) 39 | 40 | # define HAMON_CURRENT_FUNCTION __func__ 41 | 42 | #else 43 | 44 | # define HAMON_CURRENT_FUNCTION "(unknown)" 45 | 46 | #endif 47 | 48 | #endif // HAMON_CONFIG_SUFFIX_CURRENT_FUNCTION_HPP 49 | -------------------------------------------------------------------------------- /libs/config/include/hamon/config/suffix/deprecated.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file deprecated.hpp 3 | * 4 | * @brief HAMON_DEPRECATED の定義 5 | */ 6 | 7 | #ifndef HAMON_CONFIG_SUFFIX_DEPRECATED_HPP 8 | #define HAMON_CONFIG_SUFFIX_DEPRECATED_HPP 9 | 10 | // 11 | // [[deprecated]] workaround 12 | // 13 | #if !defined(HAMON_DEPRECATED) 14 | # if defined(HAMON_HAS_CXX14_DEPRECATED) 15 | # define HAMON_DEPRECATED(message) [[deprecated(message)]] 16 | # elif defined(_MSC_VER) 17 | # define HAMON_DEPRECATED(message) __declspec(deprecated(message)) 18 | # elif defined(__GNUC__) 19 | # define HAMON_DEPRECATED(message) __attribute__((deprecated(message))) 20 | # else 21 | # define HAMON_DEPRECATED(message) 22 | # define HAMON_NO_DEPRECATED 23 | # endif 24 | #endif 25 | 26 | #endif // HAMON_CONFIG_SUFFIX_DEPRECATED_HPP 27 | -------------------------------------------------------------------------------- /libs/config/include/hamon/config/suffix/extern_template.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file extern_template.hpp 3 | * 4 | * @brief HAMON_EXTERN_TEMPLATE の定義 5 | */ 6 | 7 | #ifndef HAMON_CONFIG_SUFFIX_EXTERN_TEMPLATE_HPP 8 | #define HAMON_CONFIG_SUFFIX_EXTERN_TEMPLATE_HPP 9 | 10 | #if !defined(HAMON_EXTERN_TEMPLATE) 11 | # if defined(HAMON_HAS_CXX11_EXTERN_TEMPLATE) 12 | # define HAMON_EXTERN_TEMPLATE(...) extern template __VA_ARGS__ 13 | # else 14 | # define HAMON_EXTERN_TEMPLATE(...) 15 | # define HAMON_NO_EXTERN_TEMPLATE 16 | # endif 17 | #endif 18 | 19 | #endif // HAMON_CONFIG_SUFFIX_EXTERN_TEMPLATE_HPP 20 | -------------------------------------------------------------------------------- /libs/config/include/hamon/config/suffix/fallthrough.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file fallthrough.hpp 3 | * 4 | * @brief HAMON_FALLTHROUGH の定義 5 | */ 6 | 7 | #ifndef HAMON_CONFIG_SUFFIX_FALLTHROUGH_HPP 8 | #define HAMON_CONFIG_SUFFIX_FALLTHROUGH_HPP 9 | 10 | // 11 | // fallthrough workaround 12 | // 13 | #if !defined(HAMON_FALLTHROUGH) 14 | # if defined(HAMON_HAS_CXX17_FALLTHROUGH) 15 | # define HAMON_FALLTHROUGH() [[fallthrough]] 16 | # elif HAMON_HAS_ATTRIBUTE(fallthrough) 17 | # define HAMON_FALLTHROUGH() __attribute__((__fallthrough__)) 18 | # else 19 | # define HAMON_FALLTHROUGH() 20 | # define HAMON_NO_FALLTHROUGH 21 | # endif 22 | #endif 23 | 24 | #endif // HAMON_CONFIG_SUFFIX_FALLTHROUGH_HPP 25 | -------------------------------------------------------------------------------- /libs/config/include/hamon/config/suffix/final.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file final.hpp 3 | * 4 | * @brief HAMON_FINAL の定義 5 | */ 6 | 7 | #ifndef HAMON_CONFIG_SUFFIX_FINAL_HPP 8 | #define HAMON_CONFIG_SUFFIX_FINAL_HPP 9 | 10 | // 11 | // final workaround 12 | // 13 | #if !defined(HAMON_FINAL) 14 | # if defined(HAMON_HAS_CXX11_FINAL) 15 | # define HAMON_FINAL final 16 | # else 17 | # define HAMON_FINAL 18 | # define HAMON_NO_FINAL 19 | # endif 20 | #endif 21 | 22 | #endif // HAMON_CONFIG_SUFFIX_FINAL_HPP 23 | -------------------------------------------------------------------------------- /libs/config/include/hamon/config/suffix/inline_var.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file inline_var.hpp 3 | * 4 | * @brief HAMON_INLINE_VAR の定義 5 | */ 6 | 7 | #ifndef HAMON_CONFIG_SUFFIX_INLINE_VAR_HPP 8 | #define HAMON_CONFIG_SUFFIX_INLINE_VAR_HPP 9 | 10 | // 11 | // inline variables workaround 12 | // 13 | #if !defined(HAMON_INLINE_VAR) 14 | # if defined(HAMON_HAS_CXX17_INLINE_VARIABLES) 15 | # define HAMON_INLINE_VAR inline 16 | # else 17 | # define HAMON_INLINE_VAR 18 | # endif 19 | #endif 20 | 21 | #endif // HAMON_CONFIG_SUFFIX_INLINE_VAR_HPP 22 | -------------------------------------------------------------------------------- /libs/config/include/hamon/config/suffix/likely.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file likely.hpp 3 | * 4 | * @brief HAMON_LIKELY の定義 5 | */ 6 | 7 | #ifndef HAMON_CONFIG_SUFFIX_LIKELY_HPP 8 | #define HAMON_CONFIG_SUFFIX_LIKELY_HPP 9 | 10 | // 11 | // 分岐予測ヒント 12 | // 13 | #if !defined(HAMON_LIKELY) 14 | # if HAMON_HAS_BUILTIN(__builtin_expect) 15 | # define HAMON_LIKELY(x) __builtin_expect(x, 1) 16 | # else 17 | # define HAMON_LIKELY(x) x 18 | # endif 19 | #endif 20 | 21 | #if !defined(HAMON_UNLIKELY) 22 | # if HAMON_HAS_BUILTIN(__builtin_expect) 23 | # define HAMON_UNLIKELY(x) __builtin_expect(x, 0) 24 | # else 25 | # define HAMON_UNLIKELY(x) x 26 | # endif 27 | #endif 28 | 29 | #endif // HAMON_CONFIG_SUFFIX_LIKELY_HPP 30 | -------------------------------------------------------------------------------- /libs/config/include/hamon/config/suffix/no_unique_address.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file no_unique_address.hpp 3 | * 4 | * @brief HAMON_NO_UNIQUE_ADDRESS の定義 5 | */ 6 | 7 | #ifndef HAMON_CONFIG_SUFFIX_NO_UNIQUE_ADDRESS_HPP 8 | #define HAMON_CONFIG_SUFFIX_NO_UNIQUE_ADDRESS_HPP 9 | 10 | // 11 | // [[no_unique_address]] workaround 12 | // 13 | #if !defined(HAMON_NO_UNIQUE_ADDRESS) 14 | # if defined(HAMON_HAS_CXX20_NO_UNIQUE_ADDRESS) 15 | # define HAMON_NO_UNIQUE_ADDRESS [[no_unique_address]] 16 | # else 17 | # define HAMON_NO_UNIQUE_ADDRESS 18 | # define HAMON_NO_NO_UNIQUE_ADDRESS 19 | # endif 20 | #endif 21 | 22 | #endif // HAMON_CONFIG_SUFFIX_NO_UNIQUE_ADDRESS_HPP 23 | -------------------------------------------------------------------------------- /libs/config/include/hamon/config/suffix/nodiscard.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file nodiscard.hpp 3 | * 4 | * @brief HAMON_NODISCARD の定義 5 | */ 6 | 7 | #ifndef HAMON_CONFIG_SUFFIX_NODISCARD_HPP 8 | #define HAMON_CONFIG_SUFFIX_NODISCARD_HPP 9 | 10 | // 11 | // [[nodiscard]] workaround 12 | // 13 | #if !defined(HAMON_NODISCARD) 14 | # if HAMON_HAS_CPP_ATTRIBUTE(nodiscard) 15 | # define HAMON_NODISCARD [[nodiscard]] 16 | # else 17 | # define HAMON_NODISCARD 18 | # define HAMON_NO_NODISCARD 19 | # endif 20 | #endif 21 | 22 | #endif // HAMON_CONFIG_SUFFIX_NODISCARD_HPP 23 | -------------------------------------------------------------------------------- /libs/config/include/hamon/config/suffix/noexcept.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file noexcept.hpp 3 | * 4 | * @brief HAMON_NOEXCEPT の定義 5 | */ 6 | 7 | #ifndef HAMON_CONFIG_SUFFIX_NOEXCEPT_HPP 8 | #define HAMON_CONFIG_SUFFIX_NOEXCEPT_HPP 9 | 10 | // 11 | // noexcept workarounds 12 | // 13 | #if !defined(HAMON_NOEXCEPT) 14 | # if defined(HAMON_HAS_CXX11_NOEXCEPT) 15 | # define HAMON_NOEXCEPT noexcept 16 | # else 17 | # define HAMON_NOEXCEPT 18 | # endif 19 | #endif 20 | 21 | #if !defined(HAMON_NOEXCEPT_OR_NOTHROW) 22 | # if defined(HAMON_HAS_CXX11_NOEXCEPT) 23 | # define HAMON_NOEXCEPT_OR_NOTHROW noexcept 24 | # else 25 | # define HAMON_NOEXCEPT_OR_NOTHROW throw() 26 | # endif 27 | #endif 28 | 29 | #if !defined(HAMON_NOEXCEPT_IF) 30 | # if defined(HAMON_HAS_CXX11_NOEXCEPT) 31 | # define HAMON_NOEXCEPT_IF(Predicate) noexcept((Predicate)) 32 | # else 33 | # define HAMON_NOEXCEPT_IF(Predicate) 34 | # endif 35 | #endif 36 | 37 | #if !defined(HAMON_NOEXCEPT_EXPR) 38 | # if defined(HAMON_HAS_CXX11_NOEXCEPT) 39 | # define HAMON_NOEXCEPT_EXPR(Expression) noexcept((Expression)) 40 | # else 41 | # define HAMON_NOEXCEPT_EXPR(Expression) false 42 | # endif 43 | #endif 44 | 45 | #if !defined(HAMON_NOEXCEPT_IF_EXPR) 46 | # define HAMON_NOEXCEPT_IF_EXPR(Expression) HAMON_NOEXCEPT_IF(HAMON_NOEXCEPT_EXPR((Expression))) 47 | #endif 48 | 49 | #endif // HAMON_CONFIG_SUFFIX_NOEXCEPT_HPP 50 | -------------------------------------------------------------------------------- /libs/config/include/hamon/config/suffix/noreturn.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file noreturn.hpp 3 | * 4 | * @brief HAMON_NORETURN の定義 5 | */ 6 | 7 | #ifndef HAMON_CONFIG_SUFFIX_NORETURN_HPP 8 | #define HAMON_CONFIG_SUFFIX_NORETURN_HPP 9 | 10 | // 11 | // [[noreturn]] workaround 12 | // 13 | #if !defined(HAMON_NORETURN) 14 | # if defined(HAMON_HAS_CXX11_NORETURN) 15 | # define HAMON_NORETURN [[noreturn]] 16 | # elif defined(_MSC_VER) 17 | # define HAMON_NORETURN __declspec(noreturn) 18 | # elif defined(__GNUC__) 19 | # define HAMON_NORETURN __attribute__ ((__noreturn__)) 20 | # else 21 | # define HAMON_NORETURN 22 | # define HAMON_NO_NORETURN 23 | # endif 24 | #endif 25 | 26 | #endif // HAMON_CONFIG_SUFFIX_NORETURN_HPP 27 | -------------------------------------------------------------------------------- /libs/config/include/hamon/config/suffix/override.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file override.hpp 3 | * 4 | * @brief HAMON_OVERRIDE の定義 5 | */ 6 | 7 | #ifndef HAMON_CONFIG_SUFFIX_OVERRIDE_HPP 8 | #define HAMON_CONFIG_SUFFIX_OVERRIDE_HPP 9 | 10 | // 11 | // override workaround 12 | // 13 | #if !defined(HAMON_OVERRIDE) 14 | # if defined(HAMON_HAS_CXX11_OVERRIDE) 15 | # define HAMON_OVERRIDE override 16 | # else 17 | # define HAMON_OVERRIDE 18 | # define HAMON_NO_OVERRIDE 19 | # endif 20 | #endif 21 | 22 | #endif // HAMON_CONFIG_SUFFIX_OVERRIDE_HPP 23 | -------------------------------------------------------------------------------- /libs/config/include/hamon/config/suffix/pragma.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file pragma.hpp 3 | * 4 | * @brief HAMON_PRAGMA の定義 5 | */ 6 | 7 | #ifndef HAMON_CONFIG_SUFFIX_PRAGMA_HPP 8 | #define HAMON_CONFIG_SUFFIX_PRAGMA_HPP 9 | 10 | // 11 | // Pragma演算子 12 | // 13 | #if !defined(HAMON_PRAGMA) 14 | # if defined(HAMON_HAS_CXX11_PRAGMA_OPERATOR) 15 | # define HAMON_PRAGMA(x) _Pragma(#x) 16 | # else 17 | # define HAMON_PRAGMA(x) __pragma(x) 18 | # endif 19 | #endif 20 | 21 | #endif // HAMON_CONFIG_SUFFIX_PRAGMA_HPP 22 | -------------------------------------------------------------------------------- /libs/config/include/hamon/config/suffix/unreachable.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file unreachable.hpp 3 | * 4 | * @brief HAMON_UNREACHABLE の定義 5 | */ 6 | 7 | #ifndef HAMON_CONFIG_SUFFIX_UNREACHABLE_HPP 8 | #define HAMON_CONFIG_SUFFIX_UNREACHABLE_HPP 9 | 10 | // 11 | // unreachable workaround 12 | // 13 | #if !defined(HAMON_UNREACHABLE) 14 | # ifdef __GNUC__ 15 | # define HAMON_UNREACHABLE() __builtin_unreachable() 16 | # else 17 | # define HAMON_UNREACHABLE() 18 | # endif 19 | #endif 20 | 21 | #endif // HAMON_CONFIG_SUFFIX_UNREACHABLE_HPP 22 | -------------------------------------------------------------------------------- /libs/config/include/hamon/config/user.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file user.hpp 3 | * 4 | * @brief 5 | */ 6 | 7 | // NO INCLUDE GUARD 8 | 9 | // define this to locate a compiler config file: 10 | // #define HAMON_COMPILER_CONFIG 11 | 12 | // define this to locate a stdlib config file: 13 | // #define HAMON_STDLIB_CONFIG 14 | 15 | // define this to locate a platform config file: 16 | // #define HAMON_PLATFORM_CONFIG 17 | -------------------------------------------------------------------------------- /libs/config/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | set(TARGET_NAME_BASE config) 4 | set(TARGET_NAME hamon_${TARGET_NAME_BASE}_test) 5 | 6 | add_executable(${TARGET_NAME}) 7 | 8 | file(GLOB_RECURSE test_sources CONFIGURE_DEPENDS src/*) 9 | target_sources(${TARGET_NAME} PRIVATE ${test_sources}) 10 | target_include_directories(${TARGET_NAME} PRIVATE src) 11 | target_link_libraries(${TARGET_NAME} PRIVATE Hamon::${TARGET_NAME_BASE}) 12 | 13 | enable_testing() 14 | 15 | option(BUILD_GMOCK "Builds the googlemock subproject" OFF) 16 | add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../../../externals/googletest ${CMAKE_CURRENT_BINARY_DIR}/googletest) 17 | target_link_libraries(${TARGET_NAME} 18 | PRIVATE 19 | GTest::gtest 20 | GTest::gtest_main) 21 | 22 | include(GoogleTest) 23 | gtest_discover_tests(${TARGET_NAME}) 24 | -------------------------------------------------------------------------------- /libs/config/test/src/unit_test_config.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file unit_test_config.cpp 3 | * 4 | * @brief config のテスト 5 | */ 6 | 7 | #include 8 | 9 | #define STRINGIZE(text) STRINGIZE_I(text) 10 | #define STRINGIZE_I(text) #text 11 | 12 | #pragma message("HAMON_PLATFORM = " HAMON_PLATFORM) 13 | #pragma message("HAMON_ARCHITECTURE = " HAMON_ARCHITECTURE) 14 | #pragma message("HAMON_COMPILER = " HAMON_COMPILER) 15 | #pragma message("HAMON_COMPILER_VERSION = " STRINGIZE(HAMON_COMPILER_VERSION)) 16 | #pragma message("HAMON_STDLIB = " HAMON_STDLIB) 17 | #pragma message("HAMON_CXX_STANDARD = " STRINGIZE(HAMON_CXX_STANDARD)) 18 | 19 | #undef STRINGIZE 20 | #undef STRINGIZE_I 21 | -------------------------------------------------------------------------------- /libs/config/test/src/unit_test_config_alignof.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file unit_test_config_alignof.cpp 3 | * 4 | * @brief HAMON_ALIGNOF のテスト 5 | */ 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | namespace hamon_config_alignof_test 12 | { 13 | 14 | struct empty{}; 15 | 16 | static_assert(1u == HAMON_ALIGNOF(std::int8_t), ""); 17 | static_assert(2u == HAMON_ALIGNOF(std::int16_t), ""); 18 | static_assert(4u == HAMON_ALIGNOF(std::int32_t), ""); 19 | static_assert(8u == HAMON_ALIGNOF(std::int64_t), ""); 20 | static_assert(1u == HAMON_ALIGNOF(empty), ""); 21 | static_assert(HAMON_ALIGNOF(int*) == HAMON_ALIGNOF(void*), ""); 22 | 23 | } // namespace hamon_config_alignof_test 24 | -------------------------------------------------------------------------------- /libs/config/test/src/unit_test_config_carries_dependency.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file unit_test_config_carries_dependency.cpp 3 | * 4 | * @brief HAMON_CARRIES_DEPENDENCY のテスト 5 | */ 6 | 7 | #include 8 | #include 9 | 10 | namespace hamon_config_carries_dependency_test 11 | { 12 | 13 | HAMON_WARNING_PUSH() 14 | HAMON_WARNING_DISABLE_MSVC(4648) // 標準属性 'carries_dependency' は無視されます 15 | 16 | HAMON_CARRIES_DEPENDENCY void f() 17 | { 18 | } 19 | 20 | void g(int* r HAMON_CARRIES_DEPENDENCY) 21 | { 22 | (void)r; 23 | } 24 | 25 | HAMON_WARNING_POP() 26 | 27 | GTEST_TEST(ConfigTest, CarriesDependencyTest) 28 | { 29 | f(); 30 | g(nullptr); 31 | } 32 | 33 | } // namespace hamon_config_carries_dependency_test 34 | -------------------------------------------------------------------------------- /libs/config/test/src/unit_test_config_current_function.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file unit_test_config_current_function.cpp 3 | * 4 | * @brief HAMON_CURRENT_FUNCTION のテスト 5 | */ 6 | 7 | #include 8 | #include 9 | 10 | namespace hamon_config_current_function_test 11 | { 12 | 13 | static char const* s_function_name_1; 14 | static char const* s_function_name_2; 15 | static char const* s_function_name_3; 16 | 17 | static void f1(void) 18 | { 19 | s_function_name_1 = HAMON_CURRENT_FUNCTION; 20 | } 21 | 22 | static void f2(int) 23 | { 24 | s_function_name_2 = HAMON_CURRENT_FUNCTION; 25 | } 26 | 27 | GTEST_TEST(ConfigTest, CurrentFunctionTest) 28 | { 29 | s_function_name_3 = HAMON_CURRENT_FUNCTION; 30 | 31 | f1(); 32 | f2(0); 33 | 34 | EXPECT_TRUE(s_function_name_1 != nullptr); 35 | EXPECT_TRUE(s_function_name_2 != nullptr); 36 | EXPECT_TRUE(s_function_name_3 != nullptr); 37 | EXPECT_STRNE(s_function_name_1, s_function_name_2); 38 | EXPECT_STRNE(s_function_name_1, s_function_name_3); 39 | EXPECT_STRNE(s_function_name_2, s_function_name_3); 40 | } 41 | 42 | } // namespace hamon_config_current_function_test 43 | -------------------------------------------------------------------------------- /libs/config/test/src/unit_test_config_extern_template.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file unit_test_config_extern_template.cpp 3 | * 4 | * @brief HAMON_EXTERN_TEMPLATE のテスト 5 | */ 6 | 7 | #include 8 | #include 9 | 10 | namespace hamon_config_extern_template_test 11 | { 12 | 13 | template 14 | class Class1 {}; 15 | 16 | template 17 | class Class2 {}; 18 | 19 | template 20 | void Function1() {} 21 | 22 | template 23 | void Function2(T1, T2) {} 24 | 25 | HAMON_EXTERN_TEMPLATE(class Class1); 26 | HAMON_EXTERN_TEMPLATE(class Class1); 27 | HAMON_EXTERN_TEMPLATE(class Class2); 28 | HAMON_EXTERN_TEMPLATE(void Function1()); 29 | HAMON_EXTERN_TEMPLATE(void Function1()); 30 | HAMON_EXTERN_TEMPLATE(void Function2(int, char)); 31 | 32 | //template class Class1; 33 | template void Function1(); 34 | template void Function2(int, char); 35 | 36 | GTEST_TEST(ConfigTest, ExternTemplateTest) 37 | { 38 | { 39 | Class1 x; 40 | (void)x; 41 | } 42 | { 43 | Class2 x; 44 | (void)x; 45 | } 46 | { 47 | Function1(); 48 | } 49 | { 50 | int i = 0; 51 | char c = 0; 52 | Function2(i, c); 53 | } 54 | } 55 | 56 | } // namespace hamon_config_extern_template_test 57 | -------------------------------------------------------------------------------- /libs/config/test/src/unit_test_config_fallthrough.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file unit_test_config_fallthrough.cpp 3 | * 4 | * @brief HAMON_FALLTHROUGH のテスト 5 | */ 6 | 7 | #include 8 | #include 9 | 10 | HAMON_WARNING_PUSH() 11 | HAMON_WARNING_DISABLE_CLANG("-Wmissing-declarations") 12 | 13 | namespace hamon_config_fallthrough_test 14 | { 15 | 16 | void f() {} 17 | 18 | void fallthrough_test(int n) 19 | { 20 | switch (n) 21 | { 22 | case 1: 23 | case 2: 24 | f(); 25 | HAMON_FALLTHROUGH(); 26 | case 3: 27 | if (n < 2) 28 | { 29 | f(); 30 | } 31 | else 32 | { 33 | return; 34 | } 35 | HAMON_FALLTHROUGH(); 36 | case 4: 37 | f(); 38 | } 39 | } 40 | 41 | GTEST_TEST(ConfigTest, FallthroughTest) 42 | { 43 | fallthrough_test(1); 44 | fallthrough_test(2); 45 | fallthrough_test(3); 46 | fallthrough_test(4); 47 | } 48 | 49 | } // namespace hamon_config_fallthrough_test 50 | 51 | HAMON_WARNING_POP() 52 | -------------------------------------------------------------------------------- /libs/config/test/src/unit_test_config_final.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file unit_test_config_final.cpp 3 | * 4 | * @brief HAMON_FINAL のテスト 5 | */ 6 | 7 | #include 8 | 9 | namespace hamon_config_final_test 10 | { 11 | 12 | class base 13 | { 14 | virtual void final_func() HAMON_FINAL; 15 | 16 | virtual void virtual_func(); 17 | 18 | // NG, 仮想でない関数にfinal宣言することはできない 19 | //void non_virtual_func() HAMON_FINAL; 20 | }; 21 | 22 | class derived : public base 23 | { 24 | // NG, finalとして宣言されている関数をオーバーライドすることはできない 25 | //void final_func(); 26 | 27 | void virtual_func(); 28 | }; 29 | 30 | class non_base HAMON_FINAL {}; 31 | 32 | // NG, finalとして宣言されているクラスを継承することはできない 33 | //class derived2 : public non_base {}; 34 | 35 | } // namespace hamon_config_final_test 36 | -------------------------------------------------------------------------------- /libs/config/test/src/unit_test_config_likely.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file unit_test_config_likely.cpp 3 | * 4 | * @brief HAMON_LIKELY のテスト 5 | */ 6 | 7 | #include 8 | #include 9 | 10 | GTEST_TEST(ConfigTest, LikelyTest) 11 | { 12 | bool f1 = true; 13 | bool f2 = false; 14 | 15 | if (HAMON_LIKELY(f1)) 16 | { 17 | EXPECT_TRUE(f1); 18 | } 19 | else 20 | { 21 | EXPECT_FALSE(f1); 22 | } 23 | 24 | if (HAMON_UNLIKELY(f1)) 25 | { 26 | EXPECT_TRUE(f1); 27 | } 28 | else 29 | { 30 | EXPECT_FALSE(f1); 31 | } 32 | 33 | if (HAMON_LIKELY(f2)) 34 | { 35 | EXPECT_TRUE(f2); 36 | } 37 | else 38 | { 39 | EXPECT_FALSE(f2); 40 | } 41 | 42 | if (HAMON_UNLIKELY(f2)) 43 | { 44 | EXPECT_TRUE(f2); 45 | } 46 | else 47 | { 48 | EXPECT_FALSE(f2); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /libs/config/test/src/unit_test_config_nodiscard.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file unit_test_config_nodiscard.cpp 3 | * 4 | * @brief HAMON_NODISCARD のテスト 5 | */ 6 | 7 | #include 8 | #include 9 | 10 | namespace hamon_config_nodiscard_test 11 | { 12 | 13 | HAMON_NODISCARD int func() 14 | { 15 | return 42; 16 | } 17 | 18 | GTEST_TEST(ConfigTest, NoDiscardTest) 19 | { 20 | //func(); 21 | int t = func(); 22 | (void)t; 23 | } 24 | 25 | } // namespace hamon_config_nodiscard_test 26 | -------------------------------------------------------------------------------- /libs/config/test/src/unit_test_config_noexcept.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file unit_test_config_noexcept.cpp 3 | * 4 | * @brief 5 | */ 6 | 7 | #include 8 | #include 9 | 10 | namespace hamon_config_noexcept_test 11 | { 12 | 13 | void f1(); 14 | void f2() HAMON_NOEXCEPT; 15 | void f3() HAMON_NOEXCEPT_OR_NOTHROW; 16 | void f4() HAMON_NOEXCEPT_IF(true); 17 | void f5() HAMON_NOEXCEPT_IF(false); 18 | void f6() HAMON_NOEXCEPT_IF(HAMON_NOEXCEPT_EXPR(f1())); 19 | void f7() HAMON_NOEXCEPT_IF(HAMON_NOEXCEPT_EXPR(f2())); 20 | void f8() HAMON_NOEXCEPT_IF_EXPR(f1()); 21 | void f9() HAMON_NOEXCEPT_IF_EXPR(f2()); 22 | 23 | GTEST_TEST(ConfigTest, NoexceptTest) 24 | { 25 | #if defined(HAMON_HAS_CXX11_NOEXCEPT) 26 | static_assert(!HAMON_NOEXCEPT_EXPR(f1()), ""); 27 | static_assert( HAMON_NOEXCEPT_EXPR(f2()), ""); 28 | static_assert( HAMON_NOEXCEPT_EXPR(f3()), ""); 29 | static_assert( HAMON_NOEXCEPT_EXPR(f4()), ""); 30 | static_assert(!HAMON_NOEXCEPT_EXPR(f5()), ""); 31 | static_assert(!HAMON_NOEXCEPT_EXPR(f6()), ""); 32 | static_assert( HAMON_NOEXCEPT_EXPR(f7()), ""); 33 | static_assert(!HAMON_NOEXCEPT_EXPR(f8()), ""); 34 | static_assert( HAMON_NOEXCEPT_EXPR(f9()), ""); 35 | #endif 36 | } 37 | 38 | } // namespace hamon_config_noexcept_test 39 | -------------------------------------------------------------------------------- /libs/config/test/src/unit_test_config_noreturn.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file unit_test_config_noreturn.cpp 3 | * 4 | * @brief HAMON_NORETURN のテスト 5 | */ 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | namespace hamon_config_noreturn_test 12 | { 13 | 14 | HAMON_NORETURN void report_error() 15 | { 16 | throw std::runtime_error(""); 17 | } 18 | 19 | int func(int x) 20 | { 21 | if (x > 0) 22 | { 23 | return x; 24 | } 25 | 26 | report_error(); 27 | } 28 | 29 | GTEST_TEST(ConfigTest, NoReturnTest) 30 | { 31 | func(1); 32 | } 33 | 34 | } // namespace hamon_config_noreturn_test 35 | -------------------------------------------------------------------------------- /libs/config/test/src/unit_test_config_override.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file unit_test_config_override.cpp 3 | * 4 | * @brief HAMON_OVERRIDE のテスト 5 | */ 6 | 7 | #include 8 | 9 | namespace hamon_config_override_test 10 | { 11 | 12 | class base 13 | { 14 | virtual void final_func() HAMON_FINAL; 15 | 16 | virtual void virtual_func(); 17 | 18 | virtual void virtual_func2(); 19 | 20 | void non_virtual_func(); 21 | }; 22 | 23 | class derived : public base 24 | { 25 | // NG, finalとして宣言されている関数をオーバーライドすることはできない 26 | //void final_func() HAMON_OVERRIDE; 27 | 28 | // OK 29 | void virtual_func() HAMON_OVERRIDE; 30 | 31 | // NG, 基底クラスの関数と引数が違っており、オーバーライドできていない 32 | //void virtual_func2(int) HAMON_OVERRIDE; 33 | 34 | // NG, 基底クラスの関数ではないので、オーバーライドできていない 35 | //void func() HAMON_OVERRIDE; 36 | 37 | // NG, 基底クラスの関数は仮想ではないので、オーバーライドできていない 38 | //void non_virtual_func() HAMON_OVERRIDE; 39 | }; 40 | 41 | } // namespace hamon_config_override_test 42 | -------------------------------------------------------------------------------- /libs/render/README.md: -------------------------------------------------------------------------------- 1 | # Windowライブラリ 2 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file render.hpp 3 | * 4 | * @brief Render library 5 | */ 6 | 7 | #ifndef HAMON_RENDER_HPP 8 | #define HAMON_RENDER_HPP 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | #endif // HAMON_RENDER_HPP 30 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/blend_factor.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file blend_factor.hpp 3 | * 4 | * @brief BlendFactor 5 | */ 6 | 7 | #ifndef HAMON_RENDER_BLEND_FACTOR_HPP 8 | #define HAMON_RENDER_BLEND_FACTOR_HPP 9 | 10 | #include 11 | 12 | namespace hamon 13 | { 14 | 15 | inline namespace render 16 | { 17 | 18 | enum class BlendFactor : std::uint32_t 19 | { 20 | Zero, 21 | One, 22 | SrcColor, 23 | OneMinusSrcColor, 24 | DstColor, 25 | OneMinusDstColor, 26 | SrcAlpha, 27 | OneMinusSrcAlpha, 28 | DstAlpha, 29 | OneMinusDstAlpha, 30 | ConstantColor, 31 | OneMinusConstantColor, 32 | ConstantAlpha, 33 | OneMinusConstantAlpha, 34 | SrcAlphaSaturate, 35 | Src1Color, 36 | OneMinusSrc1Color, 37 | Src1Alpha, 38 | OneMinusSrc1Alpha, 39 | }; 40 | 41 | } // inline namespace render 42 | 43 | } // namespace hamon 44 | 45 | #endif // HAMON_RENDER_BLEND_FACTOR_HPP 46 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/blend_operation.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file blend_operation.hpp 3 | * 4 | * @brief BlendOperation 5 | */ 6 | 7 | #ifndef HAMON_RENDER_BLEND_OPERATION_HPP 8 | #define HAMON_RENDER_BLEND_OPERATION_HPP 9 | 10 | #include 11 | 12 | namespace hamon 13 | { 14 | 15 | inline namespace render 16 | { 17 | 18 | enum class BlendOperation : std::uint32_t 19 | { 20 | Add, 21 | Subtract, 22 | ReverseSubtract, 23 | Min, 24 | Max, 25 | }; 26 | 27 | } // inline namespace render 28 | 29 | } // namespace hamon 30 | 31 | #endif // HAMON_RENDER_BLEND_OPERATION_HPP 32 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/border_color.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file border_color.hpp 3 | * 4 | * @brief BorderColor 5 | */ 6 | 7 | #ifndef HAMON_RENDER_BORDER_COLOR_HPP 8 | #define HAMON_RENDER_BORDER_COLOR_HPP 9 | 10 | #include 11 | 12 | namespace hamon 13 | { 14 | 15 | inline namespace render 16 | { 17 | 18 | enum class BorderColor : std::uint32_t 19 | { 20 | TransparentBlack, 21 | OpaqueBlack, 22 | OpaqueWhite, 23 | }; 24 | 25 | } // inline namespace render 26 | 27 | } // namespace hamon 28 | 29 | #endif // HAMON_RENDER_BORDER_COLOR_HPP 30 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/clear_value.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file clear_value.hpp 3 | * 4 | * @brief ClearValue 5 | */ 6 | 7 | #ifndef HAMON_RENDER_CLEAR_VALUE_HPP 8 | #define HAMON_RENDER_CLEAR_VALUE_HPP 9 | 10 | #include 11 | 12 | namespace hamon 13 | { 14 | 15 | inline namespace render 16 | { 17 | 18 | struct ClearValue 19 | { 20 | struct 21 | { 22 | float r; 23 | float g; 24 | float b; 25 | float a; 26 | } color{0, 0, 0, 0}; 27 | float depth{1.0f}; 28 | std::uint8_t stencil{0}; 29 | }; 30 | 31 | } // inline namespace render 32 | 33 | } // namespace hamon 34 | 35 | #endif // HAMON_RENDER_CLEAR_VALUE_HPP 36 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/color_write_mask.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file color_write_mask.hpp 3 | * 4 | * @brief ColorWriteMask 5 | */ 6 | 7 | #ifndef HAMON_RENDER_COLOR_WRITE_MASK_HPP 8 | #define HAMON_RENDER_COLOR_WRITE_MASK_HPP 9 | 10 | #include 11 | 12 | namespace hamon 13 | { 14 | 15 | inline namespace render 16 | { 17 | 18 | enum ColorWriteMask : std::uint32_t 19 | { 20 | Red = (1 << 0), 21 | Green = (1 << 1), 22 | Blue = (1 << 2), 23 | Alpha = (1 << 3), 24 | All = (Red | Green | Blue | Alpha), 25 | }; 26 | 27 | } // inline namespace render 28 | 29 | } // namespace hamon 30 | 31 | #endif // HAMON_RENDER_COLOR_WRITE_MASK_HPP 32 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/compare_operation.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file compare_operation.hpp 3 | * 4 | * @brief CompareOperation 5 | */ 6 | 7 | #ifndef HAMON_RENDER_COMPARE_OPERATION_HPP 8 | #define HAMON_RENDER_COMPARE_OPERATION_HPP 9 | 10 | #include 11 | 12 | namespace hamon 13 | { 14 | 15 | inline namespace render 16 | { 17 | 18 | enum class CompareOperation : std::uint32_t 19 | { 20 | Never, 21 | Less, 22 | Equal, 23 | LessEqual, 24 | Greater, 25 | NotEqual, 26 | GreaterEqual, 27 | Always, 28 | }; 29 | 30 | } // inline namespace render 31 | 32 | } // namespace hamon 33 | 34 | #endif // HAMON_RENDER_COMPARE_OPERATION_HPP 35 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/cull_mode.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file cull_mode.hpp 3 | * 4 | * @brief CullMode 5 | */ 6 | 7 | #ifndef HAMON_RENDER_CULL_MODE_HPP 8 | #define HAMON_RENDER_CULL_MODE_HPP 9 | 10 | #include 11 | 12 | namespace hamon 13 | { 14 | 15 | inline namespace render 16 | { 17 | 18 | enum class CullMode : std::uint32_t 19 | { 20 | None, 21 | Front, 22 | Back, 23 | }; 24 | 25 | } // inline namespace render 26 | 27 | } // namespace hamon 28 | 29 | #endif // HAMON_RENDER_CULL_MODE_HPP 30 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/d3d/com_ptr.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file com_ptr.hpp 3 | * 4 | * @brief 5 | */ 6 | 7 | #ifndef HAMON_RENDER_D3D_COM_PTR_HPP 8 | #define HAMON_RENDER_D3D_COM_PTR_HPP 9 | 10 | #if !defined(WIN32_LEAN_AND_MEAN) 11 | #define WIN32_LEAN_AND_MEAN 12 | #endif 13 | 14 | #if !defined(NOMINMAX) 15 | #define NOMINMAX 16 | #endif 17 | 18 | #include 19 | 20 | namespace hamon 21 | { 22 | 23 | inline namespace render 24 | { 25 | 26 | using Microsoft::WRL::ComPtr; 27 | 28 | } // inline namespace render 29 | 30 | } // namespace hamon 31 | 32 | #endif // HAMON_RENDER_D3D_COM_PTR_HPP 33 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/d3d/d3d11.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file d3d11.hpp 3 | * 4 | * @brief 5 | */ 6 | 7 | #ifndef HAMON_RENDER_D3D_D3D11_HPP 8 | #define HAMON_RENDER_D3D_D3D11_HPP 9 | 10 | #if !defined(WIN32_LEAN_AND_MEAN) 11 | #define WIN32_LEAN_AND_MEAN 12 | #endif 13 | 14 | #if !defined(NOMINMAX) 15 | #define NOMINMAX 16 | #endif 17 | 18 | #include 19 | 20 | #if defined(_MSC_VER) 21 | # pragma comment(lib, "d3d11.lib") 22 | #endif 23 | 24 | #endif // HAMON_RENDER_D3D_D3D11_HPP 25 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/d3d/d3d11shader.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file d3d11shader.hpp 3 | * 4 | * @brief 5 | */ 6 | 7 | #ifndef HAMON_RENDER_D3D_D3D11SHADER_HPP 8 | #define HAMON_RENDER_D3D_D3D11SHADER_HPP 9 | 10 | #if !defined(WIN32_LEAN_AND_MEAN) 11 | #define WIN32_LEAN_AND_MEAN 12 | #endif 13 | 14 | #if !defined(NOMINMAX) 15 | #define NOMINMAX 16 | #endif 17 | 18 | #include 19 | 20 | #endif // HAMON_RENDER_D3D_D3D11SHADER_HPP 21 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/d3d/d3d12.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file d3d12.hpp 3 | * 4 | * @brief 5 | */ 6 | 7 | #ifndef HAMON_RENDER_D3D_D3D12_HPP 8 | #define HAMON_RENDER_D3D_D3D12_HPP 9 | 10 | #if !defined(WIN32_LEAN_AND_MEAN) 11 | #define WIN32_LEAN_AND_MEAN 12 | #endif 13 | 14 | #if !defined(NOMINMAX) 15 | #define NOMINMAX 16 | #endif 17 | 18 | #include 19 | 20 | #if defined(_MSC_VER) 21 | # pragma comment(lib, "d3d12.lib") 22 | #endif 23 | 24 | #endif // HAMON_RENDER_D3D_D3D12_HPP 25 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/d3d/d3d12shader.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file d3d12shader.hpp 3 | * 4 | * @brief 5 | */ 6 | 7 | #ifndef HAMON_RENDER_D3D_D3D12SHADER_HPP 8 | #define HAMON_RENDER_D3D_D3D12SHADER_HPP 9 | 10 | #if !defined(WIN32_LEAN_AND_MEAN) 11 | #define WIN32_LEAN_AND_MEAN 12 | #endif 13 | 14 | #if !defined(NOMINMAX) 15 | #define NOMINMAX 16 | #endif 17 | 18 | #include 19 | 20 | #endif // HAMON_RENDER_D3D_D3D12SHADER_HPP 21 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/d3d/d3dcompiler.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file d3dcompiler.hpp 3 | * 4 | * @brief 5 | */ 6 | 7 | #ifndef HAMON_RENDER_D3D_D3DCOMPILER_HPP 8 | #define HAMON_RENDER_D3D_D3DCOMPILER_HPP 9 | 10 | #if !defined(WIN32_LEAN_AND_MEAN) 11 | #define WIN32_LEAN_AND_MEAN 12 | #endif 13 | 14 | #if !defined(NOMINMAX) 15 | #define NOMINMAX 16 | #endif 17 | 18 | #include 19 | 20 | #if defined(_MSC_VER) 21 | # pragma comment(lib, "d3dcompiler.lib") 22 | # pragma comment(lib, "dxguid.lib") 23 | #endif 24 | 25 | #endif // HAMON_RENDER_D3D_D3DCOMPILER_HPP 26 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/d3d/dxgi.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file dxgi.hpp 3 | * 4 | * @brief 5 | */ 6 | 7 | #ifndef HAMON_RENDER_D3D_DXGI_HPP 8 | #define HAMON_RENDER_D3D_DXGI_HPP 9 | 10 | #if !defined(WIN32_LEAN_AND_MEAN) 11 | #define WIN32_LEAN_AND_MEAN 12 | #endif 13 | 14 | #if !defined(NOMINMAX) 15 | #define NOMINMAX 16 | #endif 17 | 18 | #include 19 | 20 | #if defined(_MSC_VER) 21 | # pragma comment(lib, "dxgi.lib") 22 | #endif 23 | 24 | #endif // HAMON_RENDER_D3D_DXGI_HPP 25 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/d3d/throw_if_failed.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file throw_if_failed.hpp 3 | * 4 | * @brief ThrowIfFailed関数 5 | */ 6 | 7 | #ifndef HAMON_RENDER_D3D_THROW_IF_FAILED_HPP 8 | #define HAMON_RENDER_D3D_THROW_IF_FAILED_HPP 9 | 10 | #include 11 | #include 12 | 13 | namespace hamon 14 | { 15 | 16 | inline namespace render 17 | { 18 | 19 | 20 | class HResultException : public std::runtime_error 21 | { 22 | public: 23 | explicit HResultException(::HRESULT res) 24 | : std::runtime_error(ToString(res)) 25 | {} 26 | 27 | private: 28 | static std::string ToString(::HRESULT res) 29 | { 30 | return std::to_string(static_cast(res)); 31 | } 32 | }; 33 | 34 | inline ::HRESULT ThrowIfFailed(::HRESULT res) 35 | { 36 | if (FAILED(res)) 37 | { 38 | throw HResultException(res); 39 | } 40 | return res; 41 | } 42 | 43 | } // inline namespace render 44 | 45 | } // namespace hamon 46 | 47 | #endif // HAMON_RENDER_D3D_THROW_IF_FAILED_HPP 48 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/d3d11/blend_operation.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file blend_operation.hpp 3 | * 4 | * @brief BlendOperation 5 | */ 6 | 7 | #ifndef HAMON_RENDER_D3D11_BLEND_OPERATION_HPP 8 | #define HAMON_RENDER_D3D11_BLEND_OPERATION_HPP 9 | 10 | #include 11 | #include 12 | 13 | namespace hamon 14 | { 15 | 16 | inline namespace render 17 | { 18 | 19 | namespace d3d11 20 | { 21 | 22 | inline ::D3D11_BLEND_OP BlendOperation(render::BlendOperation op) 23 | { 24 | switch (op) 25 | { 26 | case render::BlendOperation::Add: return D3D11_BLEND_OP_ADD; 27 | case render::BlendOperation::Subtract: return D3D11_BLEND_OP_SUBTRACT; 28 | case render::BlendOperation::ReverseSubtract: return D3D11_BLEND_OP_REV_SUBTRACT; 29 | case render::BlendOperation::Min: return D3D11_BLEND_OP_MIN; 30 | case render::BlendOperation::Max: return D3D11_BLEND_OP_MAX; 31 | } 32 | return D3D11_BLEND_OP_ADD; 33 | } 34 | 35 | } // namespace d3d11 36 | 37 | } // inline namespace render 38 | 39 | } // namespace hamon 40 | 41 | #endif // HAMON_RENDER_D3D11_BLEND_OPERATION_HPP 42 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/d3d11/border_color.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file border_color.hpp 3 | * 4 | * @brief BorderColor 5 | */ 6 | 7 | #ifndef HAMON_RENDER_D3D11_BORDER_COLOR_HPP 8 | #define HAMON_RENDER_D3D11_BORDER_COLOR_HPP 9 | 10 | #include 11 | #include 12 | 13 | namespace hamon 14 | { 15 | 16 | inline namespace render 17 | { 18 | 19 | namespace d3d11 20 | { 21 | 22 | inline std::array BorderColor(render::BorderColor border_color) 23 | { 24 | switch (border_color) 25 | { 26 | case render::BorderColor::TransparentBlack: 27 | return { 0, 0, 0, 0 }; 28 | case render::BorderColor::OpaqueBlack: 29 | return { 0, 0, 0, 1 }; 30 | case render::BorderColor::OpaqueWhite: 31 | return { 1, 1, 1, 1 }; 32 | } 33 | return { 0, 0, 0, 0 }; 34 | } 35 | 36 | } // namespace d3d11 37 | 38 | } // inline namespace render 39 | 40 | } // namespace hamon 41 | 42 | #endif // HAMON_RENDER_D3D11_BORDER_COLOR_HPP 43 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/d3d11/buffer.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file buffer.hpp 3 | * 4 | * @brief Buffer 5 | */ 6 | 7 | #ifndef HAMON_RENDER_D3D11_BUFFER_HPP 8 | #define HAMON_RENDER_D3D11_BUFFER_HPP 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | namespace hamon 15 | { 16 | 17 | inline namespace render 18 | { 19 | 20 | namespace d3d11 21 | { 22 | 23 | class Buffer 24 | { 25 | private: 26 | 27 | public: 28 | Buffer( 29 | Device* device, 30 | ::UINT size, 31 | ::D3D11_USAGE usage, 32 | ::UINT bind_flags, 33 | void const* data) 34 | { 35 | ::D3D11_BUFFER_DESC desc{}; 36 | desc.ByteWidth = size; 37 | desc.Usage = usage; 38 | desc.BindFlags = bind_flags; 39 | 40 | if (data == nullptr) 41 | { 42 | m_buffer = device->CreateBuffer(&desc, nullptr); 43 | } 44 | else 45 | { 46 | ::D3D11_SUBRESOURCE_DATA subresource_data{}; 47 | subresource_data.pSysMem = data; 48 | 49 | m_buffer = device->CreateBuffer(&desc, &subresource_data); 50 | } 51 | } 52 | 53 | ::ID3D11Buffer* Get(void) const { return m_buffer.Get(); } 54 | 55 | private: 56 | ComPtr<::ID3D11Buffer> m_buffer; 57 | }; 58 | 59 | } // namespace d3d11 60 | 61 | } // inline namespace render 62 | 63 | } // namespace hamon 64 | 65 | #endif // HAMON_RENDER_D3D11_BUFFER_HPP 66 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/d3d11/color_write_mask.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file color_write_mask.hpp 3 | * 4 | * @brief ColorWriteMask 5 | */ 6 | 7 | #ifndef HAMON_RENDER_D3D11_COLOR_WRITE_MASK_HPP 8 | #define HAMON_RENDER_D3D11_COLOR_WRITE_MASK_HPP 9 | 10 | #include 11 | #include 12 | 13 | namespace hamon 14 | { 15 | 16 | inline namespace render 17 | { 18 | 19 | namespace d3d11 20 | { 21 | 22 | inline ::UINT8 ColorWriteMask(std::uint32_t mask) 23 | { 24 | ::UINT8 result = 0; 25 | if (mask & render::ColorWriteMask::Red) 26 | { 27 | result |= D3D11_COLOR_WRITE_ENABLE_RED; 28 | } 29 | if (mask & render::ColorWriteMask::Green) 30 | { 31 | result |= D3D11_COLOR_WRITE_ENABLE_GREEN; 32 | } 33 | if (mask & render::ColorWriteMask::Blue) 34 | { 35 | result |= D3D11_COLOR_WRITE_ENABLE_BLUE; 36 | } 37 | if (mask & render::ColorWriteMask::Alpha) 38 | { 39 | result |= D3D11_COLOR_WRITE_ENABLE_ALPHA; 40 | } 41 | return result; 42 | } 43 | 44 | } // namespace d3d11 45 | 46 | } // inline namespace render 47 | 48 | } // namespace hamon 49 | 50 | #endif // HAMON_RENDER_D3D11_COLOR_WRITE_MASK_HPP 51 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/d3d11/compare_operation.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file compare_operation.hpp 3 | * 4 | * @brief CompareOperation 5 | */ 6 | 7 | #ifndef HAMON_RENDER_D3D11_COMPARE_OPERATION_HPP 8 | #define HAMON_RENDER_D3D11_COMPARE_OPERATION_HPP 9 | 10 | #include 11 | #include 12 | 13 | namespace hamon 14 | { 15 | 16 | inline namespace render 17 | { 18 | 19 | namespace d3d11 20 | { 21 | 22 | inline ::D3D11_COMPARISON_FUNC CompareOperation(render::CompareOperation op) 23 | { 24 | switch (op) 25 | { 26 | case render::CompareOperation::Never: return D3D11_COMPARISON_NEVER; 27 | case render::CompareOperation::Less: return D3D11_COMPARISON_LESS; 28 | case render::CompareOperation::Equal: return D3D11_COMPARISON_EQUAL; 29 | case render::CompareOperation::LessEqual: return D3D11_COMPARISON_LESS_EQUAL; 30 | case render::CompareOperation::Greater: return D3D11_COMPARISON_GREATER; 31 | case render::CompareOperation::NotEqual: return D3D11_COMPARISON_NOT_EQUAL; 32 | case render::CompareOperation::GreaterEqual: return D3D11_COMPARISON_GREATER_EQUAL; 33 | case render::CompareOperation::Always: return D3D11_COMPARISON_ALWAYS; 34 | } 35 | return D3D11_COMPARISON_NEVER; 36 | } 37 | 38 | } // namespace d3d11 39 | 40 | } // inline namespace render 41 | 42 | } // namespace hamon 43 | 44 | #endif // HAMON_RENDER_D3D11_COMPARE_OPERATION_HPP 45 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/d3d11/cull_mode.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file cull_mode.hpp 3 | * 4 | * @brief CullMode 5 | */ 6 | 7 | #ifndef HAMON_RENDER_D3D11_CULL_MODE_HPP 8 | #define HAMON_RENDER_D3D11_CULL_MODE_HPP 9 | 10 | #include 11 | #include 12 | 13 | namespace hamon 14 | { 15 | 16 | inline namespace render 17 | { 18 | 19 | namespace d3d11 20 | { 21 | 22 | inline ::D3D11_CULL_MODE CullMode(render::CullMode cull_mode) 23 | { 24 | switch (cull_mode) 25 | { 26 | case render::CullMode::None: return D3D11_CULL_NONE; 27 | case render::CullMode::Front: return D3D11_CULL_FRONT; 28 | case render::CullMode::Back: return D3D11_CULL_BACK; 29 | } 30 | return D3D11_CULL_NONE; 31 | } 32 | 33 | } // namespace d3d11 34 | 35 | } // inline namespace render 36 | 37 | } // namespace hamon 38 | 39 | #endif // HAMON_RENDER_D3D11_CULL_MODE_HPP 40 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/d3d11/fill_mode.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file fill_mode.hpp 3 | * 4 | * @brief FillMode 5 | */ 6 | 7 | #ifndef HAMON_RENDER_D3D11_FILL_MODE_HPP 8 | #define HAMON_RENDER_D3D11_FILL_MODE_HPP 9 | 10 | #include 11 | #include 12 | 13 | namespace hamon 14 | { 15 | 16 | inline namespace render 17 | { 18 | 19 | namespace d3d11 20 | { 21 | 22 | inline ::D3D11_FILL_MODE FillMode(render::FillMode fill_mode) 23 | { 24 | switch (fill_mode) 25 | { 26 | case render::FillMode::Solid: return D3D11_FILL_SOLID; 27 | case render::FillMode::Wireframe: return D3D11_FILL_WIREFRAME; 28 | } 29 | return D3D11_FILL_SOLID; 30 | } 31 | 32 | } // namespace d3d11 33 | 34 | } // inline namespace render 35 | 36 | } // namespace hamon 37 | 38 | #endif // HAMON_RENDER_D3D11_FILL_MODE_HPP 39 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/d3d11/index_buffer.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file index_buffer.hpp 3 | * 4 | * @brief IndexBuffer 5 | */ 6 | 7 | #ifndef HAMON_RENDER_D3D11_INDEX_BUFFER_HPP 8 | #define HAMON_RENDER_D3D11_INDEX_BUFFER_HPP 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | namespace hamon 17 | { 18 | 19 | inline namespace render 20 | { 21 | 22 | namespace d3d11 23 | { 24 | 25 | class IndexBuffer 26 | { 27 | public: 28 | IndexBuffer(Device* device, render::detail::IndexArrayBase const* index_array) 29 | : m_buffer( 30 | device, 31 | static_cast<::UINT>(index_array->GetBytes()), 32 | D3D11_USAGE_DEFAULT, 33 | D3D11_BIND_INDEX_BUFFER, 34 | index_array->GetData()) 35 | , m_count(static_cast<::UINT>(index_array->GetCount())) 36 | , m_format(d3d11::IndexType(index_array->GetType())) 37 | { 38 | } 39 | 40 | void Bind(DeviceContext* device_context) 41 | { 42 | device_context->IASetIndexBuffer(m_buffer.Get(), m_format, 0); 43 | } 44 | 45 | void Draw(DeviceContext* device_context) 46 | { 47 | device_context->DrawIndexed(m_count, 0, 0); 48 | } 49 | 50 | private: 51 | d3d11::Buffer m_buffer; 52 | ::UINT m_count = 0; 53 | ::DXGI_FORMAT m_format; 54 | }; 55 | 56 | } // namespace d3d11 57 | 58 | } // inline namespace render 59 | 60 | } // namespace hamon 61 | 62 | #endif // HAMON_RENDER_D3D11_INDEX_BUFFER_HPP 63 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/d3d11/index_type.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file index_type.hpp 3 | * 4 | * @brief IndexType 5 | */ 6 | 7 | #ifndef HAMON_RENDER_D3D11_INDEX_TYPE_HPP 8 | #define HAMON_RENDER_D3D11_INDEX_TYPE_HPP 9 | 10 | #include 11 | #include 12 | 13 | namespace hamon 14 | { 15 | 16 | inline namespace render 17 | { 18 | 19 | namespace d3d11 20 | { 21 | 22 | inline ::DXGI_FORMAT 23 | IndexType(render::IndexType type) 24 | { 25 | switch (type) 26 | { 27 | case render::IndexType::UInt16: return DXGI_FORMAT_R16_UINT; 28 | case render::IndexType::UInt32: return DXGI_FORMAT_R32_UINT; 29 | } 30 | return DXGI_FORMAT_R16_UINT; 31 | } 32 | 33 | } // namespace d3d11 34 | 35 | } // inline namespace render 36 | 37 | } // namespace hamon 38 | 39 | #endif // HAMON_RENDER_D3D11_INDEX_TYPE_HPP 40 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/d3d11/primitive_topology.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file primitive_topology.hpp 3 | * 4 | * @brief PrimitiveTopology 5 | */ 6 | 7 | #ifndef HAMON_RENDER_D3D11_PRIMITIVE_TOPOLOGY_HPP 8 | #define HAMON_RENDER_D3D11_PRIMITIVE_TOPOLOGY_HPP 9 | 10 | #include 11 | #include 12 | 13 | namespace hamon 14 | { 15 | 16 | inline namespace render 17 | { 18 | 19 | namespace d3d11 20 | { 21 | 22 | inline ::D3D11_PRIMITIVE_TOPOLOGY 23 | PrimitiveTopology(render::PrimitiveTopology topology) 24 | { 25 | switch (topology) 26 | { 27 | case render::PrimitiveTopology::PointList: return D3D11_PRIMITIVE_TOPOLOGY_POINTLIST; 28 | case render::PrimitiveTopology::LineList: return D3D11_PRIMITIVE_TOPOLOGY_LINELIST; 29 | case render::PrimitiveTopology::TriangleList: return D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST; 30 | } 31 | return D3D11_PRIMITIVE_TOPOLOGY_UNDEFINED; 32 | } 33 | 34 | } // namespace d3d11 35 | 36 | } // inline namespace render 37 | 38 | } // namespace hamon 39 | 40 | #endif // HAMON_RENDER_D3D11_PRIMITIVE_TOPOLOGY_HPP 41 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/d3d11/rasterizer_state.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file rasterizer_state.hpp 3 | * 4 | * @brief RasterizerState 5 | */ 6 | 7 | #ifndef HAMON_RENDER_D3D11_RASTERIZER_STATE_HPP 8 | #define HAMON_RENDER_D3D11_RASTERIZER_STATE_HPP 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | namespace hamon 16 | { 17 | 18 | inline namespace render 19 | { 20 | 21 | namespace d3d11 22 | { 23 | 24 | inline ::D3D11_RASTERIZER_DESC RasterizerState(render::RasterizerState const& state) 25 | { 26 | ::D3D11_RASTERIZER_DESC desc{}; 27 | desc.FillMode = d3d11::FillMode(state.fill_mode); 28 | desc.CullMode = d3d11::CullMode(state.cull_mode); 29 | desc.FrontCounterClockwise = (state.front_face == FrontFace::CounterClockwise); 30 | desc.DepthBias = D3D11_DEFAULT_DEPTH_BIAS; 31 | desc.DepthBiasClamp = D3D11_DEFAULT_DEPTH_BIAS_CLAMP; 32 | desc.SlopeScaledDepthBias = D3D11_DEFAULT_SLOPE_SCALED_DEPTH_BIAS; 33 | desc.DepthClipEnable = FALSE; 34 | desc.ScissorEnable = FALSE; 35 | desc.MultisampleEnable = FALSE; 36 | desc.AntialiasedLineEnable = FALSE; 37 | 38 | return desc; 39 | } 40 | 41 | } // namespace d3d11 42 | 43 | } // inline namespace render 44 | 45 | } // namespace hamon 46 | 47 | #endif // HAMON_RENDER_D3D11_RASTERIZER_STATE_HPP 48 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/d3d11/render_target_view.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file render_target_view.hpp 3 | * 4 | * @brief RenderTargetView 5 | */ 6 | 7 | #ifndef HAMON_RENDER_D3D11_RENDER_TARGET_VIEW_HPP 8 | #define HAMON_RENDER_D3D11_RENDER_TARGET_VIEW_HPP 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | namespace hamon 16 | { 17 | 18 | inline namespace render 19 | { 20 | 21 | namespace d3d11 22 | { 23 | 24 | class RenderTargetView 25 | { 26 | public: 27 | explicit RenderTargetView(d3d11::Device* device, DXGISwapChain* swap_chain) 28 | { 29 | ComPtr<::ID3D11Texture2D> back_buffer; 30 | swap_chain->GetBuffer(0, IID_PPV_ARGS(&back_buffer)); 31 | 32 | m_render_target_view = device->CreateRenderTargetView( 33 | back_buffer.Get(), 34 | nullptr); 35 | } 36 | 37 | ::ID3D11RenderTargetView1* Get(void) const 38 | { 39 | return m_render_target_view.Get(); 40 | } 41 | 42 | private: 43 | ComPtr<::ID3D11RenderTargetView1> m_render_target_view; 44 | }; 45 | 46 | } // namespace d3d11 47 | 48 | } // inline namespace render 49 | 50 | } // namespace hamon 51 | 52 | #endif // HAMON_RENDER_D3D11_RENDER_TARGET_VIEW_HPP 53 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/d3d11/sampler_address_mode.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file sampler_address_mode.hpp 3 | * 4 | * @brief SamplerAddressMode 5 | */ 6 | 7 | #ifndef HAMON_RENDER_D3D11_SAMPLER_ADDRESS_MODE_HPP 8 | #define HAMON_RENDER_D3D11_SAMPLER_ADDRESS_MODE_HPP 9 | 10 | #include 11 | #include 12 | 13 | namespace hamon 14 | { 15 | 16 | inline namespace render 17 | { 18 | 19 | namespace d3d11 20 | { 21 | 22 | inline ::D3D11_TEXTURE_ADDRESS_MODE 23 | SamplerAddressMode(render::SamplerAddressMode mode) 24 | { 25 | switch (mode) 26 | { 27 | case render::SamplerAddressMode::Repeat: return D3D11_TEXTURE_ADDRESS_WRAP; 28 | case render::SamplerAddressMode::MirroredRepeat: return D3D11_TEXTURE_ADDRESS_MIRROR; 29 | case render::SamplerAddressMode::ClampToEdge: return D3D11_TEXTURE_ADDRESS_CLAMP; 30 | case render::SamplerAddressMode::ClampToBorder: return D3D11_TEXTURE_ADDRESS_BORDER; 31 | case render::SamplerAddressMode::MirrorClampToEdge: return D3D11_TEXTURE_ADDRESS_MIRROR_ONCE; 32 | } 33 | return D3D11_TEXTURE_ADDRESS_WRAP; 34 | } 35 | 36 | } // namespace d3d11 37 | 38 | } // inline namespace render 39 | 40 | } // namespace hamon 41 | 42 | #endif // HAMON_RENDER_D3D11_SAMPLER_ADDRESS_MODE_HPP 43 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/d3d11/stencil_operation.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file stencil_operation.hpp 3 | * 4 | * @brief StencilOperation 5 | */ 6 | 7 | #ifndef HAMON_RENDER_D3D11_STENCIL_OPERATION_HPP 8 | #define HAMON_RENDER_D3D11_STENCIL_OPERATION_HPP 9 | 10 | #include 11 | #include 12 | 13 | namespace hamon 14 | { 15 | 16 | inline namespace render 17 | { 18 | 19 | namespace d3d11 20 | { 21 | 22 | inline ::D3D11_STENCIL_OP StencilOperation(render::StencilOperation op) 23 | { 24 | switch (op) 25 | { 26 | case render::StencilOperation::Keep: return D3D11_STENCIL_OP_KEEP; 27 | case render::StencilOperation::Zero: return D3D11_STENCIL_OP_ZERO; 28 | case render::StencilOperation::Replace: return D3D11_STENCIL_OP_REPLACE; 29 | case render::StencilOperation::IncrementAndClamp: return D3D11_STENCIL_OP_INCR_SAT; 30 | case render::StencilOperation::DecrementAndClamp: return D3D11_STENCIL_OP_DECR_SAT; 31 | case render::StencilOperation::Invert: return D3D11_STENCIL_OP_INVERT; 32 | case render::StencilOperation::IncrementAndWrap: return D3D11_STENCIL_OP_INCR; 33 | case render::StencilOperation::DecrementAndWrap: return D3D11_STENCIL_OP_DECR; 34 | } 35 | return D3D11_STENCIL_OP_KEEP; 36 | } 37 | 38 | } // namespace d3d11 39 | 40 | } // inline namespace render 41 | 42 | } // namespace hamon 43 | 44 | #endif // HAMON_RENDER_D3D11_STENCIL_OPERATION_HPP 45 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/d3d11/vertex_buffer.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file vertex_buffer.hpp 3 | * 4 | * @brief VertexBuffer 5 | */ 6 | 7 | #ifndef HAMON_RENDER_D3D11_VERTEX_BUFFER_HPP 8 | #define HAMON_RENDER_D3D11_VERTEX_BUFFER_HPP 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | namespace hamon 16 | { 17 | 18 | inline namespace render 19 | { 20 | 21 | namespace d3d11 22 | { 23 | 24 | class VertexBuffer 25 | { 26 | public: 27 | VertexBuffer(d3d11::Device* device, render::Geometry const& geometry) 28 | : m_buffer( 29 | device, 30 | static_cast<::UINT>(geometry.GetVertexArrayBytes()), 31 | D3D11_USAGE_DEFAULT, 32 | D3D11_BIND_VERTEX_BUFFER, 33 | geometry.GetVertexArrayData()) 34 | , m_stride(static_cast<::UINT>(geometry.GetLayout().GetBytes())) 35 | , m_count(static_cast<::UINT>(geometry.GetVertexArrayCount())) 36 | { 37 | } 38 | 39 | void Bind(d3d11::DeviceContext* device_context) 40 | { 41 | ::ID3D11Buffer* buffers[] 42 | { 43 | m_buffer.Get() 44 | }; 45 | device_context->IASetVertexBuffers(0, 1, buffers, &m_stride, &m_offset); 46 | } 47 | 48 | void Draw(d3d11::DeviceContext* device_context) 49 | { 50 | device_context->Draw(m_count, 0); 51 | } 52 | 53 | private: 54 | d3d11::Buffer m_buffer; 55 | ::UINT m_stride = 0; 56 | ::UINT m_offset = 0; 57 | ::UINT m_count = 0; 58 | }; 59 | 60 | } // namespace d3d11 61 | 62 | } // inline namespace render 63 | 64 | } // namespace hamon 65 | 66 | #endif // HAMON_RENDER_D3D11_VERTEX_BUFFER_HPP 67 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/d3d11_renderer.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file d3d11_renderer.hpp 3 | * 4 | * @brief D3D11Renderer 5 | */ 6 | 7 | #ifndef HAMON_RENDER_D3D11_RENDERER_HPP 8 | #define HAMON_RENDER_D3D11_RENDERER_HPP 9 | 10 | #if defined(HAMON_HAS_D3D11) 11 | #include 12 | #endif 13 | 14 | #endif // HAMON_RENDER_D3D11_RENDERER_HPP 15 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/d3d12/blend_operation.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file blend_operation.hpp 3 | * 4 | * @brief BlendOperation 5 | */ 6 | 7 | #ifndef HAMON_RENDER_D3D12_BLEND_OPERATION_HPP 8 | #define HAMON_RENDER_D3D12_BLEND_OPERATION_HPP 9 | 10 | #include 11 | #include 12 | 13 | namespace hamon 14 | { 15 | 16 | inline namespace render 17 | { 18 | 19 | namespace d3d12 20 | { 21 | 22 | inline ::D3D12_BLEND_OP BlendOperation(render::BlendOperation op) 23 | { 24 | switch (op) 25 | { 26 | case render::BlendOperation::Add: return D3D12_BLEND_OP_ADD; 27 | case render::BlendOperation::Subtract: return D3D12_BLEND_OP_SUBTRACT; 28 | case render::BlendOperation::ReverseSubtract: return D3D12_BLEND_OP_REV_SUBTRACT; 29 | case render::BlendOperation::Min: return D3D12_BLEND_OP_MIN; 30 | case render::BlendOperation::Max: return D3D12_BLEND_OP_MAX; 31 | } 32 | return D3D12_BLEND_OP_ADD; 33 | } 34 | 35 | } // namespace d3d12 36 | 37 | } // inline namespace render 38 | 39 | } // namespace hamon 40 | 41 | #endif // HAMON_RENDER_D3D12_BLEND_OPERATION_HPP 42 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/d3d12/border_color.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file border_color.hpp 3 | * 4 | * @brief BorderColor 5 | */ 6 | 7 | #ifndef HAMON_RENDER_D3D12_BORDER_COLOR_HPP 8 | #define HAMON_RENDER_D3D12_BORDER_COLOR_HPP 9 | 10 | #include 11 | #include 12 | 13 | namespace hamon 14 | { 15 | 16 | inline namespace render 17 | { 18 | 19 | namespace d3d12 20 | { 21 | 22 | inline std::array BorderColor(render::BorderColor border_color) 23 | { 24 | switch (border_color) 25 | { 26 | case render::BorderColor::TransparentBlack: 27 | return { 0, 0, 0, 0 }; 28 | case render::BorderColor::OpaqueBlack: 29 | return { 0, 0, 0, 1 }; 30 | case render::BorderColor::OpaqueWhite: 31 | return { 1, 1, 1, 1 }; 32 | } 33 | return { 0, 0, 0, 0 }; 34 | } 35 | 36 | } // namespace d3d12 37 | 38 | } // inline namespace render 39 | 40 | } // namespace hamon 41 | 42 | #endif // HAMON_RENDER_D3D12_BORDER_COLOR_HPP 43 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/d3d12/color_write_mask.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file color_write_mask.hpp 3 | * 4 | * @brief ColorWriteMask 5 | */ 6 | 7 | #ifndef HAMON_RENDER_D3D12_COLOR_WRITE_MASK_HPP 8 | #define HAMON_RENDER_D3D12_COLOR_WRITE_MASK_HPP 9 | 10 | #include 11 | #include 12 | 13 | namespace hamon 14 | { 15 | 16 | inline namespace render 17 | { 18 | 19 | namespace d3d12 20 | { 21 | 22 | static ::UINT8 ColorWriteMask(std::uint32_t mask) 23 | { 24 | ::UINT8 result = 0; 25 | if (mask & render::ColorWriteMask::Red) 26 | { 27 | result |= D3D12_COLOR_WRITE_ENABLE_RED; 28 | } 29 | if (mask & render::ColorWriteMask::Green) 30 | { 31 | result |= D3D12_COLOR_WRITE_ENABLE_GREEN; 32 | } 33 | if (mask & render::ColorWriteMask::Blue) 34 | { 35 | result |= D3D12_COLOR_WRITE_ENABLE_BLUE; 36 | } 37 | if (mask & render::ColorWriteMask::Alpha) 38 | { 39 | result |= D3D12_COLOR_WRITE_ENABLE_ALPHA; 40 | } 41 | return result; 42 | } 43 | 44 | } // namespace d3d12 45 | 46 | } // inline namespace render 47 | 48 | } // namespace hamon 49 | 50 | #endif // HAMON_RENDER_D3D12_COLOR_WRITE_MASK_HPP 51 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/d3d12/command_allocator.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file command_allocator.hpp 3 | * 4 | * @brief CommandAllocator 5 | */ 6 | 7 | #ifndef HAMON_RENDER_D3D12_COMMAND_ALLOCATOR_HPP 8 | #define HAMON_RENDER_D3D12_COMMAND_ALLOCATOR_HPP 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | namespace hamon 16 | { 17 | 18 | inline namespace render 19 | { 20 | 21 | namespace d3d12 22 | { 23 | 24 | class CommandAllocator 25 | { 26 | public: 27 | explicit CommandAllocator(d3d12::Device* device) 28 | { 29 | m_command_allocator = device->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT); 30 | } 31 | 32 | void Reset() 33 | { 34 | ThrowIfFailed(m_command_allocator->Reset()); 35 | } 36 | 37 | ::ID3D12CommandAllocator* Get(void) const 38 | { 39 | return m_command_allocator.Get(); 40 | } 41 | 42 | private: 43 | ComPtr<::ID3D12CommandAllocator> m_command_allocator; 44 | }; 45 | 46 | } // namespace d3d12 47 | 48 | } // inline namespace render 49 | 50 | } // namespace hamon 51 | 52 | #endif // HAMON_RENDER_D3D12_COMMAND_ALLOCATOR_HPP 53 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/d3d12/command_queue.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file command_queue.hpp 3 | * 4 | * @brief CommandQueue 5 | */ 6 | 7 | #ifndef HAMON_RENDER_D3D12_COMMAND_QUEUE_HPP 8 | #define HAMON_RENDER_D3D12_COMMAND_QUEUE_HPP 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | namespace hamon 17 | { 18 | 19 | inline namespace render 20 | { 21 | 22 | namespace d3d12 23 | { 24 | 25 | class CommandQueue 26 | { 27 | public: 28 | explicit CommandQueue(d3d12::Device* device) 29 | { 30 | ::D3D12_COMMAND_QUEUE_DESC desc {}; 31 | desc.Flags = D3D12_COMMAND_QUEUE_FLAG_NONE; 32 | desc.Type = D3D12_COMMAND_LIST_TYPE_DIRECT; 33 | 34 | m_command_queue = device->CreateCommandQueue(desc); 35 | } 36 | 37 | void Signal(::ID3D12Fence* fence, ::UINT64 value) 38 | { 39 | ThrowIfFailed(m_command_queue->Signal(fence, value)); 40 | } 41 | 42 | void ExecuteCommandList(d3d12::CommandList* command_list) 43 | { 44 | ::ID3D12CommandList* command_lists[] = { command_list->Get() }; 45 | m_command_queue->ExecuteCommandLists(ARRAYSIZE(command_lists), command_lists); 46 | } 47 | 48 | ::ID3D12CommandQueue* Get(void) const 49 | { 50 | return m_command_queue.Get(); 51 | } 52 | 53 | private: 54 | ComPtr<::ID3D12CommandQueue> m_command_queue; 55 | }; 56 | 57 | } // namespace d3d12 58 | 59 | } // inline namespace render 60 | 61 | } // namespace hamon 62 | 63 | #endif // HAMON_RENDER_D3D12_COMMAND_QUEUE_HPP 64 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/d3d12/compare_operation.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file compare_operation.hpp 3 | * 4 | * @brief CompareOperation 5 | */ 6 | 7 | #ifndef HAMON_RENDER_D3D12_COMPARE_OPERATION_HPP 8 | #define HAMON_RENDER_D3D12_COMPARE_OPERATION_HPP 9 | 10 | #include 11 | #include 12 | 13 | namespace hamon 14 | { 15 | 16 | inline namespace render 17 | { 18 | 19 | namespace d3d12 20 | { 21 | 22 | inline ::D3D12_COMPARISON_FUNC CompareOperation(render::CompareOperation op) 23 | { 24 | switch (op) 25 | { 26 | case render::CompareOperation::Never: return D3D12_COMPARISON_FUNC_NEVER; 27 | case render::CompareOperation::Less: return D3D12_COMPARISON_FUNC_LESS; 28 | case render::CompareOperation::Equal: return D3D12_COMPARISON_FUNC_EQUAL; 29 | case render::CompareOperation::LessEqual: return D3D12_COMPARISON_FUNC_LESS_EQUAL; 30 | case render::CompareOperation::Greater: return D3D12_COMPARISON_FUNC_GREATER; 31 | case render::CompareOperation::NotEqual: return D3D12_COMPARISON_FUNC_NOT_EQUAL; 32 | case render::CompareOperation::GreaterEqual: return D3D12_COMPARISON_FUNC_GREATER_EQUAL; 33 | case render::CompareOperation::Always: return D3D12_COMPARISON_FUNC_ALWAYS; 34 | } 35 | return D3D12_COMPARISON_FUNC_NEVER; 36 | } 37 | 38 | } // namespace d3d12 39 | 40 | } // inline namespace render 41 | 42 | } // namespace hamon 43 | 44 | #endif // HAMON_RENDER_D3D12_COMPARE_OPERATION_HPP 45 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/d3d12/cull_mode.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file cull_mode.hpp 3 | * 4 | * @brief CullMode 5 | */ 6 | 7 | #ifndef HAMON_RENDER_D3D12_CULL_MODE_HPP 8 | #define HAMON_RENDER_D3D12_CULL_MODE_HPP 9 | 10 | #include 11 | #include 12 | 13 | namespace hamon 14 | { 15 | 16 | inline namespace render 17 | { 18 | 19 | namespace d3d12 20 | { 21 | 22 | inline ::D3D12_CULL_MODE CullMode(render::CullMode cull_mode) 23 | { 24 | switch (cull_mode) 25 | { 26 | case render::CullMode::None: return D3D12_CULL_MODE_NONE; 27 | case render::CullMode::Front: return D3D12_CULL_MODE_FRONT; 28 | case render::CullMode::Back: return D3D12_CULL_MODE_BACK; 29 | } 30 | return D3D12_CULL_MODE_NONE; 31 | } 32 | 33 | } // namespace d3d12 34 | 35 | } // inline namespace render 36 | 37 | } // namespace hamon 38 | 39 | #endif // HAMON_RENDER_D3D12_CULL_MODE_HPP 40 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/d3d12/fill_mode.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file fill_mode.hpp 3 | * 4 | * @brief FillMode 5 | */ 6 | 7 | #ifndef HAMON_RENDER_D3D12_FILL_MODE_HPP 8 | #define HAMON_RENDER_D3D12_FILL_MODE_HPP 9 | 10 | #include 11 | #include 12 | 13 | namespace hamon 14 | { 15 | 16 | inline namespace render 17 | { 18 | 19 | namespace d3d12 20 | { 21 | 22 | inline ::D3D12_FILL_MODE FillMode(render::FillMode fill_mode) 23 | { 24 | switch (fill_mode) 25 | { 26 | case render::FillMode::Solid: return D3D12_FILL_MODE_SOLID; 27 | case render::FillMode::Wireframe: return D3D12_FILL_MODE_WIREFRAME; 28 | } 29 | return D3D12_FILL_MODE_SOLID; 30 | } 31 | 32 | } // namespace d3d12 33 | 34 | } // inline namespace render 35 | 36 | } // namespace hamon 37 | 38 | #endif // HAMON_RENDER_D3D12_FILL_MODE_HPP 39 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/d3d12/index_type.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file index_type.hpp 3 | * 4 | * @brief IndexType 5 | */ 6 | 7 | #ifndef HAMON_RENDER_D3D12_INDEX_TYPE_HPP 8 | #define HAMON_RENDER_D3D12_INDEX_TYPE_HPP 9 | 10 | #include 11 | #include 12 | 13 | namespace hamon 14 | { 15 | 16 | inline namespace render 17 | { 18 | 19 | namespace d3d12 20 | { 21 | 22 | inline ::DXGI_FORMAT 23 | IndexType(render::IndexType type) 24 | { 25 | switch (type) 26 | { 27 | case render::IndexType::UInt16: return DXGI_FORMAT_R16_UINT; 28 | case render::IndexType::UInt32: return DXGI_FORMAT_R32_UINT; 29 | } 30 | return DXGI_FORMAT_R16_UINT; 31 | } 32 | 33 | } // namespace d3d12 34 | 35 | } // inline namespace render 36 | 37 | } // namespace hamon 38 | 39 | #endif // HAMON_RENDER_D3D12_INDEX_TYPE_HPP 40 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/d3d12/primitive_topology.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file primitive_topology.hpp 3 | * 4 | * @brief PrimitiveTopology 5 | */ 6 | 7 | #ifndef HAMON_RENDER_D3D12_PRIMITIVE_TOPOLOGY_HPP 8 | #define HAMON_RENDER_D3D12_PRIMITIVE_TOPOLOGY_HPP 9 | 10 | #include 11 | #include 12 | 13 | namespace hamon 14 | { 15 | 16 | inline namespace render 17 | { 18 | 19 | namespace d3d12 20 | { 21 | 22 | inline ::D3D12_PRIMITIVE_TOPOLOGY 23 | PrimitiveTopology(render::PrimitiveTopology primitive_topology) 24 | { 25 | switch (primitive_topology) 26 | { 27 | case render::PrimitiveTopology::PointList: return D3D_PRIMITIVE_TOPOLOGY_POINTLIST; 28 | case render::PrimitiveTopology::LineList: return D3D_PRIMITIVE_TOPOLOGY_LINELIST; 29 | case render::PrimitiveTopology::TriangleList: return D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST; 30 | } 31 | return D3D_PRIMITIVE_TOPOLOGY_UNDEFINED; 32 | } 33 | 34 | } // namespace d3d12 35 | 36 | } // inline namespace render 37 | 38 | } // namespace hamon 39 | 40 | #endif // HAMON_RENDER_D3D12_PRIMITIVE_TOPOLOGY_HPP 41 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/d3d12/primitive_topology_type.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file primitive_topology_type.hpp 3 | * 4 | * @brief PrimitiveTopologyType 5 | */ 6 | 7 | #ifndef HAMON_RENDER_D3D12_PRIMITIVE_TOPOLOGY_TYPE_HPP 8 | #define HAMON_RENDER_D3D12_PRIMITIVE_TOPOLOGY_TYPE_HPP 9 | 10 | #include 11 | #include 12 | 13 | namespace hamon 14 | { 15 | 16 | inline namespace render 17 | { 18 | 19 | namespace d3d12 20 | { 21 | 22 | inline ::D3D12_PRIMITIVE_TOPOLOGY_TYPE 23 | PrimitiveTopologyType(render::PrimitiveTopology primitive_topology) 24 | { 25 | switch (primitive_topology) 26 | { 27 | case render::PrimitiveTopology::PointList: return D3D12_PRIMITIVE_TOPOLOGY_TYPE_POINT; 28 | case render::PrimitiveTopology::LineList: return D3D12_PRIMITIVE_TOPOLOGY_TYPE_LINE; 29 | case render::PrimitiveTopology::TriangleList: return D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE; 30 | } 31 | return D3D12_PRIMITIVE_TOPOLOGY_TYPE_UNDEFINED; 32 | } 33 | 34 | } // namespace d3d12 35 | 36 | } // inline namespace render 37 | 38 | } // namespace hamon 39 | 40 | #endif // HAMON_RENDER_D3D12_PRIMITIVE_TOPOLOGY_TYPE_HPP 41 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/d3d12/rasterizer_state.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file rasterizer_state.hpp 3 | * 4 | * @brief RasterizerState 5 | */ 6 | 7 | #ifndef HAMON_RENDER_D3D12_RASTERIZER_STATE_HPP 8 | #define HAMON_RENDER_D3D12_RASTERIZER_STATE_HPP 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | namespace hamon 16 | { 17 | 18 | inline namespace render 19 | { 20 | 21 | namespace d3d12 22 | { 23 | 24 | inline ::D3D12_RASTERIZER_DESC 25 | RasterizerState(render::RasterizerState const& rasterizer_state) 26 | { 27 | ::D3D12_RASTERIZER_DESC desc{}; 28 | desc.FillMode = d3d12::FillMode(rasterizer_state.fill_mode); 29 | desc.CullMode = d3d12::CullMode(rasterizer_state.cull_mode); 30 | desc.FrontCounterClockwise = rasterizer_state.front_face == FrontFace::CounterClockwise; 31 | desc.DepthBias = D3D12_DEFAULT_DEPTH_BIAS; 32 | desc.DepthBiasClamp = D3D12_DEFAULT_DEPTH_BIAS_CLAMP; 33 | desc.SlopeScaledDepthBias = D3D12_DEFAULT_SLOPE_SCALED_DEPTH_BIAS; 34 | desc.DepthClipEnable = FALSE; 35 | desc.MultisampleEnable = FALSE; 36 | desc.AntialiasedLineEnable = FALSE; 37 | desc.ForcedSampleCount = 0; 38 | desc.ConservativeRaster = D3D12_CONSERVATIVE_RASTERIZATION_MODE_OFF; 39 | 40 | return desc; 41 | } 42 | 43 | } // namespace d3d12 44 | 45 | } // inline namespace render 46 | 47 | } // namespace hamon 48 | 49 | #endif // HAMON_RENDER_D3D12_RASTERIZER_STATE_HPP 50 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/d3d12/sampler_address_mode.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file sampler_address_mode.hpp 3 | * 4 | * @brief SamplerAddressMode 5 | */ 6 | 7 | #ifndef HAMON_RENDER_D3D12_SAMPLER_ADDRESS_MODE_HPP 8 | #define HAMON_RENDER_D3D12_SAMPLER_ADDRESS_MODE_HPP 9 | 10 | #include 11 | #include 12 | 13 | namespace hamon 14 | { 15 | 16 | inline namespace render 17 | { 18 | 19 | namespace d3d12 20 | { 21 | 22 | inline ::D3D12_TEXTURE_ADDRESS_MODE 23 | SamplerAddressMode(render::SamplerAddressMode mode) 24 | { 25 | switch (mode) 26 | { 27 | case render::SamplerAddressMode::Repeat: return D3D12_TEXTURE_ADDRESS_MODE_WRAP; 28 | case render::SamplerAddressMode::MirroredRepeat: return D3D12_TEXTURE_ADDRESS_MODE_MIRROR; 29 | case render::SamplerAddressMode::ClampToEdge: return D3D12_TEXTURE_ADDRESS_MODE_CLAMP; 30 | case render::SamplerAddressMode::ClampToBorder: return D3D12_TEXTURE_ADDRESS_MODE_BORDER; 31 | case render::SamplerAddressMode::MirrorClampToEdge: return D3D12_TEXTURE_ADDRESS_MODE_MIRROR_ONCE; 32 | } 33 | return D3D12_TEXTURE_ADDRESS_MODE_WRAP; 34 | } 35 | 36 | } // namespace d3d12 37 | 38 | } // inline namespace render 39 | 40 | } // namespace hamon 41 | 42 | #endif // HAMON_RENDER_D3D12_SAMPLER_ADDRESS_MODE_HPP 43 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/d3d12/sampler_descriptor.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file sampler_descriptor.hpp 3 | * 4 | * @brief SamplerDescriptor 5 | */ 6 | 7 | #ifndef HAMON_RENDER_D3D12_SAMPLER_DESCRIPTOR_HPP 8 | #define HAMON_RENDER_D3D12_SAMPLER_DESCRIPTOR_HPP 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | namespace hamon 15 | { 16 | 17 | inline namespace render 18 | { 19 | 20 | namespace d3d12 21 | { 22 | 23 | class SamplerDescriptor 24 | { 25 | public: 26 | explicit SamplerDescriptor(::D3D12_SHADER_INPUT_BIND_DESC const& desc) 27 | : m_name(desc.Name) 28 | { 29 | } 30 | 31 | void LoadUniforms( 32 | d3d12::Device* device, 33 | d3d12::ResourceMap* resource_map, 34 | d3d12::DescriptorHeap* descriptor_heap, 35 | render::Uniforms const& uniforms) 36 | { 37 | auto uniform = uniforms[m_name]; 38 | if (uniform == nullptr) 39 | { 40 | return; 41 | } 42 | 43 | using type = render::Sampler; 44 | auto data = static_cast(uniform->GetData()); 45 | auto sampler = resource_map->GetSampler(*data); 46 | device->CreateSampler( 47 | sampler->GetDesc(), 48 | descriptor_heap->AssignCpuDescriptorHandle()); 49 | } 50 | 51 | private: 52 | std::string m_name; 53 | }; 54 | 55 | } // namespace d3d12 56 | 57 | } // inline namespace render 58 | 59 | } // namespace hamon 60 | 61 | #endif // HAMON_RENDER_D3D12_SAMPLER_DESCRIPTOR_HPP 62 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/d3d12/shader_visibility.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file shader_visibility.hpp 3 | * 4 | * @brief ShaderVisibility 5 | */ 6 | 7 | #ifndef HAMON_RENDER_D3D12_SHADER_VISIBILITY_HPP 8 | #define HAMON_RENDER_D3D12_SHADER_VISIBILITY_HPP 9 | 10 | #include 11 | #include 12 | 13 | namespace hamon 14 | { 15 | 16 | inline namespace render 17 | { 18 | 19 | namespace d3d12 20 | { 21 | 22 | inline ::D3D12_SHADER_VISIBILITY 23 | ShaderVisibility(render::ShaderStage stage) 24 | { 25 | switch (stage) 26 | { 27 | case render::ShaderStage::Vertex: return D3D12_SHADER_VISIBILITY_VERTEX; 28 | case render::ShaderStage::Hull: return D3D12_SHADER_VISIBILITY_HULL; 29 | case render::ShaderStage::Domain: return D3D12_SHADER_VISIBILITY_DOMAIN; 30 | case render::ShaderStage::Geometry: return D3D12_SHADER_VISIBILITY_GEOMETRY; 31 | case render::ShaderStage::Pixel: return D3D12_SHADER_VISIBILITY_PIXEL; 32 | default: return D3D12_SHADER_VISIBILITY_ALL; 33 | } 34 | } 35 | 36 | } // namespace d3d12 37 | 38 | } // inline namespace render 39 | 40 | } // namespace hamon 41 | 42 | #endif // HAMON_RENDER_D3D12_SHADER_VISIBILITY_HPP 43 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/d3d12/stencil_operation.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file stencil_operation.hpp 3 | * 4 | * @brief StencilOperation 5 | */ 6 | 7 | #ifndef HAMON_RENDER_D3D12_stencil_operation_HPP 8 | #define HAMON_RENDER_D3D12_stencil_operation_HPP 9 | 10 | #include 11 | #include 12 | 13 | namespace hamon 14 | { 15 | 16 | inline namespace render 17 | { 18 | 19 | namespace d3d12 20 | { 21 | 22 | inline ::D3D12_STENCIL_OP StencilOperation(render::StencilOperation op) 23 | { 24 | switch (op) 25 | { 26 | case render::StencilOperation::Keep: return D3D12_STENCIL_OP_KEEP; 27 | case render::StencilOperation::Zero: return D3D12_STENCIL_OP_ZERO; 28 | case render::StencilOperation::Replace: return D3D12_STENCIL_OP_REPLACE; 29 | case render::StencilOperation::IncrementAndClamp: return D3D12_STENCIL_OP_INCR_SAT; 30 | case render::StencilOperation::DecrementAndClamp: return D3D12_STENCIL_OP_DECR_SAT; 31 | case render::StencilOperation::Invert: return D3D12_STENCIL_OP_INVERT; 32 | case render::StencilOperation::IncrementAndWrap: return D3D12_STENCIL_OP_INCR; 33 | case render::StencilOperation::DecrementAndWrap: return D3D12_STENCIL_OP_DECR; 34 | } 35 | return D3D12_STENCIL_OP_KEEP; 36 | } 37 | 38 | } // namespace d3d12 39 | 40 | } // inline namespace render 41 | 42 | } // namespace hamon 43 | 44 | #endif // HAMON_RENDER_D3D12_stencil_operation_HPP 45 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/d3d12/texture_descriptor.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file texture_descriptor.hpp 3 | * 4 | * @brief TextureDescriptor 5 | */ 6 | 7 | #ifndef HAMON_RENDER_D3D12_TEXTURE_DESCRIPTOR_HPP 8 | #define HAMON_RENDER_D3D12_TEXTURE_DESCRIPTOR_HPP 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | namespace hamon 15 | { 16 | 17 | inline namespace render 18 | { 19 | 20 | namespace d3d12 21 | { 22 | 23 | class TextureDescriptor 24 | { 25 | public: 26 | explicit TextureDescriptor(::D3D12_SHADER_INPUT_BIND_DESC const& desc) 27 | : m_name(desc.Name) 28 | { 29 | } 30 | 31 | void LoadUniforms( 32 | d3d12::Device* device, 33 | d3d12::ResourceMap* resource_map, 34 | d3d12::DescriptorHeap* descriptor_heap, 35 | render::Uniforms const& uniforms) 36 | { 37 | auto uniform = uniforms[m_name]; 38 | if (uniform == nullptr) 39 | { 40 | return; 41 | } 42 | 43 | using type = render::Texture; 44 | auto data = static_cast(uniform->GetData()); 45 | auto texture = resource_map->GetTexture(device, *data); 46 | device->CreateShaderResourceView( 47 | texture->GetResource(), 48 | texture->GetShaderResourceViewDesc(), 49 | descriptor_heap->AssignCpuDescriptorHandle()); 50 | } 51 | 52 | private: 53 | std::string m_name; 54 | }; 55 | 56 | } // namespace d3d12 57 | 58 | } // inline namespace render 59 | 60 | } // namespace hamon 61 | 62 | #endif // HAMON_RENDER_D3D12_TEXTURE_DESCRIPTOR_HPP 63 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/d3d12_renderer.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file d3d12_renderer.hpp 3 | * 4 | * @brief D3D12Renderer 5 | */ 6 | 7 | #ifndef HAMON_RENDER_D3D12_RENDERER_HPP 8 | #define HAMON_RENDER_D3D12_RENDERER_HPP 9 | 10 | #if defined(HAMON_HAS_D3D12) 11 | #include 12 | #endif 13 | 14 | #endif // HAMON_RENDER_D3D12_RENDERER_HPP 15 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/detail/hash_combine.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file hash_combine.hpp 3 | * 4 | * @brief HashCombine 5 | */ 6 | 7 | #ifndef HAMON_RENDER_DETAIL_HASH_COMBINE_HPP 8 | #define HAMON_RENDER_DETAIL_HASH_COMBINE_HPP 9 | 10 | 11 | namespace hamon 12 | { 13 | 14 | inline namespace render 15 | { 16 | 17 | namespace detail 18 | { 19 | 20 | template 21 | struct dependent_false : std::false_type {}; 22 | 23 | template 24 | inline std::size_t HashCombineImpl2(std::size_t seed, T const& v) 25 | { 26 | if constexpr (sizeof(std::size_t) == 4) 27 | { 28 | return seed ^ (std::hash{}(v) + 0x9e3779b9U + (seed << 6) + (seed >> 2)); 29 | } 30 | else if constexpr (sizeof(std::size_t) == 8) 31 | { 32 | return seed ^ (std::hash{}(v) + 0x9e3779b97f4a7c15LLU + (seed << 12) + (seed >> 4)); 33 | } 34 | else 35 | { 36 | static_assert(dependent_false::value); 37 | } 38 | } 39 | 40 | inline std::size_t HashCombineImpl(std::size_t seed) 41 | { 42 | return seed; 43 | } 44 | 45 | template 46 | inline std::size_t HashCombineImpl(std::size_t seed, T const& v, Args const&... rest) 47 | { 48 | return HashCombineImpl(HashCombineImpl2(seed, v), rest...); 49 | } 50 | 51 | template 52 | inline std::size_t HashCombine(Args const&... args) 53 | { 54 | return HashCombineImpl(0, args...); 55 | } 56 | 57 | } // namespace detail 58 | 59 | } // inline namespace render 60 | 61 | } // namespace hamon 62 | 63 | #endif // HAMON_RENDER_DETAIL_HASH_COMBINE_HPP 64 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/detail/identifiable.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file identifiable.hpp 3 | * 4 | * @brief Identifiable 5 | */ 6 | 7 | #ifndef HAMON_RENDER_DETAIL_IDENTIFIABLE_HPP 8 | #define HAMON_RENDER_DETAIL_IDENTIFIABLE_HPP 9 | 10 | #include 11 | 12 | namespace hamon 13 | { 14 | 15 | inline namespace render 16 | { 17 | 18 | namespace detail 19 | { 20 | 21 | // ユニークなIDを取得できるクラスのベース 22 | // このクラスを継承したクラスはイミュータブルにしなければいけない 23 | // (つまりコンストラクタで値を設定し、その後変更されない) 24 | // コピーをされる可能性はあるので、コピーされても問題ないようにしなければいけない 25 | class Identifiable 26 | { 27 | public: 28 | Identifiable() = default; 29 | 30 | Identifier const& GetID(void) const { return m_id; } 31 | 32 | private: 33 | Identifier m_id; 34 | }; 35 | 36 | } // namespace detail 37 | 38 | } // inline namespace render 39 | 40 | } // namespace hamon 41 | 42 | #endif // HAMON_RENDER_DETAIL_IDENTIFIABLE_HPP 43 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/detail/index_array.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file index_array.hpp 3 | * 4 | * @brief IndexArray 5 | */ 6 | 7 | #ifndef HAMON_RENDER_DETAIL_INDEX_ARRAY_HPP 8 | #define HAMON_RENDER_DETAIL_INDEX_ARRAY_HPP 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | namespace hamon 15 | { 16 | 17 | inline namespace render 18 | { 19 | 20 | namespace detail 21 | { 22 | 23 | class IndexArrayBase 24 | { 25 | public: 26 | virtual ~IndexArrayBase() 27 | { 28 | } 29 | 30 | virtual std::size_t GetCount(void) const = 0; 31 | virtual std::size_t GetBytes(void) const = 0; 32 | virtual void const* GetData(void) const = 0; 33 | virtual IndexType GetType(void) const = 0; 34 | }; 35 | 36 | template 37 | class IndexArray : public IndexArrayBase 38 | { 39 | public: 40 | template 41 | IndexArray(Iterator first, Iterator last) 42 | : m_value(first, last) 43 | { 44 | } 45 | 46 | std::size_t GetCount(void) const override 47 | { 48 | return m_value.size(); 49 | } 50 | 51 | std::size_t GetBytes(void) const override 52 | { 53 | return sizeof(T) * m_value.size(); 54 | } 55 | 56 | void const* GetData(void) const override 57 | { 58 | return m_value.empty() ? nullptr : m_value.data(); 59 | } 60 | 61 | IndexType GetType(void) const override 62 | { 63 | return GetIndexType::value; 64 | } 65 | 66 | private: 67 | std::vector m_value; 68 | }; 69 | 70 | } // namespace detail 71 | 72 | } // inline namespace render 73 | 74 | } // namespace hamon 75 | 76 | #endif // HAMON_RENDER_DETAIL_INDEX_ARRAY_HPP 77 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/detail/pixels.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file pixels.hpp 3 | * 4 | * @brief Pixels 5 | */ 6 | 7 | #ifndef HAMON_RENDER_DETAIL_pixels_HPP 8 | #define HAMON_RENDER_DETAIL_pixels_HPP 9 | 10 | #include 11 | #include 12 | 13 | namespace hamon 14 | { 15 | 16 | inline namespace render 17 | { 18 | 19 | namespace detail 20 | { 21 | 22 | class Pixels 23 | { 24 | public: 25 | explicit Pixels(std::size_t bytes, void const* src) 26 | : m_value(bytes) 27 | { 28 | std::memcpy(m_value.data(), src, bytes); 29 | } 30 | 31 | void const* GetData(void) const 32 | { 33 | return m_value.empty() ? nullptr : m_value.data(); 34 | } 35 | 36 | private: 37 | std::vector m_value; 38 | }; 39 | 40 | } // namespace detail 41 | 42 | } // inline namespace render 43 | 44 | } // namespace hamon 45 | 46 | #endif // HAMON_RENDER_DETAIL_pixels_HPP 47 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/fill_mode.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file fill_mode.hpp 3 | * 4 | * @brief FillMode 5 | */ 6 | 7 | #ifndef HAMON_RENDER_FILL_MODE_HPP 8 | #define HAMON_RENDER_FILL_MODE_HPP 9 | 10 | #include 11 | 12 | namespace hamon 13 | { 14 | 15 | inline namespace render 16 | { 17 | 18 | enum class FillMode : std::uint32_t 19 | { 20 | Solid, 21 | Wireframe, 22 | }; 23 | 24 | } // inline namespace render 25 | 26 | } // namespace hamon 27 | 28 | #endif // HAMON_RENDER_FILL_MODE_HPP 29 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/filter_mode.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file filter_mode.hpp 3 | * 4 | * @brief FilterMode 5 | */ 6 | 7 | #ifndef HAMON_RENDER_FILTER_MODE_HPP 8 | #define HAMON_RENDER_FILTER_MODE_HPP 9 | 10 | #include 11 | 12 | namespace hamon 13 | { 14 | 15 | inline namespace render 16 | { 17 | 18 | enum class FilterMode : std::uint32_t 19 | { 20 | Nearest, 21 | Linear, 22 | }; 23 | 24 | } // inline namespace render 25 | 26 | } // namespace hamon 27 | 28 | #endif // HAMON_RENDER_FILTER_MODE_HPP 29 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/front_face.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file front_face.hpp 3 | * 4 | * @brief FrontFace 5 | */ 6 | 7 | #ifndef HAMON_RENDER_FRONT_FACE_HPP 8 | #define HAMON_RENDER_FRONT_FACE_HPP 9 | 10 | #include 11 | 12 | namespace hamon 13 | { 14 | 15 | inline namespace render 16 | { 17 | 18 | enum class FrontFace : std::uint32_t 19 | { 20 | Clockwise, 21 | CounterClockwise, 22 | 23 | // alias 24 | CW = Clockwise, 25 | CCW = CounterClockwise, 26 | }; 27 | 28 | } // inline namespace render 29 | 30 | } // namespace hamon 31 | 32 | #endif // HAMON_RENDER_FRONT_FACE_HPP 33 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/gl/blend_operation.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file blend_operation.hpp 3 | * 4 | * @brief BlendOperation 5 | */ 6 | 7 | #ifndef HAMON_RENDER_GL_BLEND_OPERATION_HPP 8 | #define HAMON_RENDER_GL_BLEND_OPERATION_HPP 9 | 10 | #include 11 | #include 12 | 13 | namespace hamon 14 | { 15 | 16 | inline namespace render 17 | { 18 | 19 | namespace gl 20 | { 21 | 22 | inline ::GLenum BlendOperation(render::BlendOperation op) 23 | { 24 | switch (op) 25 | { 26 | case render::BlendOperation::Add: return GL_FUNC_ADD; 27 | case render::BlendOperation::Subtract: return GL_FUNC_SUBTRACT; 28 | case render::BlendOperation::ReverseSubtract: return GL_FUNC_REVERSE_SUBTRACT; 29 | case render::BlendOperation::Min: return GL_MIN; 30 | case render::BlendOperation::Max: return GL_MAX; 31 | } 32 | return GL_FUNC_ADD; 33 | } 34 | 35 | } // namespace gl 36 | 37 | } // inline namespace render 38 | 39 | } // namespace hamon 40 | 41 | #endif // HAMON_RENDER_GL_BLEND_OPERATION_HPP 42 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/gl/border_color.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file border_color.hpp 3 | * 4 | * @brief BorderColor 5 | */ 6 | 7 | #ifndef HAMON_RENDER_GL_BORDER_COLOR_HPP 8 | #define HAMON_RENDER_GL_BORDER_COLOR_HPP 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | namespace hamon 15 | { 16 | 17 | inline namespace render 18 | { 19 | 20 | namespace gl 21 | { 22 | 23 | inline std::array BorderColor(render::BorderColor border_color) 24 | { 25 | switch (border_color) 26 | { 27 | case render::BorderColor::TransparentBlack: 28 | return { 0, 0, 0, 0 }; 29 | case render::BorderColor::OpaqueBlack: 30 | return { 0, 0, 0, 1 }; 31 | case render::BorderColor::OpaqueWhite: 32 | return { 1, 1, 1, 1 }; 33 | } 34 | return { 0, 0, 0, 0 }; 35 | } 36 | 37 | } // namespace gl 38 | 39 | } // inline namespace render 40 | 41 | } // namespace hamon 42 | 43 | #endif // HAMON_RENDER_GL_BORDER_COLOR_HPP 44 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/gl/buffer.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file buffer.hpp 3 | * 4 | * @brief Buffer 5 | */ 6 | 7 | #ifndef HAMON_RENDER_GL_BUFFER_HPP 8 | #define HAMON_RENDER_GL_BUFFER_HPP 9 | 10 | #include 11 | 12 | namespace hamon 13 | { 14 | 15 | inline namespace render 16 | { 17 | 18 | namespace gl 19 | { 20 | 21 | class Buffer 22 | { 23 | public: 24 | explicit Buffer(::GLsizeiptr size, void const* data, ::GLenum usage) 25 | { 26 | if (size > 0) 27 | { 28 | gl::glCreateBuffers(1, &m_id); 29 | gl::glNamedBufferData(m_id, size, data, usage); 30 | } 31 | } 32 | 33 | ~Buffer() 34 | { 35 | if (m_id != 0) 36 | { 37 | gl::glDeleteBuffers(1, &m_id); 38 | } 39 | } 40 | 41 | void SubData(::GLintptr offset, ::GLsizeiptr size, const void* data) const 42 | { 43 | gl::glNamedBufferSubData(m_id, offset, size, data); 44 | } 45 | 46 | ::GLuint GetId(void) const { return m_id; } 47 | 48 | private: 49 | ::GLuint m_id{}; 50 | }; 51 | 52 | } // namespace gl 53 | 54 | } // inline namespace render 55 | 56 | } // namespace hamon 57 | 58 | #endif // HAMON_RENDER_GL_BUFFER_HPP 59 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/gl/clear_value.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file clear_value.hpp 3 | * 4 | * @brief ClearValue 5 | */ 6 | 7 | #ifndef HAMON_RENDER_GL_CLEAR_VALUE_HPP 8 | #define HAMON_RENDER_GL_CLEAR_VALUE_HPP 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | namespace hamon 15 | { 16 | 17 | inline namespace render 18 | { 19 | 20 | namespace gl 21 | { 22 | 23 | class ClearValue 24 | { 25 | public: 26 | static void Apply(render::ClearValue const& value) 27 | { 28 | ::glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 29 | ::glDepthMask(GL_TRUE); 30 | ::glStencilMask(~0u); 31 | ::glClearColor( 32 | value.color.r, 33 | value.color.g, 34 | value.color.b, 35 | value.color.a); 36 | ::glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); 37 | } 38 | }; 39 | 40 | } // namespace gl 41 | 42 | } // inline namespace render 43 | 44 | } // namespace hamon 45 | 46 | #endif // HAMON_RENDER_GL_CLEAR_VALUE_HPP 47 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/gl/compare_operation.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file compare_operation.hpp 3 | * 4 | * @brief CompareOperation 5 | */ 6 | 7 | #ifndef HAMON_RENDER_GL_COMPARE_OPERATION_HPP 8 | #define HAMON_RENDER_GL_COMPARE_OPERATION_HPP 9 | 10 | #include 11 | #include 12 | 13 | namespace hamon 14 | { 15 | 16 | inline namespace render 17 | { 18 | 19 | namespace gl 20 | { 21 | 22 | inline ::GLenum CompareOperation(render::CompareOperation op) 23 | { 24 | switch (op) 25 | { 26 | case render::CompareOperation::Never: return GL_NEVER; 27 | case render::CompareOperation::Less: return GL_LESS; 28 | case render::CompareOperation::Equal: return GL_EQUAL; 29 | case render::CompareOperation::LessEqual: return GL_LEQUAL; 30 | case render::CompareOperation::Greater: return GL_GREATER; 31 | case render::CompareOperation::NotEqual: return GL_NOTEQUAL; 32 | case render::CompareOperation::GreaterEqual: return GL_GEQUAL; 33 | case render::CompareOperation::Always: return GL_ALWAYS; 34 | } 35 | return GL_LESS; 36 | } 37 | 38 | } // namespace gl 39 | 40 | } // inline namespace render 41 | 42 | } // namespace hamon 43 | 44 | #endif // HAMON_RENDER_GL_COMPARE_OPERATION_HPP 45 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/gl/context.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file context.hpp 3 | * 4 | * @brief Context 5 | */ 6 | 7 | #ifndef HAMON_RENDER_GL_CONTEXT_HPP 8 | #define HAMON_RENDER_GL_CONTEXT_HPP 9 | 10 | #if defined(_WIN32) 11 | #include 12 | #elif defined(__linux) 13 | #include 14 | #endif 15 | 16 | #endif // HAMON_RENDER_GL_CONTEXT_HPP 17 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/gl/cull_mode.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file cull_mode.hpp 3 | * 4 | * @brief CullMode 5 | */ 6 | 7 | #ifndef HAMON_RENDER_GL_CULL_MODE_HPP 8 | #define HAMON_RENDER_GL_CULL_MODE_HPP 9 | 10 | #include 11 | #include 12 | 13 | namespace hamon 14 | { 15 | 16 | inline namespace render 17 | { 18 | 19 | namespace gl 20 | { 21 | 22 | inline ::GLenum CullMode(render::CullMode cull_mode) 23 | { 24 | switch (cull_mode) 25 | { 26 | case render::CullMode::Front: return GL_FRONT; 27 | case render::CullMode::Back: return GL_BACK; 28 | case render::CullMode::None: 29 | default: 30 | // glCullFaceにNONEは設定できないので、適当な値を返す 31 | // glDisable(GL_CULL_FACE)を呼んでカリングを無効にすること 32 | return GL_BACK; 33 | } 34 | } 35 | 36 | } // namespace gl 37 | 38 | } // inline namespace render 39 | 40 | } // namespace hamon 41 | 42 | #endif // HAMON_RENDER_GL_CULL_MODE_HPP 43 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/gl/depth_stencil_state.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file depth_stencil_state.hpp 3 | * 4 | * @brief DepthStencilState 5 | */ 6 | 7 | #ifndef HAMON_RENDER_GL_DEPTH_STENCIL_STATE_HPP 8 | #define HAMON_RENDER_GL_DEPTH_STENCIL_STATE_HPP 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | namespace hamon 16 | { 17 | 18 | inline namespace render 19 | { 20 | 21 | namespace gl 22 | { 23 | 24 | class DepthStencilState 25 | { 26 | public: 27 | static void Apply(render::DepthStencilState const& state) 28 | { 29 | if (state.depth.enable) 30 | { 31 | ::glEnable(GL_DEPTH_TEST); 32 | } 33 | else 34 | { 35 | ::glDisable(GL_DEPTH_TEST); 36 | } 37 | ::glDepthMask(state.depth.write); 38 | ::glDepthFunc(gl::CompareOperation(state.depth.compare_operation)); 39 | 40 | if (state.stencil.enable) 41 | { 42 | ::glEnable(GL_STENCIL_TEST); 43 | } 44 | else 45 | { 46 | ::glDisable(GL_STENCIL_TEST); 47 | } 48 | ::glStencilFunc( 49 | gl::CompareOperation(state.stencil.compare_operation), 50 | state.stencil.reference, 51 | state.stencil.read_mask); 52 | ::glStencilMask(state.stencil.write_mask); 53 | ::glStencilOp( 54 | gl::StencilOperation(state.stencil.fail_operation), 55 | gl::StencilOperation(state.stencil.depth_fail_operation), 56 | gl::StencilOperation(state.stencil.pass_operation)); 57 | } 58 | }; 59 | 60 | } // namespace gl 61 | 62 | } // inline namespace render 63 | 64 | } // namespace hamon 65 | 66 | #endif // HAMON_RENDER_GL_DEPTH_STENCIL_STATE_HPP 67 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/gl/fill_mode.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file fill_mode.hpp 3 | * 4 | * @brief FillMode 5 | */ 6 | 7 | #ifndef HAMON_RENDER_GL_FILL_MODE_HPP 8 | #define HAMON_RENDER_GL_FILL_MODE_HPP 9 | 10 | #include 11 | #include 12 | 13 | namespace hamon 14 | { 15 | 16 | inline namespace render 17 | { 18 | 19 | namespace gl 20 | { 21 | 22 | inline ::GLenum FillMode(render::FillMode fill_mode) 23 | { 24 | switch (fill_mode) 25 | { 26 | case render::FillMode::Solid: return GL_FILL; 27 | case render::FillMode::Wireframe: return GL_LINE; 28 | } 29 | return GL_FILL; 30 | } 31 | 32 | } // namespace gl 33 | 34 | } // inline namespace render 35 | 36 | } // namespace hamon 37 | 38 | #endif // HAMON_RENDER_GL_FILL_MODE_HPP 39 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/gl/filter_mode.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file filter_mode.hpp 3 | * 4 | * @brief FilterMode 5 | */ 6 | 7 | #ifndef HAMON_RENDER_GL_FILTER_MODE_HPP 8 | #define HAMON_RENDER_GL_FILTER_MODE_HPP 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | namespace hamon 15 | { 16 | 17 | inline namespace render 18 | { 19 | 20 | namespace gl 21 | { 22 | 23 | inline ::GLenum FilterMode(render::FilterMode mag_filter) 24 | { 25 | switch (mag_filter) 26 | { 27 | case render::FilterMode::Nearest: return GL_NEAREST; 28 | case render::FilterMode::Linear: return GL_LINEAR; 29 | } 30 | return GL_LINEAR; 31 | } 32 | 33 | inline ::GLenum FilterMode(render::FilterMode min_filter, render::MipmapMode mip_filter) 34 | { 35 | switch (min_filter) 36 | { 37 | case render::FilterMode::Nearest: 38 | switch (mip_filter) 39 | { 40 | case render::MipmapMode::Disable: return GL_NEAREST; 41 | case render::MipmapMode::Nearest: return GL_NEAREST_MIPMAP_NEAREST; 42 | case render::MipmapMode::Linear: return GL_NEAREST_MIPMAP_LINEAR; 43 | } 44 | break; 45 | case render::FilterMode::Linear: 46 | switch (mip_filter) 47 | { 48 | case render::MipmapMode::Disable: return GL_LINEAR; 49 | case render::MipmapMode::Nearest: return GL_LINEAR_MIPMAP_NEAREST; 50 | case render::MipmapMode::Linear: return GL_LINEAR_MIPMAP_LINEAR; 51 | } 52 | break; 53 | } 54 | return GL_NEAREST_MIPMAP_LINEAR; 55 | } 56 | 57 | } // namespace gl 58 | 59 | } // inline namespace render 60 | 61 | } // namespace hamon 62 | 63 | #endif // HAMON_RENDER_GL_FILTER_MODE_HPP 64 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/gl/front_face.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file front_face.hpp 3 | * 4 | * @brief FrontFace 5 | */ 6 | 7 | #ifndef HAMON_RENDER_GL_FRONT_FACE_HPP 8 | #define HAMON_RENDER_GL_FRONT_FACE_HPP 9 | 10 | #include 11 | #include 12 | 13 | namespace hamon 14 | { 15 | 16 | inline namespace render 17 | { 18 | 19 | namespace gl 20 | { 21 | 22 | inline ::GLenum FrontFace(render::FrontFace front_face) 23 | { 24 | switch (front_face) 25 | { 26 | case render::FrontFace::CW: return GL_CW; 27 | case render::FrontFace::CCW: return GL_CCW; 28 | } 29 | return GL_CW; 30 | } 31 | 32 | } // namespace gl 33 | 34 | } // inline namespace render 35 | 36 | } // namespace hamon 37 | 38 | #endif // HAMON_RENDER_GL_FRONT_FACE_HPP 39 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/gl/gl.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file gl.hpp 3 | * 4 | * @brief OpenGL関係のヘッダをインクルードする 5 | */ 6 | 7 | #ifndef HAMON_RENDER_GL_GL_HPP 8 | #define HAMON_RENDER_GL_GL_HPP 9 | 10 | #define GL_GLEXT_PROTOTYPES 11 | #include 12 | #include 13 | 14 | #if defined(_WIN32) 15 | #define WGL_WGLEXT_PROTOTYPES 16 | #include 17 | #endif 18 | #if defined(__linux) 19 | #define GLX_GLXEXT_PROTOTYPES 20 | #include 21 | #include 22 | #endif 23 | 24 | #endif // HAMON_RENDER_GL_GL_HPP 25 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/gl/index_buffer.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file index_buffer.hpp 3 | * 4 | * @brief IndexBuffer 5 | */ 6 | 7 | #ifndef HAMON_RENDER_GL_INDEX_BUFFER_HPP 8 | #define HAMON_RENDER_GL_INDEX_BUFFER_HPP 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | namespace hamon 16 | { 17 | 18 | inline namespace render 19 | { 20 | 21 | namespace gl 22 | { 23 | 24 | class IndexBuffer 25 | { 26 | public: 27 | explicit IndexBuffer(render::detail::IndexArrayBase const* index_array) 28 | : m_buffer(index_array->GetBytes(), index_array->GetData(), GL_STATIC_DRAW) 29 | , m_count(static_cast<::GLsizei>(index_array->GetCount())) 30 | , m_type(gl::IndexType(index_array->GetType())) 31 | { 32 | } 33 | 34 | void Draw(::GLenum topology) 35 | { 36 | ::glDrawElements(topology, m_count, m_type, 0); 37 | } 38 | 39 | ::GLuint GetId(void) const { return m_buffer.GetId(); } 40 | 41 | private: 42 | gl::Buffer m_buffer; 43 | ::GLsizei m_count; 44 | ::GLenum m_type; 45 | }; 46 | 47 | } // namespace gl 48 | 49 | } // inline namespace render 50 | 51 | } // namespace hamon 52 | 53 | #endif // HAMON_RENDER_GL_INDEX_BUFFER_HPP 54 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/gl/index_type.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file index_type.hpp 3 | * 4 | * @brief IndexType 5 | */ 6 | 7 | #ifndef HAMON_RENDER_GL_INDEX_TYPE_HPP 8 | #define HAMON_RENDER_GL_INDEX_TYPE_HPP 9 | 10 | #include 11 | #include 12 | 13 | namespace hamon 14 | { 15 | 16 | inline namespace render 17 | { 18 | 19 | namespace gl 20 | { 21 | 22 | inline ::GLenum 23 | IndexType(render::IndexType type) 24 | { 25 | switch (type) 26 | { 27 | case render::IndexType::UInt16: return GL_UNSIGNED_SHORT; 28 | case render::IndexType::UInt32: return GL_UNSIGNED_INT; 29 | } 30 | return GL_UNSIGNED_SHORT; 31 | } 32 | 33 | } // namespace gl 34 | 35 | } // inline namespace render 36 | 37 | } // namespace hamon 38 | 39 | #endif // HAMON_RENDER_GL_INDEX_TYPE_HPP 40 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/gl/primitive_topology.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file primitive_topology.hpp 3 | * 4 | * @brief PrimitiveTopology 5 | */ 6 | 7 | #ifndef HAMON_RENDER_GL_PRIMITIVE_TOPOLOGY_HPP 8 | #define HAMON_RENDER_GL_PRIMITIVE_TOPOLOGY_HPP 9 | 10 | #include 11 | #include 12 | 13 | namespace hamon 14 | { 15 | 16 | inline namespace render 17 | { 18 | 19 | namespace gl 20 | { 21 | 22 | inline ::GLenum PrimitiveTopology(render::PrimitiveTopology topology) 23 | { 24 | switch (topology) 25 | { 26 | case render::PrimitiveTopology::PointList: return GL_POINTS; 27 | case render::PrimitiveTopology::LineList: return GL_LINES; 28 | case render::PrimitiveTopology::TriangleList: return GL_TRIANGLES; 29 | } 30 | return GL_POINTS; 31 | } 32 | 33 | } // namespace gl 34 | 35 | } // inline namespace render 36 | 37 | } // namespace hamon 38 | 39 | #endif // HAMON_RENDER_GL_PRIMITIVE_TOPOLOGY_HPP 40 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/gl/rasterizer_state.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file rasterizer_state.hpp 3 | * 4 | * @brief RasterizerState 5 | */ 6 | 7 | #ifndef HAMON_RENDER_GL_RASTERIZER_STATE_HPP 8 | #define HAMON_RENDER_GL_RASTERIZER_STATE_HPP 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | namespace hamon 17 | { 18 | 19 | inline namespace render 20 | { 21 | 22 | namespace gl 23 | { 24 | 25 | class RasterizerState 26 | { 27 | public: 28 | static void Apply(render::RasterizerState const& state) 29 | { 30 | if (state.cull_mode != render::CullMode::None) 31 | { 32 | ::glEnable(GL_CULL_FACE); 33 | ::glCullFace(gl::CullMode(state.cull_mode)); 34 | } 35 | else 36 | { 37 | ::glDisable(GL_CULL_FACE); 38 | } 39 | 40 | ::glFrontFace(gl::FrontFace(state.front_face)); 41 | 42 | ::glPolygonMode(GL_FRONT_AND_BACK, gl::FillMode(state.fill_mode)); 43 | } 44 | }; 45 | 46 | } // namespace gl 47 | 48 | } // inline namespace render 49 | 50 | } // namespace hamon 51 | 52 | #endif // HAMON_RENDER_GL_RASTERIZER_STATE_HPP 53 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/gl/sampler_address_mode.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file sampler_address_mode.hpp 3 | * 4 | * @brief SamplerAddressMode 5 | */ 6 | 7 | #ifndef HAMON_RENDER_GL_SAMPLER_ADDRESS_MODE_HPP 8 | #define HAMON_RENDER_GL_SAMPLER_ADDRESS_MODE_HPP 9 | 10 | #include 11 | #include 12 | 13 | namespace hamon 14 | { 15 | 16 | inline namespace render 17 | { 18 | 19 | namespace gl 20 | { 21 | 22 | inline ::GLenum SamplerAddressMode(render::SamplerAddressMode mode) 23 | { 24 | switch (mode) 25 | { 26 | case hamon::render::SamplerAddressMode::Repeat: return GL_REPEAT; 27 | case hamon::render::SamplerAddressMode::MirroredRepeat: return GL_MIRRORED_REPEAT; 28 | case hamon::render::SamplerAddressMode::ClampToEdge: return GL_CLAMP_TO_EDGE; 29 | case hamon::render::SamplerAddressMode::ClampToBorder: return GL_CLAMP_TO_BORDER; 30 | case hamon::render::SamplerAddressMode::MirrorClampToEdge: return GL_MIRROR_CLAMP_TO_EDGE; 31 | } 32 | return GL_REPEAT; 33 | } 34 | 35 | } // namespace gl 36 | 37 | } // inline namespace render 38 | 39 | } // namespace hamon 40 | 41 | #endif // HAMON_RENDER_GL_SAMPLER_ADDRESS_MODE_HPP 42 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/gl/shader_stage.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file shader_stage.hpp 3 | * 4 | * @brief ShaderStage 5 | */ 6 | 7 | #ifndef HAMON_RENDER_GL_SHADER_STAGE_HPP 8 | #define HAMON_RENDER_GL_SHADER_STAGE_HPP 9 | 10 | #include 11 | #include 12 | 13 | namespace hamon 14 | { 15 | 16 | inline namespace render 17 | { 18 | 19 | namespace gl 20 | { 21 | 22 | inline ::GLenum ShaderStage(render::ShaderStage stage) 23 | { 24 | switch (stage) 25 | { 26 | case render::ShaderStage::Compute: return GL_COMPUTE_SHADER; 27 | case render::ShaderStage::Vertex: return GL_VERTEX_SHADER; 28 | case render::ShaderStage::TessellationControl: return GL_TESS_CONTROL_SHADER; 29 | case render::ShaderStage::TessellationEvaluation: return GL_TESS_EVALUATION_SHADER; 30 | case render::ShaderStage::Geometry: return GL_GEOMETRY_SHADER; 31 | case render::ShaderStage::Fragment: return GL_FRAGMENT_SHADER; 32 | } 33 | return GL_VERTEX_SHADER; 34 | } 35 | 36 | } // namespace gl 37 | 38 | } // inline namespace render 39 | 40 | } // namespace hamon 41 | 42 | #endif // HAMON_RENDER_GL_SHADER_STAGE_HPP 43 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/gl/stencil_operation.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file stencil_operation.hpp 3 | * 4 | * @brief StencilOperation 5 | */ 6 | 7 | #ifndef HAMON_RENDER_GL_STENCIL_OPERATION_HPP 8 | #define HAMON_RENDER_GL_STENCIL_OPERATION_HPP 9 | 10 | #include 11 | #include 12 | 13 | namespace hamon 14 | { 15 | 16 | inline namespace render 17 | { 18 | 19 | namespace gl 20 | { 21 | 22 | inline ::GLenum StencilOperation(render::StencilOperation op) 23 | { 24 | switch (op) 25 | { 26 | case render::StencilOperation::Keep: return GL_KEEP; 27 | case render::StencilOperation::Zero: return GL_ZERO; 28 | case render::StencilOperation::Replace: return GL_REPLACE; 29 | case render::StencilOperation::IncrementAndClamp: return GL_INCR; 30 | case render::StencilOperation::DecrementAndClamp: return GL_DECR; 31 | case render::StencilOperation::Invert: return GL_INVERT; 32 | case render::StencilOperation::IncrementAndWrap: return GL_INCR_WRAP; 33 | case render::StencilOperation::DecrementAndWrap: return GL_DECR_WRAP; 34 | } 35 | return GL_KEEP; 36 | } 37 | 38 | } // namespace gl 39 | 40 | } // inline namespace render 41 | 42 | } // namespace hamon 43 | 44 | #endif // HAMON_RENDER_GL_STENCIL_OPERATION_HPP 45 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/gl/type.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file type.hpp 3 | * 4 | * @brief Type 5 | */ 6 | 7 | #ifndef HAMON_RENDER_GL_TYPE_HPP 8 | #define HAMON_RENDER_GL_TYPE_HPP 9 | 10 | #include 11 | #include 12 | 13 | namespace hamon 14 | { 15 | 16 | inline namespace render 17 | { 18 | 19 | namespace gl 20 | { 21 | 22 | inline ::GLenum Type(render::Type type) 23 | { 24 | switch (type) 25 | { 26 | case render::Type::Int8: return GL_BYTE; 27 | case render::Type::Int16: return GL_SHORT; 28 | case render::Type::Int32: return GL_INT; 29 | case render::Type::UInt8: return GL_UNSIGNED_BYTE; 30 | case render::Type::UInt16: return GL_UNSIGNED_SHORT; 31 | case render::Type::UInt32: return GL_UNSIGNED_INT; 32 | case render::Type::Float: return GL_FLOAT; 33 | default: return GL_BYTE; 34 | } 35 | } 36 | 37 | } // namespace gl 38 | 39 | } // inline namespace render 40 | 41 | } // namespace hamon 42 | 43 | #endif // HAMON_RENDER_GL_TYPE_HPP 44 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/gl/vertex_buffer.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file vertex_buffer.hpp 3 | * 4 | * @brief VertexBuffer 5 | */ 6 | 7 | #ifndef HAMON_RENDER_GL_VERTEX_BUFFER_HPP 8 | #define HAMON_RENDER_GL_VERTEX_BUFFER_HPP 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | namespace hamon 15 | { 16 | 17 | inline namespace render 18 | { 19 | 20 | namespace gl 21 | { 22 | 23 | class VertexBuffer 24 | { 25 | public: 26 | explicit VertexBuffer(render::Geometry const& geometry) 27 | : m_buffer(geometry.GetVertexArrayBytes(), geometry.GetVertexArrayData(), GL_STATIC_DRAW) 28 | , m_count(static_cast<::GLsizei>(geometry.GetVertexArrayCount())) 29 | { 30 | } 31 | 32 | void Draw(::GLenum topology) 33 | { 34 | ::glDrawArrays(topology, 0, m_count); 35 | } 36 | 37 | ::GLuint GetId(void) const { return m_buffer.GetId(); } 38 | 39 | private: 40 | gl::Buffer m_buffer; 41 | ::GLsizei m_count; 42 | }; 43 | 44 | } // namespace gl 45 | 46 | } // inline namespace render 47 | 48 | } // namespace hamon 49 | 50 | #endif // HAMON_RENDER_GL_VERTEX_BUFFER_HPP 51 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/gl/viewport.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file viewport.hpp 3 | * 4 | * @brief Viewport 5 | */ 6 | 7 | #ifndef HAMON_RENDER_GL_VIEWPORT_HPP 8 | #define HAMON_RENDER_GL_VIEWPORT_HPP 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | namespace hamon 15 | { 16 | 17 | inline namespace render 18 | { 19 | 20 | namespace gl 21 | { 22 | 23 | class Viewport 24 | { 25 | public: 26 | static void Apply(render::Viewport const& viewport) 27 | { 28 | ::glViewport( 29 | static_cast<::GLint>(viewport.left), 30 | static_cast<::GLint>(viewport.top), 31 | static_cast<::GLsizei>(viewport.width), 32 | static_cast<::GLsizei>(viewport.height)); 33 | gl::glDepthRangef( 34 | viewport.min_depth, 35 | viewport.max_depth); 36 | } 37 | }; 38 | 39 | } // namespace gl 40 | 41 | } // inline namespace render 42 | 43 | } // namespace hamon 44 | 45 | #endif // HAMON_RENDER_GL_VIEWPORT_HPP 46 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/gl/wgl/wglext.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file wglext.hpp 3 | * 4 | * @brief wglext 5 | */ 6 | 7 | #ifndef HAMON_RENDER_GL_WGLEXT_HPP 8 | #define HAMON_RENDER_GL_WGLEXT_HPP 9 | 10 | #include 11 | 12 | namespace hamon 13 | { 14 | 15 | inline namespace render 16 | { 17 | 18 | namespace gl 19 | { 20 | 21 | inline HGLRC WINAPI wglCreateContextAttribsARB(HDC hDC, HGLRC hShareContext, const int *attribList) 22 | { 23 | static auto func = (PFNWGLCREATECONTEXTATTRIBSARBPROC)::wglGetProcAddress("wglCreateContextAttribsARB"); 24 | return func(hDC, hShareContext, attribList); 25 | } 26 | 27 | } // namespace gl 28 | 29 | } // inline namespace render 30 | 31 | } // namespace hamon 32 | 33 | #endif // HAMON_RENDER_GL_WGLEXT_HPP 34 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/gl_renderer.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file gl_renderer.hpp 3 | * 4 | * @brief GLRenderer 5 | */ 6 | 7 | #ifndef HAMON_RENDER_GL_RENDERER_HPP 8 | #define HAMON_RENDER_GL_RENDERER_HPP 9 | 10 | #if defined(HAMON_HAS_OPEN_GL) 11 | #include 12 | #endif 13 | 14 | #endif // HAMON_RENDER_GL_RENDERER_HPP 15 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/index_type.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file index_type.hpp 3 | * 4 | * @brief IndexType 5 | */ 6 | 7 | #ifndef HAMON_RENDER_INDEX_TYPE_HPP 8 | #define HAMON_RENDER_INDEX_TYPE_HPP 9 | 10 | #include 11 | #include 12 | 13 | namespace hamon 14 | { 15 | 16 | inline namespace render 17 | { 18 | 19 | enum class IndexType : std::uint32_t 20 | { 21 | UInt16, 22 | UInt32, 23 | }; 24 | 25 | template 26 | struct GetIndexType 27 | { 28 | private: 29 | template 30 | struct Helper; 31 | 32 | template struct Helper { static const IndexType value = IndexType::UInt16; }; 33 | template struct Helper { static const IndexType value = IndexType::UInt32; }; 34 | 35 | public: 36 | static const IndexType value = Helper, sizeof(T)>::value; 37 | }; 38 | 39 | } // inline namespace render 40 | 41 | } // namespace hamon 42 | 43 | #endif // HAMON_RENDER_INDEX_TYPE_HPP 44 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/logic_operation.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file logic_operation.hpp 3 | * 4 | * @brief LogicOperation 5 | */ 6 | 7 | #ifndef HAMON_RENDER_LOGIC_OPERATION_HPP 8 | #define HAMON_RENDER_LOGIC_OPERATION_HPP 9 | 10 | #include 11 | 12 | namespace hamon 13 | { 14 | 15 | inline namespace render 16 | { 17 | 18 | enum class LogicOperation : std::uint32_t 19 | { 20 | Clear, 21 | Set, 22 | Copy, 23 | CopyInverted, 24 | Noop, 25 | Invert, 26 | And, 27 | Nand, 28 | Or, 29 | Nor, 30 | Xor, 31 | Equivalent, 32 | AndReverse, 33 | AndInverted, 34 | OrReverse, 35 | OrInverted, 36 | }; 37 | 38 | } // inline namespace render 39 | 40 | } // namespace hamon 41 | 42 | #endif // HAMON_RENDER_LOGIC_OPERATION_HPP 43 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/mipmap_mode.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file mipmap_mode.hpp 3 | * 4 | * @brief MipmapMode 5 | */ 6 | 7 | #ifndef HAMON_RENDER_MIPMAP_MODE_HPP 8 | #define HAMON_RENDER_MIPMAP_MODE_HPP 9 | 10 | #include 11 | 12 | namespace hamon 13 | { 14 | 15 | inline namespace render 16 | { 17 | 18 | enum class MipmapMode : std::uint32_t 19 | { 20 | Disable, 21 | Nearest, 22 | Linear, 23 | }; 24 | 25 | } // inline namespace render 26 | 27 | } // namespace hamon 28 | 29 | #endif // HAMON_RENDER_MIPMAP_MODE_HPP 30 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/primitive_topology.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file primitive_topology.hpp 3 | * 4 | * @brief PrimitiveTopology 5 | */ 6 | 7 | #ifndef HAMON_RENDER_PRIMITIVE_TOPOLOGY_HPP 8 | #define HAMON_RENDER_PRIMITIVE_TOPOLOGY_HPP 9 | 10 | #include 11 | 12 | namespace hamon 13 | { 14 | 15 | inline namespace render 16 | { 17 | 18 | enum class PrimitiveTopology : std::uint32_t 19 | { 20 | PointList, 21 | LineList, 22 | TriangleList, 23 | }; 24 | 25 | } // inline namespace render 26 | 27 | } // namespace hamon 28 | 29 | #endif // HAMON_RENDER_PRIMITIVE_TOPOLOGY_HPP 30 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/program.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file program.hpp 3 | * 4 | * @brief Program 5 | */ 6 | 7 | #ifndef HAMON_RENDER_PROGRAM_HPP 8 | #define HAMON_RENDER_PROGRAM_HPP 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | namespace hamon 16 | { 17 | 18 | inline namespace render 19 | { 20 | 21 | class Program : public detail::Identifiable 22 | { 23 | public: 24 | Program(ShaderLanguage language, std::vector shaders) 25 | : m_language(language) 26 | , m_shaders(std::move(shaders)) 27 | {} 28 | 29 | ShaderLanguage GetLanguage(void) const 30 | { 31 | return m_language; 32 | } 33 | 34 | std::vector const& 35 | GetShaders(void) const 36 | { 37 | return m_shaders; 38 | } 39 | 40 | private: 41 | ShaderLanguage m_language; 42 | std::vector m_shaders; 43 | }; 44 | 45 | } // inline namespace render 46 | 47 | } // namespace hamon 48 | 49 | #endif // HAMON_RENDER_PROGRAM_HPP 50 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/rasterizer_state.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file rasterizer_state.hpp 3 | * 4 | * @brief RasterizerState 5 | */ 6 | 7 | #ifndef HAMON_RENDER_RASTERIZER_STATE_HPP 8 | #define HAMON_RENDER_RASTERIZER_STATE_HPP 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | namespace hamon 15 | { 16 | 17 | inline namespace render 18 | { 19 | 20 | struct RasterizerState 21 | { 22 | FillMode fill_mode { FillMode::Solid }; 23 | CullMode cull_mode { CullMode::Back }; 24 | FrontFace front_face { FrontFace::Clockwise }; 25 | }; 26 | 27 | } // inline namespace render 28 | 29 | } // namespace hamon 30 | 31 | #include 32 | #include 33 | 34 | namespace std 35 | { 36 | 37 | template <> 38 | struct hash 39 | { 40 | std::size_t operator()(hamon::render::RasterizerState const& arg) const 41 | { 42 | return hamon::render::detail::HashCombine( 43 | arg.fill_mode, 44 | arg.cull_mode, 45 | arg.front_face); 46 | } 47 | }; 48 | 49 | } // namespace std 50 | 51 | #endif // HAMON_RENDER_RASTERIZER_STATE_HPP 52 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/render_pass_state.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file render_pass_state.hpp 3 | * 4 | * @brief RenderPassState 5 | */ 6 | 7 | #ifndef HAMON_RENDER_RENDER_PASS_STATE_HPP 8 | #define HAMON_RENDER_RENDER_PASS_STATE_HPP 9 | 10 | #include 11 | #include 12 | 13 | namespace hamon 14 | { 15 | 16 | inline namespace render 17 | { 18 | 19 | struct RenderPassState 20 | { 21 | ClearValue clear_value; 22 | Viewport viewport; 23 | }; 24 | 25 | } // inline namespace render 26 | 27 | } // namespace hamon 28 | 29 | #endif // HAMON_RENDER_RENDER_PASS_STATE_HPP 30 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/render_state.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file render_state.hpp 3 | * 4 | * @brief RenderState 5 | */ 6 | 7 | #ifndef HAMON_RENDER_RENDER_STATE_HPP 8 | #define HAMON_RENDER_RENDER_STATE_HPP 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | namespace hamon 15 | { 16 | 17 | inline namespace render 18 | { 19 | 20 | struct RenderState 21 | { 22 | BlendState blend_state; 23 | DepthStencilState depth_stencil_state; 24 | RasterizerState rasterizer_state; 25 | }; 26 | 27 | } // inline namespace render 28 | 29 | } // namespace hamon 30 | 31 | #include 32 | #include 33 | 34 | namespace std 35 | { 36 | 37 | template <> 38 | struct hash 39 | { 40 | std::size_t operator()(hamon::render::RenderState const& arg) const 41 | { 42 | return hamon::render::detail::HashCombine( 43 | arg.blend_state, 44 | arg.depth_stencil_state, 45 | arg.rasterizer_state); 46 | } 47 | }; 48 | 49 | } // namespace std 50 | 51 | #endif // HAMON_RENDER_RENDER_STATE_HPP 52 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/renderer.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file renderer.hpp 3 | * 4 | * @brief Renderer 5 | */ 6 | 7 | #ifndef HAMON_RENDER_RENDERER_HPP 8 | #define HAMON_RENDER_RENDERER_HPP 9 | 10 | #include 11 | 12 | namespace hamon 13 | { 14 | 15 | inline namespace render 16 | { 17 | 18 | class Geometry; 19 | class Program; 20 | class Uniforms; 21 | struct RenderPassState; 22 | struct RenderState; 23 | 24 | class Renderer 25 | { 26 | public: 27 | virtual ~Renderer() {} 28 | 29 | virtual void Begin(void) = 0; 30 | virtual void End(void) = 0; 31 | 32 | virtual void BeginRenderPass(RenderPassState const& render_pass_state) = 0; 33 | virtual void EndRenderPass(void) = 0; 34 | 35 | virtual void Render( 36 | Geometry const& geometry, 37 | Program const& program, 38 | Uniforms const& uniforms, 39 | RenderState const& render_state) = 0; 40 | }; 41 | 42 | } // inline namespace render 43 | 44 | } // namespace hamon 45 | 46 | #endif // HAMON_RENDER_RENDERER_HPP 47 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/sampler_address_mode.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file sampler_address_mode.hpp 3 | * 4 | * @brief SamplerAddressMode 5 | */ 6 | 7 | #ifndef HAMON_RENDER_SAMPLER_ADDRESS_MODE_HPP 8 | #define HAMON_RENDER_SAMPLER_ADDRESS_MODE_HPP 9 | 10 | #include 11 | 12 | namespace hamon 13 | { 14 | 15 | inline namespace render 16 | { 17 | 18 | enum class SamplerAddressMode : std::uint32_t 19 | { 20 | Repeat, 21 | MirroredRepeat, 22 | ClampToEdge, 23 | ClampToBorder, 24 | MirrorClampToEdge, 25 | }; 26 | 27 | } // inline namespace render 28 | 29 | } // namespace hamon 30 | 31 | #endif // HAMON_RENDER_SAMPLER_ADDRESS_MODE_HPP 32 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/semantic.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file semantic.hpp 3 | * 4 | * @brief Semantic 5 | */ 6 | 7 | #ifndef HAMON_RENDER_SEMANTIC_HPP 8 | #define HAMON_RENDER_SEMANTIC_HPP 9 | 10 | #include 11 | 12 | namespace hamon 13 | { 14 | 15 | inline namespace render 16 | { 17 | 18 | enum class Semantic : std::uint32_t 19 | { 20 | Position, 21 | Normal, 22 | Color, 23 | TexCoord, 24 | Binormal, 25 | BlendIndices, 26 | BlendWeights, 27 | PointSize, 28 | Tangent, 29 | }; 30 | 31 | } // inline namespace render 32 | 33 | } // namespace hamon 34 | 35 | #endif // HAMON_RENDER_SEMANTIC_HPP 36 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/shader.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file shader.hpp 3 | * 4 | * @brief Shader 5 | */ 6 | 7 | #ifndef HAMON_RENDER_SHADER_HPP 8 | #define HAMON_RENDER_SHADER_HPP 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | namespace hamon 15 | { 16 | 17 | inline namespace render 18 | { 19 | 20 | class Shader 21 | { 22 | public: 23 | Shader(ShaderStage stage, std::string source) 24 | : m_stage(stage) 25 | , m_source(std::move(source)) 26 | {} 27 | 28 | Shader(ShaderStage stage, std::string source, std::string entry_point) 29 | : m_stage(stage) 30 | , m_source(std::move(source)) 31 | , m_entry_point(std::move(entry_point)) 32 | {} 33 | 34 | ShaderStage GetStage(void) const 35 | { 36 | return m_stage; 37 | } 38 | 39 | std::string const& GetSource(void) const 40 | { 41 | return m_source; 42 | } 43 | 44 | std::string const& GetEntryPoint(void) const 45 | { 46 | return m_entry_point; 47 | } 48 | 49 | private: 50 | ShaderStage m_stage; 51 | std::string m_source; 52 | std::string m_entry_point {"main"}; 53 | }; 54 | 55 | } // inline namespace render 56 | 57 | } // namespace hamon 58 | 59 | #endif // HAMON_RENDER_SHADER_HPP 60 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/shader_language.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file shader_language.hpp 3 | * 4 | * @brief ShaderLanguage 5 | */ 6 | 7 | #ifndef HAMON_RENDER_SHADER_LANGUAGE_HPP 8 | #define HAMON_RENDER_SHADER_LANGUAGE_HPP 9 | 10 | #include 11 | 12 | namespace hamon 13 | { 14 | 15 | inline namespace render 16 | { 17 | 18 | enum class ShaderLanguage : std::uint32_t 19 | { 20 | GLSL, 21 | HLSL, 22 | }; 23 | 24 | } // inline namespace render 25 | 26 | } // namespace hamon 27 | 28 | #endif // HAMON_RENDER_SHADER_LANGUAGE_HPP 29 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/shader_stage.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file shader_stage.hpp 3 | * 4 | * @brief ShaderStage 5 | */ 6 | 7 | #ifndef HAMON_RENDER_SHADER_STAGE_HPP 8 | #define HAMON_RENDER_SHADER_STAGE_HPP 9 | 10 | #include 11 | 12 | namespace hamon 13 | { 14 | 15 | inline namespace render 16 | { 17 | 18 | enum class ShaderStage : std::uint32_t 19 | { 20 | Compute, 21 | Vertex, 22 | Hull, 23 | Domain, 24 | Geometry, 25 | Pixel, 26 | 27 | TessellationControl = Hull, 28 | TessellationEvaluation = Domain, 29 | Fragment = Pixel, 30 | }; 31 | 32 | } // inline namespace render 33 | 34 | } // namespace hamon 35 | 36 | #endif // HAMON_RENDER_SHADER_STAGE_HPP 37 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/stencil_operation.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file stencil_operation.hpp 3 | * 4 | * @brief StencilOperation 5 | */ 6 | 7 | #ifndef HAMON_RENDER_STENCIL_OPERATION_HPP 8 | #define HAMON_RENDER_STENCIL_OPERATION_HPP 9 | 10 | #include 11 | 12 | namespace hamon 13 | { 14 | 15 | inline namespace render 16 | { 17 | 18 | enum class StencilOperation : std::uint32_t 19 | { 20 | Keep, 21 | Zero, 22 | Replace, 23 | IncrementAndClamp, 24 | DecrementAndClamp, 25 | Invert, 26 | IncrementAndWrap, 27 | DecrementAndWrap, 28 | }; 29 | 30 | } // inline namespace render 31 | 32 | } // namespace hamon 33 | 34 | #endif // HAMON_RENDER_STENCIL_OPERATION_HPP 35 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/texture.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file texture.hpp 3 | * 4 | * @brief Texture 5 | */ 6 | 7 | #ifndef HAMON_RENDER_TEXTURE_HPP 8 | #define HAMON_RENDER_TEXTURE_HPP 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | namespace hamon 18 | { 19 | 20 | inline namespace render 21 | { 22 | 23 | class Texture : public detail::Identifiable 24 | { 25 | public: 26 | explicit Texture( 27 | TextureFormat format, 28 | std::uint32_t width, 29 | std::uint32_t height, 30 | std::uint32_t mipmap_count, 31 | void const* data) 32 | : m_format(format) 33 | , m_width(width) 34 | , m_height(height) 35 | , m_mipmap_count(mipmap_count) 36 | { 37 | auto const bytes = GetMipmappedSizeInBytes( 38 | format, width, height, mipmap_count); 39 | m_pixels = std::make_shared(bytes, data); 40 | } 41 | 42 | TextureFormat GetFormat(void) const { return m_format; } 43 | std::uint32_t GetWidth(void) const { return m_width; } 44 | std::uint32_t GetHeight(void) const { return m_height; } 45 | std::uint32_t GetMipmapCount(void) const { return m_mipmap_count; } 46 | void const* GetData(void) const { return m_pixels->GetData(); } 47 | 48 | private: 49 | TextureFormat m_format; 50 | std::uint32_t m_width; 51 | std::uint32_t m_height; 52 | std::uint32_t m_mipmap_count; 53 | std::shared_ptr m_pixels; 54 | }; 55 | 56 | } // inline namespace render 57 | 58 | } // namespace hamon 59 | 60 | #endif // HAMON_RENDER_TEXTURE_HPP 61 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/type.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file type.hpp 3 | * 4 | * @brief Type 5 | */ 6 | 7 | #ifndef HAMON_RENDER_TYPE_HPP 8 | #define HAMON_RENDER_TYPE_HPP 9 | 10 | #include 11 | #include 12 | 13 | namespace hamon 14 | { 15 | 16 | inline namespace render 17 | { 18 | 19 | enum class Type : std::uint32_t 20 | { 21 | Int8, 22 | Int16, 23 | Int32, 24 | UInt8, 25 | UInt16, 26 | UInt32, 27 | Float, 28 | }; 29 | 30 | template 31 | struct TypeToEnum 32 | { 33 | private: 34 | template 35 | struct Helper; 36 | 37 | template struct Helper { static const Type value = Type::Int8; }; 38 | template struct Helper { static const Type value = Type::Int16; }; 39 | template struct Helper { static const Type value = Type::Int32; }; 40 | template struct Helper { static const Type value = Type::UInt8; }; 41 | template struct Helper { static const Type value = Type::UInt16; }; 42 | template struct Helper { static const Type value = Type::UInt32; }; 43 | 44 | public: 45 | static const Type value = Helper, sizeof(T)>::value; 46 | }; 47 | 48 | template <> 49 | struct TypeToEnum 50 | { 51 | static const Type value = Type::Float; 52 | }; 53 | 54 | } // inline namespace render 55 | 56 | } // namespace hamon 57 | 58 | #endif // HAMON_RENDER_TYPE_HPP 59 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/uniforms.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file uniforms.hpp 3 | * 4 | * @brief Uniforms 5 | */ 6 | 7 | #ifndef HAMON_RENDER_UNIFORMS_HPP 8 | #define HAMON_RENDER_UNIFORMS_HPP 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | namespace hamon 16 | { 17 | 18 | inline namespace render 19 | { 20 | 21 | class Uniforms 22 | { 23 | public: 24 | detail::UniformProxy operator[](std::string const& key) 25 | { 26 | return detail::UniformProxy{m_map[key]}; 27 | } 28 | 29 | detail::UniformBase const* operator[](std::string const& key) const 30 | { 31 | auto it = m_map.find(key); 32 | if (it != m_map.end()) 33 | { 34 | return it->second.get(); 35 | } 36 | return nullptr; 37 | } 38 | 39 | private: 40 | std::map> m_map; 41 | }; 42 | 43 | } // inline namespace render 44 | 45 | } // namespace hamon 46 | 47 | #endif // HAMON_RENDER_UNIFORMS_HPP 48 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/vertex_attribute.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file vertex_attribute.hpp 3 | * 4 | * @brief VertexAttribute 5 | */ 6 | 7 | #ifndef HAMON_RENDER_VERTEX_ATTRIBUTE_HPP 8 | #define HAMON_RENDER_VERTEX_ATTRIBUTE_HPP 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | namespace hamon 15 | { 16 | 17 | inline namespace render 18 | { 19 | 20 | struct VertexAttribute 21 | { 22 | Semantic semantic; 23 | Type type; 24 | std::size_t element_num; 25 | std::size_t offset; 26 | }; 27 | 28 | } // inline namespace render 29 | 30 | } // namespace hamon 31 | 32 | #endif // HAMON_RENDER_VERTEX_ATTRIBUTE_HPP 33 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/vertex_layout.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file vertex_layout.hpp 3 | * 4 | * @brief VertexLayout 5 | */ 6 | 7 | #ifndef HAMON_RENDER_VERTEX_LAYOUT_HPP 8 | #define HAMON_RENDER_VERTEX_LAYOUT_HPP 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | namespace hamon 16 | { 17 | 18 | inline namespace render 19 | { 20 | 21 | class VertexLayout 22 | { 23 | public: 24 | VertexLayout(std::size_t bytes, std::vector attributes) 25 | : m_bytes(bytes) 26 | , m_attributes(attributes) 27 | { 28 | } 29 | 30 | std::size_t GetBytes(void) const { return m_bytes; } 31 | 32 | std::vector const& GetAttributes(void) const 33 | { 34 | return m_attributes; 35 | } 36 | 37 | private: 38 | std::size_t m_bytes; 39 | std::vector m_attributes; 40 | }; 41 | 42 | } // inline namespace render 43 | 44 | } // namespace hamon 45 | 46 | #endif // HAMON_RENDER_VERTEX_LAYOUT_HPP 47 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/viewport.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file viewport.hpp 3 | * 4 | * @brief Viewport 5 | */ 6 | 7 | #ifndef HAMON_RENDER_VIEWPORT_HPP 8 | #define HAMON_RENDER_VIEWPORT_HPP 9 | 10 | namespace hamon 11 | { 12 | 13 | inline namespace render 14 | { 15 | 16 | struct Viewport 17 | { 18 | float left {0.0f}; 19 | float top {0.0f}; 20 | float width {0.0f}; 21 | float height {0.0f}; 22 | float min_depth {0.0f}; 23 | float max_depth {1.0f}; 24 | }; 25 | 26 | } // inline namespace render 27 | 28 | } // namespace hamon 29 | 30 | #endif // HAMON_RENDER_VIEWPORT_HPP 31 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/vulkan/array_proxy.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file array_proxy.hpp 3 | * 4 | * @brief ArrayProxy 5 | */ 6 | 7 | #ifndef HAMON_RENDER_VULKAN_ARRAY_PROXY_HPP 8 | #define HAMON_RENDER_VULKAN_ARRAY_PROXY_HPP 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | namespace hamon 15 | { 16 | 17 | inline namespace render 18 | { 19 | 20 | namespace vulkan 21 | { 22 | 23 | template 24 | class ArrayProxy 25 | { 26 | public: 27 | constexpr ArrayProxy() 28 | : m_ptr(nullptr) 29 | , m_size(0) 30 | {} 31 | 32 | constexpr ArrayProxy(std::nullptr_t) 33 | : m_ptr(nullptr) 34 | , m_size(0) 35 | {} 36 | 37 | template 38 | constexpr ArrayProxy(T const (&arr)[N]) 39 | : m_ptr(arr) 40 | , m_size(N) 41 | {} 42 | 43 | constexpr ArrayProxy(std::vector const& vec) 44 | : m_ptr(vec.empty() ? nullptr : vec.data()) 45 | , m_size(static_cast(vec.size())) 46 | {} 47 | 48 | constexpr ArrayProxy(T const& value) 49 | : m_ptr(&value) 50 | , m_size(1) 51 | {} 52 | 53 | constexpr T const* GetData(void) const 54 | { 55 | return m_ptr; 56 | } 57 | 58 | constexpr std::uint32_t GetSize(void) const 59 | { 60 | return m_size; 61 | } 62 | 63 | private: 64 | T const* m_ptr; 65 | std::uint32_t m_size; 66 | }; 67 | 68 | } // namespace vulkan 69 | 70 | } // inline namespace render 71 | 72 | } // namespace hamon 73 | 74 | #endif // HAMON_RENDER_VULKAN_ARRAY_PROXY_HPP 75 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/vulkan/blend_operation.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file blend_operation.hpp 3 | * 4 | * @brief BlendOperation 5 | */ 6 | 7 | #ifndef HAMON_RENDER_VULKAN_BLEND_OPERATION_HPP 8 | #define HAMON_RENDER_VULKAN_BLEND_OPERATION_HPP 9 | 10 | #include 11 | #include 12 | 13 | namespace hamon 14 | { 15 | 16 | inline namespace render 17 | { 18 | 19 | namespace vulkan 20 | { 21 | 22 | inline ::VkBlendOp 23 | BlendOperation(render::BlendOperation op) 24 | { 25 | switch (op) 26 | { 27 | case render::BlendOperation::Add: return VK_BLEND_OP_ADD; 28 | case render::BlendOperation::Subtract: return VK_BLEND_OP_SUBTRACT; 29 | case render::BlendOperation::ReverseSubtract: return VK_BLEND_OP_REVERSE_SUBTRACT; 30 | case render::BlendOperation::Min: return VK_BLEND_OP_MIN; 31 | case render::BlendOperation::Max: return VK_BLEND_OP_MAX; 32 | } 33 | return VK_BLEND_OP_ADD; 34 | } 35 | 36 | } // namespace vulkan 37 | 38 | } // inline namespace render 39 | 40 | } // namespace hamon 41 | 42 | #endif // HAMON_RENDER_VULKAN_BLEND_OPERATION_HPP 43 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/vulkan/border_color.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file border_color.hpp 3 | * 4 | * @brief BorderColor 5 | */ 6 | 7 | #ifndef HAMON_RENDER_VULKAN_BORDER_COLOR_HPP 8 | #define HAMON_RENDER_VULKAN_BORDER_COLOR_HPP 9 | 10 | #include 11 | #include 12 | 13 | namespace hamon 14 | { 15 | 16 | inline namespace render 17 | { 18 | 19 | namespace vulkan 20 | { 21 | 22 | inline ::VkBorderColor 23 | BorderColor(render::BorderColor border_color) 24 | { 25 | switch (border_color) 26 | { 27 | case render::BorderColor::TransparentBlack: return VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK; 28 | case render::BorderColor::OpaqueBlack: return VK_BORDER_COLOR_FLOAT_OPAQUE_BLACK; 29 | case render::BorderColor::OpaqueWhite: return VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; 30 | } 31 | return VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK; 32 | } 33 | 34 | } // namespace vulkan 35 | 36 | } // inline namespace render 37 | 38 | } // namespace hamon 39 | 40 | #endif // HAMON_RENDER_VULKAN_BORDER_COLOR_HPP 41 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/vulkan/color_write_mask.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file color_write_mask.hpp 3 | * 4 | * @brief ColorWriteMask 5 | */ 6 | 7 | #ifndef HAMON_RENDER_VULKAN_COLOR_WRITE_MASK_HPP 8 | #define HAMON_RENDER_VULKAN_COLOR_WRITE_MASK_HPP 9 | 10 | #include 11 | #include 12 | 13 | namespace hamon 14 | { 15 | 16 | inline namespace render 17 | { 18 | 19 | namespace vulkan 20 | { 21 | 22 | inline ::VkColorComponentFlags 23 | ColorWriteMask(std::uint32_t mask) 24 | { 25 | ::VkColorComponentFlags result{}; 26 | 27 | if (mask & render::ColorWriteMask::Red) 28 | { 29 | result |= VK_COLOR_COMPONENT_R_BIT; 30 | } 31 | if (mask & render::ColorWriteMask::Green) 32 | { 33 | result |= VK_COLOR_COMPONENT_G_BIT; 34 | } 35 | if (mask & render::ColorWriteMask::Blue) 36 | { 37 | result |= VK_COLOR_COMPONENT_B_BIT; 38 | } 39 | if (mask & render::ColorWriteMask::Alpha) 40 | { 41 | result |= VK_COLOR_COMPONENT_A_BIT; 42 | } 43 | 44 | return result; 45 | } 46 | 47 | } // namespace vulkan 48 | 49 | } // inline namespace render 50 | 51 | } // namespace hamon 52 | 53 | #endif // HAMON_RENDER_VULKAN_COLOR_WRITE_MASK_HPP 54 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/vulkan/compare_operation.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file compare_operation.hpp 3 | * 4 | * @brief CompareOperation 5 | */ 6 | 7 | #ifndef HAMON_RENDER_VULKAN_compare_operation_HPP 8 | #define HAMON_RENDER_VULKAN_compare_operation_HPP 9 | 10 | #include 11 | #include 12 | 13 | namespace hamon 14 | { 15 | 16 | inline namespace render 17 | { 18 | 19 | namespace vulkan 20 | { 21 | 22 | inline ::VkCompareOp 23 | CompareOperation(render::CompareOperation op) 24 | { 25 | switch (op) 26 | { 27 | case render::CompareOperation::Never: return VK_COMPARE_OP_NEVER; 28 | case render::CompareOperation::Less: return VK_COMPARE_OP_LESS; 29 | case render::CompareOperation::Equal: return VK_COMPARE_OP_EQUAL; 30 | case render::CompareOperation::LessEqual: return VK_COMPARE_OP_LESS_OR_EQUAL; 31 | case render::CompareOperation::Greater: return VK_COMPARE_OP_GREATER; 32 | case render::CompareOperation::NotEqual: return VK_COMPARE_OP_NOT_EQUAL; 33 | case render::CompareOperation::GreaterEqual: return VK_COMPARE_OP_GREATER_OR_EQUAL; 34 | case render::CompareOperation::Always: return VK_COMPARE_OP_ALWAYS; 35 | } 36 | return VK_COMPARE_OP_NEVER; 37 | } 38 | 39 | } // namespace vulkan 40 | 41 | } // inline namespace render 42 | 43 | } // namespace hamon 44 | 45 | #endif // HAMON_RENDER_VULKAN_compare_operation_HPP 46 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/vulkan/cull_mode.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file cull_mode.hpp 3 | * 4 | * @brief CullMode 5 | */ 6 | 7 | #ifndef HAMON_RENDER_VULKAN_CULL_MODE_HPP 8 | #define HAMON_RENDER_VULKAN_CULL_MODE_HPP 9 | 10 | #include 11 | #include 12 | 13 | namespace hamon 14 | { 15 | 16 | inline namespace render 17 | { 18 | 19 | namespace vulkan 20 | { 21 | 22 | inline ::VkCullModeFlags 23 | CullMode(render::CullMode mode) 24 | { 25 | switch (mode) 26 | { 27 | case render::CullMode::None: return VK_CULL_MODE_NONE; 28 | case render::CullMode::Front: return VK_CULL_MODE_FRONT_BIT; 29 | case render::CullMode::Back: return VK_CULL_MODE_BACK_BIT; 30 | } 31 | return VK_CULL_MODE_NONE; 32 | } 33 | 34 | } // namespace vulkan 35 | 36 | } // inline namespace render 37 | 38 | } // namespace hamon 39 | 40 | #endif // HAMON_RENDER_VULKAN_CULL_MODE_HPP 41 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/vulkan/debug_report_callback.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file debug_report_callback.hpp 3 | * 4 | * @brief DebugReportCallback 5 | */ 6 | 7 | #ifndef HAMON_RENDER_VULKAN_DEBUG_REPORT_CALLBACK_HPP 8 | #define HAMON_RENDER_VULKAN_DEBUG_REPORT_CALLBACK_HPP 9 | 10 | #include 11 | #include 12 | 13 | namespace hamon 14 | { 15 | 16 | inline namespace render 17 | { 18 | 19 | namespace vulkan 20 | { 21 | 22 | class DebugReportCallback 23 | { 24 | public: 25 | DebugReportCallback( 26 | vulkan::Instance* instance, 27 | ::VkDebugReportFlagsEXT flags, 28 | ::PFN_vkDebugReportCallbackEXT callback) 29 | : m_instance(instance) 30 | { 31 | ::VkDebugReportCallbackCreateInfoEXT info{}; 32 | info.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT; 33 | info.flags = flags; 34 | info.pfnCallback = callback; 35 | m_callback = m_instance->CreateDebugReportCallback(info); 36 | } 37 | 38 | ~DebugReportCallback() 39 | { 40 | m_instance->DestroyDebugReportCallback(m_callback); 41 | } 42 | 43 | private: 44 | ::VkDebugReportCallbackEXT m_callback; 45 | vulkan::Instance* m_instance; 46 | }; 47 | 48 | } // namespace vulkan 49 | 50 | } // inline namespace render 51 | 52 | } // namespace hamon 53 | 54 | #endif // HAMON_RENDER_VULKAN_DEBUG_REPORT_CALLBACK_HPP 55 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/vulkan/descriptor_set_layout.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file descriptor_set_layout.hpp 3 | * 4 | * @brief DescriptorSetLayout 5 | */ 6 | 7 | #ifndef HAMON_RENDER_VULKAN_DESCRIPTOR_SET_LAYOUT_HPP 8 | #define HAMON_RENDER_VULKAN_DESCRIPTOR_SET_LAYOUT_HPP 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | namespace hamon 15 | { 16 | 17 | inline namespace render 18 | { 19 | 20 | namespace vulkan 21 | { 22 | 23 | class DescriptorSetLayout 24 | { 25 | public: 26 | DescriptorSetLayout( 27 | vulkan::Device* device, 28 | vulkan::ArrayProxy<::VkDescriptorSetLayoutBinding> layout_bindings) 29 | : m_device(device) 30 | { 31 | ::VkDescriptorSetLayoutCreateInfo info{}; 32 | info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; 33 | info.pNext = NULL; 34 | info.flags = 0; 35 | info.bindingCount = layout_bindings.GetSize(); 36 | info.pBindings = layout_bindings.GetData(); 37 | 38 | m_descriptor_set_layout = m_device->CreateDescriptorSetLayout(info); 39 | } 40 | 41 | ~DescriptorSetLayout() 42 | { 43 | m_device->DestroyDescriptorSetLayout(m_descriptor_set_layout); 44 | } 45 | 46 | ::VkDescriptorSetLayout const& Get(void) const 47 | { 48 | return m_descriptor_set_layout; 49 | } 50 | 51 | private: 52 | ::VkDescriptorSetLayout m_descriptor_set_layout; 53 | vulkan::Device* m_device; 54 | }; 55 | 56 | } // namespace vulkan 57 | 58 | } // inline namespace render 59 | 60 | } // namespace hamon 61 | 62 | #endif // HAMON_RENDER_VULKAN_DESCRIPTOR_SET_LAYOUT_HPP 63 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/vulkan/fence.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file fence.hpp 3 | * 4 | * @brief Fence 5 | */ 6 | 7 | #ifndef HAMON_RENDER_VULKAN_fence_HPP 8 | #define HAMON_RENDER_VULKAN_fence_HPP 9 | 10 | #include 11 | #include 12 | 13 | namespace hamon 14 | { 15 | 16 | inline namespace render 17 | { 18 | 19 | namespace vulkan 20 | { 21 | 22 | class Fence 23 | { 24 | public: 25 | Fence(vulkan::Device* device) 26 | : m_device(device) 27 | { 28 | ::VkFenceCreateInfo info{}; 29 | info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; 30 | info.pNext = nullptr; 31 | info.flags = 0; 32 | m_fence = m_device->CreateFence(info); 33 | } 34 | 35 | ~Fence() 36 | { 37 | m_device->DestroyFence(m_fence); 38 | } 39 | 40 | ::VkResult Wait(::VkBool32 wait_all, std::uint64_t timeout) 41 | { 42 | return m_device->WaitForFences(m_fence, wait_all, timeout); 43 | } 44 | 45 | void Reset() 46 | { 47 | m_device->ResetFences(m_fence); 48 | } 49 | 50 | ::VkFence const& Get(void) const 51 | { 52 | return m_fence; 53 | } 54 | 55 | private: 56 | ::VkFence m_fence; 57 | vulkan::Device* m_device; 58 | }; 59 | 60 | } // namespace vulkan 61 | 62 | } // inline namespace render 63 | 64 | } // namespace hamon 65 | 66 | #endif // HAMON_RENDER_VULKAN_fence_HPP 67 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/vulkan/fill_mode.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file fill_mode.hpp 3 | * 4 | * @brief FillMode 5 | */ 6 | 7 | #ifndef HAMON_RENDER_VULKAN_FILL_MODE_HPP 8 | #define HAMON_RENDER_VULKAN_FILL_MODE_HPP 9 | 10 | #include 11 | #include 12 | 13 | namespace hamon 14 | { 15 | 16 | inline namespace render 17 | { 18 | 19 | namespace vulkan 20 | { 21 | 22 | inline ::VkPolygonMode 23 | FillMode(render::FillMode mode) 24 | { 25 | switch (mode) 26 | { 27 | case render::FillMode::Solid: return VK_POLYGON_MODE_FILL; 28 | case render::FillMode::Wireframe: return VK_POLYGON_MODE_LINE; 29 | } 30 | return VK_POLYGON_MODE_FILL; 31 | } 32 | 33 | } // namespace vulkan 34 | 35 | } // inline namespace render 36 | 37 | } // namespace hamon 38 | 39 | #endif // HAMON_RENDER_VULKAN_FILL_MODE_HPP 40 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/vulkan/filter_mode.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file filter_mode.hpp 3 | * 4 | * @brief FilterMode 5 | */ 6 | 7 | #ifndef HAMON_RENDER_VULKAN_filter_mode_HPP 8 | #define HAMON_RENDER_VULKAN_filter_mode_HPP 9 | 10 | #include 11 | #include 12 | 13 | namespace hamon 14 | { 15 | 16 | inline namespace render 17 | { 18 | 19 | namespace vulkan 20 | { 21 | 22 | inline ::VkFilter 23 | FilterMode(render::FilterMode mode) 24 | { 25 | switch (mode) 26 | { 27 | case render::FilterMode::Nearest: return VK_FILTER_NEAREST; 28 | case render::FilterMode::Linear: return VK_FILTER_LINEAR; 29 | } 30 | return VK_FILTER_NEAREST; 31 | } 32 | 33 | } // namespace vulkan 34 | 35 | } // inline namespace render 36 | 37 | } // namespace hamon 38 | 39 | #endif // HAMON_RENDER_VULKAN_filter_mode_HPP 40 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/vulkan/front_face.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file front_face.hpp 3 | * 4 | * @brief FrontFace 5 | */ 6 | 7 | #ifndef HAMON_RENDER_VULKAN_FRONT_FACE_HPP 8 | #define HAMON_RENDER_VULKAN_FRONT_FACE_HPP 9 | 10 | #include 11 | #include 12 | 13 | namespace hamon 14 | { 15 | 16 | inline namespace render 17 | { 18 | 19 | namespace vulkan 20 | { 21 | 22 | inline ::VkFrontFace 23 | FrontFace(render::FrontFace face) 24 | { 25 | switch (face) 26 | { 27 | case render::FrontFace::Clockwise: return VK_FRONT_FACE_CLOCKWISE; 28 | case render::FrontFace::CounterClockwise: return VK_FRONT_FACE_COUNTER_CLOCKWISE; 29 | } 30 | return VK_FRONT_FACE_CLOCKWISE; 31 | } 32 | 33 | } // namespace vulkan 34 | 35 | } // inline namespace render 36 | 37 | } // namespace hamon 38 | 39 | #endif // HAMON_RENDER_VULKAN_FRONT_FACE_HPP 40 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/vulkan/geometry.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file geometry.hpp 3 | * 4 | * @brief Geometry 5 | */ 6 | 7 | #ifndef HAMON_RENDER_VULKAN_GEOMETRY_HPP 8 | #define HAMON_RENDER_VULKAN_GEOMETRY_HPP 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | namespace hamon 18 | { 19 | 20 | inline namespace render 21 | { 22 | 23 | namespace vulkan 24 | { 25 | 26 | class Geometry 27 | { 28 | public: 29 | explicit Geometry(vulkan::Device* device, render::Geometry const& geometry) 30 | { 31 | m_vertex_buffer = std::make_unique(device, geometry); 32 | if (geometry.GetIndexArray() != nullptr) 33 | { 34 | m_index_buffer = std::make_unique(device, geometry.GetIndexArray()); 35 | } 36 | } 37 | 38 | ~Geometry() 39 | { 40 | } 41 | 42 | void Draw(vulkan::CommandBuffer* command_buffer) 43 | { 44 | m_vertex_buffer->Bind(command_buffer); 45 | if (m_index_buffer) 46 | { 47 | m_index_buffer->Bind(command_buffer); 48 | m_index_buffer->Draw(command_buffer); 49 | } 50 | else 51 | { 52 | m_vertex_buffer->Draw(command_buffer); 53 | } 54 | } 55 | 56 | private: 57 | std::unique_ptr m_vertex_buffer; 58 | std::unique_ptr m_index_buffer; 59 | }; 60 | 61 | } // namespace vulkan 62 | 63 | } // inline namespace render 64 | 65 | } // namespace hamon 66 | 67 | #endif // HAMON_RENDER_VULKAN_GEOMETRY_HPP 68 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/vulkan/index_type.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file index_type.hpp 3 | * 4 | * @brief IndexType 5 | */ 6 | 7 | #ifndef HAMON_RENDER_VULKAN_index_type_HPP 8 | #define HAMON_RENDER_VULKAN_index_type_HPP 9 | 10 | #include 11 | #include 12 | 13 | namespace hamon 14 | { 15 | 16 | inline namespace render 17 | { 18 | 19 | namespace vulkan 20 | { 21 | 22 | inline ::VkIndexType 23 | IndexType(render::IndexType type) 24 | { 25 | switch (type) 26 | { 27 | case render::IndexType::UInt16: return VK_INDEX_TYPE_UINT16; 28 | case render::IndexType::UInt32: return VK_INDEX_TYPE_UINT32; 29 | } 30 | return VK_INDEX_TYPE_UINT16; 31 | } 32 | 33 | } // namespace vulkan 34 | 35 | } // inline namespace render 36 | 37 | } // namespace hamon 38 | 39 | #endif // HAMON_RENDER_VULKAN_index_type_HPP 40 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/vulkan/mipmap_mode.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file mipmap_mode.hpp 3 | * 4 | * @brief MipmapMode 5 | */ 6 | 7 | #ifndef HAMON_RENDER_VULKAN_MIPMAP_MODE_HPP 8 | #define HAMON_RENDER_VULKAN_MIPMAP_MODE_HPP 9 | 10 | #include 11 | #include 12 | 13 | namespace hamon 14 | { 15 | 16 | inline namespace render 17 | { 18 | 19 | namespace vulkan 20 | { 21 | 22 | inline ::VkSamplerMipmapMode 23 | MipmapMode(render::MipmapMode mode) 24 | { 25 | switch (mode) 26 | { 27 | case hamon::render::MipmapMode::Nearest: return VK_SAMPLER_MIPMAP_MODE_NEAREST; 28 | case hamon::render::MipmapMode::Linear: return VK_SAMPLER_MIPMAP_MODE_LINEAR; 29 | } 30 | return VK_SAMPLER_MIPMAP_MODE_NEAREST; 31 | } 32 | 33 | } // namespace vulkan 34 | 35 | } // inline namespace render 36 | 37 | } // namespace hamon 38 | 39 | #endif // HAMON_RENDER_VULKAN_MIPMAP_MODE_HPP 40 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/vulkan/pipeline_dynamic_state.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file pipeline_dynamic_state.hpp 3 | * 4 | * @brief PipelineDynamicState 5 | */ 6 | 7 | #ifndef HAMON_RENDER_VULKAN_PIPELINE_DYNAMIC_STATE_HPP 8 | #define HAMON_RENDER_VULKAN_PIPELINE_DYNAMIC_STATE_HPP 9 | 10 | #include 11 | #include 12 | 13 | namespace hamon 14 | { 15 | 16 | inline namespace render 17 | { 18 | 19 | namespace vulkan 20 | { 21 | 22 | inline ::VkPipelineDynamicStateCreateInfo 23 | PipelineDynamicState(vulkan::ArrayProxy<::VkDynamicState> dynamic_state_enables) 24 | { 25 | ::VkPipelineDynamicStateCreateInfo info {}; 26 | info.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; 27 | info.pNext = nullptr; 28 | info.flags = 0; 29 | info.dynamicStateCount = dynamic_state_enables.GetSize(); 30 | info.pDynamicStates = dynamic_state_enables.GetData(); 31 | return info; 32 | } 33 | 34 | } // namespace vulkan 35 | 36 | } // inline namespace render 37 | 38 | } // namespace hamon 39 | 40 | #endif // HAMON_RENDER_VULKAN_PIPELINE_DYNAMIC_STATE_HPP 41 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/vulkan/pipeline_input_assembly_state.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file pipeline_input_assembly_state.hpp 3 | * 4 | * @brief PipelineInputAssemblyState 5 | */ 6 | 7 | #ifndef HAMON_RENDER_VULKAN_PIPELINE_INPUT_ASSEMBLY_STATE_HPP 8 | #define HAMON_RENDER_VULKAN_PIPELINE_INPUT_ASSEMBLY_STATE_HPP 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | namespace hamon 15 | { 16 | 17 | inline namespace render 18 | { 19 | 20 | namespace vulkan 21 | { 22 | 23 | inline ::VkPipelineInputAssemblyStateCreateInfo 24 | PipelineInputAssemblyState(render::PrimitiveTopology primitive_topology) 25 | { 26 | ::VkPipelineInputAssemblyStateCreateInfo info{}; 27 | info.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; 28 | info.pNext = nullptr; 29 | info.flags = 0; 30 | info.primitiveRestartEnable = VK_FALSE; 31 | info.topology = vulkan::PrimitiveTopology(primitive_topology); 32 | return info; 33 | } 34 | 35 | } // namespace vulkan 36 | 37 | } // inline namespace render 38 | 39 | } // namespace hamon 40 | 41 | #endif // HAMON_RENDER_VULKAN_PIPELINE_INPUT_ASSEMBLY_STATE_HPP 42 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/vulkan/pipeline_multisample_state.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file pipeline_multisample_state.hpp 3 | * 4 | * @brief PipelineMultisampleState 5 | */ 6 | 7 | #ifndef HAMON_RENDER_VULKAN_PIPELINE_MULTISAMPLE_STATE_HPP 8 | #define HAMON_RENDER_VULKAN_PIPELINE_MULTISAMPLE_STATE_HPP 9 | 10 | #include 11 | 12 | namespace hamon 13 | { 14 | 15 | inline namespace render 16 | { 17 | 18 | namespace vulkan 19 | { 20 | 21 | inline ::VkPipelineMultisampleStateCreateInfo 22 | PipelineMultisampleState(::VkSampleCountFlagBits samples) 23 | { 24 | ::VkPipelineMultisampleStateCreateInfo info{}; 25 | info.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; 26 | info.pNext = nullptr; 27 | info.flags = 0; 28 | info.pSampleMask = nullptr; 29 | info.rasterizationSamples = samples; 30 | info.sampleShadingEnable = VK_FALSE; 31 | info.alphaToCoverageEnable = VK_FALSE; 32 | info.alphaToOneEnable = VK_FALSE; 33 | info.minSampleShading = 0.0; 34 | return info; 35 | } 36 | 37 | } // namespace vulkan 38 | 39 | } // inline namespace render 40 | 41 | } // namespace hamon 42 | 43 | #endif // HAMON_RENDER_VULKAN_PIPELINE_MULTISAMPLE_STATE_HPP 44 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/vulkan/pipeline_shader_stage.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file pipeline_shader_stage.hpp 3 | * 4 | * @brief PipelineShaderStage 5 | */ 6 | 7 | #ifndef HAMON_RENDER_VULKAN_PIPELINE_SHADER_STAGE_HPP 8 | #define HAMON_RENDER_VULKAN_PIPELINE_SHADER_STAGE_HPP 9 | 10 | #include 11 | #include 12 | 13 | namespace hamon 14 | { 15 | 16 | inline namespace render 17 | { 18 | 19 | namespace vulkan 20 | { 21 | 22 | inline ::VkPipelineShaderStageCreateInfo 23 | PipelineShaderStage(vulkan::Shader const& shader) 24 | { 25 | ::VkPipelineShaderStageCreateInfo info{}; 26 | info.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; 27 | info.pNext = nullptr; 28 | info.flags = 0; 29 | info.stage = shader.GetStage(); 30 | info.module = shader.GetModule(); 31 | info.pName = "main"; // TODO 32 | info.pSpecializationInfo = nullptr; 33 | return info; 34 | } 35 | 36 | } // namespace vulkan 37 | 38 | } // inline namespace render 39 | 40 | } // namespace hamon 41 | 42 | #endif // HAMON_RENDER_VULKAN_PIPELINE_SHADER_STAGE_HPP 43 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/vulkan/pipeline_viewport_state.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file pipeline_viewport_state.hpp 3 | * 4 | * @brief PipelineViewportState 5 | */ 6 | 7 | #ifndef HAMON_RENDER_VULKAN_PIPELINE_VIEWPORT_STATE_HPP 8 | #define HAMON_RENDER_VULKAN_PIPELINE_VIEWPORT_STATE_HPP 9 | 10 | #include 11 | 12 | namespace hamon 13 | { 14 | 15 | inline namespace render 16 | { 17 | 18 | namespace vulkan 19 | { 20 | 21 | inline ::VkPipelineViewportStateCreateInfo 22 | PipelineViewportState(void) 23 | { 24 | ::VkPipelineViewportStateCreateInfo info {}; 25 | info.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; 26 | info.pNext = nullptr; 27 | info.flags = 0; 28 | info.viewportCount = 1; 29 | info.scissorCount = 1; 30 | info.pScissors = nullptr; 31 | info.pViewports = nullptr; 32 | return info; 33 | } 34 | 35 | } // namespace vulkan 36 | 37 | } // inline namespace render 38 | 39 | } // namespace hamon 40 | 41 | #endif // HAMON_RENDER_VULKAN_PIPELINE_VIEWPORT_STATE_HPP 42 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/vulkan/primitive_topology.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file primitive_topology.hpp 3 | * 4 | * @brief PrimitiveTopology 5 | */ 6 | 7 | #ifndef HAMON_RENDER_VULKAN_PRIMITIVE_TOPOLOGY_HPP 8 | #define HAMON_RENDER_VULKAN_PRIMITIVE_TOPOLOGY_HPP 9 | 10 | #include 11 | #include 12 | 13 | namespace hamon 14 | { 15 | 16 | inline namespace render 17 | { 18 | 19 | namespace vulkan 20 | { 21 | 22 | inline ::VkPrimitiveTopology 23 | PrimitiveTopology(render::PrimitiveTopology primitive_topology) 24 | { 25 | switch (primitive_topology) 26 | { 27 | case render::PrimitiveTopology::PointList: return VK_PRIMITIVE_TOPOLOGY_POINT_LIST; 28 | case render::PrimitiveTopology::LineList: return VK_PRIMITIVE_TOPOLOGY_LINE_LIST; 29 | case render::PrimitiveTopology::TriangleList: return VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST; 30 | } 31 | return VK_PRIMITIVE_TOPOLOGY_POINT_LIST; 32 | } 33 | 34 | } // namespace vulkan 35 | 36 | } // inline namespace render 37 | 38 | } // namespace hamon 39 | 40 | #endif // HAMON_RENDER_VULKAN_PRIMITIVE_TOPOLOGY_HPP 41 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/vulkan/sampler_address_mode.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file sampler_address_mode.hpp 3 | * 4 | * @brief SamplerAddressMode 5 | */ 6 | 7 | #ifndef HAMON_RENDER_VULKAN_SAMPLER_ADDRESS_MODE_HPP 8 | #define HAMON_RENDER_VULKAN_SAMPLER_ADDRESS_MODE_HPP 9 | 10 | #include 11 | #include 12 | 13 | namespace hamon 14 | { 15 | 16 | inline namespace render 17 | { 18 | 19 | namespace vulkan 20 | { 21 | 22 | inline ::VkSamplerAddressMode 23 | SamplerAddressMode(render::SamplerAddressMode mode) 24 | { 25 | switch (mode) 26 | { 27 | case render::SamplerAddressMode::Repeat: return VK_SAMPLER_ADDRESS_MODE_REPEAT; 28 | case render::SamplerAddressMode::MirroredRepeat: return VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT; 29 | case render::SamplerAddressMode::ClampToEdge: return VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; 30 | case render::SamplerAddressMode::ClampToBorder: return VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER; 31 | case render::SamplerAddressMode::MirrorClampToEdge: return VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE; 32 | } 33 | return VK_SAMPLER_ADDRESS_MODE_REPEAT; 34 | } 35 | 36 | } // namespace vulkan 37 | 38 | } // inline namespace render 39 | 40 | } // namespace hamon 41 | 42 | #endif // HAMON_RENDER_VULKAN_SAMPLER_ADDRESS_MODE_HPP 43 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/vulkan/semaphore.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file semaphore.hpp 3 | * 4 | * @brief Semaphore 5 | */ 6 | 7 | #ifndef HAMON_RENDER_VULKAN_SEMAPHORE_HPP 8 | #define HAMON_RENDER_VULKAN_SEMAPHORE_HPP 9 | 10 | #include 11 | #include 12 | 13 | namespace hamon 14 | { 15 | 16 | inline namespace render 17 | { 18 | 19 | namespace vulkan 20 | { 21 | 22 | class Semaphore 23 | { 24 | public: 25 | Semaphore(vulkan::Device* device) 26 | : m_device(device) 27 | { 28 | ::VkSemaphoreCreateInfo info{}; 29 | info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; 30 | info.pNext = nullptr; 31 | info.flags = 0; 32 | m_semaphore = m_device->CreateSemaphore(info); 33 | } 34 | 35 | ~Semaphore() 36 | { 37 | m_device->DestroySemaphore(m_semaphore); 38 | } 39 | 40 | ::VkSemaphore const& Get(void) const 41 | { 42 | return m_semaphore; 43 | } 44 | 45 | private: 46 | ::VkSemaphore m_semaphore; 47 | vulkan::Device* m_device; 48 | }; 49 | 50 | } // namespace vulkan 51 | 52 | } // inline namespace render 53 | 54 | } // namespace hamon 55 | 56 | #endif // HAMON_RENDER_VULKAN_SEMAPHORE_HPP 57 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/vulkan/shader.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file shader.hpp 3 | * 4 | * @brief Shader 5 | */ 6 | 7 | #ifndef HAMON_RENDER_VULKAN_SHADER_HPP 8 | #define HAMON_RENDER_VULKAN_SHADER_HPP 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | namespace hamon 18 | { 19 | 20 | inline namespace render 21 | { 22 | 23 | namespace vulkan 24 | { 25 | 26 | class Shader 27 | { 28 | public: 29 | explicit Shader( 30 | vulkan::Device* device, 31 | render::ShaderStage stage, 32 | std::vector const& spv) 33 | : m_shader_module(device, spv) 34 | , m_stage(vulkan::ShaderStage(stage)) 35 | { 36 | } 37 | 38 | ::VkShaderModule GetModule(void) const 39 | { 40 | return m_shader_module.Get(); 41 | } 42 | 43 | ::VkShaderStageFlagBits GetStage(void) const 44 | { 45 | return m_stage; 46 | } 47 | 48 | private: 49 | vulkan::ShaderModule m_shader_module; 50 | ::VkShaderStageFlagBits m_stage; 51 | }; 52 | 53 | } // namespace vulkan 54 | 55 | } // inline namespace render 56 | 57 | } // namespace hamon 58 | 59 | #endif // HAMON_RENDER_VULKAN_SHADER_HPP 60 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/vulkan/shader_stage.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file shader_stage.hpp 3 | * 4 | * @brief ShaderStage 5 | */ 6 | 7 | #ifndef HAMON_RENDER_VULKAN_SHADER_STAGE_HPP 8 | #define HAMON_RENDER_VULKAN_SHADER_STAGE_HPP 9 | 10 | #include 11 | #include 12 | 13 | namespace hamon 14 | { 15 | 16 | inline namespace render 17 | { 18 | 19 | namespace vulkan 20 | { 21 | 22 | inline ::VkShaderStageFlagBits ShaderStage(render::ShaderStage stage) 23 | { 24 | switch (stage) 25 | { 26 | case render::ShaderStage::Compute: return VK_SHADER_STAGE_COMPUTE_BIT; 27 | case render::ShaderStage::Vertex: return VK_SHADER_STAGE_VERTEX_BIT; 28 | case render::ShaderStage::Geometry: return VK_SHADER_STAGE_GEOMETRY_BIT; 29 | case render::ShaderStage::TessellationControl: return VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT; 30 | case render::ShaderStage::TessellationEvaluation: return VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT; 31 | case render::ShaderStage::Fragment: return VK_SHADER_STAGE_FRAGMENT_BIT; 32 | } 33 | return VK_SHADER_STAGE_VERTEX_BIT; 34 | } 35 | 36 | } // namespace vulkan 37 | 38 | } // inline namespace render 39 | 40 | } // namespace hamon 41 | 42 | #endif // HAMON_RENDER_VULKAN_SHADER_STAGE_HPP 43 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/vulkan/spirv_program.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file spirv_program.hpp 3 | * 4 | * @brief SpirvProgram 5 | */ 6 | 7 | #ifndef HAMON_RENDER_VULKAN_SPIRV_PROGRAM_HPP 8 | #define HAMON_RENDER_VULKAN_SPIRV_PROGRAM_HPP 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | namespace hamon 15 | { 16 | 17 | inline namespace render 18 | { 19 | 20 | namespace vulkan 21 | { 22 | 23 | class SpirvProgram 24 | { 25 | public: 26 | explicit SpirvProgram(render::Program const& program) 27 | { 28 | for (auto const& shader : program.GetShaders()) 29 | { 30 | m_shaders.emplace_back(shader); 31 | } 32 | } 33 | 34 | std::vector const& GetShaders(void) const 35 | { 36 | return m_shaders; 37 | } 38 | 39 | private: 40 | std::vector m_shaders; 41 | }; 42 | 43 | } // namespace vulkan 44 | 45 | } // inline namespace render 46 | 47 | } // namespace hamon 48 | 49 | #endif // HAMON_RENDER_VULKAN_SPIRV_PROGRAM_HPP 50 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/vulkan/stencil_operation.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file stencil_operation.hpp 3 | * 4 | * @brief StencilOperation 5 | */ 6 | 7 | #ifndef HAMON_RENDER_VULKAN_STENCIL_OPERATION_HPP 8 | #define HAMON_RENDER_VULKAN_STENCIL_OPERATION_HPP 9 | 10 | #include 11 | #include 12 | 13 | namespace hamon 14 | { 15 | 16 | inline namespace render 17 | { 18 | 19 | namespace vulkan 20 | { 21 | 22 | inline ::VkStencilOp 23 | StencilOperation(render::StencilOperation op) 24 | { 25 | switch (op) 26 | { 27 | case render::StencilOperation::Keep: return VK_STENCIL_OP_KEEP; 28 | case render::StencilOperation::Zero: return VK_STENCIL_OP_ZERO; 29 | case render::StencilOperation::Replace: return VK_STENCIL_OP_REPLACE; 30 | case render::StencilOperation::IncrementAndClamp: return VK_STENCIL_OP_INCREMENT_AND_CLAMP; 31 | case render::StencilOperation::DecrementAndClamp: return VK_STENCIL_OP_DECREMENT_AND_CLAMP; 32 | case render::StencilOperation::Invert: return VK_STENCIL_OP_INVERT; 33 | case render::StencilOperation::IncrementAndWrap: return VK_STENCIL_OP_INCREMENT_AND_WRAP; 34 | case render::StencilOperation::DecrementAndWrap: return VK_STENCIL_OP_DECREMENT_AND_WRAP; 35 | } 36 | return VK_STENCIL_OP_KEEP; 37 | } 38 | 39 | } // namespace vulkan 40 | 41 | } // inline namespace render 42 | 43 | } // namespace hamon 44 | 45 | #endif // HAMON_RENDER_VULKAN_STENCIL_OPERATION_HPP 46 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/vulkan/vulkan.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file vulkan.hpp 3 | * 4 | * @brief 5 | */ 6 | 7 | #ifndef HAMON_RENDER_VULKAN_VULKAN_HPP 8 | #define HAMON_RENDER_VULKAN_VULKAN_HPP 9 | 10 | #define VK_USE_PLATFORM_WIN32_KHR 11 | #include 12 | 13 | #endif // HAMON_RENDER_VULKAN_VULKAN_HPP 14 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/vulkan/vulkan_ext.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file vulkan_ext.hpp 3 | * 4 | * @brief 5 | */ 6 | 7 | #ifndef HAMON_RENDER_VULKAN_VULKAN_EXT_HPP 8 | #define HAMON_RENDER_VULKAN_VULKAN_EXT_HPP 9 | 10 | #include 11 | 12 | namespace hamon 13 | { 14 | 15 | inline namespace render 16 | { 17 | 18 | namespace vulkan 19 | { 20 | 21 | inline VkResult vkCreateDebugReportCallbackEXT( 22 | VkInstance instance, 23 | const VkDebugReportCallbackCreateInfoEXT* pCreateInfo, 24 | const VkAllocationCallbacks* pAllocator, 25 | VkDebugReportCallbackEXT* pCallback) 26 | { 27 | static auto func = (PFN_vkCreateDebugReportCallbackEXT)vkGetInstanceProcAddr(instance, "vkCreateDebugReportCallbackEXT"); 28 | return func(instance, pCreateInfo, pAllocator, pCallback); 29 | } 30 | 31 | inline void VKAPI_CALL vkDestroyDebugReportCallbackEXT( 32 | VkInstance instance, 33 | VkDebugReportCallbackEXT callback, 34 | const VkAllocationCallbacks* pAllocator) 35 | { 36 | static auto func = (PFN_vkDestroyDebugReportCallbackEXT)vkGetInstanceProcAddr(instance, "vkDestroyDebugReportCallbackEXT"); 37 | return func(instance, callback, pAllocator); 38 | } 39 | 40 | } // namespace vulkan 41 | 42 | } // inline namespace render 43 | 44 | } // namespace hamon 45 | 46 | #endif // HAMON_RENDER_VULKAN_VULKAN_EXT_HPP 47 | -------------------------------------------------------------------------------- /libs/render/include/hamon/render/vulkan_renderer.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file vulkan_renderer.hpp 3 | * 4 | * @brief VulkanRenderer 5 | */ 6 | 7 | #ifndef HAMON_RENDER_VULKAN_RENDERER_HPP 8 | #define HAMON_RENDER_VULKAN_RENDERER_HPP 9 | 10 | #if defined(HAMON_HAS_VULKAN) 11 | #include 12 | #endif 13 | 14 | #endif // HAMON_RENDER_VULKAN_RENDERER_HPP 15 | -------------------------------------------------------------------------------- /libs/render/samples/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(clear) 2 | add_subdirectory(color_write_mask) 3 | add_subdirectory(cull_mode) 4 | add_subdirectory(fill_mode) 5 | add_subdirectory(indexed) 6 | add_subdirectory(primitive_topology) 7 | add_subdirectory(texture) 8 | add_subdirectory(triangle) 9 | add_subdirectory(uniform) 10 | add_subdirectory(viewport) 11 | -------------------------------------------------------------------------------- /libs/render/samples/clear/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(TARGET_NAME "sample_render_clear") 2 | 3 | add_executable(${TARGET_NAME} sample_render_clear_main.cpp) 4 | set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "samples") 5 | target_link_libraries(${TARGET_NAME} PRIVATE Hamon::render) 6 | -------------------------------------------------------------------------------- /libs/render/samples/color_write_mask/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(TARGET_NAME "sample_render_color_write_mask") 2 | 3 | add_executable(${TARGET_NAME} sample_render_color_write_mask_main.cpp) 4 | set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "samples") 5 | target_link_libraries(${TARGET_NAME} PRIVATE Hamon::render) 6 | -------------------------------------------------------------------------------- /libs/render/samples/cull_mode/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(TARGET_NAME "sample_render_cull_mode") 2 | 3 | add_executable(${TARGET_NAME} sample_render_cull_mode_main.cpp) 4 | set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "samples") 5 | target_link_libraries(${TARGET_NAME} PRIVATE Hamon::render) 6 | -------------------------------------------------------------------------------- /libs/render/samples/fill_mode/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(TARGET_NAME "sample_render_fill_mode") 2 | 3 | add_executable(${TARGET_NAME} sample_render_fill_mode_main.cpp) 4 | set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "samples") 5 | target_link_libraries(${TARGET_NAME} PRIVATE Hamon::render) 6 | -------------------------------------------------------------------------------- /libs/render/samples/indexed/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(TARGET_NAME "sample_render_indexed") 2 | 3 | add_executable(${TARGET_NAME} sample_render_indexed_main.cpp) 4 | set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "samples") 5 | target_link_libraries(${TARGET_NAME} PRIVATE Hamon::render) 6 | -------------------------------------------------------------------------------- /libs/render/samples/primitive_topology/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(TARGET_NAME "sample_render_primitive_topology") 2 | 3 | add_executable(${TARGET_NAME} sample_render_primitive_topology_main.cpp) 4 | set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "samples") 5 | target_link_libraries(${TARGET_NAME} PRIVATE Hamon::render) 6 | -------------------------------------------------------------------------------- /libs/render/samples/texture/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(TARGET_NAME "sample_render_texture") 2 | 3 | add_executable(${TARGET_NAME} sample_render_texture_main.cpp) 4 | set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "samples") 5 | target_link_libraries(${TARGET_NAME} PRIVATE Hamon::render) 6 | -------------------------------------------------------------------------------- /libs/render/samples/triangle/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(TARGET_NAME "sample_render_triangle") 2 | 3 | add_executable(${TARGET_NAME} sample_render_triangle_main.cpp) 4 | set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "samples") 5 | target_link_libraries(${TARGET_NAME} PRIVATE Hamon::render) 6 | -------------------------------------------------------------------------------- /libs/render/samples/uniform/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(TARGET_NAME "sample_render_uniform") 2 | 3 | add_executable(${TARGET_NAME} sample_render_uniform_main.cpp) 4 | set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "samples") 5 | target_link_libraries(${TARGET_NAME} PRIVATE Hamon::render) 6 | -------------------------------------------------------------------------------- /libs/render/samples/viewport/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(TARGET_NAME "sample_render_viewport") 2 | 3 | add_executable(${TARGET_NAME} sample_render_viewport_main.cpp) 4 | set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "samples") 5 | target_link_libraries(${TARGET_NAME} PRIVATE Hamon::render) 6 | -------------------------------------------------------------------------------- /libs/type_traits/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | set(TARGET_NAME_BASE type_traits) 4 | 5 | set(TARGET_NAME hamon_${TARGET_NAME_BASE}) 6 | set(TARGET_ALIAS_NAME Hamon::${TARGET_NAME_BASE}) 7 | 8 | if (TARGET ${TARGET_NAME}) 9 | RETURN() 10 | endif() 11 | 12 | project(${TARGET_NAME} LANGUAGES C CXX) 13 | 14 | add_library(${TARGET_NAME} INTERFACE) 15 | add_library(${TARGET_ALIAS_NAME} ALIAS ${TARGET_NAME}) 16 | 17 | add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../config ${CMAKE_CURRENT_BINARY_DIR}/config) 18 | target_link_libraries(${TARGET_NAME} INTERFACE Hamon::config) 19 | 20 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 21 | set(CMAKE_CXX_EXTENSIONS OFF) 22 | 23 | target_include_directories(${TARGET_NAME} INTERFACE ${PROJECT_SOURCE_DIR}/include) 24 | 25 | if (MSVC) 26 | # /W4 (Warning Level) 27 | target_compile_options(${TARGET_NAME} INTERFACE /W4) 28 | 29 | # /WX (Treat all warnings as errors) 30 | target_compile_options(${TARGET_NAME} INTERFACE /WX) 31 | 32 | # /GR- (Disable Run-Time Type Information) 33 | target_compile_options(${TARGET_NAME} INTERFACE /GR-) 34 | 35 | # /MP (Build with Multiple Processes) 36 | if (NOT CMAKE_CXX_COMPILER_ID STREQUAL "Clang") 37 | target_compile_options(${TARGET_NAME} INTERFACE /MP) 38 | endif() 39 | 40 | elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") 41 | target_compile_options(${TARGET_NAME} INTERFACE -Wall -Wextra -Werror) 42 | 43 | elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") 44 | target_compile_options(${TARGET_NAME} INTERFACE -Wall -Wextra -Werror) 45 | 46 | endif() 47 | 48 | if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) 49 | add_subdirectory(test) 50 | endif() 51 | -------------------------------------------------------------------------------- /libs/type_traits/README.md: -------------------------------------------------------------------------------- 1 | # Windowライブラリ 2 | -------------------------------------------------------------------------------- /libs/type_traits/include/hamon/type_traits.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file type_traits.hpp 3 | * 4 | * @brief TypeTraits library 5 | */ 6 | 7 | #ifndef HAMON_TYPE_TRAITS_HPP 8 | #define HAMON_TYPE_TRAITS_HPP 9 | 10 | #include 11 | 12 | #endif // HAMON_TYPE_TRAITS_HPP 13 | -------------------------------------------------------------------------------- /libs/type_traits/include/hamon/type_traits/is_implicitly_copy_constructible.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file is_implicitly_copy_constructible.hpp 3 | * 4 | * @brief is_implicitly_copy_constructible の定義 5 | */ 6 | 7 | #ifndef HAMON_TYPE_TRAITS_IS_IMPLICITLY_COPY_CONSTRUCTIBLE_HPP 8 | #define HAMON_TYPE_TRAITS_IS_IMPLICITLY_COPY_CONSTRUCTIBLE_HPP 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | namespace hamon 15 | { 16 | 17 | /** 18 | * @brief 型Tが暗黙にコピー構築可能か調べる。 19 | * 20 | * @tparam T チェックする型 21 | * 22 | * @require 型Tは完全型であるか、void(cv修飾を含む)か、要素数不明の配列型でなければならない 23 | * 24 | * is_implicitly_copy_constructible は、型Tが暗黙にコピー構築可能であるならば 25 | * true_typeから派生し、そうでなければfalse_typeから派生する。 26 | */ 27 | template 28 | struct is_implicitly_copy_constructible 29 | : public hamon::is_implicitly_constructible< 30 | T, 31 | typename std::add_lvalue_reference< 32 | typename std::add_const::type 33 | >::type 34 | > 35 | {}; 36 | 37 | #if defined(HAMON_HAS_CXX14_VARIABLE_TEMPLATES) 38 | 39 | template 40 | HAMON_INLINE_VAR HAMON_CONSTEXPR 41 | bool is_implicitly_copy_constructible_v = is_implicitly_copy_constructible::value; 42 | 43 | #endif 44 | 45 | } // namespace hamon 46 | 47 | #endif // HAMON_TYPE_TRAITS_IS_IMPLICITLY_COPY_CONSTRUCTIBLE_HPP 48 | -------------------------------------------------------------------------------- /libs/type_traits/include/hamon/type_traits/is_implicitly_default_constructible.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file is_implicitly_default_constructible.hpp 3 | * 4 | * @brief is_implicitly_default_constructible の定義 5 | */ 6 | 7 | #ifndef HAMON_TYPE_TRAITS_IS_IMPLICITLY_DEFAULT_CONSTRUCTIBLE_HPP 8 | #define HAMON_TYPE_TRAITS_IS_IMPLICITLY_DEFAULT_CONSTRUCTIBLE_HPP 9 | 10 | #include 11 | #include 12 | 13 | namespace hamon 14 | { 15 | 16 | /** 17 | * @brief 型Tが暗黙にデフォルト構築可能か調べる。 18 | * 19 | * @tparam T チェックする型 20 | * 21 | * @require 型Tは完全型であるか、void(cv修飾を含む)か、要素数不明の配列型でなければならない。 22 | * 23 | * is_implicitly_default_constructibleは、型Tが暗黙にデフォルト構築可能であるならば 24 | * true_typeから派生し、そうでなければfalse_typeから派生する。 25 | */ 26 | template 27 | struct is_implicitly_default_constructible 28 | : public hamon::is_implicitly_constructible 29 | {}; 30 | 31 | #if defined(HAMON_HAS_CXX14_VARIABLE_TEMPLATES) 32 | 33 | template 34 | HAMON_INLINE_VAR HAMON_CONSTEXPR 35 | bool is_implicitly_default_constructible_v = is_implicitly_default_constructible::value; 36 | 37 | #endif 38 | 39 | } // namespace hamon 40 | 41 | #endif // HAMON_TYPE_TRAITS_IS_IMPLICITLY_DEFAULT_CONSTRUCTIBLE_HPP 42 | -------------------------------------------------------------------------------- /libs/type_traits/include/hamon/type_traits/is_implicitly_move_constructible.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file is_implicitly_move_constructible.hpp 3 | * 4 | * @brief is_implicitly_move_constructible の定義 5 | */ 6 | 7 | #ifndef HAMON_TYPE_TRAITS_IS_IMPLICITLY_MOVE_CONSTRUCTIBLE_HPP 8 | #define HAMON_TYPE_TRAITS_IS_IMPLICITLY_MOVE_CONSTRUCTIBLE_HPP 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | namespace hamon 15 | { 16 | 17 | /** 18 | * @brief 型Tが暗黙にムーブ構築可能か調べる 19 | * 20 | * @tparam T チェックする型 21 | * 22 | * @require 型Tは完全型であるか、void(cv修飾を含む)か、要素数不明の配列型でなければならない 23 | * 24 | * is_implicitly_move_constructible は、型Tが暗黙にムーブ構築可能であるならば 25 | * true_typeから派生し、そうでなければfalse_typeから派生する。 26 | */ 27 | template 28 | struct is_implicitly_move_constructible 29 | : public hamon::is_implicitly_constructible< 30 | T, 31 | typename std::add_rvalue_reference::type 32 | > 33 | {}; 34 | 35 | #if defined(HAMON_HAS_CXX14_VARIABLE_TEMPLATES) 36 | 37 | template 38 | HAMON_INLINE_VAR HAMON_CONSTEXPR 39 | bool is_implicitly_move_constructible_v = is_implicitly_move_constructible::value; 40 | 41 | #endif 42 | 43 | } // namespace hamon 44 | 45 | #endif // HAMON_TYPE_TRAITS_IS_IMPLICITLY_MOVE_CONSTRUCTIBLE_HPP 46 | -------------------------------------------------------------------------------- /libs/type_traits/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | set(TARGET_NAME_BASE type_traits) 4 | set(TARGET_NAME hamon_${TARGET_NAME_BASE}_test) 5 | 6 | add_executable(${TARGET_NAME}) 7 | 8 | file(GLOB_RECURSE test_sources CONFIGURE_DEPENDS src/*) 9 | target_sources(${TARGET_NAME} PRIVATE ${test_sources}) 10 | target_include_directories(${TARGET_NAME} PRIVATE src) 11 | target_link_libraries(${TARGET_NAME} PRIVATE Hamon::${TARGET_NAME_BASE}) 12 | 13 | enable_testing() 14 | 15 | if (NOT TARGET GTest::gtest) 16 | option(BUILD_GMOCK "Builds the googlemock subproject" OFF) 17 | add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../../../externals/googletest ${CMAKE_CURRENT_BINARY_DIR}/googletest) 18 | endif() 19 | 20 | target_link_libraries(${TARGET_NAME} 21 | PRIVATE 22 | GTest::gtest 23 | GTest::gtest_main) 24 | 25 | include(GoogleTest) 26 | gtest_discover_tests(${TARGET_NAME}) 27 | -------------------------------------------------------------------------------- /libs/window/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | set(TARGET_NAME_BASE window) 4 | 5 | set(TARGET_NAME hamon_${TARGET_NAME_BASE}) 6 | set(TARGET_ALIAS_NAME Hamon::${TARGET_NAME_BASE}) 7 | 8 | if (TARGET ${TARGET_NAME}) 9 | RETURN() 10 | endif() 11 | 12 | project(${TARGET_NAME} LANGUAGES C CXX) 13 | 14 | add_library(${TARGET_NAME} INTERFACE) 15 | add_library(${TARGET_ALIAS_NAME} ALIAS ${TARGET_NAME}) 16 | 17 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 18 | set(CMAKE_CXX_EXTENSIONS OFF) 19 | 20 | target_include_directories(${TARGET_NAME} INTERFACE ${PROJECT_SOURCE_DIR}/include) 21 | 22 | find_package(X11) 23 | if (X11_FOUND) 24 | target_link_libraries(${TARGET_NAME} INTERFACE X11::X11) 25 | endif() 26 | 27 | add_subdirectory(samples) 28 | -------------------------------------------------------------------------------- /libs/window/README.md: -------------------------------------------------------------------------------- 1 | # Windowライブラリ 2 | -------------------------------------------------------------------------------- /libs/window/include/hamon/window.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file window.hpp 3 | * 4 | * @brief Window library 5 | */ 6 | 7 | #ifndef HAMON_WINDOW_HPP 8 | #define HAMON_WINDOW_HPP 9 | 10 | #include 11 | 12 | #endif // HAMON_WINDOW_HPP 13 | -------------------------------------------------------------------------------- /libs/window/include/hamon/window/window.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file window.hpp 3 | * 4 | * @brief Window library 5 | */ 6 | 7 | #ifndef HAMON_WINDOW_WINDOW_HPP 8 | #define HAMON_WINDOW_WINDOW_HPP 9 | 10 | #if defined(_WIN32) 11 | #include 12 | //#elif defined(HAMON_PLATFORM_LINUX) 13 | #else 14 | #include 15 | #endif 16 | 17 | #endif // HAMON_WINDOW_WINDOW_HPP 18 | -------------------------------------------------------------------------------- /libs/window/samples/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(window) 2 | -------------------------------------------------------------------------------- /libs/window/samples/window/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(TARGET_NAME "sample_window_window") 2 | 3 | add_executable(${TARGET_NAME} sample_window_window_main.cpp) 4 | set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "samples") 5 | target_link_libraries(${TARGET_NAME} PRIVATE Hamon::window) 6 | -------------------------------------------------------------------------------- /libs/window/samples/window/sample_window_window_main.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file sample_window_window_main.cpp 3 | * 4 | * @brief Window のサンプル 5 | */ 6 | 7 | #include 8 | 9 | int main() 10 | { 11 | hamon::Window window(800, 600, "サンプルウィンドウ"); 12 | 13 | while (window.Update()) 14 | { 15 | } 16 | 17 | return 0; 18 | } 19 | --------------------------------------------------------------------------------