First commit
This commit is contained in:
3625
include/GL3/gl3.h
Normal file
3625
include/GL3/gl3.h
Normal file
File diff suppressed because it is too large
Load Diff
11751
include/GLext/glext.h
Normal file
11751
include/GLext/glext.h
Normal file
File diff suppressed because it is too large
Load Diff
1001
include/GLext/glxext.h
Normal file
1001
include/GLext/glxext.h
Normal file
File diff suppressed because it is too large
Load Diff
943
include/GLext/wglext.h
Normal file
943
include/GLext/wglext.h
Normal file
@@ -0,0 +1,943 @@
|
||||
#ifndef __wglext_h_
|
||||
#define __wglext_h_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
** Copyright (c) 2007-2012 The Khronos Group Inc.
|
||||
**
|
||||
** Permission is hereby granted, free of charge, to any person obtaining a
|
||||
** copy of this software and/or associated documentation files (the
|
||||
** "Materials"), to deal in the Materials without restriction, including
|
||||
** without limitation the rights to use, copy, modify, merge, publish,
|
||||
** distribute, sublicense, and/or sell copies of the Materials, and to
|
||||
** permit persons to whom the Materials are furnished to do so, subject to
|
||||
** the following conditions:
|
||||
**
|
||||
** The above copyright notice and this permission notice shall be included
|
||||
** in all copies or substantial portions of the Materials.
|
||||
**
|
||||
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
|
||||
*/
|
||||
|
||||
/* Function declaration macros - to move into glplatform.h */
|
||||
|
||||
#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__)
|
||||
#define WIN32_LEAN_AND_MEAN 1
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#ifndef APIENTRY
|
||||
#define APIENTRY
|
||||
#endif
|
||||
#ifndef APIENTRYP
|
||||
#define APIENTRYP APIENTRY *
|
||||
#endif
|
||||
#ifndef GLAPI
|
||||
#define GLAPI extern
|
||||
#endif
|
||||
|
||||
/*************************************************************/
|
||||
|
||||
/* Header file version number */
|
||||
/* wglext.h last updated 2012/01/04 */
|
||||
/* Current version at http://www.opengl.org/registry/ */
|
||||
#define WGL_WGLEXT_VERSION 24
|
||||
|
||||
#ifndef WGL_ARB_buffer_region
|
||||
#define WGL_FRONT_COLOR_BUFFER_BIT_ARB 0x00000001
|
||||
#define WGL_BACK_COLOR_BUFFER_BIT_ARB 0x00000002
|
||||
#define WGL_DEPTH_BUFFER_BIT_ARB 0x00000004
|
||||
#define WGL_STENCIL_BUFFER_BIT_ARB 0x00000008
|
||||
#endif
|
||||
|
||||
#ifndef WGL_ARB_multisample
|
||||
#define WGL_SAMPLE_BUFFERS_ARB 0x2041
|
||||
#define WGL_SAMPLES_ARB 0x2042
|
||||
#endif
|
||||
|
||||
#ifndef WGL_ARB_extensions_string
|
||||
#endif
|
||||
|
||||
#ifndef WGL_ARB_pixel_format
|
||||
#define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000
|
||||
#define WGL_DRAW_TO_WINDOW_ARB 0x2001
|
||||
#define WGL_DRAW_TO_BITMAP_ARB 0x2002
|
||||
#define WGL_ACCELERATION_ARB 0x2003
|
||||
#define WGL_NEED_PALETTE_ARB 0x2004
|
||||
#define WGL_NEED_SYSTEM_PALETTE_ARB 0x2005
|
||||
#define WGL_SWAP_LAYER_BUFFERS_ARB 0x2006
|
||||
#define WGL_SWAP_METHOD_ARB 0x2007
|
||||
#define WGL_NUMBER_OVERLAYS_ARB 0x2008
|
||||
#define WGL_NUMBER_UNDERLAYS_ARB 0x2009
|
||||
#define WGL_TRANSPARENT_ARB 0x200A
|
||||
#define WGL_TRANSPARENT_RED_VALUE_ARB 0x2037
|
||||
#define WGL_TRANSPARENT_GREEN_VALUE_ARB 0x2038
|
||||
#define WGL_TRANSPARENT_BLUE_VALUE_ARB 0x2039
|
||||
#define WGL_TRANSPARENT_ALPHA_VALUE_ARB 0x203A
|
||||
#define WGL_TRANSPARENT_INDEX_VALUE_ARB 0x203B
|
||||
#define WGL_SHARE_DEPTH_ARB 0x200C
|
||||
#define WGL_SHARE_STENCIL_ARB 0x200D
|
||||
#define WGL_SHARE_ACCUM_ARB 0x200E
|
||||
#define WGL_SUPPORT_GDI_ARB 0x200F
|
||||
#define WGL_SUPPORT_OPENGL_ARB 0x2010
|
||||
#define WGL_DOUBLE_BUFFER_ARB 0x2011
|
||||
#define WGL_STEREO_ARB 0x2012
|
||||
#define WGL_PIXEL_TYPE_ARB 0x2013
|
||||
#define WGL_COLOR_BITS_ARB 0x2014
|
||||
#define WGL_RED_BITS_ARB 0x2015
|
||||
#define WGL_RED_SHIFT_ARB 0x2016
|
||||
#define WGL_GREEN_BITS_ARB 0x2017
|
||||
#define WGL_GREEN_SHIFT_ARB 0x2018
|
||||
#define WGL_BLUE_BITS_ARB 0x2019
|
||||
#define WGL_BLUE_SHIFT_ARB 0x201A
|
||||
#define WGL_ALPHA_BITS_ARB 0x201B
|
||||
#define WGL_ALPHA_SHIFT_ARB 0x201C
|
||||
#define WGL_ACCUM_BITS_ARB 0x201D
|
||||
#define WGL_ACCUM_RED_BITS_ARB 0x201E
|
||||
#define WGL_ACCUM_GREEN_BITS_ARB 0x201F
|
||||
#define WGL_ACCUM_BLUE_BITS_ARB 0x2020
|
||||
#define WGL_ACCUM_ALPHA_BITS_ARB 0x2021
|
||||
#define WGL_DEPTH_BITS_ARB 0x2022
|
||||
#define WGL_STENCIL_BITS_ARB 0x2023
|
||||
#define WGL_AUX_BUFFERS_ARB 0x2024
|
||||
#define WGL_NO_ACCELERATION_ARB 0x2025
|
||||
#define WGL_GENERIC_ACCELERATION_ARB 0x2026
|
||||
#define WGL_FULL_ACCELERATION_ARB 0x2027
|
||||
#define WGL_SWAP_EXCHANGE_ARB 0x2028
|
||||
#define WGL_SWAP_COPY_ARB 0x2029
|
||||
#define WGL_SWAP_UNDEFINED_ARB 0x202A
|
||||
#define WGL_TYPE_RGBA_ARB 0x202B
|
||||
#define WGL_TYPE_COLORINDEX_ARB 0x202C
|
||||
#endif
|
||||
|
||||
#ifndef WGL_ARB_make_current_read
|
||||
#define ERROR_INVALID_PIXEL_TYPE_ARB 0x2043
|
||||
#define ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB 0x2054
|
||||
#endif
|
||||
|
||||
#ifndef WGL_ARB_pbuffer
|
||||
#define WGL_DRAW_TO_PBUFFER_ARB 0x202D
|
||||
#define WGL_MAX_PBUFFER_PIXELS_ARB 0x202E
|
||||
#define WGL_MAX_PBUFFER_WIDTH_ARB 0x202F
|
||||
#define WGL_MAX_PBUFFER_HEIGHT_ARB 0x2030
|
||||
#define WGL_PBUFFER_LARGEST_ARB 0x2033
|
||||
#define WGL_PBUFFER_WIDTH_ARB 0x2034
|
||||
#define WGL_PBUFFER_HEIGHT_ARB 0x2035
|
||||
#define WGL_PBUFFER_LOST_ARB 0x2036
|
||||
#endif
|
||||
|
||||
#ifndef WGL_ARB_render_texture
|
||||
#define WGL_BIND_TO_TEXTURE_RGB_ARB 0x2070
|
||||
#define WGL_BIND_TO_TEXTURE_RGBA_ARB 0x2071
|
||||
#define WGL_TEXTURE_FORMAT_ARB 0x2072
|
||||
#define WGL_TEXTURE_TARGET_ARB 0x2073
|
||||
#define WGL_MIPMAP_TEXTURE_ARB 0x2074
|
||||
#define WGL_TEXTURE_RGB_ARB 0x2075
|
||||
#define WGL_TEXTURE_RGBA_ARB 0x2076
|
||||
#define WGL_NO_TEXTURE_ARB 0x2077
|
||||
#define WGL_TEXTURE_CUBE_MAP_ARB 0x2078
|
||||
#define WGL_TEXTURE_1D_ARB 0x2079
|
||||
#define WGL_TEXTURE_2D_ARB 0x207A
|
||||
#define WGL_MIPMAP_LEVEL_ARB 0x207B
|
||||
#define WGL_CUBE_MAP_FACE_ARB 0x207C
|
||||
#define WGL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x207D
|
||||
#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x207E
|
||||
#define WGL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x207F
|
||||
#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x2080
|
||||
#define WGL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x2081
|
||||
#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x2082
|
||||
#define WGL_FRONT_LEFT_ARB 0x2083
|
||||
#define WGL_FRONT_RIGHT_ARB 0x2084
|
||||
#define WGL_BACK_LEFT_ARB 0x2085
|
||||
#define WGL_BACK_RIGHT_ARB 0x2086
|
||||
#define WGL_AUX0_ARB 0x2087
|
||||
#define WGL_AUX1_ARB 0x2088
|
||||
#define WGL_AUX2_ARB 0x2089
|
||||
#define WGL_AUX3_ARB 0x208A
|
||||
#define WGL_AUX4_ARB 0x208B
|
||||
#define WGL_AUX5_ARB 0x208C
|
||||
#define WGL_AUX6_ARB 0x208D
|
||||
#define WGL_AUX7_ARB 0x208E
|
||||
#define WGL_AUX8_ARB 0x208F
|
||||
#define WGL_AUX9_ARB 0x2090
|
||||
#endif
|
||||
|
||||
#ifndef WGL_ARB_pixel_format_float
|
||||
#define WGL_TYPE_RGBA_FLOAT_ARB 0x21A0
|
||||
#endif
|
||||
|
||||
#ifndef WGL_ARB_framebuffer_sRGB
|
||||
#define WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20A9
|
||||
#endif
|
||||
|
||||
#ifndef WGL_ARB_create_context
|
||||
#define WGL_CONTEXT_DEBUG_BIT_ARB 0x00000001
|
||||
#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002
|
||||
#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091
|
||||
#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092
|
||||
#define WGL_CONTEXT_LAYER_PLANE_ARB 0x2093
|
||||
#define WGL_CONTEXT_FLAGS_ARB 0x2094
|
||||
#define ERROR_INVALID_VERSION_ARB 0x2095
|
||||
#endif
|
||||
|
||||
#ifndef WGL_ARB_create_context_profile
|
||||
#define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126
|
||||
#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001
|
||||
#define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002
|
||||
#define ERROR_INVALID_PROFILE_ARB 0x2096
|
||||
#endif
|
||||
|
||||
#ifndef WGL_ARB_create_context_robustness
|
||||
#define WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004
|
||||
#define WGL_LOSE_CONTEXT_ON_RESET_ARB 0x8252
|
||||
#define WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256
|
||||
#define WGL_NO_RESET_NOTIFICATION_ARB 0x8261
|
||||
#endif
|
||||
|
||||
#ifndef WGL_EXT_make_current_read
|
||||
#define ERROR_INVALID_PIXEL_TYPE_EXT 0x2043
|
||||
#endif
|
||||
|
||||
#ifndef WGL_EXT_pixel_format
|
||||
#define WGL_NUMBER_PIXEL_FORMATS_EXT 0x2000
|
||||
#define WGL_DRAW_TO_WINDOW_EXT 0x2001
|
||||
#define WGL_DRAW_TO_BITMAP_EXT 0x2002
|
||||
#define WGL_ACCELERATION_EXT 0x2003
|
||||
#define WGL_NEED_PALETTE_EXT 0x2004
|
||||
#define WGL_NEED_SYSTEM_PALETTE_EXT 0x2005
|
||||
#define WGL_SWAP_LAYER_BUFFERS_EXT 0x2006
|
||||
#define WGL_SWAP_METHOD_EXT 0x2007
|
||||
#define WGL_NUMBER_OVERLAYS_EXT 0x2008
|
||||
#define WGL_NUMBER_UNDERLAYS_EXT 0x2009
|
||||
#define WGL_TRANSPARENT_EXT 0x200A
|
||||
#define WGL_TRANSPARENT_VALUE_EXT 0x200B
|
||||
#define WGL_SHARE_DEPTH_EXT 0x200C
|
||||
#define WGL_SHARE_STENCIL_EXT 0x200D
|
||||
#define WGL_SHARE_ACCUM_EXT 0x200E
|
||||
#define WGL_SUPPORT_GDI_EXT 0x200F
|
||||
#define WGL_SUPPORT_OPENGL_EXT 0x2010
|
||||
#define WGL_DOUBLE_BUFFER_EXT 0x2011
|
||||
#define WGL_STEREO_EXT 0x2012
|
||||
#define WGL_PIXEL_TYPE_EXT 0x2013
|
||||
#define WGL_COLOR_BITS_EXT 0x2014
|
||||
#define WGL_RED_BITS_EXT 0x2015
|
||||
#define WGL_RED_SHIFT_EXT 0x2016
|
||||
#define WGL_GREEN_BITS_EXT 0x2017
|
||||
#define WGL_GREEN_SHIFT_EXT 0x2018
|
||||
#define WGL_BLUE_BITS_EXT 0x2019
|
||||
#define WGL_BLUE_SHIFT_EXT 0x201A
|
||||
#define WGL_ALPHA_BITS_EXT 0x201B
|
||||
#define WGL_ALPHA_SHIFT_EXT 0x201C
|
||||
#define WGL_ACCUM_BITS_EXT 0x201D
|
||||
#define WGL_ACCUM_RED_BITS_EXT 0x201E
|
||||
#define WGL_ACCUM_GREEN_BITS_EXT 0x201F
|
||||
#define WGL_ACCUM_BLUE_BITS_EXT 0x2020
|
||||
#define WGL_ACCUM_ALPHA_BITS_EXT 0x2021
|
||||
#define WGL_DEPTH_BITS_EXT 0x2022
|
||||
#define WGL_STENCIL_BITS_EXT 0x2023
|
||||
#define WGL_AUX_BUFFERS_EXT 0x2024
|
||||
#define WGL_NO_ACCELERATION_EXT 0x2025
|
||||
#define WGL_GENERIC_ACCELERATION_EXT 0x2026
|
||||
#define WGL_FULL_ACCELERATION_EXT 0x2027
|
||||
#define WGL_SWAP_EXCHANGE_EXT 0x2028
|
||||
#define WGL_SWAP_COPY_EXT 0x2029
|
||||
#define WGL_SWAP_UNDEFINED_EXT 0x202A
|
||||
#define WGL_TYPE_RGBA_EXT 0x202B
|
||||
#define WGL_TYPE_COLORINDEX_EXT 0x202C
|
||||
#endif
|
||||
|
||||
#ifndef WGL_EXT_pbuffer
|
||||
#define WGL_DRAW_TO_PBUFFER_EXT 0x202D
|
||||
#define WGL_MAX_PBUFFER_PIXELS_EXT 0x202E
|
||||
#define WGL_MAX_PBUFFER_WIDTH_EXT 0x202F
|
||||
#define WGL_MAX_PBUFFER_HEIGHT_EXT 0x2030
|
||||
#define WGL_OPTIMAL_PBUFFER_WIDTH_EXT 0x2031
|
||||
#define WGL_OPTIMAL_PBUFFER_HEIGHT_EXT 0x2032
|
||||
#define WGL_PBUFFER_LARGEST_EXT 0x2033
|
||||
#define WGL_PBUFFER_WIDTH_EXT 0x2034
|
||||
#define WGL_PBUFFER_HEIGHT_EXT 0x2035
|
||||
#endif
|
||||
|
||||
#ifndef WGL_EXT_depth_float
|
||||
#define WGL_DEPTH_FLOAT_EXT 0x2040
|
||||
#endif
|
||||
|
||||
#ifndef WGL_3DFX_multisample
|
||||
#define WGL_SAMPLE_BUFFERS_3DFX 0x2060
|
||||
#define WGL_SAMPLES_3DFX 0x2061
|
||||
#endif
|
||||
|
||||
#ifndef WGL_EXT_multisample
|
||||
#define WGL_SAMPLE_BUFFERS_EXT 0x2041
|
||||
#define WGL_SAMPLES_EXT 0x2042
|
||||
#endif
|
||||
|
||||
#ifndef WGL_I3D_digital_video_control
|
||||
#define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_FRAMEBUFFER_I3D 0x2050
|
||||
#define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_VALUE_I3D 0x2051
|
||||
#define WGL_DIGITAL_VIDEO_CURSOR_INCLUDED_I3D 0x2052
|
||||
#define WGL_DIGITAL_VIDEO_GAMMA_CORRECTED_I3D 0x2053
|
||||
#endif
|
||||
|
||||
#ifndef WGL_I3D_gamma
|
||||
#define WGL_GAMMA_TABLE_SIZE_I3D 0x204E
|
||||
#define WGL_GAMMA_EXCLUDE_DESKTOP_I3D 0x204F
|
||||
#endif
|
||||
|
||||
#ifndef WGL_I3D_genlock
|
||||
#define WGL_GENLOCK_SOURCE_MULTIVIEW_I3D 0x2044
|
||||
#define WGL_GENLOCK_SOURCE_EXTENAL_SYNC_I3D 0x2045
|
||||
#define WGL_GENLOCK_SOURCE_EXTENAL_FIELD_I3D 0x2046
|
||||
#define WGL_GENLOCK_SOURCE_EXTENAL_TTL_I3D 0x2047
|
||||
#define WGL_GENLOCK_SOURCE_DIGITAL_SYNC_I3D 0x2048
|
||||
#define WGL_GENLOCK_SOURCE_DIGITAL_FIELD_I3D 0x2049
|
||||
#define WGL_GENLOCK_SOURCE_EDGE_FALLING_I3D 0x204A
|
||||
#define WGL_GENLOCK_SOURCE_EDGE_RISING_I3D 0x204B
|
||||
#define WGL_GENLOCK_SOURCE_EDGE_BOTH_I3D 0x204C
|
||||
#endif
|
||||
|
||||
#ifndef WGL_I3D_image_buffer
|
||||
#define WGL_IMAGE_BUFFER_MIN_ACCESS_I3D 0x00000001
|
||||
#define WGL_IMAGE_BUFFER_LOCK_I3D 0x00000002
|
||||
#endif
|
||||
|
||||
#ifndef WGL_I3D_swap_frame_lock
|
||||
#endif
|
||||
|
||||
#ifndef WGL_NV_render_depth_texture
|
||||
#define WGL_BIND_TO_TEXTURE_DEPTH_NV 0x20A3
|
||||
#define WGL_BIND_TO_TEXTURE_RECTANGLE_DEPTH_NV 0x20A4
|
||||
#define WGL_DEPTH_TEXTURE_FORMAT_NV 0x20A5
|
||||
#define WGL_TEXTURE_DEPTH_COMPONENT_NV 0x20A6
|
||||
#define WGL_DEPTH_COMPONENT_NV 0x20A7
|
||||
#endif
|
||||
|
||||
#ifndef WGL_NV_render_texture_rectangle
|
||||
#define WGL_BIND_TO_TEXTURE_RECTANGLE_RGB_NV 0x20A0
|
||||
#define WGL_BIND_TO_TEXTURE_RECTANGLE_RGBA_NV 0x20A1
|
||||
#define WGL_TEXTURE_RECTANGLE_NV 0x20A2
|
||||
#endif
|
||||
|
||||
#ifndef WGL_ATI_pixel_format_float
|
||||
#define WGL_TYPE_RGBA_FLOAT_ATI 0x21A0
|
||||
#endif
|
||||
|
||||
#ifndef WGL_NV_float_buffer
|
||||
#define WGL_FLOAT_COMPONENTS_NV 0x20B0
|
||||
#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_R_NV 0x20B1
|
||||
#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RG_NV 0x20B2
|
||||
#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGB_NV 0x20B3
|
||||
#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGBA_NV 0x20B4
|
||||
#define WGL_TEXTURE_FLOAT_R_NV 0x20B5
|
||||
#define WGL_TEXTURE_FLOAT_RG_NV 0x20B6
|
||||
#define WGL_TEXTURE_FLOAT_RGB_NV 0x20B7
|
||||
#define WGL_TEXTURE_FLOAT_RGBA_NV 0x20B8
|
||||
#endif
|
||||
|
||||
#ifndef WGL_3DL_stereo_control
|
||||
#define WGL_STEREO_EMITTER_ENABLE_3DL 0x2055
|
||||
#define WGL_STEREO_EMITTER_DISABLE_3DL 0x2056
|
||||
#define WGL_STEREO_POLARITY_NORMAL_3DL 0x2057
|
||||
#define WGL_STEREO_POLARITY_INVERT_3DL 0x2058
|
||||
#endif
|
||||
|
||||
#ifndef WGL_EXT_pixel_format_packed_float
|
||||
#define WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT 0x20A8
|
||||
#endif
|
||||
|
||||
#ifndef WGL_EXT_framebuffer_sRGB
|
||||
#define WGL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x20A9
|
||||
#endif
|
||||
|
||||
#ifndef WGL_NV_present_video
|
||||
#define WGL_NUM_VIDEO_SLOTS_NV 0x20F0
|
||||
#endif
|
||||
|
||||
#ifndef WGL_NV_video_out
|
||||
#define WGL_BIND_TO_VIDEO_RGB_NV 0x20C0
|
||||
#define WGL_BIND_TO_VIDEO_RGBA_NV 0x20C1
|
||||
#define WGL_BIND_TO_VIDEO_RGB_AND_DEPTH_NV 0x20C2
|
||||
#define WGL_VIDEO_OUT_COLOR_NV 0x20C3
|
||||
#define WGL_VIDEO_OUT_ALPHA_NV 0x20C4
|
||||
#define WGL_VIDEO_OUT_DEPTH_NV 0x20C5
|
||||
#define WGL_VIDEO_OUT_COLOR_AND_ALPHA_NV 0x20C6
|
||||
#define WGL_VIDEO_OUT_COLOR_AND_DEPTH_NV 0x20C7
|
||||
#define WGL_VIDEO_OUT_FRAME 0x20C8
|
||||
#define WGL_VIDEO_OUT_FIELD_1 0x20C9
|
||||
#define WGL_VIDEO_OUT_FIELD_2 0x20CA
|
||||
#define WGL_VIDEO_OUT_STACKED_FIELDS_1_2 0x20CB
|
||||
#define WGL_VIDEO_OUT_STACKED_FIELDS_2_1 0x20CC
|
||||
#endif
|
||||
|
||||
#ifndef WGL_NV_swap_group
|
||||
#endif
|
||||
|
||||
#ifndef WGL_NV_gpu_affinity
|
||||
#define WGL_ERROR_INCOMPATIBLE_AFFINITY_MASKS_NV 0x20D0
|
||||
#define WGL_ERROR_MISSING_AFFINITY_MASK_NV 0x20D1
|
||||
#endif
|
||||
|
||||
#ifndef WGL_AMD_gpu_association
|
||||
#define WGL_GPU_VENDOR_AMD 0x1F00
|
||||
#define WGL_GPU_RENDERER_STRING_AMD 0x1F01
|
||||
#define WGL_GPU_OPENGL_VERSION_STRING_AMD 0x1F02
|
||||
#define WGL_GPU_FASTEST_TARGET_GPUS_AMD 0x21A2
|
||||
#define WGL_GPU_RAM_AMD 0x21A3
|
||||
#define WGL_GPU_CLOCK_AMD 0x21A4
|
||||
#define WGL_GPU_NUM_PIPES_AMD 0x21A5
|
||||
#define WGL_GPU_NUM_SIMD_AMD 0x21A6
|
||||
#define WGL_GPU_NUM_RB_AMD 0x21A7
|
||||
#define WGL_GPU_NUM_SPI_AMD 0x21A8
|
||||
#endif
|
||||
|
||||
#ifndef WGL_NV_video_capture
|
||||
#define WGL_UNIQUE_ID_NV 0x20CE
|
||||
#define WGL_NUM_VIDEO_CAPTURE_SLOTS_NV 0x20CF
|
||||
#endif
|
||||
|
||||
#ifndef WGL_NV_copy_image
|
||||
#endif
|
||||
|
||||
#ifndef WGL_NV_multisample_coverage
|
||||
#define WGL_COVERAGE_SAMPLES_NV 0x2042
|
||||
#define WGL_COLOR_SAMPLES_NV 0x20B9
|
||||
#endif
|
||||
|
||||
#ifndef WGL_EXT_create_context_es2_profile
|
||||
#define WGL_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004
|
||||
#endif
|
||||
|
||||
#ifndef WGL_NV_DX_interop
|
||||
#define WGL_ACCESS_READ_ONLY_NV 0x00000000
|
||||
#define WGL_ACCESS_READ_WRITE_NV 0x00000001
|
||||
#define WGL_ACCESS_WRITE_DISCARD_NV 0x00000002
|
||||
#endif
|
||||
|
||||
#ifndef WGL_NV_DX_interop2
|
||||
#endif
|
||||
|
||||
#ifndef WGL_EXT_swap_control_tear
|
||||
#endif
|
||||
|
||||
|
||||
/*************************************************************/
|
||||
|
||||
#ifndef WGL_ARB_pbuffer
|
||||
DECLARE_HANDLE(HPBUFFERARB);
|
||||
#endif
|
||||
#ifndef WGL_EXT_pbuffer
|
||||
DECLARE_HANDLE(HPBUFFEREXT);
|
||||
#endif
|
||||
#ifndef WGL_NV_present_video
|
||||
DECLARE_HANDLE(HVIDEOOUTPUTDEVICENV);
|
||||
#endif
|
||||
#ifndef WGL_NV_video_output
|
||||
DECLARE_HANDLE(HPVIDEODEV);
|
||||
#endif
|
||||
#ifndef WGL_NV_gpu_affinity
|
||||
DECLARE_HANDLE(HPGPUNV);
|
||||
DECLARE_HANDLE(HGPUNV);
|
||||
|
||||
typedef struct _GPU_DEVICE {
|
||||
DWORD cb;
|
||||
CHAR DeviceName[32];
|
||||
CHAR DeviceString[128];
|
||||
DWORD Flags;
|
||||
RECT rcVirtualScreen;
|
||||
} GPU_DEVICE, *PGPU_DEVICE;
|
||||
#endif
|
||||
#ifndef WGL_NV_video_capture
|
||||
DECLARE_HANDLE(HVIDEOINPUTDEVICENV);
|
||||
#endif
|
||||
|
||||
#ifndef WGL_ARB_buffer_region
|
||||
#define WGL_ARB_buffer_region 1
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
extern HANDLE WINAPI wglCreateBufferRegionARB (HDC hDC, int iLayerPlane, UINT uType);
|
||||
extern VOID WINAPI wglDeleteBufferRegionARB (HANDLE hRegion);
|
||||
extern BOOL WINAPI wglSaveBufferRegionARB (HANDLE hRegion, int x, int y, int width, int height);
|
||||
extern BOOL WINAPI wglRestoreBufferRegionARB (HANDLE hRegion, int x, int y, int width, int height, int xSrc, int ySrc);
|
||||
#endif /* WGL_WGLEXT_PROTOTYPES */
|
||||
typedef HANDLE (WINAPI * PFNWGLCREATEBUFFERREGIONARBPROC) (HDC hDC, int iLayerPlane, UINT uType);
|
||||
typedef VOID (WINAPI * PFNWGLDELETEBUFFERREGIONARBPROC) (HANDLE hRegion);
|
||||
typedef BOOL (WINAPI * PFNWGLSAVEBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height);
|
||||
typedef BOOL (WINAPI * PFNWGLRESTOREBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height, int xSrc, int ySrc);
|
||||
#endif
|
||||
|
||||
#ifndef WGL_ARB_multisample
|
||||
#define WGL_ARB_multisample 1
|
||||
#endif
|
||||
|
||||
#ifndef WGL_ARB_extensions_string
|
||||
#define WGL_ARB_extensions_string 1
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
extern const char * WINAPI wglGetExtensionsStringARB (HDC hdc);
|
||||
#endif /* WGL_WGLEXT_PROTOTYPES */
|
||||
typedef const char * (WINAPI * PFNWGLGETEXTENSIONSSTRINGARBPROC) (HDC hdc);
|
||||
#endif
|
||||
|
||||
#ifndef WGL_ARB_pixel_format
|
||||
#define WGL_ARB_pixel_format 1
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
extern BOOL WINAPI wglGetPixelFormatAttribivARB (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues);
|
||||
extern BOOL WINAPI wglGetPixelFormatAttribfvARB (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues);
|
||||
extern BOOL WINAPI wglChoosePixelFormatARB (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats);
|
||||
#endif /* WGL_WGLEXT_PROTOTYPES */
|
||||
typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues);
|
||||
typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues);
|
||||
typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATARBPROC) (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats);
|
||||
#endif
|
||||
|
||||
#ifndef WGL_ARB_make_current_read
|
||||
#define WGL_ARB_make_current_read 1
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
extern BOOL WINAPI wglMakeContextCurrentARB (HDC hDrawDC, HDC hReadDC, HGLRC hglrc);
|
||||
extern HDC WINAPI wglGetCurrentReadDCARB (void);
|
||||
#endif /* WGL_WGLEXT_PROTOTYPES */
|
||||
typedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTARBPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc);
|
||||
typedef HDC (WINAPI * PFNWGLGETCURRENTREADDCARBPROC) (void);
|
||||
#endif
|
||||
|
||||
#ifndef WGL_ARB_pbuffer
|
||||
#define WGL_ARB_pbuffer 1
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
extern HPBUFFERARB WINAPI wglCreatePbufferARB (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList);
|
||||
extern HDC WINAPI wglGetPbufferDCARB (HPBUFFERARB hPbuffer);
|
||||
extern int WINAPI wglReleasePbufferDCARB (HPBUFFERARB hPbuffer, HDC hDC);
|
||||
extern BOOL WINAPI wglDestroyPbufferARB (HPBUFFERARB hPbuffer);
|
||||
extern BOOL WINAPI wglQueryPbufferARB (HPBUFFERARB hPbuffer, int iAttribute, int *piValue);
|
||||
#endif /* WGL_WGLEXT_PROTOTYPES */
|
||||
typedef HPBUFFERARB (WINAPI * PFNWGLCREATEPBUFFERARBPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList);
|
||||
typedef HDC (WINAPI * PFNWGLGETPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer);
|
||||
typedef int (WINAPI * PFNWGLRELEASEPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer, HDC hDC);
|
||||
typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFERARBPROC) (HPBUFFERARB hPbuffer);
|
||||
typedef BOOL (WINAPI * PFNWGLQUERYPBUFFERARBPROC) (HPBUFFERARB hPbuffer, int iAttribute, int *piValue);
|
||||
#endif
|
||||
|
||||
#ifndef WGL_ARB_render_texture
|
||||
#define WGL_ARB_render_texture 1
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
extern BOOL WINAPI wglBindTexImageARB (HPBUFFERARB hPbuffer, int iBuffer);
|
||||
extern BOOL WINAPI wglReleaseTexImageARB (HPBUFFERARB hPbuffer, int iBuffer);
|
||||
extern BOOL WINAPI wglSetPbufferAttribARB (HPBUFFERARB hPbuffer, const int *piAttribList);
|
||||
#endif /* WGL_WGLEXT_PROTOTYPES */
|
||||
typedef BOOL (WINAPI * PFNWGLBINDTEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer);
|
||||
typedef BOOL (WINAPI * PFNWGLRELEASETEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer);
|
||||
typedef BOOL (WINAPI * PFNWGLSETPBUFFERATTRIBARBPROC) (HPBUFFERARB hPbuffer, const int *piAttribList);
|
||||
#endif
|
||||
|
||||
#ifndef WGL_ARB_pixel_format_float
|
||||
#define WGL_ARB_pixel_format_float 1
|
||||
#endif
|
||||
|
||||
#ifndef WGL_ARB_framebuffer_sRGB
|
||||
#define WGL_ARB_framebuffer_sRGB 1
|
||||
#endif
|
||||
|
||||
#ifndef WGL_ARB_create_context
|
||||
#define WGL_ARB_create_context 1
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
extern HGLRC WINAPI wglCreateContextAttribsARB (HDC hDC, HGLRC hShareContext, const int *attribList);
|
||||
#endif /* WGL_WGLEXT_PROTOTYPES */
|
||||
typedef HGLRC (WINAPI * PFNWGLCREATECONTEXTATTRIBSARBPROC) (HDC hDC, HGLRC hShareContext, const int *attribList);
|
||||
#endif
|
||||
|
||||
#ifndef WGL_ARB_create_context_profile
|
||||
#define WGL_ARB_create_context_profile 1
|
||||
#endif
|
||||
|
||||
#ifndef WGL_ARB_create_context_robustness
|
||||
#define WGL_ARB_create_context_robustness 1
|
||||
#endif
|
||||
|
||||
#ifndef WGL_EXT_display_color_table
|
||||
#define WGL_EXT_display_color_table 1
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
extern GLboolean WINAPI wglCreateDisplayColorTableEXT (GLushort id);
|
||||
extern GLboolean WINAPI wglLoadDisplayColorTableEXT (const GLushort *table, GLuint length);
|
||||
extern GLboolean WINAPI wglBindDisplayColorTableEXT (GLushort id);
|
||||
extern VOID WINAPI wglDestroyDisplayColorTableEXT (GLushort id);
|
||||
#endif /* WGL_WGLEXT_PROTOTYPES */
|
||||
typedef GLboolean (WINAPI * PFNWGLCREATEDISPLAYCOLORTABLEEXTPROC) (GLushort id);
|
||||
typedef GLboolean (WINAPI * PFNWGLLOADDISPLAYCOLORTABLEEXTPROC) (const GLushort *table, GLuint length);
|
||||
typedef GLboolean (WINAPI * PFNWGLBINDDISPLAYCOLORTABLEEXTPROC) (GLushort id);
|
||||
typedef VOID (WINAPI * PFNWGLDESTROYDISPLAYCOLORTABLEEXTPROC) (GLushort id);
|
||||
#endif
|
||||
|
||||
#ifndef WGL_EXT_extensions_string
|
||||
#define WGL_EXT_extensions_string 1
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
extern const char * WINAPI wglGetExtensionsStringEXT (void);
|
||||
#endif /* WGL_WGLEXT_PROTOTYPES */
|
||||
typedef const char * (WINAPI * PFNWGLGETEXTENSIONSSTRINGEXTPROC) (void);
|
||||
#endif
|
||||
|
||||
#ifndef WGL_EXT_make_current_read
|
||||
#define WGL_EXT_make_current_read 1
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
extern BOOL WINAPI wglMakeContextCurrentEXT (HDC hDrawDC, HDC hReadDC, HGLRC hglrc);
|
||||
extern HDC WINAPI wglGetCurrentReadDCEXT (void);
|
||||
#endif /* WGL_WGLEXT_PROTOTYPES */
|
||||
typedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTEXTPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc);
|
||||
typedef HDC (WINAPI * PFNWGLGETCURRENTREADDCEXTPROC) (void);
|
||||
#endif
|
||||
|
||||
#ifndef WGL_EXT_pbuffer
|
||||
#define WGL_EXT_pbuffer 1
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
extern HPBUFFEREXT WINAPI wglCreatePbufferEXT (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList);
|
||||
extern HDC WINAPI wglGetPbufferDCEXT (HPBUFFEREXT hPbuffer);
|
||||
extern int WINAPI wglReleasePbufferDCEXT (HPBUFFEREXT hPbuffer, HDC hDC);
|
||||
extern BOOL WINAPI wglDestroyPbufferEXT (HPBUFFEREXT hPbuffer);
|
||||
extern BOOL WINAPI wglQueryPbufferEXT (HPBUFFEREXT hPbuffer, int iAttribute, int *piValue);
|
||||
#endif /* WGL_WGLEXT_PROTOTYPES */
|
||||
typedef HPBUFFEREXT (WINAPI * PFNWGLCREATEPBUFFEREXTPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList);
|
||||
typedef HDC (WINAPI * PFNWGLGETPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer);
|
||||
typedef int (WINAPI * PFNWGLRELEASEPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer, HDC hDC);
|
||||
typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer);
|
||||
typedef BOOL (WINAPI * PFNWGLQUERYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer, int iAttribute, int *piValue);
|
||||
#endif
|
||||
|
||||
#ifndef WGL_EXT_pixel_format
|
||||
#define WGL_EXT_pixel_format 1
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
extern BOOL WINAPI wglGetPixelFormatAttribivEXT (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, int *piValues);
|
||||
extern BOOL WINAPI wglGetPixelFormatAttribfvEXT (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, FLOAT *pfValues);
|
||||
extern BOOL WINAPI wglChoosePixelFormatEXT (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats);
|
||||
#endif /* WGL_WGLEXT_PROTOTYPES */
|
||||
typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, int *piValues);
|
||||
typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, FLOAT *pfValues);
|
||||
typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATEXTPROC) (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats);
|
||||
#endif
|
||||
|
||||
#ifndef WGL_EXT_swap_control
|
||||
#define WGL_EXT_swap_control 1
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
extern BOOL WINAPI wglSwapIntervalEXT (int interval);
|
||||
extern int WINAPI wglGetSwapIntervalEXT (void);
|
||||
#endif /* WGL_WGLEXT_PROTOTYPES */
|
||||
typedef BOOL (WINAPI * PFNWGLSWAPINTERVALEXTPROC) (int interval);
|
||||
typedef int (WINAPI * PFNWGLGETSWAPINTERVALEXTPROC) (void);
|
||||
#endif
|
||||
|
||||
#ifndef WGL_EXT_depth_float
|
||||
#define WGL_EXT_depth_float 1
|
||||
#endif
|
||||
|
||||
#ifndef WGL_NV_vertex_array_range
|
||||
#define WGL_NV_vertex_array_range 1
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
extern void* WINAPI wglAllocateMemoryNV (GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority);
|
||||
extern void WINAPI wglFreeMemoryNV (void *pointer);
|
||||
#endif /* WGL_WGLEXT_PROTOTYPES */
|
||||
typedef void* (WINAPI * PFNWGLALLOCATEMEMORYNVPROC) (GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority);
|
||||
typedef void (WINAPI * PFNWGLFREEMEMORYNVPROC) (void *pointer);
|
||||
#endif
|
||||
|
||||
#ifndef WGL_3DFX_multisample
|
||||
#define WGL_3DFX_multisample 1
|
||||
#endif
|
||||
|
||||
#ifndef WGL_EXT_multisample
|
||||
#define WGL_EXT_multisample 1
|
||||
#endif
|
||||
|
||||
#ifndef WGL_OML_sync_control
|
||||
#define WGL_OML_sync_control 1
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
extern BOOL WINAPI wglGetSyncValuesOML (HDC hdc, INT64 *ust, INT64 *msc, INT64 *sbc);
|
||||
extern BOOL WINAPI wglGetMscRateOML (HDC hdc, INT32 *numerator, INT32 *denominator);
|
||||
extern INT64 WINAPI wglSwapBuffersMscOML (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder);
|
||||
extern INT64 WINAPI wglSwapLayerBuffersMscOML (HDC hdc, int fuPlanes, INT64 target_msc, INT64 divisor, INT64 remainder);
|
||||
extern BOOL WINAPI wglWaitForMscOML (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder, INT64 *ust, INT64 *msc, INT64 *sbc);
|
||||
extern BOOL WINAPI wglWaitForSbcOML (HDC hdc, INT64 target_sbc, INT64 *ust, INT64 *msc, INT64 *sbc);
|
||||
#endif /* WGL_WGLEXT_PROTOTYPES */
|
||||
typedef BOOL (WINAPI * PFNWGLGETSYNCVALUESOMLPROC) (HDC hdc, INT64 *ust, INT64 *msc, INT64 *sbc);
|
||||
typedef BOOL (WINAPI * PFNWGLGETMSCRATEOMLPROC) (HDC hdc, INT32 *numerator, INT32 *denominator);
|
||||
typedef INT64 (WINAPI * PFNWGLSWAPBUFFERSMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder);
|
||||
typedef INT64 (WINAPI * PFNWGLSWAPLAYERBUFFERSMSCOMLPROC) (HDC hdc, int fuPlanes, INT64 target_msc, INT64 divisor, INT64 remainder);
|
||||
typedef BOOL (WINAPI * PFNWGLWAITFORMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder, INT64 *ust, INT64 *msc, INT64 *sbc);
|
||||
typedef BOOL (WINAPI * PFNWGLWAITFORSBCOMLPROC) (HDC hdc, INT64 target_sbc, INT64 *ust, INT64 *msc, INT64 *sbc);
|
||||
#endif
|
||||
|
||||
#ifndef WGL_I3D_digital_video_control
|
||||
#define WGL_I3D_digital_video_control 1
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
extern BOOL WINAPI wglGetDigitalVideoParametersI3D (HDC hDC, int iAttribute, int *piValue);
|
||||
extern BOOL WINAPI wglSetDigitalVideoParametersI3D (HDC hDC, int iAttribute, const int *piValue);
|
||||
#endif /* WGL_WGLEXT_PROTOTYPES */
|
||||
typedef BOOL (WINAPI * PFNWGLGETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int *piValue);
|
||||
typedef BOOL (WINAPI * PFNWGLSETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int *piValue);
|
||||
#endif
|
||||
|
||||
#ifndef WGL_I3D_gamma
|
||||
#define WGL_I3D_gamma 1
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
extern BOOL WINAPI wglGetGammaTableParametersI3D (HDC hDC, int iAttribute, int *piValue);
|
||||
extern BOOL WINAPI wglSetGammaTableParametersI3D (HDC hDC, int iAttribute, const int *piValue);
|
||||
extern BOOL WINAPI wglGetGammaTableI3D (HDC hDC, int iEntries, USHORT *puRed, USHORT *puGreen, USHORT *puBlue);
|
||||
extern BOOL WINAPI wglSetGammaTableI3D (HDC hDC, int iEntries, const USHORT *puRed, const USHORT *puGreen, const USHORT *puBlue);
|
||||
#endif /* WGL_WGLEXT_PROTOTYPES */
|
||||
typedef BOOL (WINAPI * PFNWGLGETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int *piValue);
|
||||
typedef BOOL (WINAPI * PFNWGLSETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int *piValue);
|
||||
typedef BOOL (WINAPI * PFNWGLGETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, USHORT *puRed, USHORT *puGreen, USHORT *puBlue);
|
||||
typedef BOOL (WINAPI * PFNWGLSETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, const USHORT *puRed, const USHORT *puGreen, const USHORT *puBlue);
|
||||
#endif
|
||||
|
||||
#ifndef WGL_I3D_genlock
|
||||
#define WGL_I3D_genlock 1
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
extern BOOL WINAPI wglEnableGenlockI3D (HDC hDC);
|
||||
extern BOOL WINAPI wglDisableGenlockI3D (HDC hDC);
|
||||
extern BOOL WINAPI wglIsEnabledGenlockI3D (HDC hDC, BOOL *pFlag);
|
||||
extern BOOL WINAPI wglGenlockSourceI3D (HDC hDC, UINT uSource);
|
||||
extern BOOL WINAPI wglGetGenlockSourceI3D (HDC hDC, UINT *uSource);
|
||||
extern BOOL WINAPI wglGenlockSourceEdgeI3D (HDC hDC, UINT uEdge);
|
||||
extern BOOL WINAPI wglGetGenlockSourceEdgeI3D (HDC hDC, UINT *uEdge);
|
||||
extern BOOL WINAPI wglGenlockSampleRateI3D (HDC hDC, UINT uRate);
|
||||
extern BOOL WINAPI wglGetGenlockSampleRateI3D (HDC hDC, UINT *uRate);
|
||||
extern BOOL WINAPI wglGenlockSourceDelayI3D (HDC hDC, UINT uDelay);
|
||||
extern BOOL WINAPI wglGetGenlockSourceDelayI3D (HDC hDC, UINT *uDelay);
|
||||
extern BOOL WINAPI wglQueryGenlockMaxSourceDelayI3D (HDC hDC, UINT *uMaxLineDelay, UINT *uMaxPixelDelay);
|
||||
#endif /* WGL_WGLEXT_PROTOTYPES */
|
||||
typedef BOOL (WINAPI * PFNWGLENABLEGENLOCKI3DPROC) (HDC hDC);
|
||||
typedef BOOL (WINAPI * PFNWGLDISABLEGENLOCKI3DPROC) (HDC hDC);
|
||||
typedef BOOL (WINAPI * PFNWGLISENABLEDGENLOCKI3DPROC) (HDC hDC, BOOL *pFlag);
|
||||
typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEI3DPROC) (HDC hDC, UINT uSource);
|
||||
typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEI3DPROC) (HDC hDC, UINT *uSource);
|
||||
typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEEDGEI3DPROC) (HDC hDC, UINT uEdge);
|
||||
typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEEDGEI3DPROC) (HDC hDC, UINT *uEdge);
|
||||
typedef BOOL (WINAPI * PFNWGLGENLOCKSAMPLERATEI3DPROC) (HDC hDC, UINT uRate);
|
||||
typedef BOOL (WINAPI * PFNWGLGETGENLOCKSAMPLERATEI3DPROC) (HDC hDC, UINT *uRate);
|
||||
typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT uDelay);
|
||||
typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT *uDelay);
|
||||
typedef BOOL (WINAPI * PFNWGLQUERYGENLOCKMAXSOURCEDELAYI3DPROC) (HDC hDC, UINT *uMaxLineDelay, UINT *uMaxPixelDelay);
|
||||
#endif
|
||||
|
||||
#ifndef WGL_I3D_image_buffer
|
||||
#define WGL_I3D_image_buffer 1
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
extern LPVOID WINAPI wglCreateImageBufferI3D (HDC hDC, DWORD dwSize, UINT uFlags);
|
||||
extern BOOL WINAPI wglDestroyImageBufferI3D (HDC hDC, LPVOID pAddress);
|
||||
extern BOOL WINAPI wglAssociateImageBufferEventsI3D (HDC hDC, const HANDLE *pEvent, const LPVOID *pAddress, const DWORD *pSize, UINT count);
|
||||
extern BOOL WINAPI wglReleaseImageBufferEventsI3D (HDC hDC, const LPVOID *pAddress, UINT count);
|
||||
#endif /* WGL_WGLEXT_PROTOTYPES */
|
||||
typedef LPVOID (WINAPI * PFNWGLCREATEIMAGEBUFFERI3DPROC) (HDC hDC, DWORD dwSize, UINT uFlags);
|
||||
typedef BOOL (WINAPI * PFNWGLDESTROYIMAGEBUFFERI3DPROC) (HDC hDC, LPVOID pAddress);
|
||||
typedef BOOL (WINAPI * PFNWGLASSOCIATEIMAGEBUFFEREVENTSI3DPROC) (HDC hDC, const HANDLE *pEvent, const LPVOID *pAddress, const DWORD *pSize, UINT count);
|
||||
typedef BOOL (WINAPI * PFNWGLRELEASEIMAGEBUFFEREVENTSI3DPROC) (HDC hDC, const LPVOID *pAddress, UINT count);
|
||||
#endif
|
||||
|
||||
#ifndef WGL_I3D_swap_frame_lock
|
||||
#define WGL_I3D_swap_frame_lock 1
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
extern BOOL WINAPI wglEnableFrameLockI3D (void);
|
||||
extern BOOL WINAPI wglDisableFrameLockI3D (void);
|
||||
extern BOOL WINAPI wglIsEnabledFrameLockI3D (BOOL *pFlag);
|
||||
extern BOOL WINAPI wglQueryFrameLockMasterI3D (BOOL *pFlag);
|
||||
#endif /* WGL_WGLEXT_PROTOTYPES */
|
||||
typedef BOOL (WINAPI * PFNWGLENABLEFRAMELOCKI3DPROC) (void);
|
||||
typedef BOOL (WINAPI * PFNWGLDISABLEFRAMELOCKI3DPROC) (void);
|
||||
typedef BOOL (WINAPI * PFNWGLISENABLEDFRAMELOCKI3DPROC) (BOOL *pFlag);
|
||||
typedef BOOL (WINAPI * PFNWGLQUERYFRAMELOCKMASTERI3DPROC) (BOOL *pFlag);
|
||||
#endif
|
||||
|
||||
#ifndef WGL_I3D_swap_frame_usage
|
||||
#define WGL_I3D_swap_frame_usage 1
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
extern BOOL WINAPI wglGetFrameUsageI3D (float *pUsage);
|
||||
extern BOOL WINAPI wglBeginFrameTrackingI3D (void);
|
||||
extern BOOL WINAPI wglEndFrameTrackingI3D (void);
|
||||
extern BOOL WINAPI wglQueryFrameTrackingI3D (DWORD *pFrameCount, DWORD *pMissedFrames, float *pLastMissedUsage);
|
||||
#endif /* WGL_WGLEXT_PROTOTYPES */
|
||||
typedef BOOL (WINAPI * PFNWGLGETFRAMEUSAGEI3DPROC) (float *pUsage);
|
||||
typedef BOOL (WINAPI * PFNWGLBEGINFRAMETRACKINGI3DPROC) (void);
|
||||
typedef BOOL (WINAPI * PFNWGLENDFRAMETRACKINGI3DPROC) (void);
|
||||
typedef BOOL (WINAPI * PFNWGLQUERYFRAMETRACKINGI3DPROC) (DWORD *pFrameCount, DWORD *pMissedFrames, float *pLastMissedUsage);
|
||||
#endif
|
||||
|
||||
#ifndef WGL_ATI_pixel_format_float
|
||||
#define WGL_ATI_pixel_format_float 1
|
||||
#endif
|
||||
|
||||
#ifndef WGL_NV_float_buffer
|
||||
#define WGL_NV_float_buffer 1
|
||||
#endif
|
||||
|
||||
#ifndef WGL_3DL_stereo_control
|
||||
#define WGL_3DL_stereo_control 1
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
extern BOOL WINAPI wglSetStereoEmitterState3DL (HDC hDC, UINT uState);
|
||||
#endif /* WGL_WGLEXT_PROTOTYPES */
|
||||
typedef BOOL (WINAPI * PFNWGLSETSTEREOEMITTERSTATE3DLPROC) (HDC hDC, UINT uState);
|
||||
#endif
|
||||
|
||||
#ifndef WGL_EXT_pixel_format_packed_float
|
||||
#define WGL_EXT_pixel_format_packed_float 1
|
||||
#endif
|
||||
|
||||
#ifndef WGL_EXT_framebuffer_sRGB
|
||||
#define WGL_EXT_framebuffer_sRGB 1
|
||||
#endif
|
||||
|
||||
#ifndef WGL_NV_present_video
|
||||
#define WGL_NV_present_video 1
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
extern int WINAPI wglEnumerateVideoDevicesNV (HDC hDC, HVIDEOOUTPUTDEVICENV *phDeviceList);
|
||||
extern BOOL WINAPI wglBindVideoDeviceNV (HDC hDC, unsigned int uVideoSlot, HVIDEOOUTPUTDEVICENV hVideoDevice, const int *piAttribList);
|
||||
extern BOOL WINAPI wglQueryCurrentContextNV (int iAttribute, int *piValue);
|
||||
#endif /* WGL_WGLEXT_PROTOTYPES */
|
||||
typedef int (WINAPI * PFNWGLENUMERATEVIDEODEVICESNVPROC) (HDC hDC, HVIDEOOUTPUTDEVICENV *phDeviceList);
|
||||
typedef BOOL (WINAPI * PFNWGLBINDVIDEODEVICENVPROC) (HDC hDC, unsigned int uVideoSlot, HVIDEOOUTPUTDEVICENV hVideoDevice, const int *piAttribList);
|
||||
typedef BOOL (WINAPI * PFNWGLQUERYCURRENTCONTEXTNVPROC) (int iAttribute, int *piValue);
|
||||
#endif
|
||||
|
||||
#ifndef WGL_NV_video_output
|
||||
#define WGL_NV_video_output 1
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
extern BOOL WINAPI wglGetVideoDeviceNV (HDC hDC, int numDevices, HPVIDEODEV *hVideoDevice);
|
||||
extern BOOL WINAPI wglReleaseVideoDeviceNV (HPVIDEODEV hVideoDevice);
|
||||
extern BOOL WINAPI wglBindVideoImageNV (HPVIDEODEV hVideoDevice, HPBUFFERARB hPbuffer, int iVideoBuffer);
|
||||
extern BOOL WINAPI wglReleaseVideoImageNV (HPBUFFERARB hPbuffer, int iVideoBuffer);
|
||||
extern BOOL WINAPI wglSendPbufferToVideoNV (HPBUFFERARB hPbuffer, int iBufferType, unsigned long *pulCounterPbuffer, BOOL bBlock);
|
||||
extern BOOL WINAPI wglGetVideoInfoNV (HPVIDEODEV hpVideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo);
|
||||
#endif /* WGL_WGLEXT_PROTOTYPES */
|
||||
typedef BOOL (WINAPI * PFNWGLGETVIDEODEVICENVPROC) (HDC hDC, int numDevices, HPVIDEODEV *hVideoDevice);
|
||||
typedef BOOL (WINAPI * PFNWGLRELEASEVIDEODEVICENVPROC) (HPVIDEODEV hVideoDevice);
|
||||
typedef BOOL (WINAPI * PFNWGLBINDVIDEOIMAGENVPROC) (HPVIDEODEV hVideoDevice, HPBUFFERARB hPbuffer, int iVideoBuffer);
|
||||
typedef BOOL (WINAPI * PFNWGLRELEASEVIDEOIMAGENVPROC) (HPBUFFERARB hPbuffer, int iVideoBuffer);
|
||||
typedef BOOL (WINAPI * PFNWGLSENDPBUFFERTOVIDEONVPROC) (HPBUFFERARB hPbuffer, int iBufferType, unsigned long *pulCounterPbuffer, BOOL bBlock);
|
||||
typedef BOOL (WINAPI * PFNWGLGETVIDEOINFONVPROC) (HPVIDEODEV hpVideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo);
|
||||
#endif
|
||||
|
||||
#ifndef WGL_NV_swap_group
|
||||
#define WGL_NV_swap_group 1
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
extern BOOL WINAPI wglJoinSwapGroupNV (HDC hDC, GLuint group);
|
||||
extern BOOL WINAPI wglBindSwapBarrierNV (GLuint group, GLuint barrier);
|
||||
extern BOOL WINAPI wglQuerySwapGroupNV (HDC hDC, GLuint *group, GLuint *barrier);
|
||||
extern BOOL WINAPI wglQueryMaxSwapGroupsNV (HDC hDC, GLuint *maxGroups, GLuint *maxBarriers);
|
||||
extern BOOL WINAPI wglQueryFrameCountNV (HDC hDC, GLuint *count);
|
||||
extern BOOL WINAPI wglResetFrameCountNV (HDC hDC);
|
||||
#endif /* WGL_WGLEXT_PROTOTYPES */
|
||||
typedef BOOL (WINAPI * PFNWGLJOINSWAPGROUPNVPROC) (HDC hDC, GLuint group);
|
||||
typedef BOOL (WINAPI * PFNWGLBINDSWAPBARRIERNVPROC) (GLuint group, GLuint barrier);
|
||||
typedef BOOL (WINAPI * PFNWGLQUERYSWAPGROUPNVPROC) (HDC hDC, GLuint *group, GLuint *barrier);
|
||||
typedef BOOL (WINAPI * PFNWGLQUERYMAXSWAPGROUPSNVPROC) (HDC hDC, GLuint *maxGroups, GLuint *maxBarriers);
|
||||
typedef BOOL (WINAPI * PFNWGLQUERYFRAMECOUNTNVPROC) (HDC hDC, GLuint *count);
|
||||
typedef BOOL (WINAPI * PFNWGLRESETFRAMECOUNTNVPROC) (HDC hDC);
|
||||
#endif
|
||||
|
||||
#ifndef WGL_NV_gpu_affinity
|
||||
#define WGL_NV_gpu_affinity 1
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
extern BOOL WINAPI wglEnumGpusNV (UINT iGpuIndex, HGPUNV *phGpu);
|
||||
extern BOOL WINAPI wglEnumGpuDevicesNV (HGPUNV hGpu, UINT iDeviceIndex, PGPU_DEVICE lpGpuDevice);
|
||||
extern HDC WINAPI wglCreateAffinityDCNV (const HGPUNV *phGpuList);
|
||||
extern BOOL WINAPI wglEnumGpusFromAffinityDCNV (HDC hAffinityDC, UINT iGpuIndex, HGPUNV *hGpu);
|
||||
extern BOOL WINAPI wglDeleteDCNV (HDC hdc);
|
||||
#endif /* WGL_WGLEXT_PROTOTYPES */
|
||||
typedef BOOL (WINAPI * PFNWGLENUMGPUSNVPROC) (UINT iGpuIndex, HGPUNV *phGpu);
|
||||
typedef BOOL (WINAPI * PFNWGLENUMGPUDEVICESNVPROC) (HGPUNV hGpu, UINT iDeviceIndex, PGPU_DEVICE lpGpuDevice);
|
||||
typedef HDC (WINAPI * PFNWGLCREATEAFFINITYDCNVPROC) (const HGPUNV *phGpuList);
|
||||
typedef BOOL (WINAPI * PFNWGLENUMGPUSFROMAFFINITYDCNVPROC) (HDC hAffinityDC, UINT iGpuIndex, HGPUNV *hGpu);
|
||||
typedef BOOL (WINAPI * PFNWGLDELETEDCNVPROC) (HDC hdc);
|
||||
#endif
|
||||
|
||||
#ifndef WGL_AMD_gpu_association
|
||||
#define WGL_AMD_gpu_association 1
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
extern UINT WINAPI wglGetGPUIDsAMD (UINT maxCount, UINT *ids);
|
||||
extern INT WINAPI wglGetGPUInfoAMD (UINT id, int property, GLenum dataType, UINT size, void *data);
|
||||
extern UINT WINAPI wglGetContextGPUIDAMD (HGLRC hglrc);
|
||||
extern HGLRC WINAPI wglCreateAssociatedContextAMD (UINT id);
|
||||
extern HGLRC WINAPI wglCreateAssociatedContextAttribsAMD (UINT id, HGLRC hShareContext, const int *attribList);
|
||||
extern BOOL WINAPI wglDeleteAssociatedContextAMD (HGLRC hglrc);
|
||||
extern BOOL WINAPI wglMakeAssociatedContextCurrentAMD (HGLRC hglrc);
|
||||
extern HGLRC WINAPI wglGetCurrentAssociatedContextAMD (void);
|
||||
extern VOID WINAPI wglBlitContextFramebufferAMD (HGLRC dstCtx, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
|
||||
#endif /* WGL_WGLEXT_PROTOTYPES */
|
||||
typedef UINT (WINAPI * PFNWGLGETGPUIDSAMDPROC) (UINT maxCount, UINT *ids);
|
||||
typedef INT (WINAPI * PFNWGLGETGPUINFOAMDPROC) (UINT id, int property, GLenum dataType, UINT size, void *data);
|
||||
typedef UINT (WINAPI * PFNWGLGETCONTEXTGPUIDAMDPROC) (HGLRC hglrc);
|
||||
typedef HGLRC (WINAPI * PFNWGLCREATEASSOCIATEDCONTEXTAMDPROC) (UINT id);
|
||||
typedef HGLRC (WINAPI * PFNWGLCREATEASSOCIATEDCONTEXTATTRIBSAMDPROC) (UINT id, HGLRC hShareContext, const int *attribList);
|
||||
typedef BOOL (WINAPI * PFNWGLDELETEASSOCIATEDCONTEXTAMDPROC) (HGLRC hglrc);
|
||||
typedef BOOL (WINAPI * PFNWGLMAKEASSOCIATEDCONTEXTCURRENTAMDPROC) (HGLRC hglrc);
|
||||
typedef HGLRC (WINAPI * PFNWGLGETCURRENTASSOCIATEDCONTEXTAMDPROC) (void);
|
||||
typedef VOID (WINAPI * PFNWGLBLITCONTEXTFRAMEBUFFERAMDPROC) (HGLRC dstCtx, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
|
||||
#endif
|
||||
|
||||
#ifndef WGL_NV_video_capture
|
||||
#define WGL_NV_video_capture 1
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
extern BOOL WINAPI wglBindVideoCaptureDeviceNV (UINT uVideoSlot, HVIDEOINPUTDEVICENV hDevice);
|
||||
extern UINT WINAPI wglEnumerateVideoCaptureDevicesNV (HDC hDc, HVIDEOINPUTDEVICENV *phDeviceList);
|
||||
extern BOOL WINAPI wglLockVideoCaptureDeviceNV (HDC hDc, HVIDEOINPUTDEVICENV hDevice);
|
||||
extern BOOL WINAPI wglQueryVideoCaptureDeviceNV (HDC hDc, HVIDEOINPUTDEVICENV hDevice, int iAttribute, int *piValue);
|
||||
extern BOOL WINAPI wglReleaseVideoCaptureDeviceNV (HDC hDc, HVIDEOINPUTDEVICENV hDevice);
|
||||
#endif /* WGL_WGLEXT_PROTOTYPES */
|
||||
typedef BOOL (WINAPI * PFNWGLBINDVIDEOCAPTUREDEVICENVPROC) (UINT uVideoSlot, HVIDEOINPUTDEVICENV hDevice);
|
||||
typedef UINT (WINAPI * PFNWGLENUMERATEVIDEOCAPTUREDEVICESNVPROC) (HDC hDc, HVIDEOINPUTDEVICENV *phDeviceList);
|
||||
typedef BOOL (WINAPI * PFNWGLLOCKVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice);
|
||||
typedef BOOL (WINAPI * PFNWGLQUERYVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice, int iAttribute, int *piValue);
|
||||
typedef BOOL (WINAPI * PFNWGLRELEASEVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice);
|
||||
#endif
|
||||
|
||||
#ifndef WGL_NV_copy_image
|
||||
#define WGL_NV_copy_image 1
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
extern BOOL WINAPI wglCopyImageSubDataNV (HGLRC hSrcRC, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, HGLRC hDstRC, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth);
|
||||
#endif /* WGL_WGLEXT_PROTOTYPES */
|
||||
typedef BOOL (WINAPI * PFNWGLCOPYIMAGESUBDATANVPROC) (HGLRC hSrcRC, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, HGLRC hDstRC, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth);
|
||||
#endif
|
||||
|
||||
#ifndef WGL_NV_multisample_coverage
|
||||
#define WGL_NV_multisample_coverage 1
|
||||
#endif
|
||||
|
||||
#ifndef WGL_NV_DX_interop
|
||||
#define WGL_NV_DX_interop 1
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
extern BOOL WINAPI wglDXSetResourceShareHandleNV (void *dxObject, HANDLE shareHandle);
|
||||
extern HANDLE WINAPI wglDXOpenDeviceNV (void *dxDevice);
|
||||
extern BOOL WINAPI wglDXCloseDeviceNV (HANDLE hDevice);
|
||||
extern HANDLE WINAPI wglDXRegisterObjectNV (HANDLE hDevice, void *dxObject, GLuint name, GLenum type, GLenum access);
|
||||
extern BOOL WINAPI wglDXUnregisterObjectNV (HANDLE hDevice, HANDLE hObject);
|
||||
extern BOOL WINAPI wglDXObjectAccessNV (HANDLE hObject, GLenum access);
|
||||
extern BOOL WINAPI wglDXLockObjectsNV (HANDLE hDevice, GLint count, HANDLE *hObjects);
|
||||
extern BOOL WINAPI wglDXUnlockObjectsNV (HANDLE hDevice, GLint count, HANDLE *hObjects);
|
||||
#endif /* WGL_WGLEXT_PROTOTYPES */
|
||||
typedef BOOL (WINAPI * PFNWGLDXSETRESOURCESHAREHANDLENVPROC) (void *dxObject, HANDLE shareHandle);
|
||||
typedef HANDLE (WINAPI * PFNWGLDXOPENDEVICENVPROC) (void *dxDevice);
|
||||
typedef BOOL (WINAPI * PFNWGLDXCLOSEDEVICENVPROC) (HANDLE hDevice);
|
||||
typedef HANDLE (WINAPI * PFNWGLDXREGISTEROBJECTNVPROC) (HANDLE hDevice, void *dxObject, GLuint name, GLenum type, GLenum access);
|
||||
typedef BOOL (WINAPI * PFNWGLDXUNREGISTEROBJECTNVPROC) (HANDLE hDevice, HANDLE hObject);
|
||||
typedef BOOL (WINAPI * PFNWGLDXOBJECTACCESSNVPROC) (HANDLE hObject, GLenum access);
|
||||
typedef BOOL (WINAPI * PFNWGLDXLOCKOBJECTSNVPROC) (HANDLE hDevice, GLint count, HANDLE *hObjects);
|
||||
typedef BOOL (WINAPI * PFNWGLDXUNLOCKOBJECTSNVPROC) (HANDLE hDevice, GLint count, HANDLE *hObjects);
|
||||
#endif
|
||||
|
||||
#ifndef WGL_NV_DX_interop2
|
||||
#define WGL_NV_DX_interop2 1
|
||||
#endif
|
||||
|
||||
#ifndef WGL_EXT_swap_control_tear
|
||||
#define WGL_EXT_swap_control_tear 1
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
35
include/Nazara/Audio/Config.hpp
Normal file
35
include/Nazara/Audio/Config.hpp
Normal file
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
Nazara Engine
|
||||
|
||||
Copyright (C) 2012 Jérôme "Lynix" Leclercq (Lynix680@gmail.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_CONFIG_AUDIO_HPP
|
||||
#define NAZARA_CONFIG_AUDIO_HPP
|
||||
|
||||
/// Chaque modification d'un paramètre du module nécessite une recompilation de celui-ci
|
||||
|
||||
// Utilise un tracker pour repérer les éventuels leaks (Ralentit l'exécution)
|
||||
#define NAZARA_AUDIO_MEMORYLEAKTRACKER 0
|
||||
|
||||
#endif // NAZARA_CONFIG_AUDIOs_HPP
|
||||
11
include/Nazara/Audio/Debug.hpp
Normal file
11
include/Nazara/Audio/Debug.hpp
Normal file
@@ -0,0 +1,11 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Audio/Config.hpp>
|
||||
#if NAZARA_AUDIO_MEMORYLEAKTRACKER || defined(NAZARA_DEBUG)
|
||||
#include <Nazara/Core/Debug/MemoryLeakTracker.hpp>
|
||||
|
||||
#define delete NzMemoryManager::NextFree(__FILE__, __LINE__), delete
|
||||
#define new new(__FILE__, __LINE__)
|
||||
#endif
|
||||
8
include/Nazara/Audio/DebugOff.hpp
Normal file
8
include/Nazara/Audio/DebugOff.hpp
Normal file
@@ -0,0 +1,8 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#if NAZARA_AUDIO_MEMORYLEAKTRACKER || defined(NAZARA_DEBUG)
|
||||
#undef delete
|
||||
#undef new
|
||||
#endif
|
||||
27
include/Nazara/Audio/Sound.hpp
Normal file
27
include/Nazara/Audio/Sound.hpp
Normal file
@@ -0,0 +1,27 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_SOUND_HPP
|
||||
#define NAZARA_SOUND_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Utility/Resource.hpp>
|
||||
|
||||
class NAZARA_API NzSound
|
||||
{
|
||||
public:
|
||||
NzSound();
|
||||
~NzSound();
|
||||
|
||||
bool LoadFromFile(const NzString& filePath);
|
||||
bool LoadFromMemory(const nzUInt8* ptr, std::size_t size);
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
#endif // NAZARA_SOUND_HPP
|
||||
124
include/Nazara/Core/ByteArray.hpp
Normal file
124
include/Nazara/Core/ByteArray.hpp
Normal file
@@ -0,0 +1,124 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_BYTEARRAY_HPP
|
||||
#define NAZARA_BYTEARRAY_HPP
|
||||
|
||||
#define NAZARA_BYTEARRAY
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/Hashable.hpp>
|
||||
#include <Nazara/Core/ThreadSafety.hpp>
|
||||
|
||||
class NzAbstractHash;
|
||||
class NzHashDigest;
|
||||
|
||||
class NAZARA_API NzByteArray : public NzHashable
|
||||
{
|
||||
public:
|
||||
struct SharedArray;
|
||||
|
||||
NzByteArray();
|
||||
NzByteArray(const nzUInt8* buffer, unsigned int bufferLength);
|
||||
NzByteArray(const NzByteArray& buffer);
|
||||
NzByteArray(NzByteArray&& buffer);
|
||||
NzByteArray(SharedArray* sharedArray);
|
||||
~NzByteArray();
|
||||
|
||||
unsigned int Capacity() const;
|
||||
|
||||
void Clear();
|
||||
|
||||
const nzUInt8* GetBuffer() const;
|
||||
unsigned int GetSize() const;
|
||||
|
||||
NzByteArray& Insert(int pos, const nzUInt8* buffer, unsigned int bufferLength);
|
||||
NzByteArray& Insert(int pos, const NzByteArray& byteArray);
|
||||
|
||||
bool IsEmpty() const;
|
||||
|
||||
void Reserve(unsigned int bufferSize);
|
||||
|
||||
NzByteArray& Resize(int size, nzUInt8 byte = '\0');
|
||||
NzByteArray Resized(int size, nzUInt8 byte = '\0') const;
|
||||
|
||||
NzByteArray SubArray(int startPos, int endPos = -1) const;
|
||||
|
||||
void Swap(NzByteArray& byteArray);
|
||||
|
||||
NzByteArray& Trim(nzUInt8 byte = '\0');
|
||||
NzByteArray Trimmed(nzUInt8 byte = '\0') const;
|
||||
|
||||
// Méthodes compatibles STD
|
||||
nzUInt8* begin();
|
||||
const nzUInt8* begin() const;
|
||||
nzUInt8* end();
|
||||
const nzUInt8* end() const;
|
||||
void push_front(nzUInt8 c);
|
||||
void push_back(nzUInt8 c);
|
||||
/*nzUInt8* rbegin();
|
||||
const nzUInt8* rbegin() const;
|
||||
nzUInt8* rend();
|
||||
const nzUInt8* rend() const;*/
|
||||
|
||||
typedef const nzUInt8& const_reference;
|
||||
typedef nzUInt8* iterator;
|
||||
//typedef nzUInt8* reverse_iterator;
|
||||
typedef nzUInt8 value_type;
|
||||
// Méthodes compatibles STD
|
||||
|
||||
nzUInt8& operator[](unsigned int pos);
|
||||
nzUInt8 operator[](unsigned int pos) const;
|
||||
|
||||
NzByteArray& operator=(const NzByteArray& byteArray);
|
||||
NzByteArray& operator=(NzByteArray&& byteArray);
|
||||
|
||||
NzByteArray operator+(const NzByteArray& byteArray) const;
|
||||
NzByteArray& operator+=(const NzByteArray& byteArray);
|
||||
|
||||
static int Compare(const NzByteArray& first, const NzByteArray& second);
|
||||
|
||||
struct NAZARA_API SharedArray
|
||||
{
|
||||
SharedArray() :
|
||||
refCount(1)
|
||||
{
|
||||
}
|
||||
|
||||
SharedArray(unsigned int bufferSize, unsigned int arraySize, unsigned short referenceCount, nzUInt8* ptr) :
|
||||
allocatedSize(bufferSize),
|
||||
size(arraySize),
|
||||
refCount(referenceCount),
|
||||
buffer(ptr)
|
||||
{
|
||||
}
|
||||
|
||||
unsigned int allocatedSize;
|
||||
unsigned int size;
|
||||
unsigned short refCount;
|
||||
nzUInt8* buffer;
|
||||
|
||||
NazaraMutex(mutex)
|
||||
};
|
||||
|
||||
static SharedArray emptyArray;
|
||||
|
||||
private:
|
||||
void EnsureOwnership();
|
||||
bool FillHash(NzHashImpl* hash) const;
|
||||
void ReleaseArray();
|
||||
|
||||
SharedArray* m_sharedArray;
|
||||
};
|
||||
|
||||
namespace std
|
||||
{
|
||||
NAZARA_API void swap(NzByteArray& lhs, NzByteArray& rhs);
|
||||
}
|
||||
|
||||
#undef NAZARA_BYTEARRAY
|
||||
|
||||
#endif // NAZARA_BYTEARRAY_HPP
|
||||
45
include/Nazara/Core/Clock.hpp
Normal file
45
include/Nazara/Core/Clock.hpp
Normal file
@@ -0,0 +1,45 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_CLOCK_HPP
|
||||
#define NAZARA_CLOCK_HPP
|
||||
|
||||
#define NAZARA_CLOCK
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/ThreadSafety.hpp>
|
||||
|
||||
class NAZARA_API NzClock
|
||||
{
|
||||
public:
|
||||
NzClock();
|
||||
|
||||
float GetSeconds() const;
|
||||
nzUInt64 GetMicroseconds() const;
|
||||
nzUInt64 GetMilliseconds() const;
|
||||
|
||||
bool IsPaused() const;
|
||||
|
||||
void Pause();
|
||||
void Restart();
|
||||
void Unpause();
|
||||
|
||||
private:
|
||||
NazaraMutexAttrib(m_mutex, mutable)
|
||||
|
||||
nzUInt64 m_elapsedTime;
|
||||
nzUInt64 m_refTime;
|
||||
bool m_paused;
|
||||
};
|
||||
|
||||
typedef nzUInt64 (*NzClockFunction)();
|
||||
|
||||
extern NAZARA_API NzClockFunction NzGetMicroseconds;
|
||||
extern NAZARA_API NzClockFunction NzGetMilliseconds;
|
||||
|
||||
#undef NAZARA_CLOCK
|
||||
|
||||
#endif // NAZARA_CLOCK_HPP
|
||||
79
include/Nazara/Core/Config.hpp
Normal file
79
include/Nazara/Core/Config.hpp
Normal file
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
Nazara Engine
|
||||
|
||||
Copyright (C) 2012 Jérôme "Lynix" Leclercq (Lynix680@gmail.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_CONFIG_CORE_HPP
|
||||
#define NAZARA_CONFIG_CORE_HPP
|
||||
|
||||
/// Chaque modification d'un paramètre du module nécessite une recompilation de celui-ci
|
||||
|
||||
// Appelle exit dès qu'une assertion est invalide
|
||||
#define NAZARA_CORE_EXIT_ON_ASSERT_FAILURE 1
|
||||
|
||||
// Teste les assertions
|
||||
#define NAZARA_CORE_ENABLE_ASSERTS 0
|
||||
|
||||
// Taille du buffer lors d'une lecture complète d'un fichier (ex: Hash)
|
||||
#define NAZARA_CORE_FILE_BUFFERSIZE 4096
|
||||
|
||||
// Le moteur doit-il incorporer les Unicode Character Data (Nécessaires pour faire fonctionner le flag NzString::HandleUTF8)
|
||||
#define NAZARA_CORE_INCLUDE_UNICODEDATA 0
|
||||
|
||||
// Utilise un tracker pour repérer les éventuels leaks (Ralentit l'exécution)
|
||||
#define NAZARA_CORE_MEMORYLEAKTRACKER 0
|
||||
|
||||
// Standardise les séparateurs des dossiers selon le système d'exploitation courant
|
||||
#define NAZARA_CORE_NORMALIZE_DIRECTORY_SEPARATORS 1
|
||||
|
||||
// Précision des réels lors de la transformation en texte (Max. chiffres après la virgule)
|
||||
#define NAZARA_CORE_REAL_PRECISION 6
|
||||
|
||||
// Redirige la sortie du log sur le flux d'erreur standard (cerr) en cas d'erreur d'écriture (ou d'ouverture du fichier)
|
||||
#define NAZARA_CORE_REDIRECT_TO_CERR_ON_LOG_FAILURE 1
|
||||
|
||||
// Active les tests de sécurité basés sur le code (Conseillé pour le développement)
|
||||
#define NAZARA_CORE_SAFE 1
|
||||
|
||||
// Protége le noyau des accès concurrentiels
|
||||
#define NAZARA_CORE_THREADSAFE 1
|
||||
|
||||
#if NAZARA_CORE_THREADSAFE
|
||||
#define NAZARA_THREADSAFETY_APPLICATION 1 // NzApplication
|
||||
#define NAZARA_THREADSAFETY_CLOCK 0 // NzClock
|
||||
#define NAZARA_THREADSAFETY_DIRECTORY 1 // NzDirectory
|
||||
#define NAZARA_THREADSAFETY_DYNLIB 1 // NzDynLib
|
||||
#define NAZARA_THREADSAFETY_FILE 1 // NzFile
|
||||
#define NAZARA_THREADSAFETY_HASHDIGEST 0 // NzHashDigest
|
||||
#define NAZARA_THREADSAFETY_LOG 1 // NzLog
|
||||
#define NAZARA_THREADSAFETY_STRING 1 // NzString
|
||||
#define NAZARA_THREADSAFETY_STRINGSTREAM 0 // NzStringStream
|
||||
#endif
|
||||
|
||||
/*
|
||||
// Règle le temps entre le réveil du thread des timers et l'activation d'un timer (En millisecondes)
|
||||
#define NAZARA_CORE_TIMER_WAKEUPTIME 10
|
||||
*/
|
||||
|
||||
#endif // NAZARA_CONFIG_CORE_HPP
|
||||
11
include/Nazara/Core/Debug.hpp
Normal file
11
include/Nazara/Core/Debug.hpp
Normal file
@@ -0,0 +1,11 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Core/Config.hpp>
|
||||
#if NAZARA_CORE_MEMORYLEAKTRACKER || defined(NAZARA_DEBUG)
|
||||
#include <Nazara/Core/Debug/MemoryLeakTracker.hpp>
|
||||
|
||||
#define delete NzMemoryManager::NextFree(__FILE__, __LINE__), delete
|
||||
#define new new(__FILE__, __LINE__)
|
||||
#endif
|
||||
40
include/Nazara/Core/Debug/MemoryLeakTracker.hpp
Normal file
40
include/Nazara/Core/Debug/MemoryLeakTracker.hpp
Normal file
@@ -0,0 +1,40 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_DEBUG_MEMORYLEAKTRACKER_HPP
|
||||
#define NAZARA_DEBUG_MEMORYLEAKTRACKER_HPP
|
||||
|
||||
#define NAZARA_DEBUG_MEMORYLEAKTRACKER
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
|
||||
class NAZARA_API NzMemoryManager
|
||||
{
|
||||
public:
|
||||
NzMemoryManager();
|
||||
~NzMemoryManager();
|
||||
|
||||
static void* Allocate(std::size_t size, bool multi, const char* file = nullptr, unsigned int line = 0);
|
||||
static void Free(void* pointer, bool multi);
|
||||
static void NextFree(const char* file, unsigned int line);
|
||||
|
||||
private:
|
||||
static void EnsureInitialization();
|
||||
static void Initialize();
|
||||
static char* TimeInfo();
|
||||
static void Uninitialize();
|
||||
};
|
||||
|
||||
NAZARA_API void* operator new(std::size_t size, const char* file, unsigned int line);
|
||||
NAZARA_API void* operator new[](std::size_t size, const char* file, unsigned int line);
|
||||
NAZARA_API void operator delete(void* ptr, const char* file, unsigned int line) throw();
|
||||
NAZARA_API void operator delete[](void* ptr, const char* file, unsigned int line) throw();
|
||||
|
||||
#undef NAZARA_DEBUG_MEMORYLEAKTRACKER
|
||||
|
||||
#endif // NAZARA_DEBUG_MEMORYLEAKTRACKER_HPP
|
||||
8
include/Nazara/Core/DebugOff.hpp
Normal file
8
include/Nazara/Core/DebugOff.hpp
Normal file
@@ -0,0 +1,8 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#if NAZARA_CORE_MEMORYLEAKTRACKER || defined(NAZARA_DEBUG)
|
||||
#undef delete
|
||||
#undef new
|
||||
#endif
|
||||
64
include/Nazara/Core/Directory.hpp
Normal file
64
include/Nazara/Core/Directory.hpp
Normal file
@@ -0,0 +1,64 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_DIRECTORY_HPP
|
||||
#define NAZARA_DIRECTORY_HPP
|
||||
|
||||
#define NAZARA_DIRECTORY
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Core/ThreadSafety.hpp>
|
||||
|
||||
#if defined(NAZARA_PLATFORM_WINDOWS)
|
||||
#define NAZARA_DIRECTORY_SEPARATOR '\\'
|
||||
#elif defined(NAZARA_PLATFORM_LINUX)
|
||||
#define NAZARA_DIRECTORY_SEPARATOR '/'
|
||||
#else
|
||||
#error OS not handled
|
||||
#define NAZARA_DIRECTORY_SEPARATOR '/'
|
||||
#endif
|
||||
|
||||
class NzDirectoryImpl;
|
||||
|
||||
class NAZARA_API NzDirectory
|
||||
{
|
||||
public:
|
||||
NzDirectory();
|
||||
NzDirectory(const NzString& dirPath);
|
||||
~NzDirectory();
|
||||
|
||||
void Close();
|
||||
|
||||
NzString GetResultName() const;
|
||||
NzString GetResultPath() const;
|
||||
nzUInt64 GetResultSize() const;
|
||||
|
||||
bool IsResultDirectory() const;
|
||||
|
||||
bool NextResult(bool skipDots = true);
|
||||
|
||||
bool Open();
|
||||
|
||||
void SetDirectory(const NzString& dirPath);
|
||||
|
||||
static bool Copy(const NzString& sourcePath, const NzString& destPath);
|
||||
static bool Create(const NzString& dirPath, bool recursive = false);
|
||||
static bool Exists(const NzString& dirPath);
|
||||
static NzString GetCurrent();
|
||||
static bool Remove(const NzString& dirPath, bool emptyDirectory = false);
|
||||
static bool SetCurrent(const NzString& dirPath);
|
||||
|
||||
private:
|
||||
NazaraMutexAttrib(m_mutex, mutable)
|
||||
|
||||
NzString m_dirPath;
|
||||
NzDirectoryImpl* m_impl;
|
||||
};
|
||||
|
||||
#undef NAZARA_DIRECTORY
|
||||
|
||||
#endif // NAZARA_DIRECTORY_HPP
|
||||
45
include/Nazara/Core/DynLib.hpp
Normal file
45
include/Nazara/Core/DynLib.hpp
Normal file
@@ -0,0 +1,45 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_DYNLIB_HPP
|
||||
#define NAZARA_DYNLIB_HPP
|
||||
|
||||
#define NAZARA_DYNLIB
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Core/ThreadSafety.hpp>
|
||||
#include <Nazara/Utility/NonCopyable.hpp>
|
||||
|
||||
class NzDynLibImpl;
|
||||
typedef int (*NzDynLibFunc)(); // Type "générique" de pointeur sur fonction
|
||||
|
||||
class NzDynLib : NzNonCopyable
|
||||
{
|
||||
friend class NzDynLibImpl;
|
||||
|
||||
public:
|
||||
NzDynLib(const NzString& libraryPath);
|
||||
~NzDynLib();
|
||||
|
||||
NzString GetLastError() const;
|
||||
NzDynLibFunc GetSymbol(const NzString& symbol) const;
|
||||
bool Load();
|
||||
void Unload();
|
||||
|
||||
private:
|
||||
void SetLastError(const NzString& error);
|
||||
|
||||
NazaraMutexAttrib(m_mutex, mutable)
|
||||
|
||||
NzString m_lastError;
|
||||
NzString m_path;
|
||||
NzDynLibImpl* m_impl;
|
||||
};
|
||||
|
||||
#undef NAZARA_DYNLIB
|
||||
|
||||
#endif // NAZARA_DYNLIB_HPP
|
||||
50
include/Nazara/Core/Endianness.hpp
Normal file
50
include/Nazara/Core/Endianness.hpp
Normal file
@@ -0,0 +1,50 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_ENDIANNESS_HPP
|
||||
#define NAZARA_ENDIANNESS_HPP
|
||||
|
||||
#define NAZARA_ENDIANNESS
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
|
||||
#if defined(NAZARA_ENDIANNESS_BIGENDIAN)
|
||||
#define NAZARA_ENDIANNESS_DETECTED 1
|
||||
#define NazaraEndianness nzEndianness_BigEndian
|
||||
#elif defined(NAZARA_ENDIANNESS_LITTLEENDIAN)
|
||||
#define NAZARA_ENDIANNESS_DETECTED 1
|
||||
#define NazaraEndianness nzEndianness_LittleEndian
|
||||
#else
|
||||
#if defined(__m68k__) || defined(mc68000) || defined(_M_M68K) || (defined(__MIPS__) && defined(__MISPEB__)) || \
|
||||
defined(__ppc__) || defined(__POWERPC__) || defined(_M_PPC) || defined(__sparc__) || defined(__hppa__)
|
||||
#define NAZARA_ENDIANNESS_DETECTED 1
|
||||
#define NAZARA_ENDIANNESS_BIGENDIAN
|
||||
#define NazaraEndianness nzEndianness_BigEndian
|
||||
#elif defined(__i386__) || defined(__i386) || defined(__X86__) || defined (__x86_64)
|
||||
#define NAZARA_ENDIANNESS_DETECTED 1
|
||||
#define NAZARA_ENDIANNESS_LITTLEENDIAN
|
||||
#define NazaraEndianness nzEndianness_LittleEndian
|
||||
#else
|
||||
#define NAZARA_ENDIANNESS_DETECTED 0
|
||||
#define NazaraEndianness NzGetPlatformEndianness()
|
||||
#endif
|
||||
#endif
|
||||
|
||||
enum nzEndianness
|
||||
{
|
||||
nzEndianness_BigEndian,
|
||||
nzEndianness_LittleEndian,
|
||||
nzEndianness_Unknown
|
||||
};
|
||||
|
||||
inline void NzByteSwap(void* buffer, unsigned int size);
|
||||
inline nzEndianness NzGetPlatformEndianness();
|
||||
|
||||
#include <Nazara/Core/Endianness.inl>
|
||||
|
||||
#undef NAZARA_ENDIANNESS
|
||||
|
||||
#endif // NAZARA_ENDIANNESS_HPP
|
||||
38
include/Nazara/Core/Endianness.inl
Normal file
38
include/Nazara/Core/Endianness.inl
Normal file
@@ -0,0 +1,38 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
inline void NzByteSwap(void* buffer, unsigned int size)
|
||||
{
|
||||
nzUInt8* bytes = reinterpret_cast<nzUInt8*>(buffer);
|
||||
unsigned int i = 0;
|
||||
unsigned int j = size-1;
|
||||
|
||||
while (i < j)
|
||||
std::swap(bytes[i++], bytes[j--]);
|
||||
}
|
||||
|
||||
inline nzEndianness NzGetPlatformEndianness()
|
||||
{
|
||||
#if NAZARA_ENDIANNESS_DETECTED
|
||||
return NazaraEndianness;
|
||||
#else
|
||||
static nzEndianness endianness = nzEndianness_Unknown;
|
||||
static bool tested = false;
|
||||
if (!tested)
|
||||
{
|
||||
nzUInt32 i = 1;
|
||||
nzUInt8* p = reinterpret_cast<nzUInt8*>(&i);
|
||||
|
||||
// Méthode de récupération de l'endianness au runtime
|
||||
if (p[0] == 1)
|
||||
endianness = nzEndianness_LittleEndian;
|
||||
else if (p[3] == 1)
|
||||
endianness = nzEndianness_BigEndian;
|
||||
|
||||
tested = true;
|
||||
}
|
||||
|
||||
return endianness;
|
||||
#endif
|
||||
}
|
||||
39
include/Nazara/Core/Error.hpp
Normal file
39
include/Nazara/Core/Error.hpp
Normal file
@@ -0,0 +1,39 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_ERROR_HPP
|
||||
#define NAZARA_ERROR_HPP
|
||||
|
||||
#define NAZARA_ERROR
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
|
||||
#if NAZARA_CORE_ENABLE_ASSERTS || defined(NAZARA_DEBUG)
|
||||
#define NazaraAssert(a, err) if (!(a)) NzError(nzErrorType_AssertFailed, err, __LINE__, __FILE__, NAZARA_FUNCTION)
|
||||
#else
|
||||
#define NazaraAssert(a, err)
|
||||
#endif
|
||||
|
||||
#define NazaraError(err) NzError(nzErrorType_Normal, err, __LINE__, __FILE__, NAZARA_FUNCTION)
|
||||
#define NazaraInternalError(err) NzError(nzErrorType_Internal, err, __LINE__, __FILE__, NAZARA_FUNCTION)
|
||||
#define NazaraWarning(err) NzError(nzErrorType_Warning, err, __LINE__, __FILE__, NAZARA_FUNCTION)
|
||||
|
||||
enum nzErrorType
|
||||
{
|
||||
nzErrorType_AssertFailed,
|
||||
nzErrorType_Internal,
|
||||
nzErrorType_Normal,
|
||||
nzErrorType_Warning
|
||||
};
|
||||
|
||||
NAZARA_API void NzError(nzErrorType type, const NzString& error, unsigned int line, const char* file, const char* function);
|
||||
NAZARA_API unsigned int NzGetLastSystemErrorCode();
|
||||
NAZARA_API NzString NzGetLastSystemError(unsigned int code = NzGetLastSystemErrorCode());
|
||||
|
||||
#undef NAZARA_ERROR
|
||||
|
||||
#endif // NAZARA_ERROR_HPP
|
||||
120
include/Nazara/Core/File.hpp
Normal file
120
include/Nazara/Core/File.hpp
Normal file
@@ -0,0 +1,120 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_FILE_HPP
|
||||
#define NAZARA_FILE_HPP
|
||||
|
||||
#define NAZARA_FILE
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/Directory.hpp>
|
||||
#include <Nazara/Core/Endianness.hpp>
|
||||
#include <Nazara/Core/Hashable.hpp>
|
||||
#include <Nazara/Core/HashDigest.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Core/ThreadSafety.hpp>
|
||||
#include <Nazara/Utility/NonCopyable.hpp>
|
||||
|
||||
class NzFileImpl;
|
||||
|
||||
class NAZARA_API NzFile : public NzHashable, NzNonCopyable
|
||||
{
|
||||
public:
|
||||
enum CursorPosition
|
||||
{
|
||||
AtBegin, // Début du fichier
|
||||
AtCurrent, // Position du pointeur
|
||||
AtEnd // Fin du fichier
|
||||
};
|
||||
|
||||
enum OpenMode
|
||||
{
|
||||
Current = 0x00, // Utilise le mode d'ouverture actuel
|
||||
|
||||
Append = 0x01, // Empêche l'écriture sur la partie déjà existante et met le curseur à la fin
|
||||
Lock = 0x02, // Empêche le fichier d'être modifié tant qu'il est ouvert
|
||||
ReadOnly = 0x04, // Ouvre uniquement en lecture
|
||||
ReadWrite = 0x08, // Ouvre en lecture/écriture
|
||||
Text = 0x10, // Ouvre en mode texte
|
||||
Truncate = 0x20, // Créé le fichier s'il n'existe pas et le vide s'il existe
|
||||
WriteOnly = 0x40 // Ouvre uniquement en écriture, créé le fichier s'il n'existe pas
|
||||
};
|
||||
|
||||
NzFile();
|
||||
NzFile(const NzString& filePath);
|
||||
NzFile(const NzString& filePath, unsigned long openMode);
|
||||
NzFile(NzFile&& file);
|
||||
~NzFile();
|
||||
|
||||
bool Copy(const NzString& newFilePath);
|
||||
void Close();
|
||||
|
||||
bool Delete();
|
||||
|
||||
bool EndOfFile() const;
|
||||
|
||||
bool Exists() const;
|
||||
|
||||
void Flush();
|
||||
|
||||
time_t GetCreationTime() const;
|
||||
nzUInt64 GetCursorPos() const;
|
||||
NzString GetDirectoryPath() const;
|
||||
NzString GetFilePath() const;
|
||||
NzString GetFileName() const;
|
||||
time_t GetLastAccessTime() const;
|
||||
time_t GetLastWriteTime() const;
|
||||
NzString GetLine(unsigned int lineSize = 0);
|
||||
nzUInt64 GetSize() const;
|
||||
|
||||
bool IsOpen() const;
|
||||
|
||||
bool Open(unsigned long openMode = Current);
|
||||
|
||||
std::size_t Read(void* buffer, std::size_t typeSize, unsigned int count);
|
||||
bool Rename(const NzString& newFilePath);
|
||||
|
||||
bool SetCursorPos(CursorPosition pos, nzInt64 offset = 0);
|
||||
bool SetCursorPos(nzUInt64 offset);
|
||||
void SetEndianness(nzEndianness endianness);
|
||||
bool SetFile(const NzString& filePath);
|
||||
bool SetOpenMode(unsigned int openMode);
|
||||
|
||||
bool Write(const NzString& string);
|
||||
std::size_t Write(const void* buffer, std::size_t typeSize, unsigned int count);
|
||||
|
||||
NzFile& operator=(const NzString& filePath);
|
||||
NzFile& operator=(NzFile&& file);
|
||||
|
||||
static NzString AbsolutePath(const NzString& filePath);
|
||||
static bool Copy(const NzString& sourcePath, const NzString& targetPath);
|
||||
static bool Delete(const NzString& filePath);
|
||||
static bool Exists(const NzString& filePath);
|
||||
static time_t GetCreationTime(const NzString& filePath);
|
||||
static time_t GetLastAccessTime(const NzString& filePath);
|
||||
static time_t GetLastWriteTime(const NzString& filePath);
|
||||
static NzHashDigest GetHash(const NzString& filePath, nzHash hash);
|
||||
static NzHashDigest GetHash(const NzString& filePath, NzHashImpl* hash);
|
||||
static nzUInt64 GetSize(const NzString& filePath);
|
||||
static bool IsAbsolute(const NzString& path);
|
||||
static NzString NormalizePath(const NzString& filePath);
|
||||
static NzString NormalizeSeparators(const NzString& filePath);
|
||||
static bool Rename(const NzString& sourcePath, const NzString& targetPath);
|
||||
|
||||
private:
|
||||
bool FillHash(NzHashImpl* hash) const;
|
||||
|
||||
NazaraMutexAttrib(m_mutex, mutable)
|
||||
|
||||
nzEndianness m_endianness;
|
||||
NzString m_filePath;
|
||||
NzFileImpl* m_impl;
|
||||
unsigned int m_openMode;
|
||||
};
|
||||
|
||||
#undef NAZARA_FILE
|
||||
|
||||
#endif // NAZARA_FILE_HPP
|
||||
18
include/Nazara/Core/Format.hpp
Normal file
18
include/Nazara/Core/Format.hpp
Normal file
@@ -0,0 +1,18 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_FORMAT_HPP
|
||||
#define NAZARA_FORMAT_HPP
|
||||
|
||||
#define NAZARA_FORMAT
|
||||
|
||||
#include <Nazara/Core/String.hpp>
|
||||
|
||||
template<typename... Args> NzString NzFormat(const NzString& str, Args... args);
|
||||
|
||||
#undef NAZARA_FORMAT
|
||||
|
||||
#endif // NAZARA_FORMAT_HPP
|
||||
33
include/Nazara/Core/Hash.hpp
Normal file
33
include/Nazara/Core/Hash.hpp
Normal file
@@ -0,0 +1,33 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_HASH_HPP
|
||||
#define NAZARA_HASH_HPP
|
||||
|
||||
#define NAZARA_HASH
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/Hashable.hpp>
|
||||
#include <Nazara/Core/HashDigest.hpp>
|
||||
#include <Nazara/Core/HashImpl.hpp>
|
||||
#include <Nazara/Utility/NonCopyable.hpp>
|
||||
|
||||
class NAZARA_API NzHash : NzNonCopyable
|
||||
{
|
||||
public:
|
||||
NzHash(nzHash hash);
|
||||
NzHash(NzHashImpl* hashImpl);
|
||||
~NzHash();
|
||||
|
||||
NzHashDigest Hash(const NzHashable& hashable);
|
||||
|
||||
private:
|
||||
NzHashImpl* m_impl;
|
||||
};
|
||||
|
||||
#undef NAZARA_HASH
|
||||
|
||||
#endif // NAZARA_HASH_HPP
|
||||
37
include/Nazara/Core/Hash/CRC32.hpp
Normal file
37
include/Nazara/Core/Hash/CRC32.hpp
Normal file
@@ -0,0 +1,37 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_HASH_CRC32_HPP
|
||||
#define NAZARA_HASH_CRC32_HPP
|
||||
|
||||
#define NAZARA_HASH_CRC32
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/HashDigest.hpp>
|
||||
#include <Nazara/Core/HashImpl.hpp>
|
||||
|
||||
struct NzHashCRC32_state;
|
||||
|
||||
class NAZARA_API NzHashCRC32 : public NzHashImpl
|
||||
{
|
||||
public:
|
||||
NzHashCRC32(nzUInt32 polynomial = 0x04c11db7);
|
||||
virtual ~NzHashCRC32();
|
||||
|
||||
void Append(const nzUInt8* data, unsigned int len);
|
||||
void Begin();
|
||||
NzHashDigest End();
|
||||
|
||||
static unsigned int GetDigestLength();
|
||||
static NzString GetHashName();
|
||||
|
||||
private:
|
||||
NzHashCRC32_state* m_state;
|
||||
};
|
||||
|
||||
#undef NAZARA_HASH_CRC32
|
||||
|
||||
#endif // NAZARA_HASH_CRC32_HPP
|
||||
38
include/Nazara/Core/Hash/Fletcher16.hpp
Normal file
38
include/Nazara/Core/Hash/Fletcher16.hpp
Normal file
@@ -0,0 +1,38 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_HASH_FLETCHER16_HPP
|
||||
#define NAZARA_HASH_FLETCHER16_HPP
|
||||
|
||||
#define NAZARA_HASH_FLETCHER16
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/HashDigest.hpp>
|
||||
#include <Nazara/Core/HashImpl.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
|
||||
struct NzHashFletcher16_state;
|
||||
|
||||
class NAZARA_API NzHashFletcher16 : public NzHashImpl
|
||||
{
|
||||
public:
|
||||
NzHashFletcher16();
|
||||
virtual ~NzHashFletcher16();
|
||||
|
||||
void Append(const nzUInt8* data, unsigned int len);
|
||||
void Begin();
|
||||
NzHashDigest End();
|
||||
|
||||
static unsigned int GetDigestLength();
|
||||
static NzString GetHashName();
|
||||
|
||||
private:
|
||||
NzHashFletcher16_state* m_state;
|
||||
};
|
||||
|
||||
#undef NAZARA_HASH_FLETCHER16
|
||||
|
||||
#endif // NAZARA_HASH_FLETCHER16_HPP
|
||||
37
include/Nazara/Core/Hash/MD5.hpp
Normal file
37
include/Nazara/Core/Hash/MD5.hpp
Normal file
@@ -0,0 +1,37 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_HASH_MD5_HPP
|
||||
#define NAZARA_HASH_MD5_HPP
|
||||
|
||||
#define NAZARA_HASH_MD5
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/HashDigest.hpp>
|
||||
#include <Nazara/Core/HashImpl.hpp>
|
||||
|
||||
struct NzHashMD5_state;
|
||||
|
||||
class NAZARA_API NzHashMD5 : public NzHashImpl
|
||||
{
|
||||
public:
|
||||
NzHashMD5();
|
||||
virtual ~NzHashMD5();
|
||||
|
||||
void Append(const nzUInt8* data, unsigned int len);
|
||||
void Begin();
|
||||
NzHashDigest End();
|
||||
|
||||
static unsigned int GetDigestLength();
|
||||
static NzString GetHashName();
|
||||
|
||||
private:
|
||||
NzHashMD5_state* m_state;
|
||||
};
|
||||
|
||||
#undef NAZARA_HASH_MD5
|
||||
|
||||
#endif // NAZARA_HASH_MD5_HPP
|
||||
35
include/Nazara/Core/Hash/Whirlpool.hpp
Normal file
35
include/Nazara/Core/Hash/Whirlpool.hpp
Normal file
@@ -0,0 +1,35 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#ifndef NAZARA_HASH_WHIRLPOOL_HPP
|
||||
#define NAZARA_HASH_WHIRLPOOL_HPP
|
||||
|
||||
#define NAZARA_HASH_WHIRLPOOL
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/HashDigest.hpp>
|
||||
#include <Nazara/Core/HashImpl.hpp>
|
||||
|
||||
struct NzHashWhirlpool_state;
|
||||
|
||||
class NAZARA_API NzHashWhirlpool : public NzHashImpl
|
||||
{
|
||||
public:
|
||||
NzHashWhirlpool();
|
||||
virtual ~NzHashWhirlpool();
|
||||
|
||||
void Append(const nzUInt8* data, unsigned int len);
|
||||
void Begin();
|
||||
NzHashDigest End();
|
||||
|
||||
static unsigned int GetDigestLength();
|
||||
static NzString GetHashName();
|
||||
|
||||
private:
|
||||
NzHashWhirlpool_state* m_state;
|
||||
};
|
||||
|
||||
#undef NAZARA_HASH_WHIRLPOOL
|
||||
|
||||
#endif // NAZARA_HASH_WHIRLPOOL_HPP
|
||||
55
include/Nazara/Core/HashDigest.hpp
Normal file
55
include/Nazara/Core/HashDigest.hpp
Normal file
@@ -0,0 +1,55 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_HASHDIGEST_HPP
|
||||
#define NAZARA_HASHDIGEST_HPP
|
||||
|
||||
#define NAZARA_HASHDIGEST
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <ostream>
|
||||
|
||||
class NAZARA_API NzHashDigest
|
||||
{
|
||||
public:
|
||||
NzHashDigest();
|
||||
NzHashDigest(NzString hashName, const nzUInt8* digest, unsigned int length);
|
||||
NzHashDigest(const NzHashDigest& rhs);
|
||||
NzHashDigest(NzHashDigest&& rhs);
|
||||
~NzHashDigest();
|
||||
|
||||
bool IsValid() const;
|
||||
|
||||
const nzUInt8* GetDigest() const;
|
||||
unsigned int GetDigestLength() const;
|
||||
NzString GetHashName() const;
|
||||
|
||||
NzString ToHex() const;
|
||||
|
||||
nzUInt8 operator[](unsigned short pos) const;
|
||||
|
||||
NzHashDigest& operator=(const NzHashDigest& rhs);
|
||||
NzHashDigest& operator=(NzHashDigest&& rhs);
|
||||
|
||||
bool operator==(const NzHashDigest& rhs) const;
|
||||
bool operator!=(const NzHashDigest& rhs) const;
|
||||
bool operator<(const NzHashDigest& rhs) const;
|
||||
bool operator<=(const NzHashDigest& rhs) const;
|
||||
bool operator>(const NzHashDigest& rhs) const;
|
||||
bool operator>=(const NzHashDigest& rhs) const;
|
||||
|
||||
NAZARA_API friend std::ostream& operator<<(std::ostream& out, const NzHashDigest& string);
|
||||
|
||||
private:
|
||||
NzString m_hashName;
|
||||
nzUInt8* m_digest;
|
||||
unsigned short m_digestLength;
|
||||
};
|
||||
|
||||
#undef NAZARA_HASHDIGEST
|
||||
|
||||
#endif // NAZARA_HASHDIGEST_HPP
|
||||
30
include/Nazara/Core/HashImpl.hpp
Normal file
30
include/Nazara/Core/HashImpl.hpp
Normal file
@@ -0,0 +1,30 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_HASHIMPL_HPP
|
||||
#define NAZARA_HASHIMPL_HPP
|
||||
|
||||
#define NAZARA_HASHIMPL
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Utility/NonCopyable.hpp>
|
||||
|
||||
class NzHashDigest;
|
||||
|
||||
class NAZARA_API NzHashImpl : NzNonCopyable
|
||||
{
|
||||
public:
|
||||
NzHashImpl() = default;
|
||||
virtual ~NzHashImpl() {}
|
||||
|
||||
virtual void Append(const nzUInt8* data, unsigned int len) = 0;
|
||||
virtual void Begin() = 0;
|
||||
virtual NzHashDigest End() = 0;
|
||||
};
|
||||
|
||||
#undef NAZARA_HASHIMPL
|
||||
|
||||
#endif // NAZARA_HASHIMPL_HPP
|
||||
39
include/Nazara/Core/Hashable.hpp
Normal file
39
include/Nazara/Core/Hashable.hpp
Normal file
@@ -0,0 +1,39 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef HASHABLE_HPP_INCLUDED
|
||||
#define HASHABLE_HPP_INCLUDED
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
|
||||
enum nzHash
|
||||
{
|
||||
nzHash_CRC32,
|
||||
nzHash_Fletcher16,
|
||||
nzHash_MD5,
|
||||
nzHash_Whirlpool
|
||||
};
|
||||
|
||||
class NzHash;
|
||||
class NzHashDigest;
|
||||
class NzHashImpl;
|
||||
|
||||
class NAZARA_API NzHashable
|
||||
{
|
||||
friend class NzHash;
|
||||
|
||||
public:
|
||||
NzHashable() = default;
|
||||
virtual ~NzHashable() {}
|
||||
|
||||
NzHashDigest GetHash(nzHash hash) const;
|
||||
NzHashDigest GetHash(NzHashImpl* impl) const;
|
||||
|
||||
private:
|
||||
virtual bool FillHash(NzHashImpl* impl) const = 0;
|
||||
};
|
||||
|
||||
#endif // HASHABLE_HPP_INCLUDED
|
||||
28
include/Nazara/Core/Lock.hpp
Normal file
28
include/Nazara/Core/Lock.hpp
Normal file
@@ -0,0 +1,28 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_LOCK_HPP
|
||||
#define NAZARA_LOCK_HPP
|
||||
|
||||
#define NAZARA_LOCK
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
|
||||
class NzMutex;
|
||||
|
||||
class NAZARA_API NzLock
|
||||
{
|
||||
public:
|
||||
NzLock(NzMutex& mutex);
|
||||
~NzLock();
|
||||
|
||||
private:
|
||||
NzMutex& m_mutex;
|
||||
};
|
||||
|
||||
#undef NAZARA_LOCK
|
||||
|
||||
#endif // NAZARA_LOCK_HPP
|
||||
55
include/Nazara/Core/Log.hpp
Normal file
55
include/Nazara/Core/Log.hpp
Normal file
@@ -0,0 +1,55 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_LOG_HPP
|
||||
#define NAZARA_LOG_HPP
|
||||
|
||||
#define NAZARA_LOG
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Core/ThreadSafety.hpp>
|
||||
#include <Nazara/Utility/NonCopyable.hpp>
|
||||
|
||||
#define NazaraLog NzLog::Instance()
|
||||
|
||||
class NzFile;
|
||||
|
||||
class NAZARA_API NzLog : NzNonCopyable
|
||||
{
|
||||
public:
|
||||
void Enable(bool enable);
|
||||
void EnableAppend(bool enable);
|
||||
void EnableDateTime(bool enable);
|
||||
|
||||
NzString GetFile() const;
|
||||
|
||||
bool IsEnabled() const;
|
||||
|
||||
void SetFile(const NzString& filePath);
|
||||
|
||||
void Write(const NzString& string);
|
||||
void WriteError(nzErrorType type, const NzString& error, unsigned int line, const NzString& file, const NzString& func);
|
||||
|
||||
static NzLog* Instance();
|
||||
|
||||
private:
|
||||
NzLog();
|
||||
~NzLog();
|
||||
|
||||
NazaraMutexAttrib(m_mutex, mutable)
|
||||
|
||||
NzString m_filePath;
|
||||
NzFile* m_file;
|
||||
bool m_append;
|
||||
bool m_enabled;
|
||||
bool m_writeTime;
|
||||
};
|
||||
|
||||
#undef NAZARA_LOGGER
|
||||
|
||||
#endif // NAZARA_LOGGER_HPP
|
||||
36
include/Nazara/Core/Mutex.hpp
Normal file
36
include/Nazara/Core/Mutex.hpp
Normal file
@@ -0,0 +1,36 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_MUTEX_HPP
|
||||
#define NAZARA_MUTEX_HPP
|
||||
|
||||
#define NAZARA_MUTEX
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Utility/NonCopyable.hpp>
|
||||
|
||||
class NzMutexImpl;
|
||||
class NzThreadCondition;
|
||||
|
||||
class NAZARA_API NzMutex : NzNonCopyable
|
||||
{
|
||||
friend class NzThreadCondition;
|
||||
|
||||
public:
|
||||
NzMutex();
|
||||
~NzMutex();
|
||||
|
||||
void Lock();
|
||||
bool TryLock();
|
||||
void Unlock();
|
||||
|
||||
private:
|
||||
NzMutexImpl* m_impl;
|
||||
};
|
||||
|
||||
#undef NAZARA_MUTEX
|
||||
|
||||
#endif // NAZARA_MUTEX_HPP
|
||||
34
include/Nazara/Core/Semaphore.hpp
Normal file
34
include/Nazara/Core/Semaphore.hpp
Normal file
@@ -0,0 +1,34 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_SEMAPHORE_HPP
|
||||
#define NAZARA_SEMAPHORE_HPP
|
||||
|
||||
#define NAZARA_SEMAPHORE
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Utility/NonCopyable.hpp>
|
||||
|
||||
class NzSemaphoreImpl;
|
||||
|
||||
class NAZARA_API NzSemaphore : NzNonCopyable
|
||||
{
|
||||
public:
|
||||
NzSemaphore(unsigned int count);
|
||||
~NzSemaphore();
|
||||
|
||||
unsigned int GetCount() const;
|
||||
void Post();
|
||||
void Wait();
|
||||
bool Wait(nzUInt32 timeout);
|
||||
|
||||
private:
|
||||
NzSemaphoreImpl* m_impl;
|
||||
};
|
||||
|
||||
#undef NAZARA_SEMAPHORE
|
||||
|
||||
#endif // NAZARA_SEMAPHORE_HPP
|
||||
323
include/Nazara/Core/String.hpp
Normal file
323
include/Nazara/Core/String.hpp
Normal file
@@ -0,0 +1,323 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_STRING_HPP
|
||||
#define NAZARA_STRING_HPP
|
||||
|
||||
#define NAZARA_STRING
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/Hashable.hpp>
|
||||
#include <Nazara/Core/ThreadSafety.hpp>
|
||||
#include <istream>
|
||||
#include <ostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class NzAbstractHash;
|
||||
class NzHashDigest;
|
||||
|
||||
class NAZARA_API NzString : public NzHashable
|
||||
{
|
||||
public:
|
||||
enum Flags
|
||||
{
|
||||
None = 0x00, // Mode par défaut
|
||||
CaseInsensitive = 0x01, // Insensible à la casse
|
||||
HandleUtf8 = 0x02 // Traite les octets comme une suite de caractères UTF-8
|
||||
};
|
||||
|
||||
struct SharedString;
|
||||
|
||||
NzString();
|
||||
NzString(char character);
|
||||
NzString(const char* string);
|
||||
NzString(const std::string& string);
|
||||
NzString(const NzString& string);
|
||||
NzString(NzString&& string);
|
||||
NzString(SharedString* sharedString);
|
||||
~NzString();
|
||||
|
||||
NzString& Append(char character);
|
||||
NzString& Append(const char* string);
|
||||
NzString& Append(const NzString& string);
|
||||
|
||||
void Clear();
|
||||
|
||||
bool Contains(char character, int start = 0, nzUInt32 flags = None) const;
|
||||
bool Contains(const char* string, int start = 0, nzUInt32 flags = None) const;
|
||||
bool Contains(const NzString& string, int start = 0, nzUInt32 flags = None) const;
|
||||
|
||||
unsigned int Count(char character, int start = 0, nzUInt32 flags = None) const;
|
||||
unsigned int Count(const char* string, int start = 0, nzUInt32 flags = None) const;
|
||||
unsigned int Count(const NzString& string, int start = 0, nzUInt32 flags = None) const;
|
||||
unsigned int CountAny(const char* string, int start = 0, nzUInt32 flags = None) const;
|
||||
unsigned int CountAny(const NzString& string, int start = 0, nzUInt32 flags = None) const;
|
||||
|
||||
bool EndsWith(char character, nzUInt32 flags = None) const;
|
||||
bool EndsWith(const char* string, nzUInt32 flags = None) const;
|
||||
bool EndsWith(const NzString& string, nzUInt32 flags = None) const;
|
||||
|
||||
unsigned int Find(char character, int start = 0, nzUInt32 flags = None) const;
|
||||
unsigned int Find(const char* string, int start = 0, nzUInt32 flags = None) const;
|
||||
unsigned int Find(const NzString& string, int start = 0, nzUInt32 flags = None) const;
|
||||
unsigned int FindAny(const char* string, int start = 0, nzUInt32 flags = None) const;
|
||||
unsigned int FindAny(const NzString& string, int start = 0, nzUInt32 flags = None) const;
|
||||
unsigned int FindLast(char character, int start = -1, nzUInt32 flags = None) const;
|
||||
unsigned int FindLast(const char *string, int start = -1, nzUInt32 flags = None) const;
|
||||
unsigned int FindLast(const NzString& string, int start = -1, nzUInt32 flags = None) const;
|
||||
unsigned int FindLastAny(const char* string, int start = -1, nzUInt32 flags = None) const;
|
||||
unsigned int FindLastAny(const NzString& string, int start = -1, nzUInt32 flags = None) const;
|
||||
unsigned int FindLastWord(const char* string, int start = -1, nzUInt32 flags = None) const;
|
||||
unsigned int FindLastWord(const NzString& string, int start = -1, nzUInt32 flags = None) const;
|
||||
unsigned int FindWord(const char* string, int start = 0, nzUInt32 flags = None) const;
|
||||
unsigned int FindWord(const NzString& string, int start = 0, nzUInt32 flags = None) const;
|
||||
|
||||
char* GetBuffer();
|
||||
unsigned int GetCapacity() const;
|
||||
const char* GetConstBuffer() const;
|
||||
unsigned int GetLength() const;
|
||||
unsigned int GetSize() const;
|
||||
char* GetUtf8Buffer(unsigned int* size = nullptr) const;
|
||||
char16_t* GetUtf16Buffer(unsigned int* size = nullptr) const;
|
||||
char32_t* GetUtf32Buffer(unsigned int* size = nullptr) const;
|
||||
wchar_t* GetWideBuffer(unsigned int* size = nullptr) const;
|
||||
|
||||
NzString GetWord(unsigned int index, nzUInt32 flags = None) const;
|
||||
unsigned int GetWordPosition(unsigned int index, nzUInt32 flags = None) const;
|
||||
|
||||
NzString& Insert(int pos, char character);
|
||||
NzString& Insert(int pos, const char* string);
|
||||
NzString& Insert(int pos, const NzString& string);
|
||||
|
||||
bool IsEmpty() const;
|
||||
bool IsNull() const;
|
||||
bool IsNumber(nzUInt8 radix = 10, nzUInt32 flags = CaseInsensitive) const;
|
||||
|
||||
bool Match(const char* pattern) const;
|
||||
bool Match(const NzString& pattern) const;
|
||||
|
||||
NzString& Prepend(char character);
|
||||
NzString& Prepend(const char* string);
|
||||
NzString& Prepend(const NzString& string);
|
||||
|
||||
unsigned int Replace(char oldCharacter, char newCharacter, int start = 0, nzUInt32 flags = None);
|
||||
unsigned int Replace(const char* oldString, const char* replaceString, int start = 0, nzUInt32 flags = None);
|
||||
unsigned int Replace(const NzString& oldString, const NzString& replaceString, int start = 0, nzUInt32 flags = None);
|
||||
unsigned int ReplaceAny(const char* oldCharacters, char replaceCharacter, int start = 0, nzUInt32 flags = None);
|
||||
unsigned int ReplaceAny(const char* oldCharacters, const char* replaceString, int start = 0, nzUInt32 flags = None);
|
||||
unsigned int ReplaceAny(const NzString& oldCharacters, const NzString& replaceString, int start = 0, nzUInt32 flags = None);
|
||||
|
||||
void Reserve(unsigned int bufferSize);
|
||||
|
||||
NzString& Resize(int size, char character = ' ');
|
||||
NzString Resized(int size, char character = ' ') const;
|
||||
|
||||
NzString& Reverse();
|
||||
NzString Reversed() const;
|
||||
|
||||
NzString Simplified(nzUInt32 flags = None) const;
|
||||
NzString& Simplify(nzUInt32 flags = None);
|
||||
|
||||
unsigned int Split(std::vector<NzString>& result, char separation = ' ', int start = 0, nzUInt32 flags = None) const;
|
||||
unsigned int Split(std::vector<NzString>& result, const char* separation, int start = 0, nzUInt32 flags = None) const;
|
||||
unsigned int Split(std::vector<NzString>& result, const NzString& separation, int start = 0, nzUInt32 flags = None) const;
|
||||
unsigned int SplitAny(std::vector<NzString>& result, const char* separations, int start = 0, nzUInt32 flags = None) const;
|
||||
unsigned int SplitAny(std::vector<NzString>& result, const NzString& separations, int start = 0, nzUInt32 flags = None) const;
|
||||
|
||||
bool StartsWith(char character, nzUInt32 flags = None) const;
|
||||
bool StartsWith(const char* string, nzUInt32 flags = None) const;
|
||||
bool StartsWith(const NzString& string, nzUInt32 flags = None) const;
|
||||
|
||||
NzString Substr(int startPos, int endPos = -1) const;
|
||||
NzString SubstrFrom(char character, int startPos = 0, bool fromLast = false, bool include = false, nzUInt32 flags = None) const;
|
||||
NzString SubstrFrom(const char *string, int startPos = 0, bool fromLast = false, bool include = false, nzUInt32 flags = None) const;
|
||||
NzString SubstrFrom(const NzString& string, int startPos = 0, bool fromLast = false, bool include = false, nzUInt32 flags = None) const;
|
||||
NzString SubstrTo(char character, int startPos = 0, bool toLast = false, bool include = false, nzUInt32 flags = None) const;
|
||||
NzString SubstrTo(const char *string, int startPos = 0, bool toLast = false, bool include = false, nzUInt32 flags = None) const;
|
||||
NzString SubstrTo(const NzString& string, int startPos = 0, bool toLast = false, bool include = false, nzUInt32 flags = None) const;
|
||||
|
||||
void Swap(NzString& str);
|
||||
|
||||
bool ToBool(bool* value, nzUInt32 flags = None) const;
|
||||
bool ToDouble(double* value) const;
|
||||
bool ToInteger(long long* value, nzUInt8 radix = 10) const;
|
||||
NzString ToLower(nzUInt32 flags = None) const;
|
||||
NzString ToUpper(nzUInt32 flags = None) const;
|
||||
|
||||
NzString& Trim(nzUInt32 flags = None);
|
||||
NzString& Trim(char character, nzUInt32 flags = None);
|
||||
NzString Trimmed(nzUInt32 flags = None) const;
|
||||
NzString Trimmed(char character, nzUInt32 flags = None) const;
|
||||
|
||||
// Méthodes compatibles STD
|
||||
char* begin();
|
||||
const char* begin() const;
|
||||
char* end();
|
||||
const char* end() const;
|
||||
void push_front(char c);
|
||||
void push_back(char c);
|
||||
/*char* rbegin();
|
||||
const char* rbegin() const;
|
||||
char* rend();
|
||||
const char* rend() const;*/
|
||||
|
||||
typedef const char& const_reference;
|
||||
typedef char* iterator;
|
||||
//typedef char* reverse_iterator;
|
||||
typedef char value_type;
|
||||
// Méthodes compatibles STD
|
||||
|
||||
operator std::string() const;
|
||||
|
||||
char& operator[](unsigned int pos);
|
||||
char operator[](unsigned int pos) const;
|
||||
|
||||
NzString& operator=(char character);
|
||||
NzString& operator=(const char* string);
|
||||
NzString& operator=(const std::string& string);
|
||||
NzString& operator=(const NzString& string);
|
||||
NzString& operator=(NzString&& string);
|
||||
|
||||
NzString operator+(char character) const;
|
||||
NzString operator+(const char* string) const;
|
||||
NzString operator+(const std::string& string) const;
|
||||
NzString operator+(const NzString& string) const;
|
||||
|
||||
NzString& operator+=(char character);
|
||||
NzString& operator+=(const char* string);
|
||||
NzString& operator+=(const std::string& string);
|
||||
NzString& operator+=(const NzString& string);
|
||||
|
||||
bool operator==(char character) const;
|
||||
bool operator==(const char* string) const;
|
||||
bool operator==(const std::string& string) const;
|
||||
|
||||
bool operator!=(char character) const;
|
||||
bool operator!=(const char* string) const;
|
||||
bool operator!=(const std::string& string) const;
|
||||
|
||||
bool operator<(char character) const;
|
||||
bool operator<(const char* string) const;
|
||||
bool operator<(const std::string& string) const;
|
||||
|
||||
bool operator<=(char character) const;
|
||||
bool operator<=(const char* string) const;
|
||||
bool operator<=(const std::string& string) const;
|
||||
|
||||
bool operator>(char character) const;
|
||||
bool operator>(const char* string) const;
|
||||
bool operator>(const std::string& string) const;
|
||||
|
||||
bool operator>=(char character) const;
|
||||
bool operator>=(const char* string) const;
|
||||
bool operator>=(const std::string& string) const;
|
||||
|
||||
static NzString Boolean(bool boolean);
|
||||
static int Compare(const NzString& first, const NzString& second);
|
||||
static NzString Number(float number);
|
||||
static NzString Number(double number);
|
||||
static NzString Number(long double number);
|
||||
static NzString Number(signed char number, nzUInt8 radix = 10);
|
||||
static NzString Number(unsigned char number, nzUInt8 radix = 10);
|
||||
static NzString Number(short number, nzUInt8 radix = 10);
|
||||
static NzString Number(unsigned short number, nzUInt8 radix = 10);
|
||||
static NzString Number(int number, nzUInt8 radix = 10);
|
||||
static NzString Number(unsigned int number, nzUInt8 radix = 10);
|
||||
static NzString Number(long number, nzUInt8 radix = 10);
|
||||
static NzString Number(unsigned long number, nzUInt8 radix = 10);
|
||||
static NzString Number(long long number, nzUInt8 radix = 10);
|
||||
static NzString Number(unsigned long long number, nzUInt8 radix = 10);
|
||||
static NzString Pointer(const void* ptr);
|
||||
static NzString Unicode(char32_t character);
|
||||
static NzString Unicode(const char* u8String);
|
||||
static NzString Unicode(const char16_t* u16String);
|
||||
static NzString Unicode(const char32_t* u32String);
|
||||
static NzString Unicode(const wchar_t* wString);
|
||||
|
||||
NAZARA_API friend std::istream& operator>>(std::istream& in, NzString& string);
|
||||
NAZARA_API friend std::ostream& operator<<(std::ostream& out, const NzString& string);
|
||||
|
||||
NAZARA_API friend NzString operator+(char character, const NzString& string);
|
||||
NAZARA_API friend NzString operator+(const char* string, const NzString& nstring);
|
||||
NAZARA_API friend NzString operator+(const std::string& string, const NzString& nstring);
|
||||
|
||||
NAZARA_API friend bool operator==(const NzString& first, const NzString& second);
|
||||
NAZARA_API friend bool operator!=(const NzString& first, const NzString& second);
|
||||
NAZARA_API friend bool operator<(const NzString& first, const NzString& second);
|
||||
NAZARA_API friend bool operator<=(const NzString& first, const NzString& second);
|
||||
NAZARA_API friend bool operator>(const NzString& first, const NzString& second);
|
||||
NAZARA_API friend bool operator>=(const NzString& first, const NzString& second);
|
||||
|
||||
NAZARA_API friend bool operator==(char character, const NzString& nstring);
|
||||
NAZARA_API friend bool operator==(const char* string, const NzString& nstring);
|
||||
NAZARA_API friend bool operator==(const std::string& string, const NzString& nstring);
|
||||
|
||||
NAZARA_API friend bool operator!=(char character, const NzString& nstring);
|
||||
NAZARA_API friend bool operator!=(const char* string, const NzString& nstring);
|
||||
NAZARA_API friend bool operator!=(const std::string& string, const NzString& nstring);
|
||||
|
||||
NAZARA_API friend bool operator<(char character, const NzString& nstring);
|
||||
NAZARA_API friend bool operator<(const char* string, const NzString& nstring);
|
||||
NAZARA_API friend bool operator<(const std::string& string, const NzString& nstring);
|
||||
|
||||
NAZARA_API friend bool operator<=(char character, const NzString& nstring);
|
||||
NAZARA_API friend bool operator<=(const char* string, const NzString& nstring);
|
||||
NAZARA_API friend bool operator<=(const std::string& string, const NzString& nstring);
|
||||
|
||||
NAZARA_API friend bool operator>(char character, const NzString& nstring);
|
||||
NAZARA_API friend bool operator>(const char* string, const NzString& nstring);
|
||||
NAZARA_API friend bool operator>(const std::string& string, const NzString& nstring);
|
||||
|
||||
NAZARA_API friend bool operator>=(char character, const NzString& nstring);
|
||||
NAZARA_API friend bool operator>=(const char* string, const NzString& nstring);
|
||||
NAZARA_API friend bool operator>=(const std::string& string, const NzString& nstring);
|
||||
|
||||
struct NAZARA_API SharedString
|
||||
{
|
||||
SharedString() :
|
||||
refCount(1)
|
||||
{
|
||||
}
|
||||
|
||||
SharedString(unsigned int bufferSize, unsigned int stringSize, unsigned short referenceCount, char* str) :
|
||||
allocatedSize(bufferSize),
|
||||
size(stringSize),
|
||||
refCount(referenceCount),
|
||||
string(str)
|
||||
{
|
||||
}
|
||||
|
||||
unsigned int allocatedSize;
|
||||
unsigned int size;
|
||||
unsigned short refCount;
|
||||
char* string;
|
||||
|
||||
NazaraMutex(mutex)
|
||||
};
|
||||
|
||||
static SharedString emptyString;
|
||||
static unsigned int npos;
|
||||
|
||||
private:
|
||||
void EnsureOwnership();
|
||||
bool FillHash(NzHashImpl* hash) const;
|
||||
void ReleaseString();
|
||||
|
||||
SharedString* m_sharedString;
|
||||
};
|
||||
|
||||
namespace std
|
||||
{
|
||||
NAZARA_API istream& getline(istream& is, NzString& str);
|
||||
NAZARA_API istream& getline(istream& is, NzString& str, char delim);
|
||||
NAZARA_API void swap(NzString& lhs, NzString& rhs);
|
||||
}
|
||||
|
||||
#undef NAZARA_STRING
|
||||
|
||||
#endif // NAZARA_STRING_HPP
|
||||
|
||||
56
include/Nazara/Core/StringStream.hpp
Normal file
56
include/Nazara/Core/StringStream.hpp
Normal file
@@ -0,0 +1,56 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_STRINGSTREAM_HPP
|
||||
#define NAZARA_STRINGSTREAM_HPP
|
||||
|
||||
#define NAZARA_STRINGSTREAM
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Core/ThreadSafety.hpp>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class NAZARA_API NzStringStream
|
||||
{
|
||||
public:
|
||||
NzStringStream();
|
||||
NzStringStream(const NzString& str);
|
||||
|
||||
NzString ToString() const;
|
||||
|
||||
NzStringStream& operator<<(bool boolean);
|
||||
NzStringStream& operator<<(short number);
|
||||
NzStringStream& operator<<(unsigned short number);
|
||||
NzStringStream& operator<<(int number);
|
||||
NzStringStream& operator<<(unsigned int number);
|
||||
NzStringStream& operator<<(long number);
|
||||
NzStringStream& operator<<(unsigned long number);
|
||||
NzStringStream& operator<<(long long number);
|
||||
NzStringStream& operator<<(unsigned long long number);
|
||||
NzStringStream& operator<<(float number);
|
||||
NzStringStream& operator<<(double number);
|
||||
NzStringStream& operator<<(long double number);
|
||||
NzStringStream& operator<<(char character);
|
||||
NzStringStream& operator<<(unsigned char character);
|
||||
NzStringStream& operator<<(const char* string);
|
||||
NzStringStream& operator<<(const std::string& string);
|
||||
NzStringStream& operator<<(const NzString& string);
|
||||
NzStringStream& operator<<(const void* ptr);
|
||||
|
||||
operator NzString() const;
|
||||
|
||||
private:
|
||||
NazaraMutexAttrib(m_mutex, mutable)
|
||||
|
||||
std::vector<NzString> m_strings;
|
||||
unsigned int m_bufferSize;
|
||||
};
|
||||
|
||||
#undef NAZARA_STRINGSTREAM
|
||||
|
||||
#endif // NAZARA_STRINGSTREAM_HPP
|
||||
69
include/Nazara/Core/Thread.hpp
Normal file
69
include/Nazara/Core/Thread.hpp
Normal file
@@ -0,0 +1,69 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
// Inspiré du code de la SFML par Laurent Gomila
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_THREAD_HPP
|
||||
#define NAZARA_THREAD_HPP
|
||||
|
||||
#define NAZARA_THREAD
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Utility/Functor.hpp>
|
||||
#include <Nazara/Utility/NonCopyable.hpp>
|
||||
|
||||
class NzThreadImpl;
|
||||
|
||||
class NAZARA_API NzThread : NzNonCopyable
|
||||
{
|
||||
friend class NzThreadImpl;
|
||||
|
||||
public:
|
||||
class NAZARA_API Id
|
||||
{
|
||||
friend class NzThread;
|
||||
friend class NzThreadImpl;
|
||||
|
||||
public:
|
||||
Id() : m_handle(nullptr) {}
|
||||
Id(Id&& rhs) = default;
|
||||
~Id();
|
||||
|
||||
Id& operator=(Id&& rhs) = default;
|
||||
bool operator==(const Id& rhs) const;
|
||||
bool operator!=(const Id& rhs) const;
|
||||
|
||||
private:
|
||||
Id(void* handle) : m_handle(handle) {}
|
||||
Id(const NzThreadImpl* thread);
|
||||
|
||||
void* m_handle;
|
||||
};
|
||||
|
||||
template<typename F> NzThread(F function);
|
||||
template<typename F, typename... Args> NzThread(F function, Args... args);
|
||||
~NzThread();
|
||||
|
||||
Id GetId() const;
|
||||
bool IsCurrent() const;
|
||||
void Launch(bool independent = false);
|
||||
void Join();
|
||||
void Terminate();
|
||||
|
||||
static Id GetCurrentId();
|
||||
static void Sleep(nzUInt32 time);
|
||||
|
||||
private:
|
||||
NzFunctor* m_func;
|
||||
NzThreadImpl* m_impl;
|
||||
bool m_independent;
|
||||
};
|
||||
|
||||
#include <Nazara/Core/Thread.inl>
|
||||
|
||||
#undef NAZARA_THREAD
|
||||
|
||||
#endif // NAZARA_THREAD_HPP
|
||||
19
include/Nazara/Core/Thread.inl
Normal file
19
include/Nazara/Core/Thread.inl
Normal file
@@ -0,0 +1,19 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Core/Debug.hpp>
|
||||
|
||||
template<typename F> NzThread::NzThread(F function) :
|
||||
m_func(new NzFunctorWithoutArgs<F>(function)),
|
||||
m_impl(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
template<typename F, typename... Args> NzThread::NzThread(F function, Args... args) :
|
||||
m_func(new NzFunctorWithArgs<F, Args...>(function, args...)),
|
||||
m_impl(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
#include <Nazara/Core/DebugOff.hpp>
|
||||
35
include/Nazara/Core/ThreadCondition.hpp
Normal file
35
include/Nazara/Core/ThreadCondition.hpp
Normal file
@@ -0,0 +1,35 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_THREADCONDITION_HPP
|
||||
#define NAZARA_THREADCONDITION_HPP
|
||||
|
||||
#define NAZARA_THREADCONDITION
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
|
||||
class NzMutex;
|
||||
class NzThreadConditionImpl;
|
||||
|
||||
class NAZARA_API NzThreadCondition
|
||||
{
|
||||
public:
|
||||
NzThreadCondition();
|
||||
~NzThreadCondition();
|
||||
|
||||
void Signal();
|
||||
void SignalAll();
|
||||
|
||||
void Wait(NzMutex* mutex);
|
||||
bool Wait(NzMutex* mutex, nzUInt32 timeout);
|
||||
|
||||
private:
|
||||
NzThreadConditionImpl* m_impl;
|
||||
};
|
||||
|
||||
#undef NAZARA_THREADCONDITION
|
||||
|
||||
#endif // NAZARA_THREADCONDITION_HPP
|
||||
43
include/Nazara/Core/ThreadSafety.hpp
Normal file
43
include/Nazara/Core/ThreadSafety.hpp
Normal file
@@ -0,0 +1,43 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
// Pas de header guard
|
||||
|
||||
#include <Nazara/Core/Config.hpp>
|
||||
|
||||
#undef NazaraLock
|
||||
#undef NazaraMutex
|
||||
#undef NazaraMutexAttrib
|
||||
#undef NazaraMutexLock
|
||||
#undef NazaraMutexUnlock
|
||||
#undef NazaraNamedLock
|
||||
|
||||
#if NAZARA_CORE_THREADSAFE && (\
|
||||
(NAZARA_THREADSAFETY_BYTEARRAY && (defined(NAZARA_BYTEARRAY) || defined(NAZARA_BYTEARRAY_CPP))) || \
|
||||
(NAZARA_THREADSAFETY_CLOCK && (defined(NAZARA_CLOCK) || defined(NAZARA_CLOCK_CPP))) || \
|
||||
(NAZARA_THREADSAFETY_DIRECTORY && (defined(NAZARA_DIRECTORY) || defined(NAZARA_DIRECTORY_CPP))) || \
|
||||
(NAZARA_THREADSAFETY_DYNLIB && (defined(NAZARA_DYNLIB) || defined(NAZARA_DYNLIB_CPP))) || \
|
||||
(NAZARA_THREADSAFETY_FILE && (defined(NAZARA_FILE) || defined(NAZARA_FILE_CPP))) || \
|
||||
(NAZARA_THREADSAFETY_HASHDIGEST && (defined(NAZARA_HASHDIGEST) || defined(NAZARA_HASHDIGEST_CPP))) || \
|
||||
(NAZARA_THREADSAFETY_LOG && (defined(NAZARA_LOG) || defined(NAZARA_LOG_CPP))) || \
|
||||
(NAZARA_THREADSAFETY_STRING && (defined(NAZARA_STRING) || defined(NAZARA_STRING_CPP))) || \
|
||||
(NAZARA_THREADSAFETY_STRINGSTREAM && (defined(NAZARA_STRINGSTREAM) || defined(NAZARA_STRINGSTREAM_CPP))))
|
||||
|
||||
#include <Nazara/Core/Lock.hpp>
|
||||
#include <Nazara/Core/Mutex.hpp>
|
||||
|
||||
#define NazaraLock(mutex) NzLock lock_mutex(mutex);
|
||||
#define NazaraMutex(name) NzMutex name;
|
||||
#define NazaraMutexAttrib(name, attribute) attribute NzMutex name;
|
||||
#define NazaraMutexLock(mutex) mutex.Lock();
|
||||
#define NazaraMutexUnlock(mutex) mutex.Unlock();
|
||||
#define NazaraNamedLock(mutex, name) NzLock lock_##name(mutex);
|
||||
#else
|
||||
#define NazaraLock(mutex)
|
||||
#define NazaraMutex(name)
|
||||
#define NazaraMutexAttrib(name, attribute)
|
||||
#define NazaraMutexLock(mutex)
|
||||
#define NazaraMutexUnlock(mutex)
|
||||
#define NazaraNamedLock(mutex, name)
|
||||
#endif
|
||||
110
include/Nazara/Core/Unicode.hpp
Normal file
110
include/Nazara/Core/Unicode.hpp
Normal file
@@ -0,0 +1,110 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_UNICODE_HPP
|
||||
#define NAZARA_UNICODE_HPP
|
||||
|
||||
#define NAZARA_UNICODE
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
|
||||
namespace NzUnicode
|
||||
{
|
||||
/*
|
||||
Catégorie Unicode:
|
||||
-Les valeurs de 0x01 à 0x80 indiquent la catégorie.
|
||||
-Les valeurs de 0x100 à 0x10000 indiquent la sous-catégorie.
|
||||
*/
|
||||
enum Category : nzUInt16
|
||||
{
|
||||
// Catégorie non-reconnue par Nazara
|
||||
Category_NoCategory = 0,
|
||||
|
||||
// Lettres
|
||||
Category_Letter = 0x01, // L
|
||||
Category_Letter_Lowercase = Category_Letter | 0x0100, // Ll
|
||||
Category_Letter_Modifier = Category_Letter | 0x0200, // Lm
|
||||
Category_Letter_Other = Category_Letter | 0x0400, // Lo
|
||||
Category_Letter_Titlecase = Category_Letter | 0x0800, // Lt
|
||||
Category_Letter_Uppercase = Category_Letter | 0x1000, // Lu
|
||||
|
||||
// Marques
|
||||
Category_Mark = 0x02, // M
|
||||
Category_Mark_Enclosing = Category_Mark | 0x100, // Me
|
||||
Category_Mark_NonSpacing = Category_Mark | 0x200, // Mn
|
||||
Category_Mark_SpacingCombining = Category_Mark | 0x400, // Mc
|
||||
|
||||
// Nombres
|
||||
Category_Number = 0x04, // N
|
||||
Category_Number_DecimalDigit = Category_Number | 0x100, // Nd
|
||||
Category_Number_Letter = Category_Number | 0x200, // Nl
|
||||
Category_Number_Other = Category_Number | 0x400, // No
|
||||
|
||||
// Autres
|
||||
Category_Other = 0x08, // C
|
||||
Category_Other_Control = Category_Other | 0x0100, // Cc
|
||||
Category_Other_Format = Category_Other | 0x0200, // Cf
|
||||
Category_Other_NotAssigned = Category_Other | 0x0400, // Cn
|
||||
Category_Other_PrivateUse = Category_Other | 0x0800, // Co
|
||||
Category_Other_Surrogate = Category_Other | 0x1000, // Cs
|
||||
|
||||
// Ponctuations
|
||||
Category_Punctuation = 0x10, // P
|
||||
Category_Punctuation_Close = Category_Punctuation | 0x0100, // Pe
|
||||
Category_Punctuation_Connector = Category_Punctuation | 0x0200, // Pc
|
||||
Category_Punctuation_Dash = Category_Punctuation | 0x0400, // Pd
|
||||
Category_Punctuation_FinalQuote = Category_Punctuation | 0x0800, // Pf
|
||||
Category_Punctuation_InitialQuote = Category_Punctuation | 0x1000, // Pi
|
||||
Category_Punctuation_Open = Category_Punctuation | 0x2000, // Ps
|
||||
Category_Punctuation_Other = Category_Punctuation | 0x4000, // Po
|
||||
|
||||
// Espacements
|
||||
Category_Separator = 0x20, // Z
|
||||
Category_Separator_Line = Category_Separator | 0x0100, // Zl
|
||||
Category_Separator_Paragraph = Category_Separator | 0x0200, // Zp
|
||||
Category_Separator_Space = Category_Separator | 0x0400, // Zs
|
||||
|
||||
// Symboles
|
||||
Category_Symbol = 0x40, // S
|
||||
Category_Symbol_Currency = Category_Symbol | 0x0100, // Sc
|
||||
Category_Symbol_Math = Category_Symbol | 0x0200, // Sm
|
||||
Category_Symbol_Modifier = Category_Symbol | 0x0400, // Sk
|
||||
Category_Symbol_Other = Category_Symbol | 0x0800 // So
|
||||
};
|
||||
|
||||
enum Direction : nzUInt8
|
||||
{
|
||||
Direction_Arabic_Letter, // AL
|
||||
Direction_Arabic_Number, // AN
|
||||
Direction_Boundary_Neutral, // BN
|
||||
Direction_Common_Separator, // CS
|
||||
Direction_European_Number, // EN
|
||||
Direction_European_Separator, // ES
|
||||
Direction_European_Terminator, // ET
|
||||
Direction_Left_To_Right, // L
|
||||
Direction_Left_To_Right_Embedding, // LRE
|
||||
Direction_Left_To_Right_Override, // LRO
|
||||
Direction_Nonspacing_Mark, // NSM
|
||||
Direction_Other_Neutral, // ON
|
||||
Direction_Paragraph_Separator, // B
|
||||
Direction_Pop_Directional_Format, // PDF
|
||||
Direction_Right_To_Left, // R
|
||||
Direction_Right_To_Left_Embedding, // RLE
|
||||
Direction_Right_To_Left_Override, // RLO
|
||||
Direction_Segment_Separator, // S
|
||||
Direction_White_Space // WS
|
||||
};
|
||||
|
||||
Category GetCategory(char32_t character);
|
||||
Direction GetDirection(char32_t character);
|
||||
char32_t GetLowercase(char32_t character);
|
||||
char32_t GetTitlecase(char32_t character);
|
||||
char32_t GetUppercase(char32_t character);
|
||||
}
|
||||
|
||||
#undef NAZARA_UNICODE
|
||||
|
||||
#endif // NAZARA_UNICODE_HPP
|
||||
48
include/Nazara/Math/Basic.hpp
Normal file
48
include/Nazara/Math/Basic.hpp
Normal file
@@ -0,0 +1,48 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_BASIC_HPP
|
||||
#define NAZARA_BASIC_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/Config.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.141592653589793238462643
|
||||
#endif
|
||||
|
||||
#ifndef M_SQRT2
|
||||
#define M_SQRT2 1.4142135623730950488016887
|
||||
#endif
|
||||
|
||||
template<typename T> T NzApproach(T value, T objective, T increment);
|
||||
template<typename T> T NzClamp(T value, T min, T max);
|
||||
template<typename T> T NzDegrees(T degrees);
|
||||
template<typename T> T NzDegreeToRadian(T degrees);
|
||||
inline unsigned int NzGetNumberLength(signed char number);
|
||||
inline unsigned int NzGetNumberLength(unsigned char number);
|
||||
inline unsigned int NzGetNumberLength(short number);
|
||||
inline unsigned int NzGetNumberLength(unsigned short number);
|
||||
inline unsigned int NzGetNumberLength(int number);
|
||||
inline unsigned int NzGetNumberLength(unsigned int number);
|
||||
inline unsigned int NzGetNumberLength(long number);
|
||||
inline unsigned int NzGetNumberLength(unsigned long number);
|
||||
inline unsigned int NzGetNumberLength(long long number);
|
||||
inline unsigned int NzGetNumberLength(unsigned long long number);
|
||||
inline unsigned int NzGetNumberLength(float number, nzUInt8 precision = NAZARA_CORE_REAL_PRECISION);
|
||||
inline unsigned int NzGetNumberLength(double number, nzUInt8 precision = NAZARA_CORE_REAL_PRECISION);
|
||||
inline unsigned int NzGetNumberLength(long double number, nzUInt8 precision = NAZARA_CORE_REAL_PRECISION);
|
||||
template<typename T> T NzNormalizeAngle(T angle);
|
||||
template<typename T> bool NzNumberEquals(T a, T b);
|
||||
inline NzString NzNumberToString(long long number, nzUInt8 radix = 10);
|
||||
template<typename T> T NzRadians(T radians);
|
||||
template<typename T> T NzRadianToDegree(T radians);
|
||||
inline long long NzStringToNumber(NzString str, nzUInt8 radix = 10);
|
||||
|
||||
#include <Nazara/Math/Basic.inl>
|
||||
|
||||
#endif // NAZARA_BASIC_HPP
|
||||
279
include/Nazara/Math/Basic.inl
Normal file
279
include/Nazara/Math/Basic.inl
Normal file
@@ -0,0 +1,279 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
#include <Nazara/Math/Config.hpp>
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
#include <Nazara/Core/Debug.hpp>
|
||||
|
||||
template<typename T>
|
||||
T NzApproach(T value, T objective, T increment)
|
||||
{
|
||||
if (value < objective)
|
||||
return std::min(value + increment, objective);
|
||||
else if (value > objective)
|
||||
return std::max(value - increment, objective);
|
||||
else
|
||||
return value;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T NzClamp(T value, T min, T max)
|
||||
{
|
||||
if (value < min)
|
||||
return min;
|
||||
else if (value > max)
|
||||
return max;
|
||||
else
|
||||
return value;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T NzDegrees(T degrees)
|
||||
{
|
||||
#if NAZARA_MATH_ANGLE_RADIAN
|
||||
return NzDegreeToRadian(degrees);
|
||||
#else
|
||||
return degrees;
|
||||
#endif
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T NzDegreeToRadian(T degrees)
|
||||
{
|
||||
return degrees * (M_PI/180.0);
|
||||
}
|
||||
|
||||
unsigned int NzGetNumberLength(signed char number)
|
||||
{
|
||||
if (number == 0)
|
||||
return 1;
|
||||
|
||||
return static_cast<unsigned int>(std::log10(std::abs(number)))+(number < 0 ? 2 : 1);
|
||||
}
|
||||
|
||||
unsigned int NzGetNumberLength(unsigned char number)
|
||||
{
|
||||
if (number == 0)
|
||||
return 1;
|
||||
|
||||
return static_cast<unsigned int>(std::log10(number))+1;
|
||||
}
|
||||
|
||||
unsigned int NzGetNumberLength(short number)
|
||||
{
|
||||
if (number == 0)
|
||||
return 1;
|
||||
|
||||
return static_cast<unsigned int>(std::log10(std::abs(number)))+(number < 0 ? 2 : 1);
|
||||
}
|
||||
|
||||
unsigned int NzGetNumberLength(unsigned short number)
|
||||
{
|
||||
if (number == 0)
|
||||
return 1;
|
||||
|
||||
return static_cast<unsigned int>(std::log10(number))+1;
|
||||
}
|
||||
|
||||
unsigned int NzGetNumberLength(int number)
|
||||
{
|
||||
if (number == 0)
|
||||
return 1;
|
||||
|
||||
return static_cast<unsigned int>(std::log10(std::abs(number)))+(number < 0 ? 2 : 1);
|
||||
}
|
||||
|
||||
unsigned int NzGetNumberLength(unsigned int number)
|
||||
{
|
||||
if (number == 0)
|
||||
return 1;
|
||||
|
||||
return static_cast<unsigned int>(std::log10(number))+1;
|
||||
}
|
||||
|
||||
unsigned int NzGetNumberLength(long number)
|
||||
{
|
||||
if (number == 0)
|
||||
return 1;
|
||||
|
||||
return static_cast<unsigned int>(std::log10(std::abs(number)))+(number < 0 ? 2 : 1);
|
||||
}
|
||||
|
||||
unsigned int NzGetNumberLength(unsigned long number)
|
||||
{
|
||||
if (number == 0)
|
||||
return 1;
|
||||
|
||||
return static_cast<unsigned int>(std::log10(number))+1;
|
||||
}
|
||||
|
||||
unsigned int NzGetNumberLength(long long number)
|
||||
{
|
||||
if (number == 0)
|
||||
return 1;
|
||||
|
||||
return static_cast<unsigned int>(std::log10(std::abs(number)))+(number < 0 ? 2 : 1);
|
||||
}
|
||||
|
||||
unsigned int NzGetNumberLength(unsigned long long number)
|
||||
{
|
||||
if (number == 0)
|
||||
return 1;
|
||||
|
||||
return static_cast<unsigned int>(std::log10(number))+1;
|
||||
}
|
||||
|
||||
unsigned int NzGetNumberLength(float number, nzUInt8 precision)
|
||||
{
|
||||
// L'imprécision des flottants nécessite un cast (log10(9.99999) = 1)
|
||||
return NzGetNumberLength(static_cast<long long>(number)) + precision + 1; // Plus un pour le point
|
||||
}
|
||||
|
||||
unsigned int NzGetNumberLength(double number, nzUInt8 precision)
|
||||
{
|
||||
// L'imprécision des flottants nécessite un cast (log10(9.99999) = 1)
|
||||
return NzGetNumberLength(static_cast<long long>(number)) + precision + 1; // Plus un pour le point
|
||||
}
|
||||
|
||||
unsigned int NzGetNumberLength(long double number, nzUInt8 precision)
|
||||
{
|
||||
// L'imprécision des flottants nécessite un cast (log10(9.99999) = 1)
|
||||
return NzGetNumberLength(static_cast<long long>(number)) + precision + 1; // Plus un pour le point
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T NzNormalizeAngle(T angle)
|
||||
{
|
||||
#if NAZARA_MATH_ANGLE_RADIAN
|
||||
const T limit = M_PI;
|
||||
#else
|
||||
const T limit = 180.0;
|
||||
#endif
|
||||
|
||||
///TODO: Trouver une solution sans duplication
|
||||
if (angle > 0.0)
|
||||
{
|
||||
angle += limit;
|
||||
angle -= static_cast<int>(angle/(2.0*limit))*(2.0*limit);
|
||||
angle -= limit;
|
||||
}
|
||||
else
|
||||
{
|
||||
angle -= limit;
|
||||
angle -= static_cast<int>(angle/(2.0*limit))*(2.0*limit);
|
||||
angle += limit;
|
||||
}
|
||||
|
||||
return angle;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzNumberEquals(T a, T b)
|
||||
{
|
||||
if (a > b)
|
||||
return (a-b) <= std::numeric_limits<T>::epsilon();
|
||||
else
|
||||
return (b-a) <= std::numeric_limits<T>::epsilon();
|
||||
|
||||
}
|
||||
|
||||
NzString NzNumberToString(long long number, nzUInt8 radix)
|
||||
{
|
||||
#if NAZARA_MATH_SAFE
|
||||
if (radix < 2 || radix > 36)
|
||||
{
|
||||
NazaraError("Base must be between 2 and 36");
|
||||
return NzString();
|
||||
}
|
||||
#endif
|
||||
|
||||
if (number == 0)
|
||||
return '0';
|
||||
|
||||
static const char* symbols("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ");
|
||||
|
||||
bool negative;
|
||||
if (number < 0)
|
||||
{
|
||||
negative = true;
|
||||
number = -number;
|
||||
}
|
||||
else
|
||||
negative = false;
|
||||
|
||||
NzString str;
|
||||
str.Reserve(NzGetNumberLength(number));
|
||||
|
||||
do
|
||||
{
|
||||
str += symbols[number % radix];
|
||||
number /= radix;
|
||||
}
|
||||
while (number > 0);
|
||||
|
||||
if (negative)
|
||||
str += '-';
|
||||
|
||||
return str.Reversed();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T NzRadians(T radians)
|
||||
{
|
||||
#if NAZARA_MATH_ANGLE_RADIAN
|
||||
return radians;
|
||||
#else
|
||||
return NzRadianToDegree(radians);
|
||||
#endif
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T NzRadianToDegree(T radians)
|
||||
{
|
||||
return radians * (180.0/M_PI);
|
||||
}
|
||||
|
||||
long long NzStringToNumber(NzString str, nzUInt8 radix)
|
||||
{
|
||||
#if NAZARA_MATH_SAFE
|
||||
if (radix < 2 || radix > 36)
|
||||
{
|
||||
NazaraError("Radix must be between 2 and 36");
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
str.Simplify();
|
||||
if (radix > 10)
|
||||
str.ToUpper();
|
||||
|
||||
bool negative = str.StartsWith('-');
|
||||
static const char* symbols = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
|
||||
char* digit = &str[(negative) ? 1 : 0];
|
||||
unsigned long long total = 0;
|
||||
do
|
||||
{
|
||||
if (*digit == ' ')
|
||||
continue;
|
||||
|
||||
total *= radix;
|
||||
const char* c = std::strchr(symbols, *digit);
|
||||
if (c && c-symbols < radix)
|
||||
total += c-symbols;
|
||||
else
|
||||
{
|
||||
NazaraError("str is not a valid number");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
while (*++digit);
|
||||
|
||||
return (negative) ? -static_cast<long long>(total) : total;
|
||||
}
|
||||
|
||||
#include <Nazara/Core/DebugOff.hpp>
|
||||
42
include/Nazara/Math/Config.hpp
Normal file
42
include/Nazara/Math/Config.hpp
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
Nazara Engine
|
||||
|
||||
Copyright (C) 2012 Jérôme "Lynix" Leclercq (Lynix680@gmail.com)
|
||||
Rémi "overdrivr" Begues (remi.beges@laposte.net)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_CONFIG_MATH_HPP
|
||||
#define NAZARA_CONFIG_MATH_HPP
|
||||
|
||||
/// Chaque modification d'un paramètre du module nécessite une recompilation de celui-ci
|
||||
|
||||
// Définit le radian comme l'unité utilisée pour les angles
|
||||
#define NAZARA_MATH_ANGLE_RADIAN 0
|
||||
|
||||
// Définit la disposition des matrices en colonnes
|
||||
#define NAZARA_MATH_MATRIX_COLUMN_MAJOR 1
|
||||
|
||||
// Active les tests de sécurité basés sur le code (Conseillé pour le développement)
|
||||
#define NAZARA_MATH_SAFE 1
|
||||
|
||||
#endif // NAZARA_CONFIG_MATH_HPP
|
||||
70
include/Nazara/Math/EulerAngles.hpp
Normal file
70
include/Nazara/Math/EulerAngles.hpp
Normal file
@@ -0,0 +1,70 @@
|
||||
// Copyright (C) 2012 Rémi Begues
|
||||
// Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_EULERANGLES_HPP
|
||||
#define NAZARA_EULERANGLES_HPP
|
||||
|
||||
#include <Nazara/Core/String.hpp>
|
||||
|
||||
template<typename T> class NzQuaternion;
|
||||
template<typename T> class NzVector3;
|
||||
|
||||
template<typename T> class NzEulerAngles
|
||||
{
|
||||
public:
|
||||
NzEulerAngles();
|
||||
NzEulerAngles(T P, T Y, T R);
|
||||
NzEulerAngles(T angles[3]);
|
||||
//NzEulerAngles(const NzMatrix3<T>& mat);
|
||||
NzEulerAngles(const NzQuaternion<T>& quat);
|
||||
template<typename U> explicit NzEulerAngles(const NzEulerAngles<U>& angles);
|
||||
NzEulerAngles(const NzEulerAngles& angles) = default;
|
||||
~NzEulerAngles() = default;
|
||||
|
||||
NzVector3<T> GetForward() const;
|
||||
NzVector3<T> GetRight() const;
|
||||
NzVector3<T> GetUp() const;
|
||||
|
||||
void Normalize();
|
||||
|
||||
void Set(T P, T Y, T R);
|
||||
void Set(T angles[3]);
|
||||
void Set(const NzEulerAngles<T>& angles);
|
||||
//void Set(const NzMatrix3<T>& mat);
|
||||
void Set(const NzQuaternion<T>& quat);
|
||||
template<typename U> void Set(const NzEulerAngles<U>& angles);
|
||||
void SetZero();
|
||||
|
||||
//NzEulerAngles<T> ToEulerAngles() const;
|
||||
//NzMatrix3<T> ToRotationMatrix() const;
|
||||
NzQuaternion<T> ToQuaternion() const;
|
||||
NzString ToString() const;
|
||||
|
||||
NzEulerAngles operator+(const NzEulerAngles& angles) const;
|
||||
NzEulerAngles operator-(const NzEulerAngles& angles) const;
|
||||
NzEulerAngles operator*(const NzEulerAngles& angles) const;
|
||||
NzEulerAngles operator/(const NzEulerAngles& angles) const;
|
||||
|
||||
NzEulerAngles operator+=(const NzEulerAngles& angles);
|
||||
NzEulerAngles operator-=(const NzEulerAngles& angles);
|
||||
NzEulerAngles operator*=(const NzEulerAngles& angles);
|
||||
NzEulerAngles operator/=(const NzEulerAngles& angles);
|
||||
|
||||
bool operator==(const NzEulerAngles& angles) const;
|
||||
bool operator!=(const NzEulerAngles& angles) const;
|
||||
|
||||
T pitch, yaw, roll;
|
||||
};
|
||||
|
||||
template<typename T> std::ostream& operator<<(std::ostream& out, const NzEulerAngles<T>& angles);
|
||||
|
||||
typedef NzEulerAngles<double> NzEulerAnglesd;
|
||||
typedef NzEulerAngles<float> NzEulerAnglesf;
|
||||
|
||||
#include <Nazara/Math/EulerAngles.inl>
|
||||
|
||||
#endif // NAZARA_EULERANGLES_HPP
|
||||
199
include/Nazara/Math/EulerAngles.inl
Normal file
199
include/Nazara/Math/EulerAngles.inl
Normal file
@@ -0,0 +1,199 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Core/StringStream.hpp>
|
||||
#include <Nazara/Math/Basic.hpp>
|
||||
#include <Nazara/Math/Quaternion.hpp>
|
||||
#include <Nazara/Math/Vector3.hpp>
|
||||
#include <cmath>
|
||||
#include <Nazara/Core/Debug.hpp>
|
||||
|
||||
template<typename T>
|
||||
NzEulerAngles<T>::NzEulerAngles()
|
||||
{
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzEulerAngles<T>::NzEulerAngles(T P, T Y, T R)
|
||||
{
|
||||
Set(P, Y, R);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzEulerAngles<T>::NzEulerAngles(T angles[3])
|
||||
{
|
||||
Set(angles);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzEulerAngles<T>::NzEulerAngles(const NzQuaternion<T>& quat)
|
||||
{
|
||||
Set(quat);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
template<typename U>
|
||||
NzEulerAngles<T>::NzEulerAngles(const NzEulerAngles<U>& angles)
|
||||
{
|
||||
Set(angles);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector3<T> NzEulerAngles<T>::GetForward() const
|
||||
{
|
||||
#if NAZARA_MATH_ANGLE_RADIAN
|
||||
return NzVector3<T>(std::cos(yaw), std::sin(roll), std::sin(yaw));
|
||||
#else
|
||||
return NzVector3<T>(std::cos(NzDegreeToRadian(yaw)), std::sin(NzDegreeToRadian(roll)), std::sin(NzDegreeToRadian(yaw)));
|
||||
#endif
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector3<T> NzEulerAngles<T>::GetRight() const
|
||||
{
|
||||
#if NAZARA_MATH_ANGLE_RADIAN
|
||||
return NzVector3<T>(std::sin(yaw), std::sin(pitch), std::cos(pitch));
|
||||
#else
|
||||
return NzVector3<T>(std::sin(NzDegreeToRadian(yaw)), std::sin(NzDegreeToRadian(pitch)), std::cos(NzDegreeToRadian(pitch)));
|
||||
#endif
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector3<T> NzEulerAngles<T>::GetUp() const
|
||||
{
|
||||
#if NAZARA_MATH_ANGLE_RADIAN
|
||||
return NzVector3<T>(std::sin(roll), std::cos(pitch), -std::sin(pitch));
|
||||
#else
|
||||
return NzVector3<T>(std::sin(NzDegreeToRadian(roll)), std::cos(NzDegreeToRadian(pitch)), -std::sin(NzDegreeToRadian(pitch)));
|
||||
#endif
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzEulerAngles<T>::Normalize()
|
||||
{
|
||||
pitch = NzNormalizeAngle(pitch);
|
||||
yaw = NzNormalizeAngle(yaw);
|
||||
roll = NzNormalizeAngle(roll);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzEulerAngles<T>::Set(T P, T Y, T R)
|
||||
{
|
||||
pitch = P;
|
||||
yaw = Y;
|
||||
roll = R;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzEulerAngles<T>::Set(T angles[3])
|
||||
{
|
||||
pitch = angles[0];
|
||||
yaw = angles[1];
|
||||
roll = angles[2];
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzEulerAngles<T>::Set(const NzEulerAngles& angles)
|
||||
{
|
||||
pitch = angles.pitch;
|
||||
yaw = angles.yaw;
|
||||
roll = angles.roll;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzEulerAngles<T>::Set(const NzQuaternion<T>& quat)
|
||||
{
|
||||
Set(quat.ToEulerAngles());
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
template<typename U>
|
||||
void NzEulerAngles<T>::Set(const NzEulerAngles<U>& angles)
|
||||
{
|
||||
pitch = static_cast<T>(angles.pitch);
|
||||
yaw = static_cast<T>(angles.yaw);
|
||||
roll = static_cast<T>(angles.roll);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzEulerAngles<T>::SetZero()
|
||||
{
|
||||
Set(0.0, 0.0, 0.0);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzQuaternion<T> NzEulerAngles<T>::ToQuaternion() const
|
||||
{
|
||||
NzQuaternion<T> Qx(pitch, NzVector3<T>(1.0, 0.0, 0.0));
|
||||
NzQuaternion<T> Qy(yaw, NzVector3<T>(0.0, 1.0, 0.0));
|
||||
NzQuaternion<T> Qz(roll, NzVector3<T>(0.0, 0.0, 1.0));
|
||||
|
||||
return Qx * Qy * Qz;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzString NzEulerAngles<T>::ToString() const
|
||||
{
|
||||
NzStringStream ss;
|
||||
|
||||
return ss << "EulerAngles(" << pitch << ", " << yaw << ", " << roll << ')';
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzEulerAngles<T> NzEulerAngles<T>::operator+(const NzEulerAngles& angles) const
|
||||
{
|
||||
return NzEulerAngles(pitch + angles.pitch,
|
||||
yaw + angles.yaw,
|
||||
roll + angles.roll);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzEulerAngles<T> NzEulerAngles<T>::operator-(const NzEulerAngles& angles) const
|
||||
{
|
||||
return NzEulerAngles(pitch - angles.pitch,
|
||||
yaw - angles.yaw,
|
||||
roll - angles.roll);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzEulerAngles<T> NzEulerAngles<T>::operator+=(const NzEulerAngles& angles)
|
||||
{
|
||||
pitch += angles.pitch;
|
||||
yaw += angles.yaw;
|
||||
roll += angles.roll;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzEulerAngles<T> NzEulerAngles<T>::operator-=(const NzEulerAngles& angles)
|
||||
{
|
||||
pitch -= angles.pitch;
|
||||
yaw -= angles.yaw;
|
||||
roll -= angles.roll;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzEulerAngles<T>::operator==(const NzEulerAngles& angles) const
|
||||
{
|
||||
return NzNumberEquals(pitch, angles.pitch) &&
|
||||
NzNumberEquals(yaw, angles.yaw) &&
|
||||
NzNumberEquals(roll, angles.roll);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzEulerAngles<T>::operator!=(const NzEulerAngles& angles) const
|
||||
{
|
||||
return !operator==(angles);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
std::ostream& operator<<(std::ostream& out, const NzEulerAngles<T>& angles)
|
||||
{
|
||||
return out << angles.ToString();
|
||||
}
|
||||
|
||||
#include <Nazara/Core/DebugOff.hpp>
|
||||
100
include/Nazara/Math/Matrix4.hpp
Normal file
100
include/Nazara/Math/Matrix4.hpp
Normal file
@@ -0,0 +1,100 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_MATRIX4_HPP
|
||||
#define NAZARA_MATRIX4_HPP
|
||||
|
||||
#include <Nazara/Core/String.hpp>
|
||||
|
||||
template<typename T> class NzEulerAngles;
|
||||
template<typename T> class NzQuaternion;
|
||||
template<typename T> class NzVector2;
|
||||
template<typename T> class NzVector3;
|
||||
template<typename T> class NzVector4;
|
||||
|
||||
template<typename T> class NzMatrix4
|
||||
{
|
||||
public:
|
||||
NzMatrix4();
|
||||
NzMatrix4(T r11, T r12, T r13, T r14,
|
||||
T r21, T r22, T r23, T r24,
|
||||
T r31, T r32, T r33, T r34,
|
||||
T r41, T r42, T r43, T r44);
|
||||
NzMatrix4(T matrix[16]);
|
||||
//NzMatrix4(const NzMatrix3<T>& mat);
|
||||
template<typename U> explicit NzMatrix4(const NzMatrix4<U>& mat);
|
||||
NzMatrix4(const NzMatrix4& mat) = default;
|
||||
~NzMatrix4() = default;
|
||||
|
||||
T GetDeterminant() const;
|
||||
NzMatrix4 GetInverse() const;
|
||||
//NzMatrix3 GetRotationMatrix() const;
|
||||
NzVector3<T> GetScale() const;
|
||||
NzVector3<T> GetTranslation() const;
|
||||
NzMatrix4 GetTransposed() const;
|
||||
|
||||
bool HasNegativeScale() const;
|
||||
bool HasScale() const;
|
||||
|
||||
void Set(T r11, T r12, T r13, T r14,
|
||||
T r21, T r22, T r23, T r24,
|
||||
T r31, T r32, T r33, T r34,
|
||||
T r41, T r42, T r43, T r44);
|
||||
void Set(T matrix[16]);
|
||||
//NzMatrix4(const NzMatrix3<T>& mat);
|
||||
void Set(const NzMatrix4& mat);
|
||||
template<typename U> void Set(const NzMatrix4<U>& mat);
|
||||
void SetIdentity();
|
||||
void SetLookAt(const NzVector3<T>& eye, const NzVector3<T>& center, const NzVector3<T>& up);
|
||||
void SetPerspective(T angle, T ratio, T zNear, T zFar);
|
||||
void SetRotation(const NzQuaternion<T>& rotation);
|
||||
void SetScale(const NzVector3<T>& scale);
|
||||
void SetTranslation(const NzVector3<T>& translation);
|
||||
void SetZero();
|
||||
|
||||
NzString ToString() const;
|
||||
|
||||
NzVector2<T> Transform(const NzVector2<T>& vector, T z = 0.0, T w = 1.0) const;
|
||||
NzVector3<T> Transform(const NzVector3<T>& vector, T w = 1.0) const;
|
||||
NzVector4<T> Transform(const NzVector4<T>& vector) const;
|
||||
|
||||
NzMatrix4& Transpose();
|
||||
|
||||
operator T*();
|
||||
operator const T*() const;
|
||||
|
||||
T& operator()(unsigned int x, unsigned int y);
|
||||
const T& operator()(unsigned int x, unsigned int y) const;
|
||||
|
||||
NzMatrix4 operator*(const NzMatrix4& mat) const;
|
||||
NzVector2<T> operator*(const NzVector2<T>& vector) const;
|
||||
NzVector3<T> operator*(const NzVector3<T>& vector) const;
|
||||
NzVector4<T> operator*(const NzVector4<T>& vector) const;
|
||||
NzMatrix4 operator*(T scalar) const;
|
||||
|
||||
NzMatrix4& operator*=(const NzMatrix4& mat);
|
||||
NzMatrix4& operator*=(T scalar);
|
||||
|
||||
static NzMatrix4 LookAt(const NzVector3<T>& eye, const NzVector3<T>& center, const NzVector3<T>& up);
|
||||
static NzMatrix4 Perspective(T angle, T ratio, T zNear, T zFar);
|
||||
static NzMatrix4 Rotate(const NzQuaternion<T>& rotation);
|
||||
static NzMatrix4 Scale(const NzVector3<T>& scale);
|
||||
static NzMatrix4 Translate(const NzVector3<T>& translation);
|
||||
|
||||
T m11, m12, m13, m14,
|
||||
m21, m22, m23, m24,
|
||||
m31, m32, m33, m34,
|
||||
m41, m42, m43, m44;
|
||||
};
|
||||
|
||||
template<typename T> std::ostream& operator<<(std::ostream& out, const NzMatrix4<T>& mat);
|
||||
|
||||
typedef NzMatrix4<double> NzMatrix4d;
|
||||
typedef NzMatrix4<float> NzMatrix4f;
|
||||
|
||||
#include <Nazara/Math/Matrix4.inl>
|
||||
|
||||
#endif // NAZARA_MATRIX4_HPP
|
||||
576
include/Nazara/Math/Matrix4.inl
Normal file
576
include/Nazara/Math/Matrix4.inl
Normal file
@@ -0,0 +1,576 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Core/StringStream.hpp>
|
||||
#include <Nazara/Math/Basic.hpp>
|
||||
#include <Nazara/Math/EulerAngles.hpp>
|
||||
#include <Nazara/Math/Quaternion.hpp>
|
||||
#include <Nazara/Math/Vector2.hpp>
|
||||
#include <Nazara/Math/Vector3.hpp>
|
||||
#include <Nazara/Math/Vector4.hpp>
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
#include <limits>
|
||||
#include <stdexcept>
|
||||
#include <Nazara/Core/Debug.hpp>
|
||||
|
||||
template<typename T>
|
||||
NzMatrix4<T>::NzMatrix4()
|
||||
{
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzMatrix4<T>::NzMatrix4(T r11, T r12, T r13, T r14,
|
||||
T r21, T r22, T r23, T r24,
|
||||
T r31, T r32, T r33, T r34,
|
||||
T r41, T r42, T r43, T r44)
|
||||
{
|
||||
Set(r11, r12, r13, r14,
|
||||
r21, r22, r23, r24,
|
||||
r31, r32, r33, r34,
|
||||
r41, r42, r43, r44);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzMatrix4<T>::NzMatrix4(T matrix[16])
|
||||
{
|
||||
Set(matrix);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
template<typename U>
|
||||
NzMatrix4<T>::NzMatrix4(const NzMatrix4<U>& mat)
|
||||
{
|
||||
Set(mat);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T NzMatrix4<T>::GetDeterminant() const
|
||||
{
|
||||
T A = m22 * (m33 * m44 - m43 * m34) - m32 * (m23 * m44 - m43 * m24) + m42 * (m23 * m34 - m33 * m24);
|
||||
T B = m12 * (m33 * m44 - m43 * m34) - m32 * (m13 * m44 - m43 * m14) + m42 * (m13 * m34 - m33 * m14);
|
||||
T C = m12 * (m23 * m44 - m43 * m24) - m22 * (m13 * m44 - m43 * m14) + m42 * (m13 * m24 - m23 * m14);
|
||||
T D = m12 * (m23 * m34 - m33 * m24) - m22 * (m13 * m34 - m33 * m14) + m32 * (m13 * m24 - m23 * m14);
|
||||
|
||||
return m11 * A - m21 * B + m31 * C - m41 * D;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzMatrix4<T> NzMatrix4<T>::GetInverse() const
|
||||
{
|
||||
NzMatrix4 mat;
|
||||
T det = GetDeterminant();
|
||||
|
||||
if (det != 0.0)
|
||||
{
|
||||
mat.m11 = (m22 * (m33 * m44 - m34 * m43) - m32 * (m23 * m44 - m43 * m24) + m42 * (m23 * m34 - m33 * m24)) / det;
|
||||
mat.m12 = -(m12 * (m33 * m44 - m43 * m34) - m32 * (m13 * m44 - m43 * m14) + m42 * (m13 * m34 - m33 * m14)) / det;
|
||||
mat.m13 = (m12 * (m23 * m44 - m43 * m24) - m22 * (m13 * m44 - m43 * m14) + m42 * (m13 * m24 - m23 * m14)) / det;
|
||||
mat.m14 = -(m12 * (m23 * m34 - m33 * m24) - m22 * (m13 * m34 - m33 * m14) + m32 * (m13 * m24 - m23 * m14)) / det;
|
||||
|
||||
mat.m21 = -(m21 * (m33 * m44 - m34 * m43) - m23 * (m31 * m44 - m34 * m41) + m24 * (m31 * m43 - m33 * m41)) / det;
|
||||
mat.m22 = (m11 * (m33 * m44 - m34 * m43) - m13 * (m31 * m44 - m34 * m41) + m14 * (m31 * m43 - m33 * m41)) / det;
|
||||
mat.m23 = -(m11 * (m23 * m44 - m24 * m43) - m13 * (m21 * m44 - m24 * m41) + m14 * (m21 * m43 - m23 * m41)) / det;
|
||||
mat.m24 = (m11 * (m23 * m34 - m24 * m33) - m13 * (m21 * m34 - m24 * m31) + m14 * (m21 * m33 - m23 * m31)) / det;
|
||||
|
||||
mat.m31 = (m21 * (m32 * m44 - m34 * m42) - m22 * (m31 * m44 - m34 * m41) + m24 * (m31 * m42 - m32 * m41)) / det;
|
||||
mat.m32 = -(m11 * (m32 * m44 - m34 * m42) - m12 * (m31 * m44 - m34 * m41) + m14 * (m31 * m42 - m32 * m41)) / det;
|
||||
mat.m33 = (m11 * (m22 * m44 - m24 * m42) - m12 * (m21 * m44 - m24 * m41) + m14 * (m21 * m42 - m22 * m41)) / det;
|
||||
mat.m34 = -(m11 * (m22 * m34 - m24 * m32) - m12 * (m21 * m34 - m24 * m31) + m14 * (m21 * m32 - m22 * m31)) / det;
|
||||
|
||||
mat.m41 = -(m21 * (m32 * m43 - m33 * m42) - m22 * (m31 * m43 - m33 * m41) + m23 * (m31 * m42 - m32 * m41)) / det;
|
||||
mat.m42 = (m11 * (m32 * m43 - m33 * m42) - m12 * (m31 * m43 - m33 * m41) + m13 * (m31 * m42 - m32 * m41)) / det;
|
||||
mat.m43 = -(m11 * (m22 * m43 - m23 * m42) - m12 * (m21 * m43 - m23 * m41) + m13 * (m21 * m42 - m22 * m41)) / det;
|
||||
mat.m44 = (m11 * (m22 * m33 - m23 * m32) - m12 * (m21 * m33 - m23 * m31) + m13 * (m21 * m32 - m22 * m31)) / det;
|
||||
}
|
||||
|
||||
return mat;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector3<T> NzMatrix4<T>::GetScale() const
|
||||
{
|
||||
return NzVector3<T>(std::sqrt(m11 * m11 + m21 * m21 + m31 * m31),
|
||||
std::sqrt(m12 * m12 + m22 * m22 + m32 * m32),
|
||||
std::sqrt(m13 * m13 + m23 * m23 + m33 * m33));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector3<T> NzMatrix4<T>::GetTranslation() const
|
||||
{
|
||||
#if NAZARA_MATH_MATRIX_COLUMN_MAJOR
|
||||
return NzVector3<T>(m41, m42, m43);
|
||||
#else
|
||||
return NzVector3<T>(m14, m24, m34);
|
||||
#endif
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzMatrix4<T> NzMatrix4<T>::GetTransposed() const
|
||||
{
|
||||
return NzMatrix4(m11, m21, m31, m41,
|
||||
m12, m22, m32, m42,
|
||||
m13, m23, m33, m43,
|
||||
m14, m24, m34, m44);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzMatrix4<T>::HasNegativeScale() const
|
||||
{
|
||||
return GetDeterminant() < 0.f;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzMatrix4<T>::HasScale() const
|
||||
{
|
||||
T t = m11 * m11 + m21 * m21 + m31 * m31;
|
||||
if (1.0 - t > std::numeric_limits<T>::epsilon())
|
||||
return true;
|
||||
|
||||
t = m12 * m12 + m22 * m22 + m32 * m32;
|
||||
if (1.0 - t > std::numeric_limits<T>::epsilon())
|
||||
return true;
|
||||
|
||||
t = m13 * m13 + m23 * m23 + m33 * m33;
|
||||
if (1.0 - t > std::numeric_limits<T>::epsilon())
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzMatrix4<T>::Set(T r11, T r12, T r13, T r14,
|
||||
T r21, T r22, T r23, T r24,
|
||||
T r31, T r32, T r33, T r34,
|
||||
T r41, T r42, T r43, T r44)
|
||||
{
|
||||
m11 = r11;
|
||||
m12 = r12;
|
||||
m13 = r13;
|
||||
m14 = r14;
|
||||
m21 = r21;
|
||||
m22 = r22;
|
||||
m23 = r23;
|
||||
m24 = r24;
|
||||
m31 = r31;
|
||||
m32 = r32;
|
||||
m33 = r33;
|
||||
m34 = r34;
|
||||
m41 = r41;
|
||||
m42 = r42;
|
||||
m43 = r43;
|
||||
m44 = r44;
|
||||
}
|
||||
|
||||
template<typename T> void NzMatrix4<T>::Set(T matrix[16])
|
||||
{
|
||||
// Ici nous sommes certains de la continuité des éléments en mémoire
|
||||
std::memcpy(&m41, matrix, 16*sizeof(T));
|
||||
}
|
||||
|
||||
template<typename T> void NzMatrix4<T>::Set(const NzMatrix4& mat)
|
||||
{
|
||||
// Pareil
|
||||
std::memcpy(&m41, &mat.m41, 16*sizeof(T));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
template<typename U>
|
||||
void NzMatrix4<T>::Set(const NzMatrix4<U>& mat)
|
||||
{
|
||||
m11 = static_cast<T>(mat.m11);
|
||||
m12 = static_cast<T>(mat.m12);
|
||||
m13 = static_cast<T>(mat.m13);
|
||||
m14 = static_cast<T>(mat.m14);
|
||||
m21 = static_cast<T>(mat.m21);
|
||||
m22 = static_cast<T>(mat.m22);
|
||||
m23 = static_cast<T>(mat.m23);
|
||||
m24 = static_cast<T>(mat.m24);
|
||||
m31 = static_cast<T>(mat.m31);
|
||||
m32 = static_cast<T>(mat.m32);
|
||||
m33 = static_cast<T>(mat.m33);
|
||||
m34 = static_cast<T>(mat.m34);
|
||||
m41 = static_cast<T>(mat.m41);
|
||||
m42 = static_cast<T>(mat.m42);
|
||||
m43 = static_cast<T>(mat.m43);
|
||||
m44 = static_cast<T>(mat.m44);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzMatrix4<T>::SetIdentity()
|
||||
{
|
||||
Set(1.0, 0.0, 0.0, 0.0,
|
||||
0.0, 1.0, 0.0, 0.0,
|
||||
0.0, 0.0, 1.0, 0.0,
|
||||
0.0, 0.0, 0.0, 1.0);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzMatrix4<T>::SetLookAt(const NzVector3<T>& eye, const NzVector3<T>& center, const NzVector3<T>& up)
|
||||
{
|
||||
NzVector3<T> f = center - eye;
|
||||
f.Normalize();
|
||||
|
||||
NzVector3<T> u = up;
|
||||
u.Normalize();
|
||||
|
||||
NzVector3<T> s = f.CrossProduct(u);
|
||||
s.Normalize();
|
||||
|
||||
u = s.CrossProduct(f);
|
||||
|
||||
Set(s.x, u.x, -f.x, 0.0,
|
||||
s.y, u.y, -f.y, 0.0,
|
||||
s.z, u.z, -f.z, 0.0,
|
||||
0.0, 0.0, 0.0, 1.0);
|
||||
|
||||
operator*=(Translate(-eye));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzMatrix4<T>::SetPerspective(T angle, T ratio, T zNear, T zFar)
|
||||
{
|
||||
#if NAZARA_MATH_ANGLE_RADIAN
|
||||
angle /= 2;
|
||||
#else
|
||||
angle = NzDegreeToRadian(angle/2);
|
||||
#endif
|
||||
|
||||
T f = 1 / std::tan(angle);
|
||||
|
||||
#if NAZARA_MATH_MATRIX_COLUMN_MAJOR
|
||||
Set(f / ratio, 0.0, 0.0, 0.0,
|
||||
0.0, f, 0.0, 0.0,
|
||||
0.0, 0.0, (zNear + zFar) / (zNear - zFar), -1.0,
|
||||
0.0, 0.0, (2 * zNear * zFar) / (zNear - zFar), 1.0);
|
||||
#else
|
||||
Set(f / ratio, 0.0, 0.0, 0.0,
|
||||
0.0, f, 0.0, 0.0,
|
||||
0.0, 0.0, (zNear + zFar) / (zNear - zFar), (2 * zNear * zFar) / (zNear - zFar),
|
||||
0.0, 0.0, -1.0, 1.0);
|
||||
#endif
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzMatrix4<T>::SetRotation(const NzQuaternion<T>& rotation)
|
||||
{
|
||||
// http://www.flipcode.com/documents/matrfaq.html#Q54
|
||||
T xx = rotation.x * rotation.x;
|
||||
T xy = rotation.x * rotation.y;
|
||||
T xz = rotation.x * rotation.z;
|
||||
T xw = rotation.x * rotation.w;
|
||||
|
||||
T yy = rotation.y * rotation.y;
|
||||
T yz = rotation.y * rotation.z;
|
||||
T yw = rotation.y * rotation.w;
|
||||
|
||||
T zz = rotation.z * rotation.z;
|
||||
T zw = rotation.z * rotation.w;
|
||||
|
||||
Set(1.0 - 2.0*(yy+zz), 2.0*(xy-zw), 2.0*(xz+yw), 0.0,
|
||||
2.0*(xz+zw), 1.0 - 2.0*(xx+zz), 2.0*(yz-xw), 0.0,
|
||||
2.0*(xz-yw), 2.0*(yz+xw), 1.0 - 2.0*(xx+yy), 0.0,
|
||||
0.0, 0.0, 0.0, 1.0);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzMatrix4<T>::SetScale(const NzVector3<T>& vector)
|
||||
{
|
||||
Set(vector.x, 0.0, 0.0, 0.0,
|
||||
0.0, vector.y, 0.0, 0.0,
|
||||
0.0, 0.0, vector.z, 0.0,
|
||||
0.0, 0.0, 0.0, 1.0);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzMatrix4<T>::SetTranslation(const NzVector3<T>& translation)
|
||||
{
|
||||
#if NAZARA_MATH_MATRIX_COLUMN_MAJOR
|
||||
Set(1.0, 0.0, 0.0, 0.0,
|
||||
0.0, 1.0, 0.0, 0.0,
|
||||
0.0, 0.0, 1.0, 0.0,
|
||||
translation.x, translation.y, translation.z, 1.0);
|
||||
#else
|
||||
Set(1.0, 0.0, 0.0, translation.x,
|
||||
0.0, 1.0, 0.0, translation.y,
|
||||
0.0, 0.0, 1.0, translation.z,
|
||||
0.0, 0.0, 0.0, 1.0);
|
||||
#endif
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzMatrix4<T>::SetZero()
|
||||
{
|
||||
Set(0.0, 0.0, 0.0, 0.0,
|
||||
0.0, 0.0, 0.0, 0.0,
|
||||
0.0, 0.0, 0.0, 0.0,
|
||||
0.0, 0.0, 0.0, 0.0);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzString NzMatrix4<T>::ToString() const
|
||||
{
|
||||
NzStringStream ss;
|
||||
|
||||
return ss << "Matrix4(" << m11 << ", " << m12 << ", " << m13 << ", " << m14 << ",\n"
|
||||
<< " " << m21 << ", " << m22 << ", " << m23 << ", " << m24 << ",\n"
|
||||
<< " " << m31 << ", " << m32 << ", " << m33 << ", " << m34 << ",\n"
|
||||
<< " " << m41 << ", " << m42 << ", " << m43 << ", " << m44 << ')';
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T> NzMatrix4<T>::Transform(const NzVector2<T>& vector, T z, T w) const
|
||||
{
|
||||
return NzVector2<T>(m11 * vector.x + m12 * vector.y + m13 * z + m14 * w,
|
||||
m21 * vector.x + m22 * vector.y + m23 * z + m24 * w);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector3<T> NzMatrix4<T>::Transform(const NzVector3<T>& vector, T w) const
|
||||
{
|
||||
return NzVector3<T>(m11 * vector.x + m12 * vector.y + m13 * vector.z + m14 * w,
|
||||
m21 * vector.x + m22 * vector.y + m23 * vector.z + m24 * w,
|
||||
m31 * vector.x + m32 * vector.y + m33 * vector.z + m34 * w);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector4<T> NzMatrix4<T>::Transform(const NzVector4<T>& vector) const
|
||||
{
|
||||
return NzVector4<T>(m11 * vector.x + m12 * vector.y + m13 * vector.z + m14 * vector.w,
|
||||
m21 * vector.x + m22 * vector.y + m23 * vector.z + m24 * vector.w,
|
||||
m31 * vector.x + m32 * vector.y + m33 * vector.z + m34 * vector.w,
|
||||
m41 * vector.x + m42 * vector.y + m43 * vector.z + m44 * vector.w);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzMatrix4<T>& NzMatrix4<T>::Transpose()
|
||||
{
|
||||
std::swap(m12, m21);
|
||||
std::swap(m13, m31);
|
||||
std::swap(m14, m41);
|
||||
std::swap(m23, m32);
|
||||
std::swap(m24, m42);
|
||||
std::swap(m34, m43);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzMatrix4<T>::operator T*()
|
||||
{
|
||||
return &m11;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzMatrix4<T>::operator const T*() const
|
||||
{
|
||||
return &m11;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T& NzMatrix4<T>::operator()(unsigned int x, unsigned int y)
|
||||
{
|
||||
#if NAZARA_MATH_SAFE
|
||||
if (x > 3 || y > 3)
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << __FILE__ << ':' << __LINE__ << ": Index out of range: (" << x << ", " << y << ") > (3,3)";
|
||||
|
||||
throw std::out_of_range(ss.ToString());
|
||||
}
|
||||
#endif
|
||||
|
||||
return (&m11)[x*4+y];
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
const T& NzMatrix4<T>::operator()(unsigned int x, unsigned int y) const
|
||||
{
|
||||
#if NAZARA_MATH_SAFE
|
||||
if (x > 3 || y > 3)
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << __FILE__ << ':' << __LINE__ << ": Index out of range: (" << x << ", " << y << ") > (3,3)";
|
||||
|
||||
throw std::out_of_range(ss.ToString());
|
||||
}
|
||||
#endif
|
||||
|
||||
return (&m11)[x*4+y];
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzMatrix4<T> NzMatrix4<T>::operator*(const NzMatrix4& mat) const
|
||||
{
|
||||
NzMatrix4 matrix;
|
||||
for(int k = 0; k < 4; k++)
|
||||
{
|
||||
for(int j = 0; j < 4; j++)
|
||||
{
|
||||
for(int i = 0; i < 4; i++)
|
||||
matrix(j, k) += (*this)(j, i) * mat(i, k);
|
||||
}
|
||||
}
|
||||
|
||||
return matrix;
|
||||
/*return NzMatrix4(m11 * mat.m11 + m21 * mat.m12 + m31 * mat.m13 + m41 * mat.m14,
|
||||
m12 * mat.m11 + m22 * mat.m12 + m32 * mat.m13 + m42 * mat.m14,
|
||||
m13 * mat.m11 + m23 * mat.m12 + m33 * mat.m13 + m43 * mat.m14,
|
||||
m14 * mat.m11 + m24 * mat.m12 + m34 * mat.m13 + m44 * mat.m14,
|
||||
m11 * mat.m21 + m21 * mat.m22 + m31 * mat.m23 + m41 * mat.m24,
|
||||
m12 * mat.m21 + m22 * mat.m22 + m32 * mat.m23 + m42 * mat.m24,
|
||||
m13 * mat.m21 + m23 * mat.m22 + m33 * mat.m23 + m43 * mat.m24,
|
||||
m14 * mat.m21 + m24 * mat.m22 + m34 * mat.m23 + m44 * mat.m24,
|
||||
m11 * mat.m31 + m21 * mat.m32 + m31 * mat.m33 + m41 * mat.m34,
|
||||
m12 * mat.m31 + m22 * mat.m32 + m32 * mat.m33 + m42 * mat.m34,
|
||||
m13 * mat.m31 + m23 * mat.m32 + m33 * mat.m33 + m43 * mat.m34,
|
||||
m14 * mat.m31 + m24 * mat.m32 + m34 * mat.m33 + m44 * mat.m34,
|
||||
m11 * mat.m41 + m21 * mat.m42 + m31 * mat.m43 + m41 * mat.m44,
|
||||
m12 * mat.m41 + m22 * mat.m42 + m32 * mat.m43 + m42 * mat.m44,
|
||||
m13 * mat.m41 + m23 * mat.m42 + m33 * mat.m43 + m43 * mat.m44,
|
||||
m14 * mat.m41 + m24 * mat.m42 + m34 * mat.m43 + m44 * mat.m44);*/
|
||||
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T> NzMatrix4<T>::operator*(const NzVector2<T>& vector) const
|
||||
{
|
||||
return Transform(vector);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector3<T> NzMatrix4<T>::operator*(const NzVector3<T>& vector) const
|
||||
{
|
||||
return Transform(vector);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector4<T> NzMatrix4<T>::operator*(const NzVector4<T>& vector) const
|
||||
{
|
||||
return Transform(vector);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzMatrix4<T> NzMatrix4<T>::operator*(T scalar) const
|
||||
{
|
||||
return NzMatrix4(m11 * scalar, m12 * scalar, m13 * scalar, m14 * scalar,
|
||||
m21 * scalar, m22 * scalar, m23 * scalar, m24 * scalar,
|
||||
m31 * scalar, m32 * scalar, m33 * scalar, m34 * scalar,
|
||||
m41 * scalar, m42 * scalar, m43 * scalar, m44 * scalar);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzMatrix4<T>& NzMatrix4<T>::operator*=(const NzMatrix4& mat)
|
||||
{
|
||||
T r11 = m11 * mat.m11 + m21 * mat.m12 + m31 * mat.m13 + m41 * mat.m14;
|
||||
T r12 = m12 * mat.m11 + m22 * mat.m12 + m32 * mat.m13 + m42 * mat.m14;
|
||||
T r13 = m13 * mat.m11 + m23 * mat.m12 + m33 * mat.m13 + m43 * mat.m14;
|
||||
T r14 = m14 * mat.m11 + m24 * mat.m12 + m34 * mat.m13 + m44 * mat.m14;
|
||||
T r21 = m11 * mat.m21 + m21 * mat.m22 + m31 * mat.m23 + m41 * mat.m24;
|
||||
T r22 = m12 * mat.m21 + m22 * mat.m22 + m32 * mat.m23 + m42 * mat.m24;
|
||||
T r23 = m13 * mat.m21 + m23 * mat.m22 + m33 * mat.m23 + m43 * mat.m24;
|
||||
T r24 = m14 * mat.m21 + m24 * mat.m22 + m34 * mat.m23 + m44 * mat.m24;
|
||||
T r31 = m11 * mat.m31 + m21 * mat.m32 + m31 * mat.m33 + m41 * mat.m34;
|
||||
T r32 = m12 * mat.m31 + m22 * mat.m32 + m32 * mat.m33 + m42 * mat.m34;
|
||||
T r33 = m13 * mat.m31 + m23 * mat.m32 + m33 * mat.m33 + m43 * mat.m34;
|
||||
T r34 = m14 * mat.m31 + m24 * mat.m32 + m34 * mat.m33 + m44 * mat.m34;
|
||||
T r41 = m11 * mat.m41 + m21 * mat.m42 + m31 * mat.m43 + m41 * mat.m44;
|
||||
T r42 = m12 * mat.m41 + m22 * mat.m42 + m32 * mat.m43 + m42 * mat.m44;
|
||||
T r43 = m13 * mat.m41 + m23 * mat.m42 + m33 * mat.m43 + m43 * mat.m44;
|
||||
|
||||
m44 = m14 * mat.m41 + m24 * mat.m42 + m34 * mat.m43 + m44 * mat.m44;
|
||||
m43 = r43;
|
||||
m42 = r42;
|
||||
m41 = r41;
|
||||
m34 = r34;
|
||||
m33 = r33;
|
||||
m32 = r32;
|
||||
m31 = r31;
|
||||
m24 = r24;
|
||||
m23 = r23;
|
||||
m22 = r22;
|
||||
m21 = r21;
|
||||
m14 = r14;
|
||||
m13 = r13;
|
||||
m12 = r12;
|
||||
m11 = r11;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzMatrix4<T>& NzMatrix4<T>::operator*=(T scalar)
|
||||
{
|
||||
m11 *= scalar;
|
||||
m12 *= scalar;
|
||||
m13 *= scalar;
|
||||
m14 *= scalar;
|
||||
m21 *= scalar;
|
||||
m22 *= scalar;
|
||||
m23 *= scalar;
|
||||
m24 *= scalar;
|
||||
m31 *= scalar;
|
||||
m32 *= scalar;
|
||||
m33 *= scalar;
|
||||
m34 *= scalar;
|
||||
m41 *= scalar;
|
||||
m42 *= scalar;
|
||||
m43 *= scalar;
|
||||
m44 *= scalar;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzMatrix4<T> NzMatrix4<T>::LookAt(const NzVector3<T>& eye, const NzVector3<T>& center, const NzVector3<T>& up)
|
||||
{
|
||||
NzMatrix4 mat;
|
||||
mat.SetLookAt(eye, center, up);
|
||||
|
||||
return mat;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzMatrix4<T> NzMatrix4<T>::Perspective(T angle, T ratio, T zNear, T zFar)
|
||||
{
|
||||
NzMatrix4 mat;
|
||||
mat.SetPerspective(angle, ratio, zNear, zFar);
|
||||
|
||||
return mat;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzMatrix4<T> NzMatrix4<T>::Rotate(const NzQuaternion<T>& rotation)
|
||||
{
|
||||
NzMatrix4 mat;
|
||||
mat.SetRotation(rotation);
|
||||
|
||||
return mat;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzMatrix4<T> NzMatrix4<T>::Scale(const NzVector3<T>& scale)
|
||||
{
|
||||
NzMatrix4 mat;
|
||||
mat.SetScale(scale);
|
||||
|
||||
return mat;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzMatrix4<T> NzMatrix4<T>::Translate(const NzVector3<T>& translation)
|
||||
{
|
||||
NzMatrix4 mat;
|
||||
mat.SetTranslation(translation);
|
||||
|
||||
return mat;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
std::ostream& operator<<(std::ostream& out, const NzMatrix4<T>& mat)
|
||||
{
|
||||
return out << mat.ToString();
|
||||
}
|
||||
|
||||
#include <Nazara/Core/DebugOff.hpp>
|
||||
78
include/Nazara/Math/Quaternion.hpp
Normal file
78
include/Nazara/Math/Quaternion.hpp
Normal file
@@ -0,0 +1,78 @@
|
||||
// Copyright (C) 2012 Rémi Begues
|
||||
// Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_QUATERNION_HPP
|
||||
#define NAZARA_QUATERNION_HPP
|
||||
|
||||
#include <Nazara/Core/String.hpp>
|
||||
|
||||
template<typename T> class NzEulerAngles;
|
||||
template<typename T> class NzVector3;
|
||||
|
||||
template<typename T> class NzQuaternion
|
||||
{
|
||||
public:
|
||||
NzQuaternion();
|
||||
NzQuaternion(T W, T X, T Y, T Z);
|
||||
NzQuaternion(T quat[4]);
|
||||
NzQuaternion(T angle, const NzVector3<T>& axis);
|
||||
NzQuaternion(const NzEulerAngles<T>& angles);
|
||||
//NzQuaternion(const NzMatrix3<T>& mat);
|
||||
template<typename U> explicit NzQuaternion(const NzQuaternion<U>& quat);
|
||||
NzQuaternion(const NzQuaternion& quat) = default;
|
||||
~NzQuaternion() = default;
|
||||
|
||||
NzQuaternion GetConjugate() const;
|
||||
NzQuaternion GetNormalized() const;
|
||||
|
||||
double Magnitude() const;
|
||||
double Normalize();
|
||||
T SquaredMagnitude() const;
|
||||
|
||||
void Set(T W, T X, T Y, T Z);
|
||||
void Set(T quat[4]);
|
||||
void Set(T angle, const NzVector3<T>& normalizedAxis);
|
||||
void Set(const NzEulerAngles<T>& angles);
|
||||
//void Set(const NzMatrix3<T>& mat);
|
||||
void Set(const NzQuaternion& quat);
|
||||
template<typename U> void Set(const NzQuaternion<U>& quat);
|
||||
void SetIdentity();
|
||||
void SetZero();
|
||||
|
||||
NzEulerAngles<T> ToEulerAngles() const;
|
||||
//NzMatrix3<T> ToRotationMatrix() const;
|
||||
NzString ToString() const;
|
||||
|
||||
NzQuaternion operator+(const NzQuaternion& quat) const;
|
||||
NzQuaternion operator*(const NzQuaternion& quat) const;
|
||||
NzVector3<T> operator*(const NzVector3<T>& vec) const;
|
||||
NzQuaternion operator*(T scale) const;
|
||||
NzQuaternion operator/(const NzQuaternion& quat) const;
|
||||
|
||||
NzQuaternion operator+=(const NzQuaternion& quat);
|
||||
NzQuaternion operator*=(const NzQuaternion& quat);
|
||||
NzQuaternion operator*=(T scale);
|
||||
NzQuaternion operator/=(const NzQuaternion& quat);
|
||||
|
||||
bool operator==(const NzQuaternion& quat) const;
|
||||
bool operator!=(const NzQuaternion& quat) const;
|
||||
bool operator<(const NzQuaternion& quat) const;
|
||||
bool operator<=(const NzQuaternion& quat) const;
|
||||
bool operator>(const NzQuaternion& quat) const;
|
||||
bool operator>=(const NzQuaternion& quat) const;
|
||||
|
||||
T w, x, y, z;
|
||||
};
|
||||
|
||||
template<typename T> std::ostream& operator<<(std::ostream& out, const NzQuaternion<T>& quat);
|
||||
|
||||
typedef NzQuaternion<double> NzQuaterniond;
|
||||
typedef NzQuaternion<float> NzQuaternionf;
|
||||
|
||||
#include <Nazara/Math/Quaternion.inl>
|
||||
|
||||
#endif // NAZARA_QUATERNION_HPP
|
||||
328
include/Nazara/Math/Quaternion.inl
Normal file
328
include/Nazara/Math/Quaternion.inl
Normal file
@@ -0,0 +1,328 @@
|
||||
// Copyright (C) 2012 Rémi Begues
|
||||
// Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Core/StringStream.hpp>
|
||||
#include <Nazara/Math/Basic.hpp>
|
||||
#include <Nazara/Math/EulerAngles.hpp>
|
||||
#include <Nazara/Math/Vector3.hpp>
|
||||
#include <Nazara/Core/Debug.hpp>
|
||||
|
||||
template<typename T>
|
||||
NzQuaternion<T>::NzQuaternion()
|
||||
{
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzQuaternion<T>::NzQuaternion(T W, T X, T Y, T Z)
|
||||
{
|
||||
Set(W, X, Y, Z);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzQuaternion<T>::NzQuaternion(T quat[4])
|
||||
{
|
||||
Set(quat);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzQuaternion<T>::NzQuaternion(T angle, const NzVector3<T>& axis)
|
||||
{
|
||||
Set(angle, axis);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzQuaternion<T>::NzQuaternion(const NzEulerAngles<T>& angles)
|
||||
{
|
||||
Set(angles);
|
||||
}
|
||||
/*
|
||||
template<typename T>
|
||||
NzQuaternion<T>::NzQuaternion(const NzMatrix3<T>& mat)
|
||||
{
|
||||
Set(mat);
|
||||
}
|
||||
*/
|
||||
template<typename T>
|
||||
template<typename U>
|
||||
NzQuaternion<T>::NzQuaternion(const NzQuaternion<U>& quat)
|
||||
{
|
||||
Set(quat);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzQuaternion<T> NzQuaternion<T>::GetConjugate() const
|
||||
{
|
||||
return NzQuaternion(w, -x, -y, -z);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzQuaternion<T> NzQuaternion<T>::GetNormalized() const
|
||||
{
|
||||
NzQuaternion<T> quat(*this);
|
||||
quat.Normalize();
|
||||
|
||||
return quat;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
double NzQuaternion<T>::Magnitude() const
|
||||
{
|
||||
return std::sqrt(SquaredMagnitude());
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
double NzQuaternion<T>::Normalize()
|
||||
{
|
||||
double length = Magnitude();
|
||||
|
||||
if (length != 0.0)
|
||||
{
|
||||
w /= length;
|
||||
x /= length;
|
||||
y /= length;
|
||||
z /= length;
|
||||
}
|
||||
|
||||
return length;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T NzQuaternion<T>::SquaredMagnitude() const
|
||||
{
|
||||
return w * w + x * x + y * y + z * z;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzQuaternion<T>::Set(T W, T X, T Y, T Z)
|
||||
{
|
||||
w = W;
|
||||
x = X;
|
||||
y = Y;
|
||||
z = Z;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzQuaternion<T>::Set(T quat[4])
|
||||
{
|
||||
w = quat[0];
|
||||
x = quat[1];
|
||||
y = quat[2];
|
||||
z = quat[3];
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzQuaternion<T>::Set(T angle, const NzVector3<T>& normalizedAxis)
|
||||
{
|
||||
#if !NAZARA_MATH_ANGLE_RADIAN
|
||||
angle = NzDegreeToRadian(angle);
|
||||
#endif
|
||||
|
||||
angle /= 2;
|
||||
|
||||
auto sinAngle = std::sin(angle);
|
||||
|
||||
w = std::cos(angle);
|
||||
x = normalizedAxis.x * sinAngle;
|
||||
y = normalizedAxis.y * sinAngle;
|
||||
z = normalizedAxis.z * sinAngle;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzQuaternion<T>::Set(const NzEulerAngles<T>& angles)
|
||||
{
|
||||
Set(angles.ToQuaternion());
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
template<typename U>
|
||||
void NzQuaternion<T>::Set(const NzQuaternion<U>& quat)
|
||||
{
|
||||
w = static_cast<T>(quat.w);
|
||||
x = static_cast<T>(quat.x);
|
||||
y = static_cast<T>(quat.y);
|
||||
z = static_cast<T>(quat.z);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzQuaternion<T>::Set(const NzQuaternion& quat)
|
||||
{
|
||||
w = quat.w;
|
||||
x = quat.x;
|
||||
y = quat.y;
|
||||
z = quat.z;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzQuaternion<T>::SetIdentity()
|
||||
{
|
||||
Set(1.0, 0.0, 0.0, 0.0);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzQuaternion<T>::SetZero()
|
||||
{
|
||||
Set(0.0, 0.0, 0.0, 0.0);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzEulerAngles<T> NzQuaternion<T>::ToEulerAngles() const
|
||||
{
|
||||
T test = x*y + z*w;
|
||||
if (test > 0.499)
|
||||
// singularity at north pole
|
||||
return NzEulerAngles<T>(NzDegrees(90.0), NzRadians(2.0 * std::atan2(x, w)), 0.0);
|
||||
|
||||
if (test < -0.499)
|
||||
return NzEulerAngles<T>(NzDegrees(-90.0), NzRadians(-2.0 * std::atan2(x, w)), 0.0);
|
||||
|
||||
T xx = x*x;
|
||||
T yy = y*y;
|
||||
T zz = z*z;
|
||||
|
||||
return NzEulerAngles<T>(NzRadians(std::atan2(2.0*x*w - 2.0*y*z, 1.0 - 2.0*xx - 2.0*zz)),
|
||||
NzRadians(std::atan2(2.0*y*w - 2.0*x*z, 1.f - 2.0*yy - 2.0*zz)),
|
||||
NzRadians(std::asin(2.0*test)));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzString NzQuaternion<T>::ToString() const
|
||||
{
|
||||
NzStringStream ss;
|
||||
|
||||
return ss << "Quaternion(" << w << " | " << x << ", " << y << ", " << z << ')';
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzQuaternion<T> NzQuaternion<T>::operator+(const NzQuaternion& quat) const
|
||||
{
|
||||
return NzQuaternion(w + quat.w,
|
||||
x + quat.x,
|
||||
y + quat.y,
|
||||
z + quat.z);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzQuaternion<T> NzQuaternion<T>::operator*(const NzQuaternion& quat) const
|
||||
{
|
||||
return NzQuaternion(w * quat.w - x * quat.x - y * quat.y - z * quat.z,
|
||||
w * quat.x + x * quat.w + y * quat.z - z * quat.y,
|
||||
w * quat.y + y * quat.w + z * quat.x - x * quat.z,
|
||||
w * quat.z + z * quat.w + x * quat.y - y * quat.x);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector3<T> NzQuaternion<T>::operator*(const NzVector3<T>& vec) const
|
||||
{
|
||||
NzVector3<T> uv, uuv;
|
||||
NzVector3<T> qvec(x, y, z);
|
||||
uv = qvec.CrossProduct(vec);
|
||||
uuv = qvec.CrossProduct(uv);
|
||||
uv *= 2.0 * w;
|
||||
uuv *= 2.0;
|
||||
|
||||
return vec + uv + uuv;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzQuaternion<T> NzQuaternion<T>::operator*(T scale) const
|
||||
{
|
||||
return NzQuaternion(w * scale,
|
||||
x * scale,
|
||||
y * scale,
|
||||
z * scale);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzQuaternion<T> NzQuaternion<T>::operator/(const NzQuaternion& quat) const
|
||||
{
|
||||
return GetConjugate(quat) * (*this);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzQuaternion<T> NzQuaternion<T>::operator+=(const NzQuaternion& quat)
|
||||
{
|
||||
w += quat.w;
|
||||
x += quat.x;
|
||||
y += quat.y;
|
||||
z += quat.z;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzQuaternion<T> NzQuaternion<T>::operator*=(const NzQuaternion& quat)
|
||||
{
|
||||
NzQuaternion q(*this);
|
||||
operator=(q * quat);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzQuaternion<T> NzQuaternion<T>::operator*=(T scale)
|
||||
{
|
||||
w *= scale;
|
||||
x *= scale;
|
||||
y *= scale;
|
||||
z *= scale;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzQuaternion<T> NzQuaternion<T>::operator/=(const NzQuaternion& quat)
|
||||
{
|
||||
NzQuaternion q(*this);
|
||||
operator=(q / quat);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzQuaternion<T>::operator==(const NzQuaternion& quat) const
|
||||
{
|
||||
return NzNumberEquals(w, quat.w) &&
|
||||
NzNumberEquals(x, quat.x) &&
|
||||
NzNumberEquals(y, quat.y) &&
|
||||
NzNumberEquals(z, quat.z);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzQuaternion<T>::operator!=(const NzQuaternion& quat) const
|
||||
{
|
||||
return !operator==(quat);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzQuaternion<T>::operator<(const NzQuaternion& quat) const
|
||||
{
|
||||
return w < quat.w && x < quat.x && y < quat.y && z < quat.z;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzQuaternion<T>::operator<=(const NzQuaternion& quat) const
|
||||
{
|
||||
return operator<(quat) || operator==(quat);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzQuaternion<T>::operator>(const NzQuaternion& quat) const
|
||||
{
|
||||
return !operator<=(quat);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzQuaternion<T>::operator>=(const NzQuaternion& quat) const
|
||||
{
|
||||
return !operator<(quat);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
std::ostream& operator<<(std::ostream& out, const NzQuaternion<T>& quat)
|
||||
{
|
||||
return out << quat.ToString();
|
||||
}
|
||||
|
||||
#include <Nazara/Core/DebugOff.hpp>
|
||||
80
include/Nazara/Math/Vector2.hpp
Normal file
80
include/Nazara/Math/Vector2.hpp
Normal file
@@ -0,0 +1,80 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_VECTOR2_HPP
|
||||
#define NAZARA_VECTOR2_HPP
|
||||
|
||||
#include <Nazara/Core/String.hpp>
|
||||
|
||||
template<typename T> class NzVector2
|
||||
{
|
||||
public:
|
||||
NzVector2();
|
||||
NzVector2(T X, T Y);
|
||||
explicit NzVector2(T scale);
|
||||
NzVector2(T vec[2]);
|
||||
template<typename U> explicit NzVector2(const NzVector2<U>& vec);
|
||||
NzVector2(const NzVector2& vec) = default;
|
||||
~NzVector2() = default;
|
||||
|
||||
T AbsDotProduct(const NzVector2& vec) const;
|
||||
double Distance(const NzVector2& vec) const;
|
||||
T DotProduct(const NzVector2& vec) const;
|
||||
NzVector2 GetNormal() const;
|
||||
void MakeCeil(const NzVector2& vec);
|
||||
void MakeFloor(const NzVector2& vec);
|
||||
double Length() const;
|
||||
double Normalize();
|
||||
T SquaredDistance(const NzVector2& vec) const;
|
||||
T SquaredLength() const;
|
||||
|
||||
NzString ToString() const;
|
||||
|
||||
operator NzString() const;
|
||||
|
||||
T& operator[](unsigned int i);
|
||||
T operator[](unsigned int i) const;
|
||||
|
||||
const NzVector2& operator+() const;
|
||||
NzVector2 operator-() const;
|
||||
|
||||
NzVector2 operator+(const NzVector2& vec) const;
|
||||
NzVector2 operator-(const NzVector2& vec) const;
|
||||
NzVector2 operator*(const NzVector2& vec) const;
|
||||
NzVector2 operator*(T scale) const;
|
||||
NzVector2 operator/(const NzVector2& vec) const;
|
||||
NzVector2 operator/(T scale) const;
|
||||
|
||||
NzVector2& operator+=(const NzVector2& vec);
|
||||
NzVector2& operator-=(const NzVector2& vec);
|
||||
NzVector2& operator*=(const NzVector2& vec);
|
||||
NzVector2& operator*=(T scale);
|
||||
NzVector2& operator/=(const NzVector2& vec);
|
||||
NzVector2& operator/=(T scale);
|
||||
|
||||
bool operator==(const NzVector2& vec) const;
|
||||
bool operator!=(const NzVector2& vec) const;
|
||||
bool operator<(const NzVector2& vec) const;
|
||||
bool operator<=(const NzVector2& vec) const;
|
||||
bool operator>(const NzVector2& vec) const;
|
||||
bool operator>=(const NzVector2& vec) const;
|
||||
|
||||
T x;
|
||||
T y;
|
||||
};
|
||||
|
||||
template<typename T> std::ostream& operator<<(std::ostream& out, const NzVector2<T>& vec);
|
||||
|
||||
template<typename T> NzVector2<T> operator*(T scale, const NzVector2<T>& vec);
|
||||
template<typename T> NzVector2<T> operator/(T scale, const NzVector2<T>& vec);
|
||||
|
||||
typedef NzVector2<double> NzVector2d;
|
||||
typedef NzVector2<float> NzVector2f;
|
||||
typedef NzVector2<int> NzVector2i;
|
||||
|
||||
#include <Nazara/Math/Vector2.inl>
|
||||
|
||||
#endif // NAZARA_VECTOR2_HPP
|
||||
369
include/Nazara/Math/Vector2.inl
Normal file
369
include/Nazara/Math/Vector2.inl
Normal file
@@ -0,0 +1,369 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Core/StringStream.hpp>
|
||||
#include <Nazara/Math/Basic.hpp>
|
||||
#include <cmath>
|
||||
#include <cstdlib>
|
||||
#include <stdexcept>
|
||||
#include <Nazara/Core/Debug.hpp>
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T>::NzVector2()
|
||||
{
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T>::NzVector2(T X, T Y) :
|
||||
x(X),
|
||||
y(Y)
|
||||
{
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T>::NzVector2(T scale) :
|
||||
x(scale),
|
||||
y(scale)
|
||||
{
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T>::NzVector2(T vec[2]) :
|
||||
x(vec[0]),
|
||||
y(vec[1])
|
||||
{
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
template<typename U>
|
||||
NzVector2<T>::NzVector2(const NzVector2<U>& vec) :
|
||||
x(static_cast<T>(vec.x)),
|
||||
y(static_cast<T>(vec.y))
|
||||
{
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T NzVector2<T>::AbsDotProduct(const NzVector2& vec) const
|
||||
{
|
||||
return std::fabs(x * vec.x) + std::fabs(y * vec.y);
|
||||
}
|
||||
|
||||
template<> inline int NzVector2<int>::AbsDotProduct(const NzVector2<int>& vec) const
|
||||
{
|
||||
return std::labs(x * vec.x) + std::labs(y * vec.y);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
double NzVector2<T>::Distance(const NzVector2& vec) const
|
||||
{
|
||||
return std::sqrt(SquaredDistance(vec));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T NzVector2<T>::DotProduct(const NzVector2& vec) const
|
||||
{
|
||||
return x * vec.x + y * vec.y;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T> NzVector2<T>::GetNormal() const
|
||||
{
|
||||
NzVector2 vec(*this);
|
||||
vec.Normalize();
|
||||
|
||||
return vec;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzVector2<T>::MakeCeil(const NzVector2& vec)
|
||||
{
|
||||
if (vec.x > x)
|
||||
x = vec.x;
|
||||
|
||||
if (vec.y > y)
|
||||
y = vec.y;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzVector2<T>::MakeFloor(const NzVector2& vec)
|
||||
{
|
||||
if (vec.x < x)
|
||||
x = vec.x;
|
||||
|
||||
if (vec.y < y)
|
||||
y = vec.y;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
double NzVector2<T>::Length() const
|
||||
{
|
||||
return std::sqrt(SquaredLength());
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
double NzVector2<T>::Normalize()
|
||||
{
|
||||
double length = Length();
|
||||
|
||||
if (length != 0.f)
|
||||
{
|
||||
x /= length;
|
||||
y /= length;
|
||||
}
|
||||
|
||||
return length;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T NzVector2<T>::SquaredDistance(const NzVector2& vec) const
|
||||
{
|
||||
return operator-(vec).SquaredLength();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T NzVector2<T>::SquaredLength() const
|
||||
{
|
||||
return x * x + y * y;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzString NzVector2<T>::ToString() const
|
||||
{
|
||||
NzStringStream ss;
|
||||
|
||||
return ss << "Vector2(" << x << ", " << y << ')';
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T>::operator NzString() const
|
||||
{
|
||||
return ToString();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T& NzVector2<T>::operator[](unsigned int i)
|
||||
{
|
||||
if (i >= 2)
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << __FILE__ << ':' << __LINE__ << ": Index out of range (" << i << " >= 2)";
|
||||
|
||||
throw std::domain_error(ss.ToString());
|
||||
}
|
||||
|
||||
return *(&x+i);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T NzVector2<T>::operator[](unsigned int i) const
|
||||
{
|
||||
if (i >= 2)
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << __FILE__ << ':' << __LINE__ << ": Index out of range (" << i << " >= 2)";
|
||||
|
||||
throw std::domain_error(ss.ToString());
|
||||
}
|
||||
|
||||
return *(&x+i);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
const NzVector2<T>& NzVector2<T>::operator+() const
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T> NzVector2<T>::operator-() const
|
||||
{
|
||||
return NzVector2(-x, -y);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T> NzVector2<T>::operator+(const NzVector2& vec) const
|
||||
{
|
||||
return NzVector2(x + vec.x, y + vec.y);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T> NzVector2<T>::operator-(const NzVector2& vec) const
|
||||
{
|
||||
return NzVector2(x - vec.x, y - vec.y);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T> NzVector2<T>::operator*(const NzVector2& vec) const
|
||||
{
|
||||
return NzVector2(x * vec.x, y * vec.y);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T> NzVector2<T>::operator*(T scale) const
|
||||
{
|
||||
return NzVector2(x * scale, y * scale);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T> NzVector2<T>::operator/(const NzVector2& vec) const
|
||||
{
|
||||
if (vec.x == 0.f || vec.y == 0.f)
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << __FILE__ << ':' << __LINE__ << ": Division by zero";
|
||||
|
||||
throw std::domain_error(ss.ToString());
|
||||
}
|
||||
|
||||
return NzVector2(x / vec.x, y / vec.y);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T> NzVector2<T>::operator/(T scale) const
|
||||
{
|
||||
if (scale == 0.f)
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << __FILE__ << ':' << __LINE__ << ": Division by zero";
|
||||
|
||||
throw std::domain_error(ss.ToString());
|
||||
}
|
||||
|
||||
return NzVector2(x / scale, y / scale);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T>& NzVector2<T>::operator+=(const NzVector2& vec)
|
||||
{
|
||||
x += vec.x;
|
||||
y += vec.y;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T>& NzVector2<T>::operator-=(const NzVector2& vec)
|
||||
{
|
||||
x -= vec.x;
|
||||
y -= vec.y;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T>& NzVector2<T>::operator*=(const NzVector2& vec)
|
||||
{
|
||||
x *= vec.x;
|
||||
y *= vec.y;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T>& NzVector2<T>::operator*=(T scale)
|
||||
{
|
||||
x *= scale;
|
||||
y *= scale;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T>& NzVector2<T>::operator/=(const NzVector2& vec)
|
||||
{
|
||||
if (vec.x == 0.f || vec.y == 0.f)
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << __FILE__ << ':' << __LINE__ << ": Division by zero";
|
||||
|
||||
throw std::domain_error(ss.ToString());
|
||||
}
|
||||
|
||||
x /= vec.x;
|
||||
y /= vec.y;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T>& NzVector2<T>::operator/=(T scale)
|
||||
{
|
||||
if (scale == 0.f)
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << __FILE__ << ':' << __LINE__ << ": Division by zero";
|
||||
|
||||
throw std::domain_error(ss.ToString());
|
||||
}
|
||||
|
||||
x /= scale;
|
||||
y /= scale;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzVector2<T>::operator==(const NzVector2& vec) const
|
||||
{
|
||||
return NzNumberEquals(x, vec.x) &&
|
||||
NzNumberEquals(y, vec.y);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzVector2<T>::operator!=(const NzVector2& vec) const
|
||||
{
|
||||
return !operator==(vec);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzVector2<T>::operator<(const NzVector2& vec) const
|
||||
{
|
||||
return x < vec.x && y < vec.y;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzVector2<T>::operator<=(const NzVector2& vec) const
|
||||
{
|
||||
return operator<(vec) || operator==(vec);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzVector2<T>::operator>(const NzVector2& vec) const
|
||||
{
|
||||
return !operator<=(vec);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzVector2<T>::operator>=(const NzVector2& vec) const
|
||||
{
|
||||
return !operator<(vec);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
std::ostream& operator<<(std::ostream& out, const NzVector2<T>& vec)
|
||||
{
|
||||
return out << vec.ToString();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T> operator*(T scale, const NzVector2<T>& vec)
|
||||
{
|
||||
return NzVector2<T>(scale * vec.x, scale * vec.y);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T> operator/(T scale, const NzVector2<T>& vec)
|
||||
{
|
||||
if (vec.x == 0.f || vec.y == 0.f)
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << __FILE__ << ':' << __LINE__ << ": Division by zero";
|
||||
|
||||
throw std::domain_error(ss.ToString());
|
||||
}
|
||||
|
||||
return NzVector2<T>(scale/vec.x, scale/vec.y);
|
||||
}
|
||||
|
||||
#include <Nazara/Core/DebugOff.hpp>
|
||||
82
include/Nazara/Math/Vector3.hpp
Normal file
82
include/Nazara/Math/Vector3.hpp
Normal file
@@ -0,0 +1,82 @@
|
||||
// Copyright (C) 2012 Rémi Begues
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_VECTOR3_HPP
|
||||
#define NAZARA_VECTOR3_HPP
|
||||
|
||||
#include <Nazara/Core/String.hpp>
|
||||
|
||||
template<typename T> class NzVector3
|
||||
{
|
||||
public:
|
||||
NzVector3();
|
||||
NzVector3(T X, T Y, T Z);
|
||||
explicit NzVector3(T scale);
|
||||
NzVector3(T vec[3]);
|
||||
template<typename U> explicit NzVector3(const NzVector3<U>& vec);
|
||||
NzVector3(const NzVector3& vec) = default;
|
||||
~NzVector3() = default;
|
||||
|
||||
T AbsDotProduct(const NzVector3& vec) const;
|
||||
NzVector3 CrossProduct(const NzVector3& vec) const;
|
||||
double Distance(const NzVector3& vec) const;
|
||||
T DotProduct(const NzVector3& vec) const;
|
||||
NzVector3 GetNormal() const;
|
||||
void MakeCeil(const NzVector3& vec);
|
||||
void MakeFloor(const NzVector3& vec);
|
||||
double Length() const;
|
||||
double Normalize();
|
||||
T SquaredDistance(const NzVector3& vec) const;
|
||||
T SquaredLength() const;
|
||||
|
||||
NzString ToString() const;
|
||||
|
||||
operator NzString() const;
|
||||
|
||||
T& operator[](unsigned int i);
|
||||
T operator[](unsigned int i) const;
|
||||
|
||||
const NzVector3& operator+() const;
|
||||
NzVector3 operator-() const;
|
||||
|
||||
NzVector3 operator+(const NzVector3& vec) const;
|
||||
NzVector3 operator-(const NzVector3& vec) const;
|
||||
NzVector3 operator*(const NzVector3& vec) const;
|
||||
NzVector3 operator*(T scale) const;
|
||||
NzVector3 operator/(const NzVector3& vec) const;
|
||||
NzVector3 operator/(T scale) const;
|
||||
|
||||
NzVector3& operator+=(const NzVector3& vec);
|
||||
NzVector3& operator-=(const NzVector3& vec);
|
||||
NzVector3& operator*=(const NzVector3& vec);
|
||||
NzVector3& operator*=(T scale);
|
||||
NzVector3& operator/=(const NzVector3& vec);
|
||||
NzVector3& operator/=(T scale);
|
||||
|
||||
bool operator==(const NzVector3& vec) const;
|
||||
bool operator!=(const NzVector3& vec) const;
|
||||
bool operator<(const NzVector3& vec) const;
|
||||
bool operator<=(const NzVector3& vec) const;
|
||||
bool operator>(const NzVector3& vec) const;
|
||||
bool operator>=(const NzVector3& vec) const;
|
||||
|
||||
T x;
|
||||
T y;
|
||||
T z;
|
||||
};
|
||||
|
||||
template<typename T> std::ostream& operator<<(std::ostream& out, const NzVector3<T>& vec);
|
||||
|
||||
template<typename T> NzVector3<T> operator*(T scale, const NzVector3<T>& vec);
|
||||
template<typename T> NzVector3<T> operator/(T scale, const NzVector3<T>& vec);
|
||||
|
||||
typedef NzVector3<double> NzVector3d;
|
||||
typedef NzVector3<float> NzVector3f;
|
||||
typedef NzVector3<int> NzVector3i;
|
||||
|
||||
#include <Nazara/Math/Vector3.inl>
|
||||
|
||||
#endif // NAZARA_VECTOR3_HPP
|
||||
393
include/Nazara/Math/Vector3.inl
Normal file
393
include/Nazara/Math/Vector3.inl
Normal file
@@ -0,0 +1,393 @@
|
||||
// Copyright (C) 2012 Rémi Begues
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Core/StringStream.hpp>
|
||||
#include <Nazara/Math/Basic.hpp>
|
||||
#include <cmath>
|
||||
#include <cstdlib>
|
||||
#include <stdexcept>
|
||||
#include <Nazara/Core/Debug.hpp>
|
||||
|
||||
template<typename T>
|
||||
NzVector3<T>::NzVector3()
|
||||
{
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector3<T>::NzVector3(T X, T Y, T Z) :
|
||||
x(X),
|
||||
y(Y),
|
||||
z(Z)
|
||||
{
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector3<T>::NzVector3(T scale) :
|
||||
x(scale),
|
||||
y(scale),
|
||||
z(scale)
|
||||
{
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector3<T>::NzVector3(T vec[3]) :
|
||||
x(vec[0]),
|
||||
y(vec[1]),
|
||||
z(vec[2])
|
||||
{
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
template<typename U>
|
||||
NzVector3<T>::NzVector3(const NzVector3<U>& vec) :
|
||||
x(static_cast<T>(vec.x)),
|
||||
y(static_cast<T>(vec.y)),
|
||||
z(static_cast<T>(vec.z))
|
||||
{
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T NzVector3<T>::AbsDotProduct(const NzVector3& vec) const
|
||||
{
|
||||
return std::fabs(x * vec.x) + std::fabs(y * vec.y) + std::fabs(z * vec.z);
|
||||
}
|
||||
|
||||
template<> inline int NzVector3<int>::AbsDotProduct(const NzVector3<int>& vec) const
|
||||
{
|
||||
return std::labs(x * vec.x) + std::labs(y * vec.y) + std::labs(z * vec.z);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector3<T> NzVector3<T>::CrossProduct(const NzVector3& vec) const
|
||||
{
|
||||
return NzVector3(y * vec.z - z * vec.y, z * vec.x - x * vec.y, x * vec.y - y * vec.x);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
double NzVector3<T>::Distance(const NzVector3& vec) const
|
||||
{
|
||||
return std::sqrt(SquaredDistance(vec));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T NzVector3<T>::DotProduct(const NzVector3& vec) const
|
||||
{
|
||||
return x * vec.x + y * vec.y + z * vec.z;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector3<T> NzVector3<T>::GetNormal() const
|
||||
{
|
||||
NzVector3 vec(*this);
|
||||
vec.Normalize();
|
||||
|
||||
return vec;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzVector3<T>::MakeCeil(const NzVector3& vec)
|
||||
{
|
||||
if (vec.x > x)
|
||||
x = vec.x;
|
||||
|
||||
if (vec.y > y)
|
||||
y = vec.y;
|
||||
|
||||
if (vec.z > z)
|
||||
z = vec.z;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzVector3<T>::MakeFloor(const NzVector3& vec)
|
||||
{
|
||||
if (vec.x < x)
|
||||
x = vec.x;
|
||||
|
||||
if (vec.y < y)
|
||||
y = vec.y;
|
||||
|
||||
if (vec.z < z)
|
||||
z = vec.z;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
double NzVector3<T>::Length() const
|
||||
{
|
||||
return std::sqrt(SquaredLength());
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
double NzVector3<T>::Normalize()
|
||||
{
|
||||
double length = Length();
|
||||
|
||||
if (length != 0.f)
|
||||
{
|
||||
x /= length;
|
||||
y /= length;
|
||||
z /= length;
|
||||
}
|
||||
|
||||
return length;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T NzVector3<T>::SquaredDistance(const NzVector3& vec) const
|
||||
{
|
||||
return operator-(vec).SquaredLength();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T NzVector3<T>::SquaredLength() const
|
||||
{
|
||||
return x * x + y * y + z * z;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzString NzVector3<T>::ToString() const
|
||||
{
|
||||
NzStringStream ss;
|
||||
|
||||
return ss << "Vector3(" << x << ", " << y << ", " << z <<')';
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector3<T>::operator NzString() const
|
||||
{
|
||||
return ToString();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T& NzVector3<T>::operator[](unsigned int i)
|
||||
{
|
||||
if (i >= 3)
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << __FILE__ << ':' << __LINE__ << ": Index out of range (" << i << " >= 3)";
|
||||
|
||||
throw std::domain_error(ss.ToString());
|
||||
}
|
||||
|
||||
return *(&x+i);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T NzVector3<T>::operator[](unsigned int i) const
|
||||
{
|
||||
if (i >= 3)
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << __FILE__ << ':' << __LINE__ << ": Index out of range (" << i << " >= 3)";
|
||||
|
||||
throw std::domain_error(ss.ToString());
|
||||
}
|
||||
|
||||
return *(&x+i);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
const NzVector3<T>& NzVector3<T>::operator+() const
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector3<T> NzVector3<T>::operator-() const
|
||||
{
|
||||
return NzVector3(-x, -y, -z);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector3<T> NzVector3<T>::operator+(const NzVector3& vec) const
|
||||
{
|
||||
return NzVector3(x + vec.x, y + vec.y, z + vec.z);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector3<T> NzVector3<T>::operator-(const NzVector3& vec) const
|
||||
{
|
||||
return NzVector3(x - vec.x, y - vec.y, z - vec.z);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector3<T> NzVector3<T>::operator*(const NzVector3& vec) const
|
||||
{
|
||||
return NzVector3(x * vec.x, y * vec.y, z * vec.z);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector3<T> NzVector3<T>::operator*(T scale) const
|
||||
{
|
||||
return NzVector3(x * scale, y * scale, z * scale);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector3<T> NzVector3<T>::operator/(const NzVector3& vec) const
|
||||
{
|
||||
if (vec.x == 0.f || vec.y == 0.f || vec.z == 0.f)
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << __FILE__ << ':' << __LINE__ << ": Division by zero";
|
||||
|
||||
throw std::domain_error(ss.ToString());
|
||||
}
|
||||
|
||||
return NzVector3(x / vec.x, y / vec.y, z / vec.z);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector3<T> NzVector3<T>::operator/(T scale) const
|
||||
{
|
||||
if (scale == 0.f)
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << __FILE__ << ':' << __LINE__ << ": Division by zero";
|
||||
|
||||
throw std::domain_error(ss.ToString());
|
||||
}
|
||||
|
||||
return NzVector3(x / scale, y / scale, z / scale);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector3<T>& NzVector3<T>::operator+=(const NzVector3& vec)
|
||||
{
|
||||
x += vec.x;
|
||||
y += vec.y;
|
||||
z += vec.z;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector3<T>& NzVector3<T>::operator-=(const NzVector3& vec)
|
||||
{
|
||||
x -= vec.x;
|
||||
y -= vec.y;
|
||||
z -= vec.z;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector3<T>& NzVector3<T>::operator*=(const NzVector3& vec)
|
||||
{
|
||||
x *= vec.x;
|
||||
y *= vec.y;
|
||||
z *= vec.z;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector3<T>& NzVector3<T>::operator*=(T scale)
|
||||
{
|
||||
x *= scale;
|
||||
y *= scale;
|
||||
z *= scale;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector3<T>& NzVector3<T>::operator/=(const NzVector3& vec)
|
||||
{
|
||||
if (vec.x == 0.f || vec.y == 0.f || vec.z == 0.f)
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << __FILE__ << ':' << __LINE__ << ": Division by zero";
|
||||
|
||||
throw std::domain_error(ss.ToString());
|
||||
}
|
||||
|
||||
x /= vec.x;
|
||||
y /= vec.y;
|
||||
z /= vec.z;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector3<T>& NzVector3<T>::operator/=(T scale)
|
||||
{
|
||||
if (scale == 0.f)
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << __FILE__ << ':' << __LINE__ << ": Division by zero";
|
||||
|
||||
throw std::domain_error(ss.ToString());
|
||||
}
|
||||
|
||||
x /= scale;
|
||||
y /= scale;
|
||||
z /= scale;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzVector3<T>::operator==(const NzVector3& vec) const
|
||||
{
|
||||
return NzNumberEquals(x, vec.x) &&
|
||||
NzNumberEquals(y, vec.y) &&
|
||||
NzNumberEquals(z, vec.z);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzVector3<T>::operator!=(const NzVector3& vec) const
|
||||
{
|
||||
return !operator==(vec);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzVector3<T>::operator<(const NzVector3& vec) const
|
||||
{
|
||||
return x < vec.x && y < vec.y && z < vec.z;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzVector3<T>::operator<=(const NzVector3& vec) const
|
||||
{
|
||||
return operator<(vec) || operator==(vec);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzVector3<T>::operator>(const NzVector3& vec) const
|
||||
{
|
||||
return !operator<=(vec);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzVector3<T>::operator>=(const NzVector3& vec) const
|
||||
{
|
||||
return !operator<(vec);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
std::ostream& operator<<(std::ostream& out, const NzVector3<T>& vec)
|
||||
{
|
||||
return out << vec.ToString();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector3<T> operator*(T scale, const NzVector3<T>& vec)
|
||||
{
|
||||
return NzVector3<T>(scale * vec.x, scale * vec.y, scale * vec.z);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector3<T> operator/(T scale, const NzVector3<T>& vec)
|
||||
{
|
||||
if (vec.x == 0.f || vec.y == 0.f || vec.z == 0.f)
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << __FILE__ << ':' << __LINE__ << ": Division by zero";
|
||||
|
||||
throw std::domain_error(ss.ToString());
|
||||
}
|
||||
|
||||
return NzVector3<T>(scale / vec.x, scale / vec.y, scale / vec.z);
|
||||
}
|
||||
|
||||
#include <Nazara/Core/DebugOff.hpp>
|
||||
77
include/Nazara/Math/Vector4.hpp
Normal file
77
include/Nazara/Math/Vector4.hpp
Normal file
@@ -0,0 +1,77 @@
|
||||
// Copyright (C) 2012 Rémi Begues
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_VECTOR4_HPP
|
||||
#define NAZARA_VECTOR4_HPP
|
||||
|
||||
#include <Nazara/Core/String.hpp>
|
||||
|
||||
template<typename T> class NzVector4
|
||||
{
|
||||
public:
|
||||
NzVector4();
|
||||
NzVector4(T X, T Y, T Z, T W = 1.0);
|
||||
explicit NzVector4(T scale);
|
||||
NzVector4(T vec[4]);
|
||||
template<typename U> explicit NzVector4(const NzVector4<U>& vec);
|
||||
NzVector4(const NzVector4& vec) = default;
|
||||
~NzVector4() = default;
|
||||
|
||||
T AbsDotProduct(const NzVector4& vec) const;
|
||||
T DotProduct(const NzVector4& vec) const;
|
||||
void MakeCeil(const NzVector4& vec);
|
||||
void MakeFloor(const NzVector4& vec);
|
||||
void Normalize();
|
||||
|
||||
NzString ToString() const;
|
||||
|
||||
operator NzString() const;
|
||||
|
||||
T& operator[](unsigned int i);
|
||||
T operator[](unsigned int i) const;
|
||||
|
||||
const NzVector4& operator+() const;
|
||||
NzVector4 operator-() const;
|
||||
|
||||
NzVector4 operator+(const NzVector4& vec) const;
|
||||
NzVector4 operator-(const NzVector4& vec) const;
|
||||
NzVector4 operator*(const NzVector4& vec) const;
|
||||
NzVector4 operator*(T scale) const;
|
||||
NzVector4 operator/(const NzVector4& vec) const;
|
||||
NzVector4 operator/(T scale) const;
|
||||
|
||||
NzVector4& operator+=(const NzVector4& vec);
|
||||
NzVector4& operator-=(const NzVector4& vec);
|
||||
NzVector4& operator*=(const NzVector4& vec);
|
||||
NzVector4& operator*=(T scale);
|
||||
NzVector4& operator/=(const NzVector4& vec);
|
||||
NzVector4& operator/=(T scale);
|
||||
|
||||
bool operator==(const NzVector4& vec) const;
|
||||
bool operator!=(const NzVector4& vec) const;
|
||||
bool operator<(const NzVector4& vec) const;
|
||||
bool operator<=(const NzVector4& vec) const;
|
||||
bool operator>(const NzVector4& vec) const;
|
||||
bool operator>=(const NzVector4& vec) const;
|
||||
|
||||
T x;
|
||||
T y;
|
||||
T z;
|
||||
T w;
|
||||
};
|
||||
|
||||
template<typename T> std::ostream& operator<<(std::ostream& out, const NzVector4<T>& vec);
|
||||
|
||||
template<typename T> NzVector4<T> operator*(T scale, const NzVector4<T>& vec);
|
||||
template<typename T> NzVector4<T> operator/(T scale, const NzVector4<T>& vec);
|
||||
|
||||
typedef NzVector4<double> NzVector4d;
|
||||
typedef NzVector4<float> NzVector4f;
|
||||
typedef NzVector4<int> NzVector4i;
|
||||
|
||||
#include <Nazara/Math/Vector4.inl>
|
||||
|
||||
#endif // NAZARA_VECTOR4_HPP
|
||||
367
include/Nazara/Math/Vector4.inl
Normal file
367
include/Nazara/Math/Vector4.inl
Normal file
@@ -0,0 +1,367 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Core/StringStream.hpp>
|
||||
#include <Nazara/Math/Basic.hpp>
|
||||
#include <cmath>
|
||||
#include <cstdlib>
|
||||
#include <stdexcept>
|
||||
#include <Nazara/Core/Debug.hpp>
|
||||
|
||||
template<typename T>
|
||||
NzVector4<T>::NzVector4()
|
||||
{
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector4<T>::NzVector4(T X, T Y, T Z, T W) :
|
||||
x(X),
|
||||
y(Y),
|
||||
z(Z),
|
||||
w(W)
|
||||
{
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector4<T>::NzVector4(T scale) :
|
||||
x(scale),
|
||||
y(scale),
|
||||
z(scale),
|
||||
w(scale)
|
||||
{
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector4<T>::NzVector4(T vec[4]) :
|
||||
x(vec[0]),
|
||||
y(vec[1]),
|
||||
z(vec[2]),
|
||||
w(vec[3])
|
||||
{
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
template<typename U>
|
||||
NzVector4<T>::NzVector4(const NzVector4<U>& vec) :
|
||||
x(static_cast<T>(vec.x)),
|
||||
y(static_cast<T>(vec.y)),
|
||||
z(static_cast<T>(vec.z)),
|
||||
w(static_cast<T>(vec.w))
|
||||
{
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T NzVector4<T>::AbsDotProduct(const NzVector4& vec) const
|
||||
{
|
||||
return std::fabs(x * vec.x) + std::fabs(y * vec.y) + std::fabs(z * vec.z) + std::fabs(w * vec.w);
|
||||
}
|
||||
|
||||
template<> inline int NzVector4<int>::AbsDotProduct(const NzVector4<int>& vec) const
|
||||
{
|
||||
return std::labs(x * vec.x) + std::labs(y * vec.y) + std::labs(z * vec.z) + std::labs(w * vec.w);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T NzVector4<T>::DotProduct(const NzVector4& vec) const
|
||||
{
|
||||
return x * vec.x + y * vec.y + z * vec.z + w * vec.w;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzVector4<T>::MakeCeil(const NzVector4& vec)
|
||||
{
|
||||
if (vec.x > x)
|
||||
x = vec.x;
|
||||
|
||||
if (vec.y > y)
|
||||
y = vec.y;
|
||||
|
||||
if (vec.z > z)
|
||||
z = vec.z;
|
||||
|
||||
if (vec.w > w)
|
||||
w = vec.w;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzVector4<T>::MakeFloor(const NzVector4& vec)
|
||||
{
|
||||
if (vec.x < x)
|
||||
x = vec.x;
|
||||
|
||||
if (vec.y < y)
|
||||
y = vec.y;
|
||||
|
||||
if (vec.z < z)
|
||||
z = vec.z;
|
||||
|
||||
if (vec.w < w)
|
||||
w = vec.w;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzVector4<T>::Normalize()
|
||||
{
|
||||
if (w != 0.f)
|
||||
{
|
||||
x /= w;
|
||||
y /= w;
|
||||
z /= w;
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzString NzVector4<T>::ToString() const
|
||||
{
|
||||
NzStringStream ss;
|
||||
|
||||
return ss << "Vector4(" << x << ", " << y << ", " << z <<')';
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector4<T>::operator NzString() const
|
||||
{
|
||||
return ToString();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T& NzVector4<T>::operator[](unsigned int i)
|
||||
{
|
||||
if (i >= 4)
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << __FILE__ << ':' << __LINE__ << ": Index out of range (" << i << " >= 4)";
|
||||
|
||||
throw std::domain_error(ss.ToString());
|
||||
}
|
||||
|
||||
return *(&x+i);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T NzVector4<T>::operator[](unsigned int i) const
|
||||
{
|
||||
if (i >= 4)
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << __FILE__ << ':' << __LINE__ << ": Index out of range (" << i << " >= 4)";
|
||||
|
||||
throw std::domain_error(ss.ToString());
|
||||
}
|
||||
|
||||
return *(&x+i);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
const NzVector4<T>& NzVector4<T>::operator+() const
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector4<T> NzVector4<T>::operator-() const
|
||||
{
|
||||
return NzVector4(-x, -y, -z, -w);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector4<T> NzVector4<T>::operator+(const NzVector4& vec) const
|
||||
{
|
||||
return NzVector4(x + vec.x, y + vec.y, z + vec.z, w + vec.w);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector4<T> NzVector4<T>::operator-(const NzVector4& vec) const
|
||||
{
|
||||
return NzVector4(x - vec.x, y - vec.y, z - vec.z);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector4<T> NzVector4<T>::operator*(const NzVector4& vec) const
|
||||
{
|
||||
return NzVector4(x * vec.x, y * vec.y, z * vec.z, w * vec.w);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector4<T> NzVector4<T>::operator*(T scale) const
|
||||
{
|
||||
return NzVector4(x * scale, y * scale, z * scale, w * scale);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector4<T> NzVector4<T>::operator/(const NzVector4& vec) const
|
||||
{
|
||||
if (vec.x == 0.f || vec.y == 0.f || vec.z == 0.f || vec.w == 0.f)
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << __FILE__ << ':' << __LINE__ << ": Division by zero";
|
||||
|
||||
throw std::domain_error(ss.ToString());
|
||||
}
|
||||
|
||||
return NzVector4(x / vec.x, y / vec.y, z / vec.z, w / vec.w);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector4<T> NzVector4<T>::operator/(T scale) const
|
||||
{
|
||||
if (scale == 0.f)
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << __FILE__ << ':' << __LINE__ << ": Division by zero";
|
||||
|
||||
throw std::domain_error(ss.ToString());
|
||||
}
|
||||
|
||||
return NzVector4(x / scale, y / scale, z / scale, w / scale);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector4<T>& NzVector4<T>::operator+=(const NzVector4& vec)
|
||||
{
|
||||
x += vec.x;
|
||||
y += vec.y;
|
||||
z += vec.z;
|
||||
w += vec.w;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector4<T>& NzVector4<T>::operator-=(const NzVector4& vec)
|
||||
{
|
||||
x -= vec.x;
|
||||
y -= vec.y;
|
||||
z -= vec.z;
|
||||
w -= vec.w;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector4<T>& NzVector4<T>::operator*=(const NzVector4& vec)
|
||||
{
|
||||
x *= vec.x;
|
||||
y *= vec.y;
|
||||
z *= vec.z;
|
||||
w *= vec.w;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector4<T>& NzVector4<T>::operator*=(T scale)
|
||||
{
|
||||
x *= scale;
|
||||
y *= scale;
|
||||
z *= scale;
|
||||
w *= scale;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector4<T>& NzVector4<T>::operator/=(const NzVector4& vec)
|
||||
{
|
||||
if (vec.x == 0.f || vec.y == 0.f || vec.z == 0.f || vec.w == 0.f)
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << __FILE__ << ':' << __LINE__ << ": Division by zero";
|
||||
|
||||
throw std::domain_error(ss.ToString());
|
||||
}
|
||||
|
||||
x /= vec.x;
|
||||
y /= vec.y;
|
||||
z /= vec.z;
|
||||
w /= vec.w;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector4<T>& NzVector4<T>::operator/=(T scale)
|
||||
{
|
||||
if (scale == 0.f)
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << __FILE__ << ':' << __LINE__ << ": Division by zero";
|
||||
|
||||
throw std::domain_error(ss.ToString());
|
||||
}
|
||||
|
||||
x /= scale;
|
||||
y /= scale;
|
||||
z /= scale;
|
||||
w /= scale;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzVector4<T>::operator==(const NzVector4& vec) const
|
||||
{
|
||||
return NzNumberEquals(x, vec.x) &&
|
||||
NzNumberEquals(y, vec.y) &&
|
||||
NzNumberEquals(z, vec.z) &&
|
||||
NzNumberEquals(w, vec.w);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzVector4<T>::operator!=(const NzVector4& vec) const
|
||||
{
|
||||
return !operator==(vec);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzVector4<T>::operator<(const NzVector4& vec) const
|
||||
{
|
||||
return x < vec.x && y < vec.y && z < vec.z && w < vec.w;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzVector4<T>::operator<=(const NzVector4& vec) const
|
||||
{
|
||||
return operator<(vec) || operator==(vec);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzVector4<T>::operator>(const NzVector4& vec) const
|
||||
{
|
||||
return !operator<=(vec);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzVector4<T>::operator>=(const NzVector4& vec) const
|
||||
{
|
||||
return !operator<(vec);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
std::ostream& operator<<(std::ostream& out, const NzVector4<T>& vec)
|
||||
{
|
||||
return out << vec.ToString();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector4<T> operator*(T scale, const NzVector4<T>& vec)
|
||||
{
|
||||
return NzVector4<T>(scale * vec.x, scale * vec.y, scale * vec.z, scale * vec.w);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector4<T> operator/(T scale, const NzVector4<T>& vec)
|
||||
{
|
||||
if (vec.x == 0.f || vec.y == 0.f || vec.z == 0.f || vec.w == 0.f)
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << __FILE__ << ':' << __LINE__ << ": Division by zero";
|
||||
|
||||
throw std::domain_error(ss.ToString());
|
||||
}
|
||||
|
||||
return NzVector3<T>(scale / vec.x, scale / vec.y, scale / vec.z, scale / vec.w);
|
||||
}
|
||||
|
||||
#include <Nazara/Core/DebugOff.hpp>
|
||||
35
include/Nazara/Network/Config.hpp
Normal file
35
include/Nazara/Network/Config.hpp
Normal file
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
Nazara Engine
|
||||
|
||||
Copyright (C) 2012 Jérôme "Lynix" Leclercq (Lynix680@gmail.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_CONFIG_NETWORK_HPP
|
||||
#define NAZARA_CONFIG_NETWORK_HPP
|
||||
|
||||
/// Chaque modification d'un paramètre du module nécessite une recompilation de celui-ci
|
||||
|
||||
// Utilise un tracker pour repérer les éventuels leaks (Ralentit l'exécution)
|
||||
#define NAZARA_NETWORK_MEMORYLEAKTRACKER 0
|
||||
|
||||
#endif // NAZARA_CONFIG_NETWORK_HPP
|
||||
11
include/Nazara/Network/Debug.hpp
Normal file
11
include/Nazara/Network/Debug.hpp
Normal file
@@ -0,0 +1,11 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Network/Config.hpp>
|
||||
#if NAZARA_NETWORK_MEMORYLEAKTRACKER || defined(NAZARA_DEBUG)
|
||||
#include <Nazara/Core/Debug/MemoryLeakTracker.hpp>
|
||||
|
||||
#define delete NzMemoryManager::NextFree(__FILE__, __LINE__), delete
|
||||
#define new new(__FILE__, __LINE__)
|
||||
#endif
|
||||
8
include/Nazara/Network/DebugOff.hpp
Normal file
8
include/Nazara/Network/DebugOff.hpp
Normal file
@@ -0,0 +1,8 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#if NAZARA_NETWORK_MEMORYLEAKTRACKER || defined(NAZARA_DEBUG)
|
||||
#undef delete
|
||||
#undef new
|
||||
#endif
|
||||
112
include/Nazara/Prerequesites.hpp
Normal file
112
include/Nazara/Prerequesites.hpp
Normal file
@@ -0,0 +1,112 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#ifndef NAZARA_PREREQUESITES_HPP
|
||||
#define NAZARA_PREREQUESITES_HPP
|
||||
|
||||
// Version du moteur
|
||||
#define NAZARA_VERSION_MAJOR 0
|
||||
#define NAZARA_VERSION_MINOR 1
|
||||
|
||||
// (Commenté en attendant GCC 4.7)
|
||||
/*#if __cplusplus < 201103L
|
||||
#error Nazara requires a C++11 compliant compiler
|
||||
#endif*/
|
||||
|
||||
///TODO: Rajouter des tests d'identification de compilateurs
|
||||
#if defined(_MSC_VER)
|
||||
#define NAZARA_COMPILER_MSVC
|
||||
#define NAZARA_DEPRECATED(txt) __declspec(deprecated(txt))
|
||||
#define NAZARA_FUNCTION __FUNCSIG__
|
||||
#elif defined(__GNUC__)
|
||||
#define NAZARA_COMPILER_GCC
|
||||
#define NAZARA_FUNCTION __PRETTY_FUNCTION__
|
||||
|
||||
#define NAZARA_DEPRECATED(txt) __attribute__((__deprecated__(txt)))
|
||||
#elif defined(__BORLANDC__)
|
||||
#define NAZARA_COMPILER_BORDLAND
|
||||
#define NAZARA_DEPRECATED(txt)
|
||||
#define NAZARA_FUNCTION __FUNC__
|
||||
#else
|
||||
#define NAZARA_COMPILER_UNKNOWN
|
||||
#define NAZARA_DEPRECATED(txt)
|
||||
#define NAZARA_FUNCTION __func__ // __func__ est standard depuis le C++11
|
||||
#error This compiler is not fully supported
|
||||
#endif
|
||||
|
||||
#define NazaraUnused(a) (void) a
|
||||
|
||||
#if defined(_WIN32) || defined(__WIN32__) || defined(NAZARA_PLATFORM_WINDOWSVISTA)
|
||||
#if !defined(NAZARA_STATIC)
|
||||
#ifdef NAZARA_BUILD
|
||||
#define NAZARA_API __declspec(dllexport)
|
||||
#else
|
||||
#define NAZARA_API __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#define NAZARA_API
|
||||
#endif
|
||||
#define NAZARA_PLATFORM_WINDOWS
|
||||
|
||||
// Des defines pour le header Windows
|
||||
#if defined(NAZARA_BUILD) // Pour ne pas entrer en conflit avec les defines de l'application ou d'une autre bibliothèque
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
|
||||
#ifndef NOMINMAX
|
||||
#define NOMINMAX
|
||||
#endif
|
||||
|
||||
#ifndef _WIN32_WINNT
|
||||
#ifdef NAZARA_PLATFORM_WINDOWSVISTA
|
||||
#define _WIN32_WINNT 0x0600 // Version de Windows minimale : Vista
|
||||
#else
|
||||
#define _WIN32_WINNT 0x0501 // Version de Windows minimale : XP
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#elif defined(linux) || defined(__linux)
|
||||
#if !defined(NAZARA_STATIC) && defined(NAZARA_COMPILER_GCC)
|
||||
#define NAZARA_API __attribute__((visibility ("default")))
|
||||
#else
|
||||
#define NAZARA_API
|
||||
#endif
|
||||
#define NAZARA_PLATFORM_LINUX
|
||||
#define NAZARA_PLATFORM_POSIX
|
||||
/*#elif defined(__APPLE__) || defined(MACOSX) || defined(macintosh) || defined(Macintosh)
|
||||
#define NAZARA_API
|
||||
#define NAZARA_PLATFORM_MACOS
|
||||
#define NAZARA_PLATFORM_POSIX
|
||||
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
||||
#define NAZARA_API
|
||||
#define NAZARA_PLATFORM_FREEBSD
|
||||
#define NAZARA_PLATFORM_POSIX*/
|
||||
#else
|
||||
// À commenter pour tenter quand même une compilation
|
||||
#error This operating system is not fully supported by the Nazara Engine
|
||||
|
||||
#define NAZARA_PLATFORM_UNKNOWN
|
||||
#define NAZARA_API
|
||||
#endif
|
||||
|
||||
#if !defined(NAZARA_DEBUG) && !defined(NDEBUG)
|
||||
#define NDEBUG
|
||||
#endif
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
typedef int8_t nzInt8;
|
||||
typedef uint8_t nzUInt8;
|
||||
|
||||
typedef int16_t nzInt16;
|
||||
typedef uint16_t nzUInt16;
|
||||
|
||||
typedef int32_t nzInt32;
|
||||
typedef uint32_t nzUInt32;
|
||||
|
||||
typedef int64_t nzInt64;
|
||||
typedef uint64_t nzUInt64;
|
||||
|
||||
#endif // NAZARA_PREREQUESITES_HPP
|
||||
82
include/Nazara/Renderer/Buffer.hpp
Normal file
82
include/Nazara/Renderer/Buffer.hpp
Normal file
@@ -0,0 +1,82 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_BUFFER_HPP
|
||||
#define NAZARA_BUFFER_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Utility/Resource.hpp>
|
||||
|
||||
enum nzBufferLock
|
||||
{
|
||||
nzBufferLock_DiscardAndWrite,
|
||||
nzBufferLock_ReadOnly,
|
||||
nzBufferLock_ReadWrite,
|
||||
nzBufferLock_WriteOnly
|
||||
};
|
||||
|
||||
enum nzBufferStorage
|
||||
{
|
||||
nzBufferStorage_Hardware,
|
||||
nzBufferStorage_Software
|
||||
};
|
||||
|
||||
enum nzBufferType
|
||||
{
|
||||
nzBufferType_Index,
|
||||
nzBufferType_Vertex
|
||||
};
|
||||
|
||||
enum nzBufferUsage
|
||||
{
|
||||
nzBufferUsage_Dynamic,
|
||||
nzBufferUsage_Static
|
||||
};
|
||||
|
||||
class NzBufferImpl;
|
||||
class NzRenderer;
|
||||
|
||||
class NAZARA_API NzBuffer : public NzResource
|
||||
{
|
||||
friend class NzRenderer;
|
||||
|
||||
public:
|
||||
NzBuffer(nzBufferType type);
|
||||
NzBuffer(nzBufferType type, unsigned int length, nzUInt8 typeSize, nzBufferUsage usage = nzBufferUsage_Static);
|
||||
~NzBuffer();
|
||||
|
||||
bool CopyContent(NzBuffer& buffer);
|
||||
|
||||
bool Create(unsigned int length, nzUInt8 typeSize, nzBufferUsage usage = nzBufferUsage_Static);
|
||||
void Destroy();
|
||||
|
||||
bool Fill(const void* data, unsigned int offset, unsigned int length);
|
||||
|
||||
unsigned int GetLength() const;
|
||||
unsigned int GetSize() const;
|
||||
nzBufferStorage GetStorage() const;
|
||||
nzBufferType GetType() const;
|
||||
nzUInt8 GetTypeSize() const;
|
||||
nzBufferUsage GetUsage() const;
|
||||
|
||||
bool IsHardware() const;
|
||||
|
||||
void* Lock(nzBufferLock lock, unsigned int offset = 0, unsigned int length = 0);
|
||||
bool Unlock();
|
||||
|
||||
static bool IsHardwareSupported();
|
||||
|
||||
private:
|
||||
nzBufferStorage m_storage;
|
||||
nzBufferType m_type;
|
||||
nzBufferUsage m_usage;
|
||||
nzUInt8 m_typeSize;
|
||||
NzBufferImpl* m_impl;
|
||||
unsigned int m_length;
|
||||
|
||||
};
|
||||
|
||||
#endif // NAZARA_BUFFER_HPP
|
||||
47
include/Nazara/Renderer/Config.hpp
Normal file
47
include/Nazara/Renderer/Config.hpp
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
Nazara Engine
|
||||
|
||||
Copyright (C) 2012 Jérôme "Lynix" Leclercq (Lynix680@gmail.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_CONFIG_RENDERER_HPP
|
||||
#define NAZARA_CONFIG_RENDERER_HPP
|
||||
|
||||
/// Chaque modification d'un paramètre du module nécessite une recompilation de celui-ci
|
||||
|
||||
// Active une fenêtre de rendu (NzRenderWindow) lors de sa création
|
||||
#define NAZARA_RENDERER_ACTIVATE_RENDERWINDOW_ON_CREATION 1
|
||||
|
||||
// Force les buffers à posséder un stride multiple de 32 bytes (Gain de performances sur certaines cartes)
|
||||
#define NAZARA_RENDERER_FORCE_DECLARATION_STRIDE_MULTIPLE_OF_32 0
|
||||
|
||||
// Utilise un tracker pour repérer les éventuels leaks (Ralentit l'exécution)
|
||||
#define NAZARA_RENDERER_MEMORYLEAKTRACKER 0
|
||||
|
||||
// Active les tests de sécurité basés sur le code (Conseillé pour le développement)
|
||||
#define NAZARA_RENDERER_SAFE 1
|
||||
|
||||
// Fait en sorte que le Renderer soit un singleton plutôt qu'une instance globale
|
||||
#define NAZARA_RENDERER_SINGLETON 0
|
||||
|
||||
#endif // NAZARA_CONFIG_MODULENAME_HPP
|
||||
44
include/Nazara/Renderer/Context.hpp
Normal file
44
include/Nazara/Renderer/Context.hpp
Normal file
@@ -0,0 +1,44 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#ifdef NAZARA_RENDERER_COMMON
|
||||
#error This file is not part of the common renderer interface, you must undefine NAZARA_RENDERER_COMMON to use it
|
||||
#endif
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_CONTEXT_HPP
|
||||
#define NAZARA_CONTEXT_HPP
|
||||
|
||||
#include <Nazara/Renderer/ContextParameters.hpp>
|
||||
|
||||
class NzContextImpl;
|
||||
|
||||
class NAZARA_API NzContext
|
||||
{
|
||||
friend class NzContextImpl;
|
||||
|
||||
public:
|
||||
NzContext();
|
||||
~NzContext();
|
||||
|
||||
bool Create(const NzContextParameters& parameters = NzContextParameters());
|
||||
const NzContextParameters& GetParameters() const;
|
||||
bool IsActive() const;
|
||||
bool SetActive(bool active);
|
||||
void SwapBuffers();
|
||||
|
||||
static const NzContext* GetCurrent();
|
||||
static const NzContext* GetReference();
|
||||
static bool InitializeReference();
|
||||
static void UninitializeReference();
|
||||
|
||||
private:
|
||||
NzContextParameters m_parameters;
|
||||
NzContextImpl* m_impl;
|
||||
|
||||
static NzContext* s_reference;
|
||||
};
|
||||
|
||||
#endif // NAZARA_CONTEXT_HPP
|
||||
54
include/Nazara/Renderer/ContextParameters.hpp
Normal file
54
include/Nazara/Renderer/ContextParameters.hpp
Normal file
@@ -0,0 +1,54 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_CONTEXTPARAMETERS_HPP
|
||||
#define NAZARA_CONTEXTPARAMETERS_HPP
|
||||
|
||||
#include <Nazara/Renderer/RenderTargetParameters.hpp>
|
||||
#include <Nazara/Utility/VideoMode.hpp>
|
||||
#include <Nazara/Utility/WindowHandle.hpp>
|
||||
|
||||
class NzContext;
|
||||
|
||||
struct NAZARA_API NzContextParameters
|
||||
{
|
||||
NzContextParameters(const NzRenderTargetParameters& parameters = NzRenderTargetParameters()) :
|
||||
antialiasingLevel(parameters.antialiasingLevel),
|
||||
bitsPerPixel(NzVideoMode::GetDesktopMode().bitsPerPixel),
|
||||
depthBits(parameters.depthBits),
|
||||
majorVersion(defaultMajorVersion),
|
||||
minorVersion(defaultMinorVersion),
|
||||
stencilBits(parameters.stencilBits),
|
||||
shareContext(defaultShareContext),
|
||||
window(defaultWindow),
|
||||
compatibilityProfile(defaultCompatibilityProfile),
|
||||
doubleBuffered(defaultDoubleBuffered),
|
||||
shared(defaultShared)
|
||||
{
|
||||
}
|
||||
|
||||
nzUInt8 antialiasingLevel;
|
||||
nzUInt8 bitsPerPixel;
|
||||
nzUInt8 depthBits;
|
||||
nzUInt8 majorVersion;
|
||||
nzUInt8 minorVersion;
|
||||
nzUInt8 stencilBits;
|
||||
const NzContext* shareContext;
|
||||
NzWindowHandle window;
|
||||
bool compatibilityProfile;
|
||||
bool doubleBuffered;
|
||||
bool shared;
|
||||
|
||||
static nzUInt8 defaultMajorVersion;
|
||||
static nzUInt8 defaultMinorVersion;
|
||||
static const NzContext* defaultShareContext;
|
||||
static NzWindowHandle defaultWindow;
|
||||
static bool defaultCompatibilityProfile;
|
||||
static bool defaultDoubleBuffered;
|
||||
static bool defaultShared;
|
||||
};
|
||||
|
||||
#endif // NAZARA_CONTEXTPARAMETERS_HPP
|
||||
11
include/Nazara/Renderer/Debug.hpp
Normal file
11
include/Nazara/Renderer/Debug.hpp
Normal file
@@ -0,0 +1,11 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Renderer/Config.hpp>
|
||||
#if NAZARA_RENDERER_MEMORYLEAKTRACKER || defined(NAZARA_DEBUG)
|
||||
#include <Nazara/Core/Debug/MemoryLeakTracker.hpp>
|
||||
|
||||
#define delete NzMemoryManager::NextFree(__FILE__, __LINE__), delete
|
||||
#define new new(__FILE__, __LINE__)
|
||||
#endif
|
||||
8
include/Nazara/Renderer/DebugOff.hpp
Normal file
8
include/Nazara/Renderer/DebugOff.hpp
Normal file
@@ -0,0 +1,8 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#if NAZARA_RENDERER_MEMORYLEAKTRACKER || defined(NAZARA_DEBUG)
|
||||
#undef delete
|
||||
#undef new
|
||||
#endif
|
||||
41
include/Nazara/Renderer/IndexBuffer.hpp
Normal file
41
include/Nazara/Renderer/IndexBuffer.hpp
Normal file
@@ -0,0 +1,41 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_INDEXBUFFER_HPP
|
||||
#define NAZARA_INDEXBUFFER_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Renderer/Buffer.hpp>
|
||||
|
||||
class NAZARA_API NzIndexBuffer
|
||||
{
|
||||
public:
|
||||
NzIndexBuffer(NzBuffer* buffer, unsigned int startIndex, unsigned int indexCount);
|
||||
NzIndexBuffer(unsigned int length, nzUInt8 indexSize, nzBufferUsage usage = nzBufferUsage_Static);
|
||||
NzIndexBuffer(const NzIndexBuffer& indexBuffer);
|
||||
~NzIndexBuffer();
|
||||
|
||||
bool Fill(const void* data, unsigned int offset, unsigned int length);
|
||||
|
||||
NzBuffer* GetBuffer() const;
|
||||
nzUInt8 GetIndexSize() const;
|
||||
unsigned int GetIndexCount() const;
|
||||
unsigned int GetStartIndex() const;
|
||||
|
||||
bool IsHardware() const;
|
||||
bool IsSequential() const;
|
||||
|
||||
void* Lock(nzBufferLock lock, unsigned int offset = 0, unsigned int length = 0);
|
||||
bool Unlock();
|
||||
|
||||
private:
|
||||
NzBuffer* m_buffer;
|
||||
bool m_ownsBuffer;
|
||||
unsigned int m_indexCount;
|
||||
unsigned int m_startIndex;
|
||||
};
|
||||
|
||||
#endif // NAZARA_INDEXBUFFER_HPP
|
||||
159
include/Nazara/Renderer/OpenGL.hpp
Normal file
159
include/Nazara/Renderer/OpenGL.hpp
Normal file
@@ -0,0 +1,159 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#ifdef NAZARA_RENDERER_COMMON
|
||||
#error This file is not part of the common renderer interface, you must undefine NAZARA_RENDERER_COMMON to use it
|
||||
#endif
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_OPENGL_HPP
|
||||
#define NAZARA_OPENGL_HPP
|
||||
|
||||
// gl3.h définit WIN32_LEAN_AND_MEAN qui entre en conflit avec la définition de Nazara et doit donc être inclut en premier
|
||||
#include <GL3/gl3.h>
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
|
||||
// Il semblerait qu'il ne soit pas conseillé d'inclure gl3.h t glext.h en même temps, mais je ne vois pas oomment gérer les extensions autrement...
|
||||
#include <GLext/glext.h>
|
||||
#if defined(NAZARA_PLATFORM_WINDOWS)
|
||||
#include <GLext/wglext.h>
|
||||
#elif defined(NAZARA_PLATFORM_LINUX)
|
||||
#include <GLext/glxext.h>
|
||||
#else
|
||||
#error OS not handled
|
||||
#endif
|
||||
|
||||
typedef void (*NzOpenGLFunc)();
|
||||
|
||||
class NAZARA_API NzOpenGL
|
||||
{
|
||||
public:
|
||||
enum Extension
|
||||
{
|
||||
AnisotropicFilter,
|
||||
FP64,
|
||||
Framebuffer_Object,
|
||||
Occlusion_Query,
|
||||
Texture3D,
|
||||
|
||||
Count
|
||||
};
|
||||
|
||||
static unsigned int GetVersion();
|
||||
static bool Initialize();
|
||||
static bool IsSupported(Extension extension);
|
||||
static bool IsSupported(const NzString& string);
|
||||
static void Uninitialize();
|
||||
};
|
||||
|
||||
NAZARA_API extern PFNGLACTIVETEXTUREPROC glActiveTexture;
|
||||
NAZARA_API extern PFNGLATTACHSHADERPROC glAttachShader;
|
||||
NAZARA_API extern PFNGLBEGINQUERYPROC glBeginQuery;
|
||||
NAZARA_API extern PFNGLBINDATTRIBLOCATIONPROC glBindAttribLocation;
|
||||
NAZARA_API extern PFNGLBINDBUFFERPROC glBindBuffer;
|
||||
NAZARA_API extern PFNGLBINDFRAMEBUFFERPROC glBindFramebuffer;
|
||||
NAZARA_API extern PFNGLBINDRENDERBUFFERPROC glBindRenderbuffer;
|
||||
NAZARA_API extern PFNGLBINDTEXTUREPROC glBindTexture;
|
||||
NAZARA_API extern PFNGLBLENDFUNCPROC glBlendFunc;
|
||||
NAZARA_API extern PFNGLBUFFERDATAPROC glBufferData;
|
||||
NAZARA_API extern PFNGLBUFFERSUBDATAPROC glBufferSubData;
|
||||
NAZARA_API extern PFNGLCLEARPROC glClear;
|
||||
NAZARA_API extern PFNGLCLEARCOLORPROC glClearColor;
|
||||
NAZARA_API extern PFNGLCLEARDEPTHPROC glClearDepth;
|
||||
NAZARA_API extern PFNGLCLEARSTENCILPROC glClearStencil;
|
||||
NAZARA_API extern PFNGLCREATEPROGRAMPROC glCreateProgram;
|
||||
NAZARA_API extern PFNGLCREATESHADERPROC glCreateShader;
|
||||
NAZARA_API extern PFNGLCHECKFRAMEBUFFERSTATUSPROC glCheckFramebufferStatus;
|
||||
NAZARA_API extern PFNGLCOLORMASKPROC glColorMask;
|
||||
NAZARA_API extern PFNGLCULLFACEPROC glCullFace;
|
||||
NAZARA_API extern PFNGLCOMPILESHADERPROC glCompileShader;
|
||||
NAZARA_API extern PFNGLDELETEBUFFERSPROC glDeleteBuffers;
|
||||
NAZARA_API extern PFNGLDELETEFRAMEBUFFERSPROC glDeleteFramebuffers;
|
||||
NAZARA_API extern PFNGLDELETEPROGRAMPROC glDeleteProgram;
|
||||
NAZARA_API extern PFNGLDELETEQUERIESPROC glDeleteQueries;
|
||||
NAZARA_API extern PFNGLDELETERENDERBUFFERSPROC glDeleteRenderbuffers;
|
||||
NAZARA_API extern PFNGLDELETESHADERPROC glDeleteShader;
|
||||
NAZARA_API extern PFNGLDELETETEXTURESPROC glDeleteTextures;
|
||||
NAZARA_API extern PFNGLDEPTHFUNCPROC glDepthFunc;
|
||||
NAZARA_API extern PFNGLDEPTHMASKPROC glDepthMask;
|
||||
NAZARA_API extern PFNGLDISABLEPROC glDisable;
|
||||
NAZARA_API extern PFNGLDISABLEVERTEXATTRIBARRAYPROC glDisableVertexAttribArray;
|
||||
NAZARA_API extern PFNGLDRAWARRAYSPROC glDrawArrays;
|
||||
NAZARA_API extern PFNGLDRAWBUFFERPROC glDrawBuffer;
|
||||
NAZARA_API extern PFNGLDRAWBUFFERSPROC glDrawBuffers;
|
||||
NAZARA_API extern PFNGLDRAWELEMENTSPROC glDrawElements;
|
||||
NAZARA_API extern PFNGLENDQUERYPROC glEndQuery;
|
||||
NAZARA_API extern PFNGLFLUSHPROC glFlush;
|
||||
NAZARA_API extern PFNGLFRAMEBUFFERRENDERBUFFERPROC glFramebufferRenderbuffer;
|
||||
NAZARA_API extern PFNGLFRAMEBUFFERTEXTURE2DPROC glFramebufferTexture2D;
|
||||
NAZARA_API extern PFNGLENABLEPROC glEnable;
|
||||
NAZARA_API extern PFNGLENABLEVERTEXATTRIBARRAYPROC glEnableVertexAttribArray;
|
||||
NAZARA_API extern PFNGLGENERATEMIPMAPPROC glGenerateMipmap;
|
||||
NAZARA_API extern PFNGLGENBUFFERSPROC glGenBuffers;
|
||||
NAZARA_API extern PFNGLGENFRAMEBUFFERSPROC glGenFramebuffers;
|
||||
NAZARA_API extern PFNGLGENQUERIESPROC glGenQueries;
|
||||
NAZARA_API extern PFNGLGENRENDERBUFFERSPROC glGenRenderbuffers;
|
||||
NAZARA_API extern PFNGLGENTEXTURESPROC glGenTextures;
|
||||
NAZARA_API extern PFNGLGETBUFFERPARAMETERIVPROC glGetBufferParameteriv;
|
||||
NAZARA_API extern PFNGLGETERRORPROC glGetError;
|
||||
NAZARA_API extern PFNGLGETINTEGERVPROC glGetIntegerv;
|
||||
NAZARA_API extern PFNGLGETPROGRAMIVPROC glGetProgramiv;
|
||||
NAZARA_API extern PFNGLGETPROGRAMINFOLOGPROC glGetProgramInfoLog;
|
||||
NAZARA_API extern PFNGLGETQUERYIVPROC glGetQueryiv;
|
||||
NAZARA_API extern PFNGLGETQUERYOBJECTIVPROC glGetQueryObjectiv;
|
||||
NAZARA_API extern PFNGLGETQUERYOBJECTUIVPROC glGetQueryObjectuiv;
|
||||
NAZARA_API extern PFNGLGETSHADERINFOLOGPROC glGetShaderInfoLog;
|
||||
NAZARA_API extern PFNGLGETSHADERIVPROC glGetShaderiv;
|
||||
NAZARA_API extern PFNGLGETSHADERSOURCEPROC glGetShaderSource;
|
||||
NAZARA_API extern PFNGLGETSTRINGPROC glGetString;
|
||||
NAZARA_API extern PFNGLGETSTRINGIPROC glGetStringi;
|
||||
NAZARA_API extern PFNGLGETTEXIMAGEPROC glGetTexImage;
|
||||
NAZARA_API extern PFNGLGETTEXPARAMETERFVPROC glGetTexParameterfv;
|
||||
NAZARA_API extern PFNGLGETTEXPARAMETERIVPROC glGetTexParameteriv;
|
||||
NAZARA_API extern PFNGLGETUNIFORMLOCATIONPROC glGetUniformLocation;
|
||||
NAZARA_API extern PFNGLLINKPROGRAMPROC glLinkProgram;
|
||||
NAZARA_API extern PFNGLMAPBUFFERPROC glMapBuffer;
|
||||
NAZARA_API extern PFNGLMAPBUFFERRANGEPROC glMapBufferRange;
|
||||
NAZARA_API extern PFNGLPOLYGONMODEPROC glPolygonMode;
|
||||
NAZARA_API extern PFNGLRENDERBUFFERSTORAGEPROC glRenderbufferStorage;
|
||||
NAZARA_API extern PFNGLSCISSORPROC glScissor;
|
||||
NAZARA_API extern PFNGLSHADERSOURCEPROC glShaderSource;
|
||||
NAZARA_API extern PFNGLSTENCILFUNCPROC glStencilFunc;
|
||||
NAZARA_API extern PFNGLSTENCILOPPROC glStencilOp;
|
||||
NAZARA_API extern PFNGLTEXIMAGE2DPROC glTexImage2D;
|
||||
NAZARA_API extern PFNGLTEXIMAGE3DEXTPROC glTexImage3D;
|
||||
NAZARA_API extern PFNGLTEXPARAMETERFPROC glTexParameterf;
|
||||
NAZARA_API extern PFNGLTEXPARAMETERIPROC glTexParameteri;
|
||||
NAZARA_API extern PFNGLTEXSUBIMAGE2DPROC glTexSubImage2D;
|
||||
NAZARA_API extern PFNGLTEXSUBIMAGE3DEXTPROC glTexSubImage3D;
|
||||
NAZARA_API extern PFNGLUNIFORM1DPROC glUniform1d;
|
||||
NAZARA_API extern PFNGLUNIFORM1FPROC glUniform1f;
|
||||
NAZARA_API extern PFNGLUNIFORM1IPROC glUniform1i;
|
||||
NAZARA_API extern PFNGLUNIFORM2DVPROC glUniform2dv;
|
||||
NAZARA_API extern PFNGLUNIFORM2FVPROC glUniform2fv;
|
||||
NAZARA_API extern PFNGLUNIFORM3DVPROC glUniform3dv;
|
||||
NAZARA_API extern PFNGLUNIFORM3FVPROC glUniform3fv;
|
||||
NAZARA_API extern PFNGLUNIFORM4DVPROC glUniform4dv;
|
||||
NAZARA_API extern PFNGLUNIFORM4FVPROC glUniform4fv;
|
||||
NAZARA_API extern PFNGLUNIFORMMATRIX4DVPROC glUniformMatrix4dv;
|
||||
NAZARA_API extern PFNGLUNIFORMMATRIX4FVPROC glUniformMatrix4fv;
|
||||
NAZARA_API extern PFNGLUNMAPBUFFERPROC glUnmapBuffer;
|
||||
NAZARA_API extern PFNGLUSEPROGRAMPROC glUseProgram;
|
||||
NAZARA_API extern PFNGLVERTEXATTRIB4FPROC glVertexAttrib4f;
|
||||
NAZARA_API extern PFNGLVERTEXATTRIBPOINTERPROC glVertexAttribPointer;
|
||||
NAZARA_API extern PFNGLVIEWPORTPROC glViewport;
|
||||
#if defined(NAZARA_PLATFORM_WINDOWS)
|
||||
NAZARA_API extern PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormat;
|
||||
NAZARA_API extern PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribs;
|
||||
NAZARA_API extern PFNWGLGETEXTENSIONSSTRINGARBPROC wglGetExtensionsStringARB;
|
||||
NAZARA_API extern PFNWGLGETEXTENSIONSSTRINGEXTPROC wglGetExtensionsStringEXT;
|
||||
NAZARA_API extern PFNWGLSWAPINTERVALEXTPROC wglSwapInterval;
|
||||
#elif defined(NAZARA_PLATFORM_LINUX)
|
||||
NAZARA_API extern PFNGLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribs;
|
||||
NAZARA_API extern PFNGLXSWAPINTERVALSGIPROC glXSwapInterval;
|
||||
#endif
|
||||
|
||||
#endif // NAZARA_OPENGL_HPP
|
||||
40
include/Nazara/Renderer/RenderTarget.hpp
Normal file
40
include/Nazara/Renderer/RenderTarget.hpp
Normal file
@@ -0,0 +1,40 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_RENDERTARGET_HPP
|
||||
#define NAZARA_RENDERTARGET_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Renderer/RenderTargetParameters.hpp>
|
||||
|
||||
class NzRenderer;
|
||||
|
||||
class NAZARA_API NzRenderTarget
|
||||
{
|
||||
friend class NzRenderer;
|
||||
|
||||
public:
|
||||
NzRenderTarget() = default;
|
||||
virtual ~NzRenderTarget();
|
||||
|
||||
virtual bool CanActivate() const = 0;
|
||||
|
||||
virtual NzRenderTargetParameters GetRenderTargetParameters() const = 0;
|
||||
|
||||
#ifdef NAZARA_RENDERER_OPENGL
|
||||
virtual bool HasContext() const = 0;
|
||||
#endif
|
||||
|
||||
bool IsActive() const;
|
||||
|
||||
bool SetActive(bool active);
|
||||
|
||||
protected:
|
||||
virtual bool Activate() = 0;
|
||||
virtual void Desactivate();
|
||||
};
|
||||
|
||||
#endif // NAZARA_RENDERTARGET_HPP
|
||||
26
include/Nazara/Renderer/RenderTargetParameters.hpp
Normal file
26
include/Nazara/Renderer/RenderTargetParameters.hpp
Normal file
@@ -0,0 +1,26 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_RENDERTARGETPARAMETERS_HPP
|
||||
#define NAZARA_RENDERTARGETPARAMETERS_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
|
||||
struct NzRenderTargetParameters
|
||||
{
|
||||
NzRenderTargetParameters(nzUInt8 antialiasing = 0, nzUInt8 depth = 24, nzUInt8 stencil = 0) :
|
||||
antialiasingLevel(antialiasing),
|
||||
depthBits(depth),
|
||||
stencilBits(stencil)
|
||||
{
|
||||
}
|
||||
|
||||
nzUInt8 antialiasingLevel;
|
||||
nzUInt8 depthBits;
|
||||
nzUInt8 stencilBits;
|
||||
};
|
||||
|
||||
#endif // NAZARA_RENDERTARGETPARAMETERS_HPP
|
||||
59
include/Nazara/Renderer/RenderWindow.hpp
Normal file
59
include/Nazara/Renderer/RenderWindow.hpp
Normal file
@@ -0,0 +1,59 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
// Interface inspirée de la SFML par Laurent Gomila
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_RENDERWINDOW_HPP
|
||||
#define NAZARA_RENDERWINDOW_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Renderer/RenderTarget.hpp>
|
||||
#include <Nazara/Utility/Window.hpp>
|
||||
|
||||
#ifndef NAZARA_RENDERER_COMMON
|
||||
#include <Nazara/Renderer/ContextParameters.hpp>
|
||||
#endif
|
||||
|
||||
class NzContext;
|
||||
struct NzContextParameters;
|
||||
|
||||
class NAZARA_API NzRenderWindow : public NzRenderTarget, public NzWindow
|
||||
{
|
||||
public:
|
||||
NzRenderWindow();
|
||||
NzRenderWindow(NzVideoMode mode, const NzString& title, nzUInt32 style = NzWindow::Default, const NzContextParameters& parameters = NzContextParameters());
|
||||
NzRenderWindow(NzWindowHandle handle, const NzContextParameters& parameters = NzContextParameters());
|
||||
virtual ~NzRenderWindow();
|
||||
|
||||
bool CanActivate() const;
|
||||
|
||||
bool Create(NzVideoMode mode, const NzString& title, nzUInt32 style = NzWindow::Default, const NzContextParameters& parameters = NzContextParameters());
|
||||
bool Create(NzWindowHandle handle, const NzContextParameters& parameters = NzContextParameters());
|
||||
|
||||
void Display();
|
||||
|
||||
void EnableVerticalSync(bool enabled);
|
||||
|
||||
NzRenderTargetParameters GetRenderTargetParameters() const;
|
||||
|
||||
#ifndef NAZARA_RENDERER_COMMON
|
||||
NzContextParameters GetContextParameters() const;
|
||||
|
||||
bool HasContext() const;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
bool Activate();
|
||||
|
||||
private:
|
||||
void OnClose();
|
||||
bool OnCreate();
|
||||
|
||||
NzContext* m_context;
|
||||
NzContextParameters m_parameters;
|
||||
};
|
||||
|
||||
#endif // NAZARA_RENDERWINDOW_HPP
|
||||
79
include/Nazara/Renderer/Renderer.hpp
Normal file
79
include/Nazara/Renderer/Renderer.hpp
Normal file
@@ -0,0 +1,79 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_RENDERER_HPP
|
||||
#define NAZARA_RENDERER_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Renderer/IndexBuffer.hpp>
|
||||
#include <Nazara/Renderer/RenderTarget.hpp>
|
||||
#include <Nazara/Renderer/Shader.hpp>
|
||||
#include <Nazara/Renderer/VertexBuffer.hpp>
|
||||
|
||||
#define NazaraRenderer NzRenderer::Instance()
|
||||
|
||||
enum nzRendererCap
|
||||
{
|
||||
nzRendererCap_AnisotropicFilter,
|
||||
nzRendererCap_FP64,
|
||||
nzRendererCap_HardwareBuffer,
|
||||
nzRendererCap_MultipleRenderTargets,
|
||||
nzRendererCap_Texture3D,
|
||||
nzRendererCap_TextureCubemap,
|
||||
nzRendererCap_TextureMulti,
|
||||
nzRendererCap_TextureNPOT,
|
||||
|
||||
nzRendererCap_Count
|
||||
};
|
||||
|
||||
enum nzRendererClear
|
||||
{
|
||||
nzRendererClear_Color = 0x01,
|
||||
nzRendererClear_Depth = 0x02,
|
||||
nzRendererClear_Stencil = 0x04
|
||||
};
|
||||
|
||||
class NAZARA_API NzRenderer
|
||||
{
|
||||
public:
|
||||
NzRenderer();
|
||||
~NzRenderer();
|
||||
|
||||
void Clear(nzRendererClear flags);
|
||||
|
||||
NzShader* GetShader() const;
|
||||
NzRenderTarget* GetTarget() const;
|
||||
|
||||
bool HasCapability(nzRendererCap capability) const;
|
||||
bool Initialize();
|
||||
|
||||
void SetClearColor(nzUInt8 r, nzUInt8 g, nzUInt8 b, nzUInt8 a = 255);
|
||||
void SetClearDepth(double depth);
|
||||
void SetClearStencil(unsigned int value);
|
||||
bool SetIndexBuffer(const NzIndexBuffer* indexBuffer);
|
||||
bool SetShader(NzShader* shader);
|
||||
bool SetTarget(NzRenderTarget* target);
|
||||
bool SetVertexBuffer(const NzVertexBuffer* vertexBuffer);
|
||||
|
||||
void Uninitialize();
|
||||
|
||||
#if NAZARA_RENDERER_SINGLETON
|
||||
static void Destroy();
|
||||
#endif
|
||||
static NzRenderer* Instance();
|
||||
|
||||
private:
|
||||
static NzRenderer* s_instance;
|
||||
|
||||
const NzIndexBuffer* m_indexBuffer;
|
||||
NzRenderTarget* m_target;
|
||||
NzShader* m_shader;
|
||||
const NzVertexBuffer* m_vertexBuffer;
|
||||
bool m_capabilities[nzRendererCap_Count];
|
||||
bool m_vertexBufferUpdated;
|
||||
};
|
||||
|
||||
#endif // NAZARA_RENDERER_HPP
|
||||
75
include/Nazara/Renderer/Shader.hpp
Normal file
75
include/Nazara/Renderer/Shader.hpp
Normal file
@@ -0,0 +1,75 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_SHADER_HPP
|
||||
#define NAZARA_SHADER_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Math/Matrix4.hpp>
|
||||
|
||||
enum nzShaderLanguage
|
||||
{
|
||||
nzShaderLanguage_Unknown,
|
||||
|
||||
nzShaderLanguage_Cg,
|
||||
nzShaderLanguage_GLSL
|
||||
};
|
||||
|
||||
enum nzShaderType
|
||||
{
|
||||
nzShaderType_Fragment,
|
||||
nzShaderType_Geometry,
|
||||
nzShaderType_Vertex,
|
||||
|
||||
nzShaderType_Count
|
||||
};
|
||||
|
||||
class NzRenderer;
|
||||
class NzShaderImpl;
|
||||
|
||||
class NAZARA_API NzShader
|
||||
{
|
||||
friend class NzRenderer;
|
||||
|
||||
public:
|
||||
NzShader();
|
||||
NzShader(nzShaderLanguage language);
|
||||
~NzShader();
|
||||
|
||||
bool Create(nzShaderLanguage language);
|
||||
bool Compile();
|
||||
|
||||
void Destroy();
|
||||
|
||||
NzString GetLog() const;
|
||||
nzShaderLanguage GetLanguage() const;
|
||||
NzString GetSourceCode(nzShaderType type) const;
|
||||
|
||||
bool IsCompiled() const;
|
||||
bool IsLoaded(nzShaderType type) const;
|
||||
|
||||
bool Load(nzShaderType type, const NzString& source);
|
||||
bool LoadFromFile(nzShaderType type, const NzString& source);
|
||||
|
||||
bool SendBoolean(const NzString& name, bool value);
|
||||
bool SendDouble(const NzString& name, double value);
|
||||
bool SendFloat(const NzString& name, float value);
|
||||
bool SendInteger(const NzString& name, int value);
|
||||
bool SendMatrix(const NzString& name, const NzMatrix4d& matrix);
|
||||
bool SendMatrix(const NzString& name, const NzMatrix4f& matrix);
|
||||
|
||||
static bool IsLanguageSupported(nzShaderLanguage language);
|
||||
static bool IsTypeSupported(nzShaderType type);
|
||||
|
||||
private:
|
||||
bool CommitUniforms();
|
||||
|
||||
NzShaderImpl* m_impl;
|
||||
bool m_compiled;
|
||||
};
|
||||
|
||||
#endif // NAZARA_SHADER_HPP
|
||||
40
include/Nazara/Renderer/VertexBuffer.hpp
Normal file
40
include/Nazara/Renderer/VertexBuffer.hpp
Normal file
@@ -0,0 +1,40 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_VERTEXBUFFER_HPP
|
||||
#define NAZARA_VERTEXBUFFER_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Renderer/Buffer.hpp>
|
||||
|
||||
class NAZARA_API NzVertexBuffer
|
||||
{
|
||||
public:
|
||||
NzVertexBuffer(NzBuffer* buffer, unsigned int startVertex, unsigned int vertexCount);
|
||||
NzVertexBuffer(unsigned int length, nzUInt8 typeSize, nzBufferUsage usage = nzBufferUsage_Static);
|
||||
NzVertexBuffer(const NzVertexBuffer& vertexBuffer);
|
||||
~NzVertexBuffer();
|
||||
|
||||
bool Fill(const void* data, unsigned int offset, unsigned int length);
|
||||
|
||||
NzBuffer* GetBuffer() const;
|
||||
unsigned int GetStartVertex() const;
|
||||
nzUInt8 GetTypeSize() const;
|
||||
unsigned int GetVertexCount() const;
|
||||
|
||||
bool IsHardware() const;
|
||||
|
||||
void* Lock(nzBufferLock lock, unsigned int offset = 0, unsigned int length = 0);
|
||||
bool Unlock();
|
||||
|
||||
private:
|
||||
NzBuffer* m_buffer;
|
||||
bool m_ownsBuffer;
|
||||
unsigned int m_startVertex;
|
||||
unsigned int m_vertexCount;
|
||||
};
|
||||
|
||||
#endif // NAZARA_VERTEXBUFFER_HPP
|
||||
75
include/Nazara/Renderer/VertexDeclaration.hpp
Normal file
75
include/Nazara/Renderer/VertexDeclaration.hpp
Normal file
@@ -0,0 +1,75 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#ifndef NAZARA_VERTEXDECLARATION_HPP
|
||||
#define NAZARA_VERTEXDECLARATION_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <vector>
|
||||
|
||||
enum nzElementType
|
||||
{
|
||||
nzElementType_Color,
|
||||
nzElementType_Double1,
|
||||
nzElementType_Double2,
|
||||
nzElementType_Double3,
|
||||
nzElementType_Double4,
|
||||
nzElementType_Float1,
|
||||
nzElementType_Float2,
|
||||
nzElementType_Float3,
|
||||
nzElementType_Float4
|
||||
};
|
||||
|
||||
enum nzElementUsage
|
||||
{
|
||||
nzElementType_Diffuse,
|
||||
nzElementType_Normal,
|
||||
nzElementType_Position,
|
||||
nzElementType_Tangent,
|
||||
nzElementType_TexCoord
|
||||
};
|
||||
|
||||
struct NzVertexElement
|
||||
{
|
||||
NzVertexElement() : stream(0), usageIndex(0) {}
|
||||
|
||||
unsigned int offset;
|
||||
unsigned int stream;
|
||||
unsigned int usageIndex;
|
||||
nzElementType type;
|
||||
nzElementUsage usage;
|
||||
};
|
||||
|
||||
class NAZARA_API NzVertexDeclaration
|
||||
{
|
||||
public:
|
||||
struct Element
|
||||
{
|
||||
unsigned int offset;
|
||||
unsigned int usageIndex;
|
||||
nzElementType type;
|
||||
nzElementUsage usage;
|
||||
};
|
||||
|
||||
NzVertexDeclaration() = default;
|
||||
~NzVertexDeclaration() = default;
|
||||
|
||||
bool Create(const NzVertexElement* elements, unsigned int elementCount);
|
||||
|
||||
const Element* GetElement(unsigned int i, unsigned int stream = 0) const;
|
||||
unsigned int GetElementCount(unsigned int stream = 0) const;
|
||||
unsigned int GetStreamCount() const;
|
||||
unsigned int GetStride(unsigned int stream = 0) const;
|
||||
|
||||
private:
|
||||
struct Stream
|
||||
{
|
||||
std::vector<Element> elements;
|
||||
unsigned int stride;
|
||||
};
|
||||
|
||||
std::vector<Stream> m_streams;
|
||||
};
|
||||
|
||||
#endif // NAZARA_VERTEXDECLARATION_HPP
|
||||
41
include/Nazara/Utility/Config.hpp
Normal file
41
include/Nazara/Utility/Config.hpp
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
Nazara Engine
|
||||
|
||||
Copyright (C) 2012 Jérôme "Lynix" Leclercq (Lynix680@gmail.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_CONFIG_UTILITY_HPP
|
||||
#define NAZARA_CONFIG_UTILITY_HPP
|
||||
|
||||
/// Chaque modification d'un paramètre du module nécessite une recompilation de celui-ci
|
||||
|
||||
// Utilise un tracker pour repérer les éventuels leaks (Ralentit l'exécution)
|
||||
#define NAZARA_UTILITY_MEMORYLEAKTRACKER 0
|
||||
|
||||
// Active les tests de sécurité basés sur le code (Conseillé pour le développement)
|
||||
#define NAZARA_UTILITY_SAFE 1
|
||||
|
||||
// Fait tourner chaque fenêtre dans un thread séparé
|
||||
#define NAZARA_UTILITY_THREADED_WINDOW 1
|
||||
|
||||
#endif // NAZARA_CONFIG_UTILITY_HPP
|
||||
11
include/Nazara/Utility/Debug.hpp
Normal file
11
include/Nazara/Utility/Debug.hpp
Normal file
@@ -0,0 +1,11 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Utility/Config.hpp>
|
||||
#if NAZARA_UTILITY_MEMORYLEAKTRACKER || defined(NAZARA_DEBUG)
|
||||
#include <Nazara/Core/Debug/MemoryLeakTracker.hpp>
|
||||
|
||||
#define delete NzMemoryManager::NextFree(__FILE__, __LINE__), delete
|
||||
#define new new(__FILE__, __LINE__)
|
||||
#endif
|
||||
8
include/Nazara/Utility/DebugOff.hpp
Normal file
8
include/Nazara/Utility/DebugOff.hpp
Normal file
@@ -0,0 +1,8 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#if NAZARA_UTILITY_MEMORYLEAKTRACKER || defined(NAZARA_DEBUG)
|
||||
#undef delete
|
||||
#undef new
|
||||
#endif
|
||||
94
include/Nazara/Utility/Event.hpp
Normal file
94
include/Nazara/Utility/Event.hpp
Normal file
@@ -0,0 +1,94 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
// Interface inspirée de la SFML par Laurent Gomila
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_EVENT_HPP
|
||||
#define NAZARA_EVENT_HPP
|
||||
|
||||
#include <Nazara/Utility/Keyboard.hpp>
|
||||
#include <Nazara/Utility/Mouse.hpp>
|
||||
|
||||
struct NzEvent
|
||||
{
|
||||
struct KeyEvent
|
||||
{
|
||||
NzKeyboard::Key code;
|
||||
bool alt;
|
||||
bool control;
|
||||
bool shift;
|
||||
bool system;
|
||||
};
|
||||
|
||||
struct MouseButtonEvent
|
||||
{
|
||||
NzMouse::Button button;
|
||||
unsigned int x;
|
||||
unsigned int y;
|
||||
};
|
||||
|
||||
struct MouseMoveEvent
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
};
|
||||
|
||||
struct MouseWheelEvent
|
||||
{
|
||||
float delta;
|
||||
};
|
||||
|
||||
struct PositionEvent
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
};
|
||||
|
||||
struct SizeEvent
|
||||
{
|
||||
unsigned int height;
|
||||
unsigned int width;
|
||||
};
|
||||
|
||||
struct TextEvent
|
||||
{
|
||||
char32_t character;
|
||||
};
|
||||
|
||||
enum Type
|
||||
{
|
||||
GainedFocus,
|
||||
LostFocus,
|
||||
KeyPressed,
|
||||
KeyReleased,
|
||||
MouseButtonDoubleClicked,
|
||||
MouseButtonPressed,
|
||||
MouseButtonReleased,
|
||||
MouseEntered,
|
||||
MouseLeft,
|
||||
MouseMoved,
|
||||
MouseWheelMoved,
|
||||
Moved,
|
||||
Quit,
|
||||
Resized,
|
||||
TextEntered
|
||||
};
|
||||
|
||||
Type type;
|
||||
|
||||
union
|
||||
{
|
||||
KeyEvent key;
|
||||
MouseButtonEvent mouseButton;
|
||||
MouseMoveEvent mouseMove;
|
||||
MouseWheelEvent mouseWheel;
|
||||
PositionEvent position;
|
||||
SizeEvent size;
|
||||
TextEvent text;
|
||||
};
|
||||
};
|
||||
|
||||
#endif // NAZARA_EVENT_HPP
|
||||
45
include/Nazara/Utility/Functor.hpp
Normal file
45
include/Nazara/Utility/Functor.hpp
Normal file
@@ -0,0 +1,45 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_FUNCTOR_HPP
|
||||
#define NAZARA_FUNCTOR_HPP
|
||||
|
||||
#include <Nazara/Utility/Tuple.hpp>
|
||||
|
||||
// Inspiré du code de la SFML par Laurent Gomila
|
||||
|
||||
struct NzFunctor
|
||||
{
|
||||
virtual ~NzFunctor() {}
|
||||
|
||||
virtual void Run() = 0;
|
||||
};
|
||||
|
||||
template<typename F> struct NzFunctorWithoutArgs : NzFunctor
|
||||
{
|
||||
NzFunctorWithoutArgs(F func);
|
||||
|
||||
void Run();
|
||||
|
||||
F function;
|
||||
};
|
||||
|
||||
template<typename F, typename... Args> struct NzFunctorWithArgs : NzFunctor
|
||||
{
|
||||
NzFunctorWithArgs(F func, Args&... args);
|
||||
|
||||
void Run();
|
||||
|
||||
F function;
|
||||
std::tuple<Args...> arguments;
|
||||
};
|
||||
|
||||
template<typename F> struct NzFunctorWithoutArgs;
|
||||
template<typename F, typename... Args> struct NzFunctorWithArgs;
|
||||
|
||||
#include <Nazara/Utility/Functor.inl>
|
||||
|
||||
#endif // NAZARA_FUNCTOR_HPP
|
||||
24
include/Nazara/Utility/Functor.inl
Normal file
24
include/Nazara/Utility/Functor.inl
Normal file
@@ -0,0 +1,24 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
template<typename F> NzFunctorWithoutArgs<F>::NzFunctorWithoutArgs(F func) :
|
||||
function(func)
|
||||
{
|
||||
}
|
||||
|
||||
template<typename F> void NzFunctorWithoutArgs<F>::Run()
|
||||
{
|
||||
function();
|
||||
}
|
||||
|
||||
template<typename F, typename... Args> NzFunctorWithArgs<F, Args...>::NzFunctorWithArgs(F func, Args&... args) :
|
||||
function(func),
|
||||
arguments(args...)
|
||||
{
|
||||
}
|
||||
|
||||
template<typename F, typename... Args> void NzFunctorWithArgs<F, Args...>::Run()
|
||||
{
|
||||
NzUnpackTuple(function, arguments);
|
||||
}
|
||||
165
include/Nazara/Utility/Keyboard.hpp
Normal file
165
include/Nazara/Utility/Keyboard.hpp
Normal file
@@ -0,0 +1,165 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
// Interface inspirée de la SFML par Laurent Gomila
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_KEYBOARD_HPP
|
||||
#define NAZARA_KEYBOARD_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
|
||||
class NAZARA_API NzKeyboard
|
||||
{
|
||||
public:
|
||||
enum Key
|
||||
{
|
||||
Undefined = -1,
|
||||
|
||||
// Lettres
|
||||
A,
|
||||
B,
|
||||
C,
|
||||
D,
|
||||
E,
|
||||
F,
|
||||
G,
|
||||
H,
|
||||
I,
|
||||
J,
|
||||
K,
|
||||
L,
|
||||
M,
|
||||
N,
|
||||
O,
|
||||
P,
|
||||
Q,
|
||||
R,
|
||||
S,
|
||||
T,
|
||||
U,
|
||||
V,
|
||||
W,
|
||||
X,
|
||||
Y,
|
||||
Z,
|
||||
|
||||
// Touches de fonction
|
||||
F1,
|
||||
F2,
|
||||
F3,
|
||||
F4,
|
||||
F5,
|
||||
F6,
|
||||
F7,
|
||||
F8,
|
||||
F9,
|
||||
F10,
|
||||
F11,
|
||||
F12,
|
||||
F13,
|
||||
F14,
|
||||
F15,
|
||||
|
||||
// Flèches directionnelles
|
||||
Down,
|
||||
Left,
|
||||
Right,
|
||||
Up,
|
||||
|
||||
// Pavé numérique
|
||||
Add,
|
||||
Divide,
|
||||
Multiply,
|
||||
Numpad0,
|
||||
Numpad1,
|
||||
Numpad2,
|
||||
Numpad3,
|
||||
Numpad4,
|
||||
Numpad5,
|
||||
Numpad6,
|
||||
Numpad7,
|
||||
Numpad8,
|
||||
Numpad9,
|
||||
Subtract,
|
||||
|
||||
// Divers
|
||||
Backslash,
|
||||
Backspace,
|
||||
Clear,
|
||||
Comma,
|
||||
Dash,
|
||||
Delete,
|
||||
End,
|
||||
Equal,
|
||||
Escape,
|
||||
Home,
|
||||
Insert,
|
||||
LAlt,
|
||||
LBracket,
|
||||
LControl,
|
||||
LShift,
|
||||
LSystem,
|
||||
Num0,
|
||||
Num1,
|
||||
Num2,
|
||||
Num3,
|
||||
Num4,
|
||||
Num5,
|
||||
Num6,
|
||||
Num7,
|
||||
Num8,
|
||||
Num9,
|
||||
PageDown,
|
||||
PageUp,
|
||||
Pause,
|
||||
Period,
|
||||
Print,
|
||||
PrintScreen,
|
||||
Quote,
|
||||
RAlt,
|
||||
RBracket,
|
||||
RControl,
|
||||
Return,
|
||||
RShift,
|
||||
RSystem,
|
||||
Semicolon,
|
||||
Slash,
|
||||
Space,
|
||||
Tab,
|
||||
Tilde,
|
||||
|
||||
// Touches navigateur
|
||||
Browser_Back,
|
||||
Browser_Favorites,
|
||||
Browser_Forward,
|
||||
Browser_Home,
|
||||
Browser_Refresh,
|
||||
Browser_Search,
|
||||
Browser_Stop,
|
||||
|
||||
// Touches de contrôle de lecture
|
||||
Media_Next,
|
||||
Media_Play,
|
||||
Media_Previous,
|
||||
Media_Stop,
|
||||
|
||||
// Touches de contrôle du volume
|
||||
Volume_Down,
|
||||
Volume_Mute,
|
||||
Volume_Up,
|
||||
|
||||
// Touches à verrouillage
|
||||
CapsLock,
|
||||
NumLock,
|
||||
ScrollLock,
|
||||
|
||||
Count
|
||||
};
|
||||
|
||||
static bool IsKeyPressed(Key key);
|
||||
};
|
||||
|
||||
#endif // NAZARA_KEYBOARD_HPP
|
||||
40
include/Nazara/Utility/Mouse.hpp
Normal file
40
include/Nazara/Utility/Mouse.hpp
Normal file
@@ -0,0 +1,40 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
// Interface inspirée de la SFML par Laurent Gomila
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_MOUSE_HPP
|
||||
#define NAZARA_MOUSE_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Math/Vector2.hpp>
|
||||
|
||||
class NzWindow;
|
||||
|
||||
class NAZARA_API NzMouse
|
||||
{
|
||||
public:
|
||||
enum Button
|
||||
{
|
||||
Left,
|
||||
Middle,
|
||||
Right,
|
||||
XButton1,
|
||||
XButton2,
|
||||
|
||||
Count
|
||||
};
|
||||
|
||||
static NzVector2i GetPosition();
|
||||
static NzVector2i GetPosition(const NzWindow& relativeTo);
|
||||
static bool IsButtonPressed(Button button);
|
||||
static void SetPosition(const NzVector2i& position);
|
||||
static void SetPosition(const NzVector2i& position, const NzWindow& relativeTo);
|
||||
static void SetPosition(int x, int y);
|
||||
static void SetPosition(int x, int y, const NzWindow& relativeTo);
|
||||
};
|
||||
|
||||
#endif // NAZARA_MOUSE_HPP
|
||||
20
include/Nazara/Utility/NonCopyable.hpp
Normal file
20
include/Nazara/Utility/NonCopyable.hpp
Normal file
@@ -0,0 +1,20 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_NONCOPYABLE_HPP
|
||||
#define NAZARA_NONCOPYABLE_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
|
||||
class NAZARA_API NzNonCopyable
|
||||
{
|
||||
protected:
|
||||
NzNonCopyable() = default;
|
||||
NzNonCopyable(const NzNonCopyable&) = delete;
|
||||
NzNonCopyable& operator=(const NzNonCopyable&) = delete;
|
||||
};
|
||||
|
||||
#endif // NAZARA_NONCOPYABLE_HPP
|
||||
30
include/Nazara/Utility/Resource.hpp
Normal file
30
include/Nazara/Utility/Resource.hpp
Normal file
@@ -0,0 +1,30 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_RESOURCE_HPP
|
||||
#define NAZARA_RESOURCE_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Utility/NonCopyable.hpp>
|
||||
|
||||
class NAZARA_API NzResource : NzNonCopyable
|
||||
{
|
||||
public:
|
||||
NzResource(bool persistent = true);
|
||||
virtual ~NzResource();
|
||||
|
||||
void AddResourceReference() const;
|
||||
bool IsPersistent() const;
|
||||
void RemoveResourceReference() const;
|
||||
void SetPersistent(bool persistent = true);
|
||||
|
||||
private:
|
||||
// Je fais précéder le nom par 'resource' pour éviter les éventuels conflits de noms
|
||||
mutable bool m_resourcePersistent;
|
||||
mutable unsigned int m_resourceReferenceCount;
|
||||
};
|
||||
|
||||
#endif // NAZARA_RESOURCE_HPP
|
||||
16
include/Nazara/Utility/Tuple.hpp
Normal file
16
include/Nazara/Utility/Tuple.hpp
Normal file
@@ -0,0 +1,16 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_TUPLE_HPP
|
||||
#define NAZARA_TUPLE_HPP
|
||||
|
||||
#include <tuple>
|
||||
|
||||
template<typename F, typename... ArgsT> void NzUnpackTuple(F func, const std::tuple<ArgsT...>& t);
|
||||
|
||||
#include <Nazara/Utility/Tuple.inl>
|
||||
|
||||
#endif // NAZARA_TUPLE_HPP
|
||||
35
include/Nazara/Utility/Tuple.inl
Normal file
35
include/Nazara/Utility/Tuple.inl
Normal file
@@ -0,0 +1,35 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
// http://stackoverflow.com/questions/687490/c0x-how-do-i-expand-a-tuple-into-variadic-template-function-arguments
|
||||
// Merci à Ryan "FullMetal Alchemist" Lahfa
|
||||
// Merci aussi à Freedom de siteduzero.com
|
||||
|
||||
#include <Nazara/Utility/Debug.hpp>
|
||||
|
||||
template<unsigned int N> struct NzTupleUnpack
|
||||
{
|
||||
template <typename F, typename... ArgsT, typename... Args>
|
||||
void operator()(F func, const std::tuple<ArgsT...>& t, Args&... args)
|
||||
{
|
||||
NzTupleUnpack<N-1>()(func, t, std::get<N-1>(t), args...);
|
||||
}
|
||||
};
|
||||
|
||||
template<> struct NzTupleUnpack<0>
|
||||
{
|
||||
template <typename F, typename... ArgsT, typename... Args>
|
||||
void operator()(F func, const std::tuple<ArgsT...>&, Args&... args)
|
||||
{
|
||||
func(args...);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename F, typename... ArgsT>
|
||||
void NzUnpackTuple(F func, const std::tuple<ArgsT...>& t )
|
||||
{
|
||||
NzTupleUnpack<sizeof...(ArgsT)>()(func, t);
|
||||
}
|
||||
|
||||
#include <Nazara/Utility/DebugOff.hpp>
|
||||
38
include/Nazara/Utility/VideoMode.hpp
Normal file
38
include/Nazara/Utility/VideoMode.hpp
Normal file
@@ -0,0 +1,38 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
// Interface inspirée de la SFML par Laurent Gomila
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_VIDEOMODE_HPP
|
||||
#define NAZARA_VIDEOMODE_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <vector>
|
||||
|
||||
class NAZARA_API NzVideoMode
|
||||
{
|
||||
public:
|
||||
NzVideoMode();
|
||||
NzVideoMode(unsigned int w, unsigned int h, nzUInt8 bpp);
|
||||
|
||||
bool IsFullscreenValid() const;
|
||||
|
||||
static NzVideoMode GetDesktopMode();
|
||||
static const std::vector<NzVideoMode>& GetFullscreenModes();
|
||||
|
||||
nzUInt8 bitsPerPixel;
|
||||
unsigned int height;
|
||||
unsigned int width;
|
||||
};
|
||||
|
||||
bool operator==(const NzVideoMode& left, const NzVideoMode& right);
|
||||
bool operator!=(const NzVideoMode& left, const NzVideoMode& right);
|
||||
bool operator<(const NzVideoMode& left, const NzVideoMode& right);
|
||||
bool operator<=(const NzVideoMode& left, const NzVideoMode& right);
|
||||
bool operator>(const NzVideoMode& left, const NzVideoMode& right);
|
||||
bool operator>=(const NzVideoMode& left, const NzVideoMode& right);
|
||||
|
||||
#endif // NAZARA_VIDEOMODE_HPP
|
||||
113
include/Nazara/Utility/Window.hpp
Normal file
113
include/Nazara/Utility/Window.hpp
Normal file
@@ -0,0 +1,113 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
// Interface inspirée de la SFML par Laurent Gomila
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_WINDOW_HPP
|
||||
#define NAZARA_WINDOW_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Math/Vector2.hpp>
|
||||
#include <Nazara/Utility/Config.hpp>
|
||||
#include <Nazara/Utility/Event.hpp>
|
||||
#include <Nazara/Utility/NonCopyable.hpp>
|
||||
#include <Nazara/Utility/VideoMode.hpp>
|
||||
#include <Nazara/Utility/WindowHandle.hpp>
|
||||
#include <queue>
|
||||
|
||||
#if NAZARA_UTILITY_THREADED_WINDOW
|
||||
#include <Nazara/Core/Mutex.hpp>
|
||||
#include <Nazara/Core/ThreadCondition.hpp>
|
||||
#endif
|
||||
|
||||
class NzWindowImpl;
|
||||
|
||||
class NAZARA_API NzWindow : NzNonCopyable
|
||||
{
|
||||
friend class NzWindowImpl;
|
||||
|
||||
public:
|
||||
enum Style
|
||||
{
|
||||
None = 0x0,
|
||||
Fullscreen = 0x1,
|
||||
|
||||
Closable = 0x2,
|
||||
Resizable = 0x4,
|
||||
Titlebar = 0x8,
|
||||
|
||||
Default = Closable | Resizable | Titlebar
|
||||
};
|
||||
|
||||
NzWindow();
|
||||
NzWindow(NzVideoMode mode, const NzString& title, nzUInt32 style = Default);
|
||||
NzWindow(NzWindowHandle handle);
|
||||
virtual ~NzWindow();
|
||||
|
||||
void Close();
|
||||
|
||||
bool Create(NzVideoMode mode, const NzString& title, nzUInt32 style = Default);
|
||||
bool Create(NzWindowHandle handle);
|
||||
|
||||
void EnableKeyRepeat(bool enable);
|
||||
void EnableSmoothScrolling(bool enable);
|
||||
|
||||
NzWindowHandle GetHandle() const;
|
||||
unsigned int GetHeight() const;
|
||||
NzVector2i GetPosition() const;
|
||||
NzVector2i GetSize() const;
|
||||
NzString GetTitle() const;
|
||||
unsigned int GetWidth() const;
|
||||
|
||||
bool HasFocus() const;
|
||||
|
||||
bool IsMinimized() const;
|
||||
bool IsOpen() const;
|
||||
bool IsVisible() const;
|
||||
|
||||
bool PollEvent(NzEvent* event);
|
||||
|
||||
void SetEventListener(bool listener);
|
||||
void SetFocus();
|
||||
void SetMaximumSize(const NzVector2i& maxSize);
|
||||
void SetMaximumSize(int width, int height);
|
||||
void SetMinimumSize(const NzVector2i& minSize);
|
||||
void SetMinimumSize(int width, int height);
|
||||
void SetPosition(const NzVector2i& position);
|
||||
void SetPosition(int x, int y);
|
||||
void SetSize(const NzVector2i& size);
|
||||
void SetSize(unsigned int width, unsigned int height);
|
||||
void SetTitle(const NzString& title);
|
||||
void SetVisible(bool visible);
|
||||
|
||||
void ShowMouseCursor(bool show);
|
||||
|
||||
void StayOnTop(bool stayOnTop);
|
||||
|
||||
bool WaitEvent(NzEvent* event);
|
||||
|
||||
protected:
|
||||
virtual void OnClose();
|
||||
virtual bool OnCreate();
|
||||
|
||||
NzWindowImpl* m_impl;
|
||||
|
||||
private:
|
||||
void PushEvent(const NzEvent& event);
|
||||
|
||||
std::queue<NzEvent> m_events;
|
||||
#if NAZARA_UTILITY_THREADED_WINDOW
|
||||
NzMutex m_eventMutex;
|
||||
NzMutex m_eventConditionMutex;
|
||||
NzThreadCondition m_eventCondition;
|
||||
bool m_eventListener;
|
||||
bool m_waitForEvent;
|
||||
#endif
|
||||
bool m_ownsWindow;
|
||||
};
|
||||
|
||||
#endif // NAZARA_WINDOW_HPP
|
||||
22
include/Nazara/Utility/WindowHandle.hpp
Normal file
22
include/Nazara/Utility/WindowHandle.hpp
Normal file
@@ -0,0 +1,22 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_WINDOWHANDLE_HPP
|
||||
#define NAZARA_WINDOWHANDLE_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
|
||||
#if defined(NAZARA_PLATFORM_WINDOWS)
|
||||
// http://msdn.microsoft.com/en-us/library/aa383751(v=vs.85).aspx
|
||||
typedef void* NzWindowHandle;
|
||||
#elif defined(NAZARA_PLATFORM_LINUX)
|
||||
// http://en.wikipedia.org/wiki/Xlib#Data_types
|
||||
typedef unsigned long NzWindowHandle;
|
||||
#else
|
||||
#error Lack of implementation: WindowHandle
|
||||
#endif
|
||||
|
||||
#endif // NAZARA_WINDOWHANDLE_HPP
|
||||
34
include/Utfcpp/utf8.h
Normal file
34
include/Utfcpp/utf8.h
Normal file
@@ -0,0 +1,34 @@
|
||||
// Copyright 2006 Nemanja Trifunovic
|
||||
|
||||
/*
|
||||
Permission is hereby granted, free of charge, to any person or organization
|
||||
obtaining a copy of the software and accompanying documentation covered by
|
||||
this license (the "Software") to use, reproduce, display, distribute,
|
||||
execute, and transmit the Software, and to prepare derivative works of the
|
||||
Software, and to permit third-parties to whom the Software is furnished to
|
||||
do so, all subject to the following:
|
||||
|
||||
The copyright notices in the Software and this entire statement, including
|
||||
the above license grant, this restriction and the following disclaimer,
|
||||
must be included in all copies of the Software, in whole or in part, and
|
||||
all derivative works of the Software, unless such copies or derivative
|
||||
works are solely in the form of machine-executable object code generated by
|
||||
a source language processor.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef UTF8_FOR_CPP_2675DCD0_9480_4c0c_B92A_CC14C027B731
|
||||
#define UTF8_FOR_CPP_2675DCD0_9480_4c0c_B92A_CC14C027B731
|
||||
|
||||
#include "utf8/checked.h"
|
||||
#include "utf8/unchecked.h"
|
||||
|
||||
#endif // header guard
|
||||
327
include/Utfcpp/utf8/checked.h
Normal file
327
include/Utfcpp/utf8/checked.h
Normal file
@@ -0,0 +1,327 @@
|
||||
// Copyright 2006 Nemanja Trifunovic
|
||||
|
||||
/*
|
||||
Permission is hereby granted, free of charge, to any person or organization
|
||||
obtaining a copy of the software and accompanying documentation covered by
|
||||
this license (the "Software") to use, reproduce, display, distribute,
|
||||
execute, and transmit the Software, and to prepare derivative works of the
|
||||
Software, and to permit third-parties to whom the Software is furnished to
|
||||
do so, all subject to the following:
|
||||
|
||||
The copyright notices in the Software and this entire statement, including
|
||||
the above license grant, this restriction and the following disclaimer,
|
||||
must be included in all copies of the Software, in whole or in part, and
|
||||
all derivative works of the Software, unless such copies or derivative
|
||||
works are solely in the form of machine-executable object code generated by
|
||||
a source language processor.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef UTF8_FOR_CPP_CHECKED_H_2675DCD0_9480_4c0c_B92A_CC14C027B731
|
||||
#define UTF8_FOR_CPP_CHECKED_H_2675DCD0_9480_4c0c_B92A_CC14C027B731
|
||||
|
||||
#include "core.h"
|
||||
#include <stdexcept>
|
||||
|
||||
namespace utf8
|
||||
{
|
||||
// Base for the exceptions that may be thrown from the library
|
||||
class exception : public std::exception {
|
||||
};
|
||||
|
||||
// Exceptions that may be thrown from the library functions.
|
||||
class invalid_code_point : public exception {
|
||||
uint32_t cp;
|
||||
public:
|
||||
invalid_code_point(uint32_t cp) : cp(cp) {}
|
||||
virtual const char* what() const throw() { return "Invalid code point"; }
|
||||
uint32_t code_point() const {return cp;}
|
||||
};
|
||||
|
||||
class invalid_utf8 : public exception {
|
||||
uint8_t u8;
|
||||
public:
|
||||
invalid_utf8 (uint8_t u) : u8(u) {}
|
||||
virtual const char* what() const throw() { return "Invalid UTF-8"; }
|
||||
uint8_t utf8_octet() const {return u8;}
|
||||
};
|
||||
|
||||
class invalid_utf16 : public exception {
|
||||
uint16_t u16;
|
||||
public:
|
||||
invalid_utf16 (uint16_t u) : u16(u) {}
|
||||
virtual const char* what() const throw() { return "Invalid UTF-16"; }
|
||||
uint16_t utf16_word() const {return u16;}
|
||||
};
|
||||
|
||||
class not_enough_room : public exception {
|
||||
public:
|
||||
virtual const char* what() const throw() { return "Not enough space"; }
|
||||
};
|
||||
|
||||
/// The library API - functions intended to be called by the users
|
||||
|
||||
template <typename octet_iterator, typename output_iterator>
|
||||
output_iterator replace_invalid(octet_iterator start, octet_iterator end, output_iterator out, uint32_t replacement)
|
||||
{
|
||||
while (start != end) {
|
||||
octet_iterator sequence_start = start;
|
||||
internal::utf_error err_code = internal::validate_next(start, end);
|
||||
switch (err_code) {
|
||||
case internal::UTF8_OK :
|
||||
for (octet_iterator it = sequence_start; it != start; ++it)
|
||||
*out++ = *it;
|
||||
break;
|
||||
case internal::NOT_ENOUGH_ROOM:
|
||||
throw not_enough_room();
|
||||
case internal::INVALID_LEAD:
|
||||
append (replacement, out);
|
||||
++start;
|
||||
break;
|
||||
case internal::INCOMPLETE_SEQUENCE:
|
||||
case internal::OVERLONG_SEQUENCE:
|
||||
case internal::INVALID_CODE_POINT:
|
||||
append (replacement, out);
|
||||
++start;
|
||||
// just one replacement mark for the sequence
|
||||
while (internal::is_trail(*start) && start != end)
|
||||
++start;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
template <typename octet_iterator, typename output_iterator>
|
||||
inline output_iterator replace_invalid(octet_iterator start, octet_iterator end, output_iterator out)
|
||||
{
|
||||
static const uint32_t replacement_marker = internal::mask16(0xfffd);
|
||||
return replace_invalid(start, end, out, replacement_marker);
|
||||
}
|
||||
|
||||
template <typename octet_iterator>
|
||||
octet_iterator append(uint32_t cp, octet_iterator result)
|
||||
{
|
||||
if (!internal::is_code_point_valid(cp))
|
||||
throw invalid_code_point(cp);
|
||||
|
||||
if (cp < 0x80) // one octet
|
||||
*(result++) = static_cast<uint8_t>(cp);
|
||||
else if (cp < 0x800) { // two octets
|
||||
*(result++) = static_cast<uint8_t>((cp >> 6) | 0xc0);
|
||||
*(result++) = static_cast<uint8_t>((cp & 0x3f) | 0x80);
|
||||
}
|
||||
else if (cp < 0x10000) { // three octets
|
||||
*(result++) = static_cast<uint8_t>((cp >> 12) | 0xe0);
|
||||
*(result++) = static_cast<uint8_t>(((cp >> 6) & 0x3f) | 0x80);
|
||||
*(result++) = static_cast<uint8_t>((cp & 0x3f) | 0x80);
|
||||
}
|
||||
else { // four octets
|
||||
*(result++) = static_cast<uint8_t>((cp >> 18) | 0xf0);
|
||||
*(result++) = static_cast<uint8_t>(((cp >> 12) & 0x3f) | 0x80);
|
||||
*(result++) = static_cast<uint8_t>(((cp >> 6) & 0x3f) | 0x80);
|
||||
*(result++) = static_cast<uint8_t>((cp & 0x3f) | 0x80);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename octet_iterator>
|
||||
uint32_t next(octet_iterator& it, octet_iterator end)
|
||||
{
|
||||
uint32_t cp = 0;
|
||||
internal::utf_error err_code = internal::validate_next(it, end, &cp);
|
||||
switch (err_code) {
|
||||
case internal::UTF8_OK :
|
||||
break;
|
||||
case internal::NOT_ENOUGH_ROOM :
|
||||
throw not_enough_room();
|
||||
case internal::INVALID_LEAD :
|
||||
case internal::INCOMPLETE_SEQUENCE :
|
||||
case internal::OVERLONG_SEQUENCE :
|
||||
throw invalid_utf8(*it);
|
||||
case internal::INVALID_CODE_POINT :
|
||||
throw invalid_code_point(cp);
|
||||
}
|
||||
return cp;
|
||||
}
|
||||
|
||||
template <typename octet_iterator>
|
||||
uint32_t peek_next(octet_iterator it, octet_iterator end)
|
||||
{
|
||||
return next(it, end);
|
||||
}
|
||||
|
||||
template <typename octet_iterator>
|
||||
uint32_t prior(octet_iterator& it, octet_iterator start)
|
||||
{
|
||||
// can't do much if it == start
|
||||
if (it == start)
|
||||
throw not_enough_room();
|
||||
|
||||
octet_iterator end = it;
|
||||
// Go back until we hit either a lead octet or start
|
||||
while (internal::is_trail(*(--it)))
|
||||
if (it == start)
|
||||
throw invalid_utf8(*it); // error - no lead byte in the sequence
|
||||
return peek_next(it, end);
|
||||
}
|
||||
|
||||
/// Deprecated in versions that include "prior"
|
||||
template <typename octet_iterator>
|
||||
uint32_t previous(octet_iterator& it, octet_iterator pass_start)
|
||||
{
|
||||
octet_iterator end = it;
|
||||
while (internal::is_trail(*(--it)))
|
||||
if (it == pass_start)
|
||||
throw invalid_utf8(*it); // error - no lead byte in the sequence
|
||||
octet_iterator temp = it;
|
||||
return next(temp, end);
|
||||
}
|
||||
|
||||
template <typename octet_iterator, typename distance_type>
|
||||
void advance (octet_iterator& it, distance_type n, octet_iterator end)
|
||||
{
|
||||
for (distance_type i = 0; i < n; ++i)
|
||||
next(it, end);
|
||||
}
|
||||
|
||||
template <typename octet_iterator>
|
||||
typename std::iterator_traits<octet_iterator>::difference_type
|
||||
distance (octet_iterator first, octet_iterator last)
|
||||
{
|
||||
typename std::iterator_traits<octet_iterator>::difference_type dist;
|
||||
for (dist = 0; first < last; ++dist)
|
||||
next(first, last);
|
||||
return dist;
|
||||
}
|
||||
|
||||
template <typename u16bit_iterator, typename octet_iterator>
|
||||
octet_iterator utf16to8 (u16bit_iterator start, u16bit_iterator end, octet_iterator result)
|
||||
{
|
||||
while (start != end) {
|
||||
uint32_t cp = internal::mask16(*start++);
|
||||
// Take care of surrogate pairs first
|
||||
if (internal::is_lead_surrogate(cp)) {
|
||||
if (start != end) {
|
||||
uint32_t trail_surrogate = internal::mask16(*start++);
|
||||
if (internal::is_trail_surrogate(trail_surrogate))
|
||||
cp = (cp << 10) + trail_surrogate + internal::SURROGATE_OFFSET;
|
||||
else
|
||||
throw invalid_utf16(static_cast<uint16_t>(trail_surrogate));
|
||||
}
|
||||
else
|
||||
throw invalid_utf16(static_cast<uint16_t>(cp));
|
||||
|
||||
}
|
||||
// Lone trail surrogate
|
||||
else if (internal::is_trail_surrogate(cp))
|
||||
throw invalid_utf16(static_cast<uint16_t>(cp));
|
||||
|
||||
result = append(cp, result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename u16bit_iterator, typename octet_iterator>
|
||||
u16bit_iterator utf8to16 (octet_iterator start, octet_iterator end, u16bit_iterator result)
|
||||
{
|
||||
while (start != end) {
|
||||
uint32_t cp = next(start, end);
|
||||
if (cp > 0xffff) { //make a surrogate pair
|
||||
*result++ = static_cast<uint16_t>((cp >> 10) + internal::LEAD_OFFSET);
|
||||
*result++ = static_cast<uint16_t>((cp & 0x3ff) + internal::TRAIL_SURROGATE_MIN);
|
||||
}
|
||||
else
|
||||
*result++ = static_cast<uint16_t>(cp);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename octet_iterator, typename u32bit_iterator>
|
||||
octet_iterator utf32to8 (u32bit_iterator start, u32bit_iterator end, octet_iterator result)
|
||||
{
|
||||
while (start != end)
|
||||
result = append(*(start++), result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename octet_iterator, typename u32bit_iterator>
|
||||
u32bit_iterator utf8to32 (octet_iterator start, octet_iterator end, u32bit_iterator result)
|
||||
{
|
||||
while (start != end)
|
||||
(*result++) = next(start, end);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// The iterator class
|
||||
template <typename octet_iterator>
|
||||
class iterator : public std::iterator <std::bidirectional_iterator_tag, uint32_t> {
|
||||
octet_iterator it;
|
||||
octet_iterator range_start;
|
||||
octet_iterator range_end;
|
||||
public:
|
||||
iterator () {};
|
||||
explicit iterator (const octet_iterator& octet_it,
|
||||
const octet_iterator& range_start,
|
||||
const octet_iterator& range_end) :
|
||||
it(octet_it), range_start(range_start), range_end(range_end)
|
||||
{
|
||||
if (it < range_start || it > range_end)
|
||||
throw std::out_of_range("Invalid utf-8 iterator position");
|
||||
}
|
||||
// the default "big three" are OK
|
||||
octet_iterator base () const { return it; }
|
||||
uint32_t operator * () const
|
||||
{
|
||||
octet_iterator temp = it;
|
||||
return next(temp, range_end);
|
||||
}
|
||||
bool operator == (const iterator& rhs) const
|
||||
{
|
||||
if (range_start != rhs.range_start || range_end != rhs.range_end)
|
||||
throw std::logic_error("Comparing utf-8 iterators defined with different ranges");
|
||||
return (it == rhs.it);
|
||||
}
|
||||
bool operator != (const iterator& rhs) const
|
||||
{
|
||||
return !(operator == (rhs));
|
||||
}
|
||||
iterator& operator ++ ()
|
||||
{
|
||||
next(it, range_end);
|
||||
return *this;
|
||||
}
|
||||
iterator operator ++ (int)
|
||||
{
|
||||
iterator temp = *this;
|
||||
next(it, range_end);
|
||||
return temp;
|
||||
}
|
||||
iterator& operator -- ()
|
||||
{
|
||||
prior(it, range_start);
|
||||
return *this;
|
||||
}
|
||||
iterator operator -- (int)
|
||||
{
|
||||
iterator temp = *this;
|
||||
prior(it, range_start);
|
||||
return temp;
|
||||
}
|
||||
}; // class iterator
|
||||
|
||||
} // namespace utf8
|
||||
|
||||
#endif //header guard
|
||||
|
||||
|
||||
351
include/Utfcpp/utf8/core.h
Normal file
351
include/Utfcpp/utf8/core.h
Normal file
@@ -0,0 +1,351 @@
|
||||
// Copyright 2006 Nemanja Trifunovic
|
||||
|
||||
/*
|
||||
Permission is hereby granted, free of charge, to any person or organization
|
||||
obtaining a copy of the software and accompanying documentation covered by
|
||||
this license (the "Software") to use, reproduce, display, distribute,
|
||||
execute, and transmit the Software, and to prepare derivative works of the
|
||||
Software, and to permit third-parties to whom the Software is furnished to
|
||||
do so, all subject to the following:
|
||||
|
||||
The copyright notices in the Software and this entire statement, including
|
||||
the above license grant, this restriction and the following disclaimer,
|
||||
must be included in all copies of the Software, in whole or in part, and
|
||||
all derivative works of the Software, unless such copies or derivative
|
||||
works are solely in the form of machine-executable object code generated by
|
||||
a source language processor.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef UTF8_FOR_CPP_CORE_H_2675DCD0_9480_4c0c_B92A_CC14C027B731
|
||||
#define UTF8_FOR_CPP_CORE_H_2675DCD0_9480_4c0c_B92A_CC14C027B731
|
||||
|
||||
#include <iterator>
|
||||
|
||||
namespace utf8
|
||||
{
|
||||
// Helper code - not intended to be directly called by the library users. May be changed at any time
|
||||
namespace internal
|
||||
{
|
||||
// Unicode constants
|
||||
// Leading (high) surrogates: 0xd800 - 0xdbff
|
||||
// Trailing (low) surrogates: 0xdc00 - 0xdfff
|
||||
const uint16_t LEAD_SURROGATE_MIN = 0xd800u;
|
||||
const uint16_t LEAD_SURROGATE_MAX = 0xdbffu;
|
||||
const uint16_t TRAIL_SURROGATE_MIN = 0xdc00u;
|
||||
const uint16_t TRAIL_SURROGATE_MAX = 0xdfffu;
|
||||
const uint16_t LEAD_OFFSET = LEAD_SURROGATE_MIN - (0x10000 >> 10);
|
||||
const uint32_t SURROGATE_OFFSET = 0x10000u - (LEAD_SURROGATE_MIN << 10) - TRAIL_SURROGATE_MIN;
|
||||
|
||||
// Maximum valid value for a Unicode code point
|
||||
const uint32_t CODE_POINT_MAX = 0x0010ffffu;
|
||||
|
||||
template<typename octet_type>
|
||||
inline uint8_t mask8(octet_type oc)
|
||||
{
|
||||
return static_cast<uint8_t>(0xff & oc);
|
||||
}
|
||||
template<typename u16_type>
|
||||
inline uint16_t mask16(u16_type oc)
|
||||
{
|
||||
return static_cast<uint16_t>(0xffff & oc);
|
||||
}
|
||||
template<typename octet_type>
|
||||
inline bool is_trail(octet_type oc)
|
||||
{
|
||||
return ((mask8(oc) >> 6) == 0x2);
|
||||
}
|
||||
|
||||
template <typename u16>
|
||||
inline bool is_lead_surrogate(u16 cp)
|
||||
{
|
||||
return (cp >= LEAD_SURROGATE_MIN && cp <= LEAD_SURROGATE_MAX);
|
||||
}
|
||||
|
||||
template <typename u16>
|
||||
inline bool is_trail_surrogate(u16 cp)
|
||||
{
|
||||
return (cp >= TRAIL_SURROGATE_MIN && cp <= TRAIL_SURROGATE_MAX);
|
||||
}
|
||||
|
||||
template <typename u16>
|
||||
inline bool is_surrogate(u16 cp)
|
||||
{
|
||||
return (cp >= LEAD_SURROGATE_MIN && cp <= TRAIL_SURROGATE_MAX);
|
||||
}
|
||||
|
||||
template <typename u32>
|
||||
inline bool is_code_point_valid(u32 cp)
|
||||
{
|
||||
return (cp <= CODE_POINT_MAX && !is_surrogate(cp));
|
||||
}
|
||||
|
||||
template <typename octet_iterator>
|
||||
inline typename std::iterator_traits<octet_iterator>::difference_type
|
||||
sequence_length(octet_iterator lead_it)
|
||||
{
|
||||
uint8_t lead = mask8(*lead_it);
|
||||
if (lead < 0x80)
|
||||
return 1;
|
||||
else if ((lead >> 5) == 0x6)
|
||||
return 2;
|
||||
else if ((lead >> 4) == 0xe)
|
||||
return 3;
|
||||
else if ((lead >> 3) == 0x1e)
|
||||
return 4;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
template <typename octet_difference_type>
|
||||
inline bool is_overlong_sequence(uint32_t cp, octet_difference_type length)
|
||||
{
|
||||
if (cp < 0x80) {
|
||||
if (length != 1)
|
||||
return true;
|
||||
}
|
||||
else if (cp < 0x800) {
|
||||
if (length != 2)
|
||||
return true;
|
||||
}
|
||||
else if (cp < 0x10000) {
|
||||
if (length != 3)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
enum utf_error {UTF8_OK, NOT_ENOUGH_ROOM, INVALID_LEAD, INCOMPLETE_SEQUENCE, OVERLONG_SEQUENCE, INVALID_CODE_POINT};
|
||||
|
||||
/// get_sequence_x functions decode utf-8 sequences of the length x
|
||||
|
||||
template <typename octet_iterator>
|
||||
utf_error get_sequence_1(octet_iterator& it, octet_iterator end, uint32_t* code_point)
|
||||
{
|
||||
if (it != end) {
|
||||
if (code_point)
|
||||
*code_point = mask8(*it);
|
||||
return UTF8_OK;
|
||||
}
|
||||
return NOT_ENOUGH_ROOM;
|
||||
}
|
||||
|
||||
template <typename octet_iterator>
|
||||
utf_error get_sequence_2(octet_iterator& it, octet_iterator end, uint32_t* code_point)
|
||||
{
|
||||
utf_error ret_code = NOT_ENOUGH_ROOM;
|
||||
|
||||
if (it != end) {
|
||||
uint32_t cp = mask8(*it);
|
||||
if (++it != end) {
|
||||
if (is_trail(*it)) {
|
||||
cp = ((cp << 6) & 0x7ff) + ((*it) & 0x3f);
|
||||
|
||||
if (code_point)
|
||||
*code_point = cp;
|
||||
ret_code = UTF8_OK;
|
||||
}
|
||||
else
|
||||
ret_code = INCOMPLETE_SEQUENCE;
|
||||
}
|
||||
else
|
||||
ret_code = NOT_ENOUGH_ROOM;
|
||||
}
|
||||
|
||||
return ret_code;
|
||||
}
|
||||
|
||||
template <typename octet_iterator>
|
||||
utf_error get_sequence_3(octet_iterator& it, octet_iterator end, uint32_t* code_point)
|
||||
{
|
||||
utf_error ret_code = NOT_ENOUGH_ROOM;
|
||||
|
||||
if (it != end) {
|
||||
uint32_t cp = mask8(*it);
|
||||
if (++it != end) {
|
||||
if (is_trail(*it)) {
|
||||
cp = ((cp << 12) & 0xffff) + ((mask8(*it) << 6) & 0xfff);
|
||||
if (++it != end) {
|
||||
if (is_trail(*it)) {
|
||||
cp += (*it) & 0x3f;
|
||||
|
||||
if (code_point)
|
||||
*code_point = cp;
|
||||
ret_code = UTF8_OK;
|
||||
}
|
||||
else
|
||||
ret_code = INCOMPLETE_SEQUENCE;
|
||||
}
|
||||
else
|
||||
ret_code = NOT_ENOUGH_ROOM;
|
||||
}
|
||||
else
|
||||
ret_code = INCOMPLETE_SEQUENCE;
|
||||
}
|
||||
else
|
||||
ret_code = NOT_ENOUGH_ROOM;
|
||||
}
|
||||
|
||||
return ret_code;
|
||||
}
|
||||
|
||||
template <typename octet_iterator>
|
||||
utf_error get_sequence_4(octet_iterator& it, octet_iterator end, uint32_t* code_point)
|
||||
{
|
||||
utf_error ret_code = NOT_ENOUGH_ROOM;
|
||||
|
||||
if (it != end) {
|
||||
uint32_t cp = mask8(*it);
|
||||
if (++it != end) {
|
||||
if (is_trail(*it)) {
|
||||
cp = ((cp << 18) & 0x1fffff) + ((mask8(*it) << 12) & 0x3ffff);
|
||||
if (++it != end) {
|
||||
if (is_trail(*it)) {
|
||||
cp += (mask8(*it) << 6) & 0xfff;
|
||||
if (++it != end) {
|
||||
if (is_trail(*it)) {
|
||||
cp += (*it) & 0x3f;
|
||||
|
||||
if (code_point)
|
||||
*code_point = cp;
|
||||
ret_code = UTF8_OK;
|
||||
}
|
||||
else
|
||||
ret_code = INCOMPLETE_SEQUENCE;
|
||||
}
|
||||
else
|
||||
ret_code = NOT_ENOUGH_ROOM;
|
||||
}
|
||||
else
|
||||
ret_code = INCOMPLETE_SEQUENCE;
|
||||
}
|
||||
else
|
||||
ret_code = NOT_ENOUGH_ROOM;
|
||||
}
|
||||
else
|
||||
ret_code = INCOMPLETE_SEQUENCE;
|
||||
}
|
||||
else
|
||||
ret_code = NOT_ENOUGH_ROOM;
|
||||
}
|
||||
|
||||
return ret_code;
|
||||
}
|
||||
|
||||
template <typename octet_iterator>
|
||||
utf_error validate_next(octet_iterator& it, octet_iterator end, uint32_t* code_point)
|
||||
{
|
||||
// Save the original value of it so we can go back in case of failure
|
||||
// Of course, it does not make much sense with i.e. stream iterators
|
||||
octet_iterator original_it = it;
|
||||
|
||||
uint32_t cp = 0;
|
||||
// Determine the sequence length based on the lead octet
|
||||
typedef typename std::iterator_traits<octet_iterator>::difference_type octet_difference_type;
|
||||
octet_difference_type length = sequence_length(it);
|
||||
if (length == 0)
|
||||
return INVALID_LEAD;
|
||||
|
||||
// Now that we have a valid sequence length, get trail octets and calculate the code point
|
||||
utf_error err = UTF8_OK;
|
||||
switch (length) {
|
||||
case 1:
|
||||
err = get_sequence_1(it, end, &cp);
|
||||
break;
|
||||
case 2:
|
||||
err = get_sequence_2(it, end, &cp);
|
||||
break;
|
||||
case 3:
|
||||
err = get_sequence_3(it, end, &cp);
|
||||
break;
|
||||
case 4:
|
||||
err = get_sequence_4(it, end, &cp);
|
||||
break;
|
||||
}
|
||||
|
||||
if (err == UTF8_OK) {
|
||||
// Decoding succeeded. Now, security checks...
|
||||
if (is_code_point_valid(cp)) {
|
||||
if (!is_overlong_sequence(cp, length)){
|
||||
// Passed! Return here.
|
||||
if (code_point)
|
||||
*code_point = cp;
|
||||
++it;
|
||||
return UTF8_OK;
|
||||
}
|
||||
else
|
||||
err = OVERLONG_SEQUENCE;
|
||||
}
|
||||
else
|
||||
err = INVALID_CODE_POINT;
|
||||
}
|
||||
|
||||
// Failure branch - restore the original value of the iterator
|
||||
it = original_it;
|
||||
return err;
|
||||
}
|
||||
|
||||
template <typename octet_iterator>
|
||||
inline utf_error validate_next(octet_iterator& it, octet_iterator end) {
|
||||
return validate_next(it, end, 0);
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
|
||||
/// The library API - functions intended to be called by the users
|
||||
|
||||
// Byte order mark
|
||||
const uint8_t bom[] = {0xef, 0xbb, 0xbf};
|
||||
|
||||
template <typename octet_iterator>
|
||||
octet_iterator find_invalid(octet_iterator start, octet_iterator end)
|
||||
{
|
||||
octet_iterator result = start;
|
||||
while (result != end) {
|
||||
internal::utf_error err_code = internal::validate_next(result, end);
|
||||
if (err_code != internal::UTF8_OK)
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename octet_iterator>
|
||||
inline bool is_valid(octet_iterator start, octet_iterator end)
|
||||
{
|
||||
return (find_invalid(start, end) == end);
|
||||
}
|
||||
|
||||
template <typename octet_iterator>
|
||||
inline bool starts_with_bom (octet_iterator it, octet_iterator end)
|
||||
{
|
||||
return (
|
||||
((it != end) && (internal::mask8(*it++)) == bom[0]) &&
|
||||
((it != end) && (internal::mask8(*it++)) == bom[1]) &&
|
||||
((it != end) && (internal::mask8(*it)) == bom[2])
|
||||
);
|
||||
}
|
||||
|
||||
//Deprecated in release 2.3
|
||||
template <typename octet_iterator>
|
||||
inline bool is_bom (octet_iterator it)
|
||||
{
|
||||
return (
|
||||
(internal::mask8(*it++)) == bom[0] &&
|
||||
(internal::mask8(*it++)) == bom[1] &&
|
||||
(internal::mask8(*it)) == bom[2]
|
||||
);
|
||||
}
|
||||
} // namespace utf8
|
||||
|
||||
#endif // header guard
|
||||
|
||||
|
||||
228
include/Utfcpp/utf8/unchecked.h
Normal file
228
include/Utfcpp/utf8/unchecked.h
Normal file
@@ -0,0 +1,228 @@
|
||||
// Copyright 2006 Nemanja Trifunovic
|
||||
|
||||
/*
|
||||
Permission is hereby granted, free of charge, to any person or organization
|
||||
obtaining a copy of the software and accompanying documentation covered by
|
||||
this license (the "Software") to use, reproduce, display, distribute,
|
||||
execute, and transmit the Software, and to prepare derivative works of the
|
||||
Software, and to permit third-parties to whom the Software is furnished to
|
||||
do so, all subject to the following:
|
||||
|
||||
The copyright notices in the Software and this entire statement, including
|
||||
the above license grant, this restriction and the following disclaimer,
|
||||
must be included in all copies of the Software, in whole or in part, and
|
||||
all derivative works of the Software, unless such copies or derivative
|
||||
works are solely in the form of machine-executable object code generated by
|
||||
a source language processor.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef UTF8_FOR_CPP_UNCHECKED_H_2675DCD0_9480_4c0c_B92A_CC14C027B731
|
||||
#define UTF8_FOR_CPP_UNCHECKED_H_2675DCD0_9480_4c0c_B92A_CC14C027B731
|
||||
|
||||
#include "core.h"
|
||||
|
||||
namespace utf8
|
||||
{
|
||||
namespace unchecked
|
||||
{
|
||||
template <typename octet_iterator>
|
||||
octet_iterator append(uint32_t cp, octet_iterator result)
|
||||
{
|
||||
if (cp < 0x80) // one octet
|
||||
*(result++) = static_cast<uint8_t>(cp);
|
||||
else if (cp < 0x800) { // two octets
|
||||
*(result++) = static_cast<uint8_t>((cp >> 6) | 0xc0);
|
||||
*(result++) = static_cast<uint8_t>((cp & 0x3f) | 0x80);
|
||||
}
|
||||
else if (cp < 0x10000) { // three octets
|
||||
*(result++) = static_cast<uint8_t>((cp >> 12) | 0xe0);
|
||||
*(result++) = static_cast<uint8_t>(((cp >> 6) & 0x3f) | 0x80);
|
||||
*(result++) = static_cast<uint8_t>((cp & 0x3f) | 0x80);
|
||||
}
|
||||
else { // four octets
|
||||
*(result++) = static_cast<uint8_t>((cp >> 18) | 0xf0);
|
||||
*(result++) = static_cast<uint8_t>(((cp >> 12) & 0x3f)| 0x80);
|
||||
*(result++) = static_cast<uint8_t>(((cp >> 6) & 0x3f) | 0x80);
|
||||
*(result++) = static_cast<uint8_t>((cp & 0x3f) | 0x80);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename octet_iterator>
|
||||
uint32_t next(octet_iterator& it)
|
||||
{
|
||||
uint32_t cp = internal::mask8(*it);
|
||||
typename std::iterator_traits<octet_iterator>::difference_type length = utf8::internal::sequence_length(it);
|
||||
switch (length) {
|
||||
case 1:
|
||||
break;
|
||||
case 2:
|
||||
it++;
|
||||
cp = ((cp << 6) & 0x7ff) + ((*it) & 0x3f);
|
||||
break;
|
||||
case 3:
|
||||
++it;
|
||||
cp = ((cp << 12) & 0xffff) + ((internal::mask8(*it) << 6) & 0xfff);
|
||||
++it;
|
||||
cp += (*it) & 0x3f;
|
||||
break;
|
||||
case 4:
|
||||
++it;
|
||||
cp = ((cp << 18) & 0x1fffff) + ((internal::mask8(*it) << 12) & 0x3ffff);
|
||||
++it;
|
||||
cp += (internal::mask8(*it) << 6) & 0xfff;
|
||||
++it;
|
||||
cp += (*it) & 0x3f;
|
||||
break;
|
||||
}
|
||||
++it;
|
||||
return cp;
|
||||
}
|
||||
|
||||
template <typename octet_iterator>
|
||||
uint32_t peek_next(octet_iterator it)
|
||||
{
|
||||
return next(it);
|
||||
}
|
||||
|
||||
template <typename octet_iterator>
|
||||
uint32_t prior(octet_iterator& it)
|
||||
{
|
||||
while (internal::is_trail(*(--it))) ;
|
||||
octet_iterator temp = it;
|
||||
return next(temp);
|
||||
}
|
||||
|
||||
// Deprecated in versions that include prior, but only for the sake of consistency (see utf8::previous)
|
||||
template <typename octet_iterator>
|
||||
inline uint32_t previous(octet_iterator& it)
|
||||
{
|
||||
return prior(it);
|
||||
}
|
||||
|
||||
template <typename octet_iterator, typename distance_type>
|
||||
void advance (octet_iterator& it, distance_type n)
|
||||
{
|
||||
for (distance_type i = 0; i < n; ++i)
|
||||
next(it);
|
||||
}
|
||||
|
||||
template <typename octet_iterator>
|
||||
typename std::iterator_traits<octet_iterator>::difference_type
|
||||
distance (octet_iterator first, octet_iterator last)
|
||||
{
|
||||
typename std::iterator_traits<octet_iterator>::difference_type dist;
|
||||
for (dist = 0; first < last; ++dist)
|
||||
next(first);
|
||||
return dist;
|
||||
}
|
||||
|
||||
template <typename u16bit_iterator, typename octet_iterator>
|
||||
octet_iterator utf16to8 (u16bit_iterator start, u16bit_iterator end, octet_iterator result)
|
||||
{
|
||||
while (start != end) {
|
||||
uint32_t cp = internal::mask16(*start++);
|
||||
// Take care of surrogate pairs first
|
||||
if (internal::is_lead_surrogate(cp)) {
|
||||
uint32_t trail_surrogate = internal::mask16(*start++);
|
||||
cp = (cp << 10) + trail_surrogate + internal::SURROGATE_OFFSET;
|
||||
}
|
||||
result = append(cp, result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename u16bit_iterator, typename octet_iterator>
|
||||
u16bit_iterator utf8to16 (octet_iterator start, octet_iterator end, u16bit_iterator result)
|
||||
{
|
||||
while (start < end) {
|
||||
uint32_t cp = next(start);
|
||||
if (cp > 0xffff) { //make a surrogate pair
|
||||
*result++ = static_cast<uint16_t>((cp >> 10) + internal::LEAD_OFFSET);
|
||||
*result++ = static_cast<uint16_t>((cp & 0x3ff) + internal::TRAIL_SURROGATE_MIN);
|
||||
}
|
||||
else
|
||||
*result++ = static_cast<uint16_t>(cp);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename octet_iterator, typename u32bit_iterator>
|
||||
octet_iterator utf32to8 (u32bit_iterator start, u32bit_iterator end, octet_iterator result)
|
||||
{
|
||||
while (start != end)
|
||||
result = append(*(start++), result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename octet_iterator, typename u32bit_iterator>
|
||||
u32bit_iterator utf8to32 (octet_iterator start, octet_iterator end, u32bit_iterator result)
|
||||
{
|
||||
while (start < end)
|
||||
(*result++) = next(start);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// The iterator class
|
||||
template <typename octet_iterator>
|
||||
class iterator : public std::iterator <std::bidirectional_iterator_tag, uint32_t> {
|
||||
octet_iterator it;
|
||||
public:
|
||||
iterator () {};
|
||||
explicit iterator (const octet_iterator& octet_it): it(octet_it) {}
|
||||
// the default "big three" are OK
|
||||
octet_iterator base () const { return it; }
|
||||
uint32_t operator * () const
|
||||
{
|
||||
octet_iterator temp = it;
|
||||
return next(temp);
|
||||
}
|
||||
bool operator == (const iterator& rhs) const
|
||||
{
|
||||
return (it == rhs.it);
|
||||
}
|
||||
bool operator != (const iterator& rhs) const
|
||||
{
|
||||
return !(operator == (rhs));
|
||||
}
|
||||
iterator& operator ++ ()
|
||||
{
|
||||
std::advance(it, internal::sequence_length(it));
|
||||
return *this;
|
||||
}
|
||||
iterator operator ++ (int)
|
||||
{
|
||||
iterator temp = *this;
|
||||
std::advance(it, internal::sequence_length(it));
|
||||
return temp;
|
||||
}
|
||||
iterator& operator -- ()
|
||||
{
|
||||
prior(it);
|
||||
return *this;
|
||||
}
|
||||
iterator operator -- (int)
|
||||
{
|
||||
iterator temp = *this;
|
||||
prior(it);
|
||||
return temp;
|
||||
}
|
||||
}; // class iterator
|
||||
|
||||
} // namespace utf8::unchecked
|
||||
} // namespace utf8
|
||||
|
||||
|
||||
#endif // header guard
|
||||
|
||||
Reference in New Issue
Block a user