├── glm
├── gtx
│ ├── type_trait.inl
│ ├── raw_data.inl
│ ├── type_aligned.inl
│ ├── std_based_type.inl
│ ├── number_precision.inl
│ ├── projection.inl
│ ├── perpendicular.inl
│ ├── mixed_product.inl
│ ├── normal.inl
│ ├── float_notmalize.inl
│ ├── optimum_pow.inl
│ ├── log_base.inl
│ ├── normalize_dot.inl
│ ├── transform.inl
│ ├── handed_coordinate_space.inl
│ ├── orthonormalize.inl
│ ├── scalar_relational.hpp
│ ├── matrix_cross_product.inl
│ ├── projection.hpp
│ ├── polar_coordinates.inl
│ ├── mixed_product.hpp
│ ├── extend.hpp
│ ├── normal.hpp
│ ├── perpendicular.hpp
│ ├── gradient_paint.inl
│ ├── extend.inl
│ ├── log_base.hpp
│ ├── raw_data.hpp
│ ├── matrix_cross_product.hpp
│ ├── orthonormalize.hpp
│ ├── polar_coordinates.hpp
│ ├── closest_point.hpp
│ ├── optimum_pow.hpp
│ ├── closest_point.inl
│ ├── matrix_decompose.hpp
│ ├── string_cast.hpp
│ ├── gradient_paint.hpp
│ ├── wrap.hpp
│ ├── handed_coordinate_space.hpp
│ ├── scalar_relational.inl
│ ├── normalize_dot.hpp
│ ├── spline.hpp
│ ├── transform.hpp
│ ├── matrix_transform_2d.inl
│ ├── vector_angle.inl
│ ├── compatibility.inl
│ ├── vector_angle.hpp
│ ├── color_space_YCoCg.hpp
│ ├── rotate_normalized_axis.inl
│ ├── matrix_interpolation.hpp
│ ├── std_based_type.hpp
│ ├── color_space.hpp
│ ├── wrap.inl
│ ├── common.hpp
│ ├── range.hpp
│ ├── spline.inl
│ ├── scalar_multiplication.hpp
│ ├── integer.hpp
│ ├── number_precision.hpp
│ ├── rotate_normalized_axis.hpp
│ ├── vector_query.hpp
│ ├── component_wise.hpp
│ ├── fast_trigonometry.hpp
│ ├── norm.hpp
│ ├── matrix_operation.hpp
│ ├── matrix_transform_2d.hpp
│ ├── matrix_query.hpp
│ ├── fast_square_root.inl
│ ├── bit.inl
│ └── matrix_operation.inl
├── detail
│ ├── func_trigonometric_simd.inl
│ ├── type_vec.inl
│ ├── type_mat.inl
│ ├── type_mat4x4_simd.inl
│ ├── func_packing_simd.inl
│ ├── func_vector_relational_simd.inl
│ ├── type_half.hpp
│ ├── _fixes.hpp
│ ├── func_exponential_simd.inl
│ ├── precision.hpp
│ ├── func_integer_simd.inl
│ └── type_float.hpp
├── gtc
│ ├── vec1.inl
│ ├── type_precision.inl
│ ├── functions.inl
│ ├── functions.hpp
│ ├── matrix_access.inl
│ ├── matrix_access.hpp
│ ├── matrix_inverse.hpp
│ ├── noise.hpp
│ ├── ulp.hpp
│ ├── epsilon.hpp
│ ├── color_space.hpp
│ ├── color_encoding.inl
│ └── integer.inl
├── vec2.hpp
├── vec3.hpp
├── vec4.hpp
├── common.hpp
├── matrix.hpp
├── integer.hpp
├── packing.hpp
├── geometric.hpp
├── exponential.hpp
├── trigonometric.hpp
├── vector_relational.hpp
├── simd
│ ├── packing.h
│ ├── vector_relational.h
│ ├── trigonometric.h
│ └── exponential.h
├── mat3x2.hpp
├── mat2x4.hpp
├── mat3x4.hpp
├── mat4x2.hpp
├── mat4x3.hpp
├── mat2x3.hpp
├── CMakeLists.txt
├── mat2x2.hpp
├── mat3x3.hpp
└── mat4x4.hpp
├── ScreenShot
├── Lesson1.png
├── Lesson2.png
├── Lesson3-1.png
├── Lesson3-2.png
├── Lesson4-1.png
├── Lesson4-2.png
└── Lesson5.png
├── Lesson2
├── Lesson2
│ ├── image.png
│ ├── tutorial.fs
│ ├── tutorial.vs
│ ├── AppDelegate.swift
│ ├── Info.plist
│ ├── Assets.xcassets
│ │ └── AppIcon.appiconset
│ │ │ └── Contents.json
│ └── Texture.swift
└── Lesson2.xcodeproj
│ └── project.xcworkspace
│ └── contents.xcworkspacedata
├── Lesson3
├── Lesson3
│ ├── texture1.png
│ ├── texture2.png
│ ├── tutorial.vs
│ ├── tutorial.fs
│ ├── Info.plist
│ ├── Assets.xcassets
│ │ └── AppIcon.appiconset
│ │ │ └── Contents.json
│ ├── FLOpenGLView.swift
│ ├── AppDelegate.swift
│ └── Texture.swift
└── Lesson3.xcodeproj
│ └── project.xcworkspace
│ └── contents.xcworkspacedata
├── Lesson4
├── Lesson4
│ ├── texture1.png
│ ├── texture2.png
│ ├── tutorial.fs
│ ├── tutorial.vs
│ ├── Info.plist
│ ├── Assets.xcassets
│ │ └── AppIcon.appiconset
│ │ │ └── Contents.json
│ ├── FLOpenGLView.swift
│ ├── AppDelegate.swift
│ └── Texture.swift
└── Lesson4.xcodeproj
│ └── project.xcworkspace
│ └── contents.xcworkspacedata
├── Lesson5
├── Lesson5
│ ├── texture1.png
│ ├── texture2.png
│ ├── Lesson5-Bridging-Header.h
│ ├── tutorial.fs
│ ├── tutorial.vs
│ ├── Info.plist
│ ├── Assets.xcassets
│ │ └── AppIcon.appiconset
│ │ │ └── Contents.json
│ ├── FLOpenGLView.swift
│ ├── AppDelegate.swift
│ └── Texture.swift
├── Lesson5.xcodeproj
│ └── project.xcworkspace
│ │ └── contents.xcworkspacedata
├── FLglmWrapper.h
└── FLglmWrapper.m
├── Lesson1
├── Lesson1
│ ├── tutorial.fs
│ ├── tutorial.vs
│ ├── AppDelegate.swift
│ ├── Info.plist
│ ├── Assets.xcassets
│ │ └── AppIcon.appiconset
│ │ │ └── Contents.json
│ └── FLOpenGLView.swift
└── Lesson1.xcodeproj
│ └── project.xcworkspace
│ └── contents.xcworkspacedata
├── README.md
└── .gitignore
/glm/gtx/type_trait.inl:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/glm/detail/func_trigonometric_simd.inl:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/glm/gtc/vec1.inl:
--------------------------------------------------------------------------------
1 | /// @ref gtc_vec1
2 | /// @file glm/gtc/vec1.inl
3 |
--------------------------------------------------------------------------------
/glm/detail/type_vec.inl:
--------------------------------------------------------------------------------
1 | /// @ref core
2 | /// @file glm/detail/type_vec.inl
3 |
--------------------------------------------------------------------------------
/glm/gtx/raw_data.inl:
--------------------------------------------------------------------------------
1 | /// @ref gtx_raw_data
2 | /// @file glm/gtx/raw_data.inl
3 |
--------------------------------------------------------------------------------
/glm/detail/type_mat.inl:
--------------------------------------------------------------------------------
1 | /// @ref core
2 | /// @file glm/detail/type_mat.inl
3 |
4 |
--------------------------------------------------------------------------------
/ScreenShot/Lesson1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fancymax/LearnOpenGL_Mac/HEAD/ScreenShot/Lesson1.png
--------------------------------------------------------------------------------
/ScreenShot/Lesson2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fancymax/LearnOpenGL_Mac/HEAD/ScreenShot/Lesson2.png
--------------------------------------------------------------------------------
/ScreenShot/Lesson3-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fancymax/LearnOpenGL_Mac/HEAD/ScreenShot/Lesson3-1.png
--------------------------------------------------------------------------------
/ScreenShot/Lesson3-2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fancymax/LearnOpenGL_Mac/HEAD/ScreenShot/Lesson3-2.png
--------------------------------------------------------------------------------
/ScreenShot/Lesson4-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fancymax/LearnOpenGL_Mac/HEAD/ScreenShot/Lesson4-1.png
--------------------------------------------------------------------------------
/ScreenShot/Lesson4-2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fancymax/LearnOpenGL_Mac/HEAD/ScreenShot/Lesson4-2.png
--------------------------------------------------------------------------------
/ScreenShot/Lesson5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fancymax/LearnOpenGL_Mac/HEAD/ScreenShot/Lesson5.png
--------------------------------------------------------------------------------
/Lesson2/Lesson2/image.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fancymax/LearnOpenGL_Mac/HEAD/Lesson2/Lesson2/image.png
--------------------------------------------------------------------------------
/Lesson3/Lesson3/texture1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fancymax/LearnOpenGL_Mac/HEAD/Lesson3/Lesson3/texture1.png
--------------------------------------------------------------------------------
/Lesson3/Lesson3/texture2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fancymax/LearnOpenGL_Mac/HEAD/Lesson3/Lesson3/texture2.png
--------------------------------------------------------------------------------
/Lesson4/Lesson4/texture1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fancymax/LearnOpenGL_Mac/HEAD/Lesson4/Lesson4/texture1.png
--------------------------------------------------------------------------------
/Lesson4/Lesson4/texture2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fancymax/LearnOpenGL_Mac/HEAD/Lesson4/Lesson4/texture2.png
--------------------------------------------------------------------------------
/Lesson5/Lesson5/texture1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fancymax/LearnOpenGL_Mac/HEAD/Lesson5/Lesson5/texture1.png
--------------------------------------------------------------------------------
/Lesson5/Lesson5/texture2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fancymax/LearnOpenGL_Mac/HEAD/Lesson5/Lesson5/texture2.png
--------------------------------------------------------------------------------
/glm/vec2.hpp:
--------------------------------------------------------------------------------
1 | /// @ref core
2 | /// @file glm/vec2.hpp
3 |
4 | #pragma once
5 |
6 | #include "detail/type_vec2.hpp"
7 |
--------------------------------------------------------------------------------
/glm/vec3.hpp:
--------------------------------------------------------------------------------
1 | /// @ref core
2 | /// @file glm/vec3.hpp
3 |
4 | #pragma once
5 |
6 | #include "detail/type_vec3.hpp"
7 |
--------------------------------------------------------------------------------
/glm/vec4.hpp:
--------------------------------------------------------------------------------
1 | /// @ref core
2 | /// @file glm/vec4.hpp
3 |
4 | #pragma once
5 |
6 | #include "detail/type_vec4.hpp"
7 |
--------------------------------------------------------------------------------
/glm/common.hpp:
--------------------------------------------------------------------------------
1 | /// @ref core
2 | /// @file glm/common.hpp
3 |
4 | #pragma once
5 |
6 | #include "detail/func_common.hpp"
7 |
--------------------------------------------------------------------------------
/glm/gtc/type_precision.inl:
--------------------------------------------------------------------------------
1 | /// @ref gtc_swizzle
2 | /// @file glm/gtc/swizzle.inl
3 |
4 | namespace glm
5 | {
6 |
7 | }
8 |
--------------------------------------------------------------------------------
/glm/matrix.hpp:
--------------------------------------------------------------------------------
1 | /// @ref core
2 | /// @file glm/matrix.hpp
3 |
4 | #pragma once
5 |
6 | #include "detail/func_matrix.hpp"
7 |
--------------------------------------------------------------------------------
/glm/integer.hpp:
--------------------------------------------------------------------------------
1 | /// @ref core
2 | /// @file glm/integer.hpp
3 |
4 | #pragma once
5 |
6 | #include "detail/func_integer.hpp"
7 |
--------------------------------------------------------------------------------
/glm/packing.hpp:
--------------------------------------------------------------------------------
1 | /// @ref core
2 | /// @file glm/packing.hpp
3 |
4 | #pragma once
5 |
6 | #include "detail/func_packing.hpp"
7 |
--------------------------------------------------------------------------------
/glm/geometric.hpp:
--------------------------------------------------------------------------------
1 | /// @ref core
2 | /// @file glm/geometric.hpp
3 |
4 | #pragma once
5 |
6 | #include "detail/func_geometric.hpp"
7 |
--------------------------------------------------------------------------------
/glm/gtx/type_aligned.inl:
--------------------------------------------------------------------------------
1 | /// @ref gtc_type_aligned
2 | /// @file glm/gtc/type_aligned.inl
3 |
4 | namespace glm
5 | {
6 |
7 | }
8 |
--------------------------------------------------------------------------------
/Lesson1/Lesson1/tutorial.fs:
--------------------------------------------------------------------------------
1 | #version 330 core
2 |
3 | out vec4 color;
4 |
5 | void main() {
6 | color = vec4(0.67, 0.0, 0.5, 1.0);
7 | }
8 |
--------------------------------------------------------------------------------
/glm/exponential.hpp:
--------------------------------------------------------------------------------
1 | /// @ref core
2 | /// @file glm/exponential.hpp
3 |
4 | #pragma once
5 |
6 | #include "detail/func_exponential.hpp"
7 |
--------------------------------------------------------------------------------
/glm/gtx/std_based_type.inl:
--------------------------------------------------------------------------------
1 | /// @ref gtx_std_based_type
2 | /// @file glm/gtx/std_based_type.inl
3 |
4 | namespace glm
5 | {
6 |
7 | }
8 |
--------------------------------------------------------------------------------
/glm/gtx/number_precision.inl:
--------------------------------------------------------------------------------
1 | /// @ref gtx_number_precision
2 | /// @file glm/gtx/number_precision.inl
3 |
4 | namespace glm
5 | {
6 |
7 | }
8 |
--------------------------------------------------------------------------------
/glm/trigonometric.hpp:
--------------------------------------------------------------------------------
1 | /// @ref core
2 | /// @file glm/trigonometric.hpp
3 |
4 | #pragma once
5 |
6 | #include "detail/func_trigonometric.hpp"
7 |
--------------------------------------------------------------------------------
/glm/detail/type_mat4x4_simd.inl:
--------------------------------------------------------------------------------
1 | /// @ref core
2 | /// @file glm/detail/type_mat4x4_sse2.inl
3 |
4 | namespace glm
5 | {
6 |
7 | }//namespace glm
8 |
--------------------------------------------------------------------------------
/glm/vector_relational.hpp:
--------------------------------------------------------------------------------
1 | /// @ref core
2 | /// @file glm/vector_relational.hpp
3 |
4 | #pragma once
5 |
6 | #include "detail/func_vector_relational.hpp"
7 |
--------------------------------------------------------------------------------
/Lesson1/Lesson1/tutorial.vs:
--------------------------------------------------------------------------------
1 | #version 330 core
2 |
3 | layout (location = 0) in vec3 position_model;
4 |
5 | void main() {
6 | gl_Position = vec4(position_model, 1.0);
7 | }
--------------------------------------------------------------------------------
/glm/simd/packing.h:
--------------------------------------------------------------------------------
1 | /// @ref simd
2 | /// @file glm/simd/packing.h
3 |
4 | #pragma once
5 |
6 | #if GLM_ARCH & GLM_ARCH_SSE2_BIT
7 |
8 | #endif//GLM_ARCH & GLM_ARCH_SSE2_BIT
9 |
--------------------------------------------------------------------------------
/Lesson5/Lesson5/Lesson5-Bridging-Header.h:
--------------------------------------------------------------------------------
1 | //
2 | // Use this file to import your target's public headers that you would like to expose to Swift.
3 | //
4 |
5 | #include "FLglmWrapper.h"
6 |
--------------------------------------------------------------------------------
/glm/simd/vector_relational.h:
--------------------------------------------------------------------------------
1 | /// @ref simd
2 | /// @file glm/simd/vector_relational.h
3 |
4 | #pragma once
5 |
6 | #if GLM_ARCH & GLM_ARCH_SSE2_BIT
7 |
8 | #endif//GLM_ARCH & GLM_ARCH_SSE2_BIT
9 |
--------------------------------------------------------------------------------
/glm/detail/func_packing_simd.inl:
--------------------------------------------------------------------------------
1 | /// @ref core
2 | /// @file glm/detail/func_packing_simd.inl
3 |
4 | namespace glm{
5 | namespace detail
6 | {
7 |
8 | }//namespace detail
9 | }//namespace glm
10 |
--------------------------------------------------------------------------------
/glm/simd/trigonometric.h:
--------------------------------------------------------------------------------
1 | /// @ref simd
2 | /// @file glm/simd/trigonometric.h
3 |
4 | #pragma once
5 |
6 | #if GLM_ARCH & GLM_ARCH_SSE2_BIT
7 |
8 | #endif//GLM_ARCH & GLM_ARCH_SSE2_BIT
9 |
10 |
--------------------------------------------------------------------------------
/glm/detail/func_vector_relational_simd.inl:
--------------------------------------------------------------------------------
1 | /// @ref core
2 | /// @file glm/detail/func_vector_relational_simd.inl
3 |
4 | namespace glm{
5 | namespace detail
6 | {
7 |
8 | }//namespace detail
9 | }//namespace glm
10 |
--------------------------------------------------------------------------------
/Lesson1/Lesson1.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Lesson2/Lesson2.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Lesson2/Lesson2/tutorial.fs:
--------------------------------------------------------------------------------
1 | #version 330 core
2 | in vec3 ourColor;
3 | in vec2 TexCoord;
4 |
5 | out vec4 color;
6 |
7 | uniform sampler2D ourTexture;
8 |
9 | void main()
10 | {
11 | color = texture(ourTexture, TexCoord);
12 | }
13 |
--------------------------------------------------------------------------------
/Lesson3/Lesson3.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Lesson4/Lesson4.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Lesson5/Lesson5.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/glm/gtx/projection.inl:
--------------------------------------------------------------------------------
1 | /// @ref gtx_projection
2 | /// @file glm/gtx/projection.inl
3 |
4 | namespace glm
5 | {
6 | template
7 | GLM_FUNC_QUALIFIER vecType proj(vecType const & x, vecType const & Normal)
8 | {
9 | return glm::dot(x, Normal) / glm::dot(Normal, Normal) * Normal;
10 | }
11 | }//namespace glm
12 |
--------------------------------------------------------------------------------
/glm/gtx/perpendicular.inl:
--------------------------------------------------------------------------------
1 | /// @ref gtx_perpendicular
2 | /// @file glm/gtx/perpendicular.inl
3 |
4 | namespace glm
5 | {
6 | template
7 | GLM_FUNC_QUALIFIER vecType perp
8 | (
9 | vecType const & x,
10 | vecType const & Normal
11 | )
12 | {
13 | return x - proj(x, Normal);
14 | }
15 | }//namespace glm
16 |
--------------------------------------------------------------------------------
/Lesson2/Lesson2/tutorial.vs:
--------------------------------------------------------------------------------
1 | #version 330 core
2 | layout (location = 0) in vec3 position;
3 | layout (location = 1) in vec3 color;
4 | layout (location = 2) in vec2 texCoord;
5 |
6 | out vec3 ourColor;
7 | out vec2 TexCoord;
8 |
9 | void main()
10 | {
11 | gl_Position = vec4(position, 1.0f);
12 | ourColor = color;
13 | TexCoord = texCoord;
14 | }
15 |
--------------------------------------------------------------------------------
/glm/gtx/mixed_product.inl:
--------------------------------------------------------------------------------
1 | /// @ref gtx_mixed_product
2 | /// @file glm/gtx/mixed_product.inl
3 |
4 | namespace glm
5 | {
6 | template
7 | GLM_FUNC_QUALIFIER T mixedProduct
8 | (
9 | tvec3 const & v1,
10 | tvec3 const & v2,
11 | tvec3 const & v3
12 | )
13 | {
14 | return dot(cross(v1, v2), v3);
15 | }
16 | }//namespace glm
17 |
--------------------------------------------------------------------------------
/glm/gtx/normal.inl:
--------------------------------------------------------------------------------
1 | /// @ref gtx_normal
2 | /// @file glm/gtx/normal.inl
3 |
4 | namespace glm
5 | {
6 | template
7 | GLM_FUNC_QUALIFIER tvec3 triangleNormal
8 | (
9 | tvec3 const & p1,
10 | tvec3 const & p2,
11 | tvec3 const & p3
12 | )
13 | {
14 | return normalize(cross(p1 - p2, p1 - p3));
15 | }
16 | }//namespace glm
17 |
--------------------------------------------------------------------------------
/Lesson3/Lesson3/tutorial.vs:
--------------------------------------------------------------------------------
1 | #version 330 core
2 | layout (location = 0) in vec3 position;
3 | layout (location = 1) in vec3 color;
4 | layout (location = 2) in vec2 texCoord;
5 |
6 | out vec3 ourColor;
7 | out vec2 TexCoord;
8 |
9 | uniform mat4 transform;
10 |
11 | void main()
12 | {
13 | gl_Position = transform * vec4(position, 1.0f);
14 | ourColor = color;
15 | TexCoord = texCoord;
16 | }
17 |
--------------------------------------------------------------------------------
/glm/detail/type_half.hpp:
--------------------------------------------------------------------------------
1 | /// @ref core
2 | /// @file glm/detail/type_half.hpp
3 |
4 | #pragma once
5 |
6 | #include "setup.hpp"
7 |
8 | namespace glm{
9 | namespace detail
10 | {
11 | typedef short hdata;
12 |
13 | GLM_FUNC_DECL float toFloat32(hdata value);
14 | GLM_FUNC_DECL hdata toFloat16(float const & value);
15 |
16 | }//namespace detail
17 | }//namespace glm
18 |
19 | #include "type_half.inl"
20 |
--------------------------------------------------------------------------------
/glm/gtx/float_notmalize.inl:
--------------------------------------------------------------------------------
1 | /// @ref gtx_float_normalize
2 | /// @file glm/gtx/float_normalize.inl
3 |
4 | #include
5 |
6 | namespace glm
7 | {
8 | template class vecType>
9 | GLM_FUNC_QUALIFIER vecType floatNormalize(vecType const & v)
10 | {
11 | return vecType(v) / static_cast(std::numeric_limits::max());
12 | }
13 |
14 | }//namespace glm
15 |
--------------------------------------------------------------------------------
/Lesson3/Lesson3/tutorial.fs:
--------------------------------------------------------------------------------
1 | #version 330 core
2 | in vec3 ourColor;
3 | in vec2 TexCoord;
4 |
5 | out vec4 color;
6 |
7 | uniform sampler2D ourTexture1;
8 | uniform sampler2D ourTexture2;
9 |
10 | vec2 flipTexCoord;
11 |
12 | void main()
13 | {
14 | //use vec2(TexCoord.x, 1.0f - TexCoord.y) to flip texture2
15 | flipTexCoord = vec2(TexCoord.x, 1.0f - TexCoord.y);
16 | color = mix(texture(ourTexture1, TexCoord),texture(ourTexture2, flipTexCoord),0.2);
17 | }
18 |
--------------------------------------------------------------------------------
/Lesson4/Lesson4/tutorial.fs:
--------------------------------------------------------------------------------
1 | #version 330 core
2 | in vec3 ourColor;
3 | in vec2 TexCoord;
4 |
5 | out vec4 color;
6 |
7 | uniform sampler2D ourTexture1;
8 | uniform sampler2D ourTexture2;
9 |
10 | vec2 flipTexCoord;
11 |
12 | void main()
13 | {
14 | //use vec2(TexCoord.x, 1.0f - TexCoord.y) to flip texture2
15 | flipTexCoord = vec2(TexCoord.x, 1.0f - TexCoord.y);
16 | color = mix(texture(ourTexture1, TexCoord),texture(ourTexture2, flipTexCoord),0.2);
17 | }
18 |
--------------------------------------------------------------------------------
/Lesson4/Lesson4/tutorial.vs:
--------------------------------------------------------------------------------
1 | #version 330 core
2 | layout (location = 0) in vec3 position;
3 | layout (location = 1) in vec3 color;
4 | layout (location = 2) in vec2 texCoord;
5 |
6 | out vec3 ourColor;
7 | out vec2 TexCoord;
8 |
9 | uniform mat4 model;
10 | uniform mat4 view;
11 | uniform mat4 projection;
12 |
13 | void main()
14 | {
15 | gl_Position = projection * view * model * vec4(position, 1.0f);
16 | ourColor = color;
17 | TexCoord = texCoord;
18 | }
19 |
--------------------------------------------------------------------------------
/Lesson5/Lesson5/tutorial.fs:
--------------------------------------------------------------------------------
1 | #version 330 core
2 | in vec3 ourColor;
3 | in vec2 TexCoord;
4 |
5 | out vec4 color;
6 |
7 | uniform sampler2D ourTexture1;
8 | uniform sampler2D ourTexture2;
9 |
10 | vec2 flipTexCoord;
11 |
12 | void main()
13 | {
14 | //use vec2(TexCoord.x, 1.0f - TexCoord.y) to flip texture2
15 | flipTexCoord = vec2(TexCoord.x, 1.0f - TexCoord.y);
16 | color = mix(texture(ourTexture1, TexCoord),texture(ourTexture2, flipTexCoord),0.2);
17 | }
18 |
--------------------------------------------------------------------------------
/Lesson5/Lesson5/tutorial.vs:
--------------------------------------------------------------------------------
1 | #version 330 core
2 | layout (location = 0) in vec3 position;
3 | layout (location = 1) in vec3 color;
4 | layout (location = 2) in vec2 texCoord;
5 |
6 | out vec3 ourColor;
7 | out vec2 TexCoord;
8 |
9 | uniform mat4 model;
10 | uniform mat4 view;
11 | uniform mat4 projection;
12 |
13 | void main()
14 | {
15 | gl_Position = projection * view * model * vec4(position, 1.0f);
16 | ourColor = color;
17 | TexCoord = texCoord;
18 | }
19 |
--------------------------------------------------------------------------------
/glm/simd/exponential.h:
--------------------------------------------------------------------------------
1 | /// @ref simd
2 | /// @file glm/simd/experimental.h
3 |
4 | #pragma once
5 |
6 | #include "platform.h"
7 |
8 | #if GLM_ARCH & GLM_ARCH_SSE2_BIT
9 |
10 | GLM_FUNC_QUALIFIER glm_vec4 glm_vec1_sqrt_lowp(glm_vec4 x)
11 | {
12 | return _mm_mul_ss(_mm_rsqrt_ss(x), x);
13 | }
14 |
15 | GLM_FUNC_QUALIFIER glm_vec4 glm_vec4_sqrt_lowp(glm_vec4 x)
16 | {
17 | return _mm_mul_ps(_mm_rsqrt_ps(x), x);
18 | }
19 |
20 | #endif//GLM_ARCH & GLM_ARCH_SSE2_BIT
21 |
--------------------------------------------------------------------------------
/glm/gtx/optimum_pow.inl:
--------------------------------------------------------------------------------
1 | /// @ref gtx_optimum_pow
2 | /// @file glm/gtx/optimum_pow.inl
3 |
4 | namespace glm
5 | {
6 | template
7 | GLM_FUNC_QUALIFIER genType pow2(genType const & x)
8 | {
9 | return x * x;
10 | }
11 |
12 | template
13 | GLM_FUNC_QUALIFIER genType pow3(genType const & x)
14 | {
15 | return x * x * x;
16 | }
17 |
18 | template
19 | GLM_FUNC_QUALIFIER genType pow4(genType const & x)
20 | {
21 | return (x * x) * (x * x);
22 | }
23 | }//namespace glm
24 |
--------------------------------------------------------------------------------
/glm/gtx/log_base.inl:
--------------------------------------------------------------------------------
1 | /// @ref gtx_log_base
2 | /// @file glm/gtx/log_base.inl
3 |
4 | namespace glm
5 | {
6 | template
7 | GLM_FUNC_QUALIFIER genType log(genType const & x, genType const & base)
8 | {
9 | assert(x != genType(0));
10 | return glm::log(x) / glm::log(base);
11 | }
12 |
13 | template class vecType>
14 | GLM_FUNC_QUALIFIER vecType log(vecType const & x, vecType const & base)
15 | {
16 | return glm::log(x) / glm::log(base);
17 | }
18 | }//namespace glm
19 |
--------------------------------------------------------------------------------
/glm/detail/_fixes.hpp:
--------------------------------------------------------------------------------
1 | /// @ref core
2 | /// @file glm/detail/_fixes.hpp
3 |
4 | #include
5 |
6 | //! Workaround for compatibility with other libraries
7 | #ifdef max
8 | #undef max
9 | #endif
10 |
11 | //! Workaround for compatibility with other libraries
12 | #ifdef min
13 | #undef min
14 | #endif
15 |
16 | //! Workaround for Android
17 | #ifdef isnan
18 | #undef isnan
19 | #endif
20 |
21 | //! Workaround for Android
22 | #ifdef isinf
23 | #undef isinf
24 | #endif
25 |
26 | //! Workaround for Chrone Native Client
27 | #ifdef log2
28 | #undef log2
29 | #endif
30 |
31 |
--------------------------------------------------------------------------------
/Lesson1/Lesson1/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.swift
3 | // Lesson1
4 | //
5 | // Created by fancymax on 1/11/2017.
6 | // Copyright © 2017年 fancy. All rights reserved.
7 | //
8 |
9 | import Cocoa
10 |
11 | @NSApplicationMain
12 | class AppDelegate: NSObject, NSApplicationDelegate {
13 |
14 | @IBOutlet weak var window: NSWindow!
15 |
16 |
17 | func applicationDidFinishLaunching(_ aNotification: Notification) {
18 | // Insert code here to initialize your application
19 | }
20 |
21 | func applicationWillTerminate(_ aNotification: Notification) {
22 | // Insert code here to tear down your application
23 | }
24 |
25 |
26 | }
27 |
28 |
--------------------------------------------------------------------------------
/Lesson2/Lesson2/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.swift
3 | // Lesson2
4 | //
5 | // Created by fancymax on 1/11/2017.
6 | // Copyright © 2017年 fancy. All rights reserved.
7 | //
8 |
9 | import Cocoa
10 |
11 | @NSApplicationMain
12 | class AppDelegate: NSObject, NSApplicationDelegate {
13 |
14 | @IBOutlet weak var window: NSWindow!
15 |
16 |
17 | func applicationDidFinishLaunching(_ aNotification: Notification) {
18 | // Insert code here to initialize your application
19 | }
20 |
21 | func applicationWillTerminate(_ aNotification: Notification) {
22 | // Insert code here to tear down your application
23 | }
24 |
25 |
26 | }
27 |
28 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # LearnOpenGL_Mac
2 | Learn OpenGL in Mac, used Swift, rendered by NSOpenGLView, followed [https://learnopengl.com/](https://learnopengl.com/) .
3 |
4 | - Lesson1(OpenGL Basic、shader、NSOpenGLView)
5 |
6 | 
7 |
8 | - Lesson2(Texture)
9 |
10 | 
11 |
12 | - Lesson3(Transformations)
13 |
14 | 
15 | 
16 |
17 | - Lesson4(Coordinate-Systems)
18 |
19 | 
20 | 
21 |
22 | - Lesson5(Camera、glm Objective-C++ Wrapper)
23 |
24 | 
--------------------------------------------------------------------------------
/glm/gtx/normalize_dot.inl:
--------------------------------------------------------------------------------
1 | /// @ref gtx_normalize_dot
2 | /// @file glm/gtx/normalize_dot.inl
3 |
4 | namespace glm
5 | {
6 | template class vecType>
7 | GLM_FUNC_QUALIFIER T normalizeDot(vecType const & x, vecType const & y)
8 | {
9 | return glm::dot(x, y) * glm::inversesqrt(glm::dot(x, x) * glm::dot(y, y));
10 | }
11 |
12 | template class vecType>
13 | GLM_FUNC_QUALIFIER T fastNormalizeDot(vecType const & x, vecType const & y)
14 | {
15 | return glm::dot(x, y) * glm::fastInverseSqrt(glm::dot(x, x) * glm::dot(y, y));
16 | }
17 | }//namespace glm
18 |
--------------------------------------------------------------------------------
/glm/gtx/transform.inl:
--------------------------------------------------------------------------------
1 | /// @ref gtx_transform
2 | /// @file glm/gtx/transform.inl
3 |
4 | namespace glm
5 | {
6 | template
7 | GLM_FUNC_QUALIFIER tmat4x4 translate(tvec3 const & v)
8 | {
9 | return translate(tmat4x4(static_cast(1)), v);
10 | }
11 |
12 | template
13 | GLM_FUNC_QUALIFIER tmat4x4 rotate(T angle, tvec3 const & v)
14 | {
15 | return rotate(tmat4x4(static_cast(1)), angle, v);
16 | }
17 |
18 | template
19 | GLM_FUNC_QUALIFIER tmat4x4 scale(tvec3 const & v)
20 | {
21 | return scale(tmat4x4(static_cast(1)), v);
22 | }
23 |
24 | }//namespace glm
25 |
--------------------------------------------------------------------------------
/Lesson5/FLglmWrapper.h:
--------------------------------------------------------------------------------
1 | //
2 | // FLglmWrapper.m
3 | // Lesson5
4 | //
5 | // Created by fancymax on 1/13/2017.
6 | // Copyright © 2017年 fancy. All rights
7 |
8 | #import
9 |
10 | @interface FLglmWrapper:NSObject
11 |
12 | +(float*) lookAtPosition:(float*)position target:(float*)target upVector:(float*)up;
13 | +(float*) perspectiveAtFov:(float)FOV aspect:(float)aspect near:(float)near far:(float)far;
14 | +(void) freeMatrix:(float*)matrix;
15 |
16 | +(float*) translateAtX:(float)x Y:(float)y Z:(float)z;
17 | +(float*) translateFrom:(float*)arrayMatrix X:(float)x Y:(float)y Z:(float)z;
18 | +(float*) rotateFrom:(float*)arrayMatrix angle:(float)angle X:(float)x Y:(float)y Z:(float)z;
19 |
20 |
21 |
22 |
23 | @end
24 |
--------------------------------------------------------------------------------
/glm/gtx/handed_coordinate_space.inl:
--------------------------------------------------------------------------------
1 | /// @ref gtx_handed_coordinate_space
2 | /// @file glm/gtx/handed_coordinate_space.inl
3 |
4 | namespace glm
5 | {
6 | template
7 | GLM_FUNC_QUALIFIER bool rightHanded
8 | (
9 | tvec3 const & tangent,
10 | tvec3 const & binormal,
11 | tvec3 const & normal
12 | )
13 | {
14 | return dot(cross(normal, tangent), binormal) > T(0);
15 | }
16 |
17 | template
18 | GLM_FUNC_QUALIFIER bool leftHanded
19 | (
20 | tvec3 const & tangent,
21 | tvec3 const & binormal,
22 | tvec3 const & normal
23 | )
24 | {
25 | return dot(cross(normal, tangent), binormal) < T(0);
26 | }
27 | }//namespace glm
28 |
--------------------------------------------------------------------------------
/glm/gtx/orthonormalize.inl:
--------------------------------------------------------------------------------
1 | /// @ref gtx_orthonormalize
2 | /// @file glm/gtx/orthonormalize.inl
3 |
4 | namespace glm
5 | {
6 | template
7 | GLM_FUNC_QUALIFIER tmat3x3 orthonormalize(tmat3x3 const & m)
8 | {
9 | tmat3x3 r = m;
10 |
11 | r[0] = normalize(r[0]);
12 |
13 | T d0 = dot(r[0], r[1]);
14 | r[1] -= r[0] * d0;
15 | r[1] = normalize(r[1]);
16 |
17 | T d1 = dot(r[1], r[2]);
18 | d0 = dot(r[0], r[2]);
19 | r[2] -= r[0] * d0 + r[1] * d1;
20 | r[2] = normalize(r[2]);
21 |
22 | return r;
23 | }
24 |
25 | template
26 | GLM_FUNC_QUALIFIER tvec3 orthonormalize(tvec3 const & x, tvec3 const & y)
27 | {
28 | return normalize(x - y * dot(y, x));
29 | }
30 | }//namespace glm
31 |
--------------------------------------------------------------------------------
/glm/gtx/scalar_relational.hpp:
--------------------------------------------------------------------------------
1 | /// @ref gtx_scalar_relational
2 | /// @file glm/gtx/scalar_relational.hpp
3 | ///
4 | /// @see core (dependence)
5 | ///
6 | /// @defgroup gtx_scalar_relational GLM_GTX_scalar_relational
7 | /// @ingroup gtx
8 | ///
9 | /// @brief Extend a position from a source to a position at a defined length.
10 | ///
11 | /// need to be included to use these functionalities.
12 |
13 | #pragma once
14 |
15 | // Dependency:
16 | #include "../glm.hpp"
17 |
18 | #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED)
19 | # pragma message("GLM: GLM_GTX_extend extension included")
20 | #endif
21 |
22 | namespace glm
23 | {
24 | /// @addtogroup gtx_scalar_relational
25 | /// @{
26 |
27 |
28 |
29 | /// @}
30 | }//namespace glm
31 |
32 | #include "scalar_relational.inl"
33 |
--------------------------------------------------------------------------------
/glm/gtx/matrix_cross_product.inl:
--------------------------------------------------------------------------------
1 | /// @ref gtx_matrix_cross_product
2 | /// @file glm/gtx/matrix_cross_product.inl
3 |
4 | namespace glm
5 | {
6 | template
7 | GLM_FUNC_QUALIFIER tmat3x3 matrixCross3
8 | (
9 | tvec3 const & x
10 | )
11 | {
12 | tmat3x3 Result(T(0));
13 | Result[0][1] = x.z;
14 | Result[1][0] = -x.z;
15 | Result[0][2] = -x.y;
16 | Result[2][0] = x.y;
17 | Result[1][2] = x.x;
18 | Result[2][1] = -x.x;
19 | return Result;
20 | }
21 |
22 | template
23 | GLM_FUNC_QUALIFIER tmat4x4 matrixCross4
24 | (
25 | tvec3 const & x
26 | )
27 | {
28 | tmat4x4 Result(T(0));
29 | Result[0][1] = x.z;
30 | Result[1][0] = -x.z;
31 | Result[0][2] = -x.y;
32 | Result[2][0] = x.y;
33 | Result[1][2] = x.x;
34 | Result[2][1] = -x.x;
35 | return Result;
36 | }
37 |
38 | }//namespace glm
39 |
--------------------------------------------------------------------------------
/glm/gtx/projection.hpp:
--------------------------------------------------------------------------------
1 | /// @ref gtx_projection
2 | /// @file glm/gtx/projection.hpp
3 | ///
4 | /// @see core (dependence)
5 | ///
6 | /// @defgroup gtx_projection GLM_GTX_projection
7 | /// @ingroup gtx
8 | ///
9 | /// @brief Projection of a vector to other one
10 | ///
11 | /// need to be included to use these functionalities.
12 |
13 | #pragma once
14 |
15 | // Dependency:
16 | #include "../geometric.hpp"
17 |
18 | #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED)
19 | # pragma message("GLM: GLM_GTX_projection extension included")
20 | #endif
21 |
22 | namespace glm
23 | {
24 | /// @addtogroup gtx_projection
25 | /// @{
26 |
27 | /// Projects x on Normal.
28 | ///
29 | /// @see gtx_projection
30 | template
31 | GLM_FUNC_DECL vecType proj(vecType const & x, vecType const & Normal);
32 |
33 | /// @}
34 | }//namespace glm
35 |
36 | #include "projection.inl"
37 |
--------------------------------------------------------------------------------
/glm/gtc/functions.inl:
--------------------------------------------------------------------------------
1 | /// @ref gtc_functions
2 | /// @file glm/gtc/functions.inl
3 |
4 | #include "../detail/func_exponential.hpp"
5 |
6 | namespace glm
7 | {
8 | template
9 | GLM_FUNC_QUALIFIER T gauss
10 | (
11 | T x,
12 | T ExpectedValue,
13 | T StandardDeviation
14 | )
15 | {
16 | return exp(-((x - ExpectedValue) * (x - ExpectedValue)) / (static_cast(2) * StandardDeviation * StandardDeviation)) / (StandardDeviation * sqrt(static_cast(6.28318530717958647692528676655900576)));
17 | }
18 |
19 | template
20 | GLM_FUNC_QUALIFIER T gauss
21 | (
22 | tvec2 const& Coord,
23 | tvec2 const& ExpectedValue,
24 | tvec2 const& StandardDeviation
25 | )
26 | {
27 | tvec2 const Squared = ((Coord - ExpectedValue) * (Coord - ExpectedValue)) / (static_cast(2) * StandardDeviation * StandardDeviation);
28 | return exp(-(Squared.x + Squared.y));
29 | }
30 | }//namespace glm
31 |
32 |
--------------------------------------------------------------------------------
/glm/gtx/polar_coordinates.inl:
--------------------------------------------------------------------------------
1 | /// @ref gtx_polar_coordinates
2 | /// @file glm/gtx/polar_coordinates.inl
3 |
4 | namespace glm
5 | {
6 | template
7 | GLM_FUNC_QUALIFIER tvec3 polar
8 | (
9 | tvec3 const & euclidean
10 | )
11 | {
12 | T const Length(length(euclidean));
13 | tvec3 const tmp(euclidean / Length);
14 | T const xz_dist(sqrt(tmp.x * tmp.x + tmp.z * tmp.z));
15 |
16 | return tvec3(
17 | asin(tmp.y), // latitude
18 | atan(tmp.x, tmp.z), // longitude
19 | xz_dist); // xz distance
20 | }
21 |
22 | template
23 | GLM_FUNC_QUALIFIER tvec3 euclidean
24 | (
25 | tvec2 const & polar
26 | )
27 | {
28 | T const latitude(polar.x);
29 | T const longitude(polar.y);
30 |
31 | return tvec3(
32 | cos(latitude) * sin(longitude),
33 | sin(latitude),
34 | cos(latitude) * cos(longitude));
35 | }
36 |
37 | }//namespace glm
38 |
--------------------------------------------------------------------------------
/glm/detail/func_exponential_simd.inl:
--------------------------------------------------------------------------------
1 | /// @ref core
2 | /// @file glm/detail/func_exponential_simd.inl
3 |
4 | #include "../simd/exponential.h"
5 |
6 | #if GLM_ARCH & GLM_ARCH_SSE2_BIT
7 |
8 | namespace glm{
9 | namespace detail
10 | {
11 | template
12 | struct compute_sqrt
13 | {
14 | GLM_FUNC_QUALIFIER static tvec4 call(tvec4 const & v)
15 | {
16 | tvec4 result(uninitialize);
17 | result.data = _mm_sqrt_ps(v.data);
18 | return result;
19 | }
20 | };
21 |
22 | template <>
23 | struct compute_sqrt
24 | {
25 | GLM_FUNC_QUALIFIER static tvec4 call(tvec4 const & v)
26 | {
27 | tvec4 result(uninitialize);
28 | result.data = glm_vec4_sqrt_lowp(v.data);
29 | return result;
30 | }
31 | };
32 | }//namespace detail
33 | }//namespace glm
34 |
35 | #endif//GLM_ARCH & GLM_ARCH_SSE2_BIT
36 |
--------------------------------------------------------------------------------
/glm/gtx/mixed_product.hpp:
--------------------------------------------------------------------------------
1 | /// @ref gtx_mixed_product
2 | /// @file glm/gtx/mixed_product.hpp
3 | ///
4 | /// @see core (dependence)
5 | ///
6 | /// @defgroup gtx_mixed_product GLM_GTX_mixed_producte
7 | /// @ingroup gtx
8 | ///
9 | /// @brief Mixed product of 3 vectors.
10 | ///
11 | /// need to be included to use these functionalities.
12 |
13 | #pragma once
14 |
15 | // Dependency:
16 | #include "../glm.hpp"
17 |
18 | #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED)
19 | # pragma message("GLM: GLM_GTX_mixed_product extension included")
20 | #endif
21 |
22 | namespace glm
23 | {
24 | /// @addtogroup gtx_mixed_product
25 | /// @{
26 |
27 | /// @brief Mixed product of 3 vectors (from GLM_GTX_mixed_product extension)
28 | template
29 | GLM_FUNC_DECL T mixedProduct(
30 | tvec3 const & v1,
31 | tvec3 const & v2,
32 | tvec3 const & v3);
33 |
34 | /// @}
35 | }// namespace glm
36 |
37 | #include "mixed_product.inl"
38 |
--------------------------------------------------------------------------------
/glm/gtx/extend.hpp:
--------------------------------------------------------------------------------
1 | /// @ref gtx_extend
2 | /// @file glm/gtx/extend.hpp
3 | ///
4 | /// @see core (dependence)
5 | ///
6 | /// @defgroup gtx_extend GLM_GTX_extend
7 | /// @ingroup gtx
8 | ///
9 | /// @brief Extend a position from a source to a position at a defined length.
10 | ///
11 | /// need to be included to use these functionalities.
12 |
13 | #pragma once
14 |
15 | // Dependency:
16 | #include "../glm.hpp"
17 |
18 | #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED)
19 | # pragma message("GLM: GLM_GTX_extend extension included")
20 | #endif
21 |
22 | namespace glm
23 | {
24 | /// @addtogroup gtx_extend
25 | /// @{
26 |
27 | /// Extends of Length the Origin position using the (Source - Origin) direction.
28 | /// @see gtx_extend
29 | template
30 | GLM_FUNC_DECL genType extend(
31 | genType const & Origin,
32 | genType const & Source,
33 | typename genType::value_type const Length);
34 |
35 | /// @}
36 | }//namespace glm
37 |
38 | #include "extend.inl"
39 |
--------------------------------------------------------------------------------
/glm/gtx/normal.hpp:
--------------------------------------------------------------------------------
1 | /// @ref gtx_normal
2 | /// @file glm/gtx/normal.hpp
3 | ///
4 | /// @see core (dependence)
5 | /// @see gtx_extented_min_max (dependence)
6 | ///
7 | /// @defgroup gtx_normal GLM_GTX_normal
8 | /// @ingroup gtx
9 | ///
10 | /// @brief Compute the normal of a triangle.
11 | ///
12 | /// need to be included to use these functionalities.
13 |
14 | #pragma once
15 |
16 | // Dependency:
17 | #include "../glm.hpp"
18 |
19 | #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED)
20 | # pragma message("GLM: GLM_GTX_normal extension included")
21 | #endif
22 |
23 | namespace glm
24 | {
25 | /// @addtogroup gtx_normal
26 | /// @{
27 |
28 | //! Computes triangle normal from triangle points.
29 | //! From GLM_GTX_normal extension.
30 | template
31 | GLM_FUNC_DECL tvec3 triangleNormal(
32 | tvec3 const & p1,
33 | tvec3 const & p2,
34 | tvec3 const & p3);
35 |
36 | /// @}
37 | }//namespace glm
38 |
39 | #include "normal.inl"
40 |
--------------------------------------------------------------------------------
/glm/gtx/perpendicular.hpp:
--------------------------------------------------------------------------------
1 | /// @ref gtx_perpendicular
2 | /// @file glm/gtx/perpendicular.hpp
3 | ///
4 | /// @see core (dependence)
5 | /// @see gtx_projection (dependence)
6 | ///
7 | /// @defgroup gtx_perpendicular GLM_GTX_perpendicular
8 | /// @ingroup gtx
9 | ///
10 | /// @brief Perpendicular of a vector from other one
11 | ///
12 | /// need to be included to use these functionalities.
13 |
14 | #pragma once
15 |
16 | // Dependency:
17 | #include "../glm.hpp"
18 | #include "../gtx/projection.hpp"
19 |
20 | #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED)
21 | # pragma message("GLM: GLM_GTX_perpendicular extension included")
22 | #endif
23 |
24 | namespace glm
25 | {
26 | /// @addtogroup gtx_perpendicular
27 | /// @{
28 |
29 | //! Projects x a perpendicular axis of Normal.
30 | //! From GLM_GTX_perpendicular extension.
31 | template
32 | GLM_FUNC_DECL vecType perp(
33 | vecType const & x,
34 | vecType const & Normal);
35 |
36 | /// @}
37 | }//namespace glm
38 |
39 | #include "perpendicular.inl"
40 |
--------------------------------------------------------------------------------
/glm/gtx/gradient_paint.inl:
--------------------------------------------------------------------------------
1 | /// @ref gtx_gradient_paint
2 | /// @file glm/gtx/gradient_paint.inl
3 |
4 | namespace glm
5 | {
6 | template
7 | GLM_FUNC_QUALIFIER T radialGradient
8 | (
9 | tvec2 const & Center,
10 | T const & Radius,
11 | tvec2 const & Focal,
12 | tvec2 const & Position
13 | )
14 | {
15 | tvec2 F = Focal - Center;
16 | tvec2 D = Position - Focal;
17 | T Radius2 = pow2(Radius);
18 | T Fx2 = pow2(F.x);
19 | T Fy2 = pow2(F.y);
20 |
21 | T Numerator = (D.x * F.x + D.y * F.y) + sqrt(Radius2 * (pow2(D.x) + pow2(D.y)) - pow2(D.x * F.y - D.y * F.x));
22 | T Denominator = Radius2 - (Fx2 + Fy2);
23 | return Numerator / Denominator;
24 | }
25 |
26 | template
27 | GLM_FUNC_QUALIFIER T linearGradient
28 | (
29 | tvec2 const & Point0,
30 | tvec2 const & Point1,
31 | tvec2 const & Position
32 | )
33 | {
34 | tvec2 Dist = Point1 - Point0;
35 | return (Dist.x * (Position.x - Point0.x) + Dist.y * (Position.y - Point0.y)) / glm::dot(Dist, Dist);
36 | }
37 | }//namespace glm
38 |
--------------------------------------------------------------------------------
/Lesson1/Lesson1/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIconFile
10 |
11 | CFBundleIdentifier
12 | $(PRODUCT_BUNDLE_IDENTIFIER)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | $(PRODUCT_NAME)
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | 1.0
21 | CFBundleVersion
22 | 1
23 | LSMinimumSystemVersion
24 | $(MACOSX_DEPLOYMENT_TARGET)
25 | NSHumanReadableCopyright
26 | Copyright © 2017年 fancy. All rights reserved.
27 | NSMainNibFile
28 | MainMenu
29 | NSPrincipalClass
30 | NSApplication
31 |
32 |
33 |
--------------------------------------------------------------------------------
/Lesson2/Lesson2/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIconFile
10 |
11 | CFBundleIdentifier
12 | $(PRODUCT_BUNDLE_IDENTIFIER)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | $(PRODUCT_NAME)
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | 1.0
21 | CFBundleVersion
22 | 1
23 | LSMinimumSystemVersion
24 | $(MACOSX_DEPLOYMENT_TARGET)
25 | NSHumanReadableCopyright
26 | Copyright © 2017年 fancy. All rights reserved.
27 | NSMainNibFile
28 | MainMenu
29 | NSPrincipalClass
30 | NSApplication
31 |
32 |
33 |
--------------------------------------------------------------------------------
/Lesson3/Lesson3/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIconFile
10 |
11 | CFBundleIdentifier
12 | $(PRODUCT_BUNDLE_IDENTIFIER)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | $(PRODUCT_NAME)
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | 1.0
21 | CFBundleVersion
22 | 1
23 | LSMinimumSystemVersion
24 | $(MACOSX_DEPLOYMENT_TARGET)
25 | NSHumanReadableCopyright
26 | Copyright © 2017年 fancy. All rights reserved.
27 | NSMainNibFile
28 | MainMenu
29 | NSPrincipalClass
30 | NSApplication
31 |
32 |
33 |
--------------------------------------------------------------------------------
/Lesson4/Lesson4/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIconFile
10 |
11 | CFBundleIdentifier
12 | $(PRODUCT_BUNDLE_IDENTIFIER)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | $(PRODUCT_NAME)
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | 1.0
21 | CFBundleVersion
22 | 1
23 | LSMinimumSystemVersion
24 | $(MACOSX_DEPLOYMENT_TARGET)
25 | NSHumanReadableCopyright
26 | Copyright © 2017年 fancy. All rights reserved.
27 | NSMainNibFile
28 | MainMenu
29 | NSPrincipalClass
30 | NSApplication
31 |
32 |
33 |
--------------------------------------------------------------------------------
/Lesson5/Lesson5/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIconFile
10 |
11 | CFBundleIdentifier
12 | $(PRODUCT_BUNDLE_IDENTIFIER)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | $(PRODUCT_NAME)
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | 1.0
21 | CFBundleVersion
22 | 1
23 | LSMinimumSystemVersion
24 | $(MACOSX_DEPLOYMENT_TARGET)
25 | NSHumanReadableCopyright
26 | Copyright © 2017年 fancy. All rights reserved.
27 | NSMainNibFile
28 | MainMenu
29 | NSPrincipalClass
30 | NSApplication
31 |
32 |
33 |
--------------------------------------------------------------------------------
/Lesson1/Lesson1/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "mac",
5 | "size" : "16x16",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "mac",
10 | "size" : "16x16",
11 | "scale" : "2x"
12 | },
13 | {
14 | "idiom" : "mac",
15 | "size" : "32x32",
16 | "scale" : "1x"
17 | },
18 | {
19 | "idiom" : "mac",
20 | "size" : "32x32",
21 | "scale" : "2x"
22 | },
23 | {
24 | "idiom" : "mac",
25 | "size" : "128x128",
26 | "scale" : "1x"
27 | },
28 | {
29 | "idiom" : "mac",
30 | "size" : "128x128",
31 | "scale" : "2x"
32 | },
33 | {
34 | "idiom" : "mac",
35 | "size" : "256x256",
36 | "scale" : "1x"
37 | },
38 | {
39 | "idiom" : "mac",
40 | "size" : "256x256",
41 | "scale" : "2x"
42 | },
43 | {
44 | "idiom" : "mac",
45 | "size" : "512x512",
46 | "scale" : "1x"
47 | },
48 | {
49 | "idiom" : "mac",
50 | "size" : "512x512",
51 | "scale" : "2x"
52 | }
53 | ],
54 | "info" : {
55 | "version" : 1,
56 | "author" : "xcode"
57 | }
58 | }
--------------------------------------------------------------------------------
/Lesson2/Lesson2/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "mac",
5 | "size" : "16x16",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "mac",
10 | "size" : "16x16",
11 | "scale" : "2x"
12 | },
13 | {
14 | "idiom" : "mac",
15 | "size" : "32x32",
16 | "scale" : "1x"
17 | },
18 | {
19 | "idiom" : "mac",
20 | "size" : "32x32",
21 | "scale" : "2x"
22 | },
23 | {
24 | "idiom" : "mac",
25 | "size" : "128x128",
26 | "scale" : "1x"
27 | },
28 | {
29 | "idiom" : "mac",
30 | "size" : "128x128",
31 | "scale" : "2x"
32 | },
33 | {
34 | "idiom" : "mac",
35 | "size" : "256x256",
36 | "scale" : "1x"
37 | },
38 | {
39 | "idiom" : "mac",
40 | "size" : "256x256",
41 | "scale" : "2x"
42 | },
43 | {
44 | "idiom" : "mac",
45 | "size" : "512x512",
46 | "scale" : "1x"
47 | },
48 | {
49 | "idiom" : "mac",
50 | "size" : "512x512",
51 | "scale" : "2x"
52 | }
53 | ],
54 | "info" : {
55 | "version" : 1,
56 | "author" : "xcode"
57 | }
58 | }
--------------------------------------------------------------------------------
/Lesson3/Lesson3/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "mac",
5 | "size" : "16x16",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "mac",
10 | "size" : "16x16",
11 | "scale" : "2x"
12 | },
13 | {
14 | "idiom" : "mac",
15 | "size" : "32x32",
16 | "scale" : "1x"
17 | },
18 | {
19 | "idiom" : "mac",
20 | "size" : "32x32",
21 | "scale" : "2x"
22 | },
23 | {
24 | "idiom" : "mac",
25 | "size" : "128x128",
26 | "scale" : "1x"
27 | },
28 | {
29 | "idiom" : "mac",
30 | "size" : "128x128",
31 | "scale" : "2x"
32 | },
33 | {
34 | "idiom" : "mac",
35 | "size" : "256x256",
36 | "scale" : "1x"
37 | },
38 | {
39 | "idiom" : "mac",
40 | "size" : "256x256",
41 | "scale" : "2x"
42 | },
43 | {
44 | "idiom" : "mac",
45 | "size" : "512x512",
46 | "scale" : "1x"
47 | },
48 | {
49 | "idiom" : "mac",
50 | "size" : "512x512",
51 | "scale" : "2x"
52 | }
53 | ],
54 | "info" : {
55 | "version" : 1,
56 | "author" : "xcode"
57 | }
58 | }
--------------------------------------------------------------------------------
/Lesson4/Lesson4/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "mac",
5 | "size" : "16x16",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "mac",
10 | "size" : "16x16",
11 | "scale" : "2x"
12 | },
13 | {
14 | "idiom" : "mac",
15 | "size" : "32x32",
16 | "scale" : "1x"
17 | },
18 | {
19 | "idiom" : "mac",
20 | "size" : "32x32",
21 | "scale" : "2x"
22 | },
23 | {
24 | "idiom" : "mac",
25 | "size" : "128x128",
26 | "scale" : "1x"
27 | },
28 | {
29 | "idiom" : "mac",
30 | "size" : "128x128",
31 | "scale" : "2x"
32 | },
33 | {
34 | "idiom" : "mac",
35 | "size" : "256x256",
36 | "scale" : "1x"
37 | },
38 | {
39 | "idiom" : "mac",
40 | "size" : "256x256",
41 | "scale" : "2x"
42 | },
43 | {
44 | "idiom" : "mac",
45 | "size" : "512x512",
46 | "scale" : "1x"
47 | },
48 | {
49 | "idiom" : "mac",
50 | "size" : "512x512",
51 | "scale" : "2x"
52 | }
53 | ],
54 | "info" : {
55 | "version" : 1,
56 | "author" : "xcode"
57 | }
58 | }
--------------------------------------------------------------------------------
/Lesson5/Lesson5/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "mac",
5 | "size" : "16x16",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "mac",
10 | "size" : "16x16",
11 | "scale" : "2x"
12 | },
13 | {
14 | "idiom" : "mac",
15 | "size" : "32x32",
16 | "scale" : "1x"
17 | },
18 | {
19 | "idiom" : "mac",
20 | "size" : "32x32",
21 | "scale" : "2x"
22 | },
23 | {
24 | "idiom" : "mac",
25 | "size" : "128x128",
26 | "scale" : "1x"
27 | },
28 | {
29 | "idiom" : "mac",
30 | "size" : "128x128",
31 | "scale" : "2x"
32 | },
33 | {
34 | "idiom" : "mac",
35 | "size" : "256x256",
36 | "scale" : "1x"
37 | },
38 | {
39 | "idiom" : "mac",
40 | "size" : "256x256",
41 | "scale" : "2x"
42 | },
43 | {
44 | "idiom" : "mac",
45 | "size" : "512x512",
46 | "scale" : "1x"
47 | },
48 | {
49 | "idiom" : "mac",
50 | "size" : "512x512",
51 | "scale" : "2x"
52 | }
53 | ],
54 | "info" : {
55 | "version" : 1,
56 | "author" : "xcode"
57 | }
58 | }
--------------------------------------------------------------------------------
/glm/gtx/extend.inl:
--------------------------------------------------------------------------------
1 | /// @ref gtx_extend
2 | /// @file glm/gtx/extend.inl
3 |
4 | namespace glm
5 | {
6 | template
7 | GLM_FUNC_QUALIFIER genType extend
8 | (
9 | genType const & Origin,
10 | genType const & Source,
11 | genType const & Distance
12 | )
13 | {
14 | return Origin + (Source - Origin) * Distance;
15 | }
16 |
17 | template
18 | GLM_FUNC_QUALIFIER tvec2 extend
19 | (
20 | tvec2 const & Origin,
21 | tvec2 const & Source,
22 | T const & Distance
23 | )
24 | {
25 | return Origin + (Source - Origin) * Distance;
26 | }
27 |
28 | template
29 | GLM_FUNC_QUALIFIER tvec3 extend
30 | (
31 | tvec3 const & Origin,
32 | tvec3 const & Source,
33 | T const & Distance
34 | )
35 | {
36 | return Origin + (Source - Origin) * Distance;
37 | }
38 |
39 | template
40 | GLM_FUNC_QUALIFIER tvec4 extend
41 | (
42 | tvec4 const & Origin,
43 | tvec4 const & Source,
44 | T const & Distance
45 | )
46 | {
47 | return Origin + (Source - Origin) * Distance;
48 | }
49 | }//namespace glm
50 |
--------------------------------------------------------------------------------
/glm/gtx/log_base.hpp:
--------------------------------------------------------------------------------
1 | /// @ref gtx_log_base
2 | /// @file glm/gtx/log_base.hpp
3 | ///
4 | /// @see core (dependence)
5 | ///
6 | /// @defgroup gtx_log_base GLM_GTX_log_base
7 | /// @ingroup gtx
8 | ///
9 | /// @brief Logarithm for any base. base can be a vector or a scalar.
10 | ///
11 | /// need to be included to use these functionalities.
12 |
13 | #pragma once
14 |
15 | // Dependency:
16 | #include "../glm.hpp"
17 |
18 | #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED)
19 | # pragma message("GLM: GLM_GTX_log_base extension included")
20 | #endif
21 |
22 | namespace glm
23 | {
24 | /// @addtogroup gtx_log_base
25 | /// @{
26 |
27 | /// Logarithm for any base.
28 | /// From GLM_GTX_log_base.
29 | template
30 | GLM_FUNC_DECL genType log(
31 | genType const & x,
32 | genType const & base);
33 |
34 | /// Logarithm for any base.
35 | /// From GLM_GTX_log_base.
36 | template class vecType>
37 | GLM_FUNC_DECL vecType sign(
38 | vecType const & x,
39 | vecType const & base);
40 |
41 | /// @}
42 | }//namespace glm
43 |
44 | #include "log_base.inl"
45 |
--------------------------------------------------------------------------------
/glm/gtx/raw_data.hpp:
--------------------------------------------------------------------------------
1 | /// @ref gtx_raw_data
2 | /// @file glm/gtx/raw_data.hpp
3 | ///
4 | /// @see core (dependence)
5 | ///
6 | /// @defgroup gtx_raw_data GLM_GTX_raw_data
7 | /// @ingroup gtx
8 | ///
9 | /// @brief Projection of a vector to other one
10 | ///
11 | /// need to be included to use these functionalities.
12 |
13 | #pragma once
14 |
15 | // Dependencies
16 | #include "../detail/setup.hpp"
17 | #include "../detail/type_int.hpp"
18 |
19 | #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED)
20 | # pragma message("GLM: GLM_GTX_raw_data extension included")
21 | #endif
22 |
23 | namespace glm
24 | {
25 | /// @addtogroup gtx_raw_data
26 | /// @{
27 |
28 | //! Type for byte numbers.
29 | //! From GLM_GTX_raw_data extension.
30 | typedef detail::uint8 byte;
31 |
32 | //! Type for word numbers.
33 | //! From GLM_GTX_raw_data extension.
34 | typedef detail::uint16 word;
35 |
36 | //! Type for dword numbers.
37 | //! From GLM_GTX_raw_data extension.
38 | typedef detail::uint32 dword;
39 |
40 | //! Type for qword numbers.
41 | //! From GLM_GTX_raw_data extension.
42 | typedef detail::uint64 qword;
43 |
44 | /// @}
45 | }// namespace glm
46 |
47 | #include "raw_data.inl"
48 |
--------------------------------------------------------------------------------
/glm/gtx/matrix_cross_product.hpp:
--------------------------------------------------------------------------------
1 | /// @ref gtx_matrix_cross_product
2 | /// @file glm/gtx/matrix_cross_product.hpp
3 | ///
4 | /// @see core (dependence)
5 | /// @see gtx_extented_min_max (dependence)
6 | ///
7 | /// @defgroup gtx_matrix_cross_product GLM_GTX_matrix_cross_product
8 | /// @ingroup gtx
9 | ///
10 | /// @brief Build cross product matrices
11 | ///
12 | /// need to be included to use these functionalities.
13 |
14 | #pragma once
15 |
16 | // Dependency:
17 | #include "../glm.hpp"
18 |
19 | #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED)
20 | # pragma message("GLM: GLM_GTX_matrix_cross_product extension included")
21 | #endif
22 |
23 | namespace glm
24 | {
25 | /// @addtogroup gtx_matrix_cross_product
26 | /// @{
27 |
28 | //! Build a cross product matrix.
29 | //! From GLM_GTX_matrix_cross_product extension.
30 | template
31 | GLM_FUNC_DECL tmat3x3 matrixCross3(
32 | tvec3 const & x);
33 |
34 | //! Build a cross product matrix.
35 | //! From GLM_GTX_matrix_cross_product extension.
36 | template
37 | GLM_FUNC_DECL tmat4x4 matrixCross4(
38 | tvec3 const & x);
39 |
40 | /// @}
41 | }//namespace glm
42 |
43 | #include "matrix_cross_product.inl"
44 |
--------------------------------------------------------------------------------
/glm/detail/precision.hpp:
--------------------------------------------------------------------------------
1 | /// @ref core
2 | /// @file glm/detail/precision.hpp
3 |
4 | #pragma once
5 |
6 | #include "setup.hpp"
7 |
8 | namespace glm
9 | {
10 | enum precision
11 | {
12 | packed_highp,
13 | packed_mediump,
14 | packed_lowp,
15 |
16 | # if GLM_HAS_ALIGNED_TYPE
17 | aligned_highp,
18 | aligned_mediump,
19 | aligned_lowp,
20 | aligned = aligned_highp,
21 | # endif
22 |
23 | highp = packed_highp,
24 | mediump = packed_mediump,
25 | lowp = packed_lowp,
26 | packed = packed_highp,
27 |
28 | # if GLM_HAS_ALIGNED_TYPE && defined(GLM_FORCE_ALIGNED)
29 | defaultp = aligned_highp
30 | # else
31 | defaultp = highp
32 | # endif
33 | };
34 |
35 | namespace detail
36 | {
37 | template
38 | struct is_aligned
39 | {
40 | static const bool value = false;
41 | };
42 |
43 | # if GLM_HAS_ALIGNED_TYPE
44 | template<>
45 | struct is_aligned
46 | {
47 | static const bool value = true;
48 | };
49 |
50 | template<>
51 | struct is_aligned
52 | {
53 | static const bool value = true;
54 | };
55 |
56 | template<>
57 | struct is_aligned
58 | {
59 | static const bool value = true;
60 | };
61 | # endif
62 | }//namespace detail
63 | }//namespace glm
64 |
--------------------------------------------------------------------------------
/glm/gtx/orthonormalize.hpp:
--------------------------------------------------------------------------------
1 | /// @ref gtx_orthonormalize
2 | /// @file glm/gtx/orthonormalize.hpp
3 | ///
4 | /// @see core (dependence)
5 | /// @see gtx_extented_min_max (dependence)
6 | ///
7 | /// @defgroup gtx_orthonormalize GLM_GTX_orthonormalize
8 | /// @ingroup gtx
9 | ///
10 | /// @brief Orthonormalize matrices.
11 | ///
12 | /// need to be included to use these functionalities.
13 |
14 | #pragma once
15 |
16 | // Dependency:
17 | #include "../vec3.hpp"
18 | #include "../mat3x3.hpp"
19 | #include "../geometric.hpp"
20 |
21 | #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED)
22 | # pragma message("GLM: GLM_GTX_orthonormalize extension included")
23 | #endif
24 |
25 | namespace glm
26 | {
27 | /// @addtogroup gtx_orthonormalize
28 | /// @{
29 |
30 | /// Returns the orthonormalized matrix of m.
31 | ///
32 | /// @see gtx_orthonormalize
33 | template
34 | GLM_FUNC_DECL tmat3x3 orthonormalize(tmat3x3 const & m);
35 |
36 | /// Orthonormalizes x according y.
37 | ///
38 | /// @see gtx_orthonormalize
39 | template
40 | GLM_FUNC_DECL tvec3 orthonormalize(tvec3 const & x, tvec3 const & y);
41 |
42 | /// @}
43 | }//namespace glm
44 |
45 | #include "orthonormalize.inl"
46 |
--------------------------------------------------------------------------------
/glm/gtx/polar_coordinates.hpp:
--------------------------------------------------------------------------------
1 | /// @ref gtx_polar_coordinates
2 | /// @file glm/gtx/polar_coordinates.hpp
3 | ///
4 | /// @see core (dependence)
5 | ///
6 | /// @defgroup gtx_polar_coordinates GLM_GTX_polar_coordinates
7 | /// @ingroup gtx
8 | ///
9 | /// @brief Conversion from Euclidean space to polar space and revert.
10 | ///
11 | /// need to be included to use these functionalities.
12 |
13 | #pragma once
14 |
15 | // Dependency:
16 | #include "../glm.hpp"
17 |
18 | #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED)
19 | # pragma message("GLM: GLM_GTX_polar_coordinates extension included")
20 | #endif
21 |
22 | namespace glm
23 | {
24 | /// @addtogroup gtx_polar_coordinates
25 | /// @{
26 |
27 | /// Convert Euclidean to Polar coordinates, x is the xz distance, y, the latitude and z the longitude.
28 | ///
29 | /// @see gtx_polar_coordinates
30 | template
31 | GLM_FUNC_DECL tvec3 polar(
32 | tvec3 const & euclidean);
33 |
34 | /// Convert Polar to Euclidean coordinates.
35 | ///
36 | /// @see gtx_polar_coordinates
37 | template
38 | GLM_FUNC_DECL tvec3 euclidean(
39 | tvec2 const & polar);
40 |
41 | /// @}
42 | }//namespace glm
43 |
44 | #include "polar_coordinates.inl"
45 |
--------------------------------------------------------------------------------
/glm/gtx/closest_point.hpp:
--------------------------------------------------------------------------------
1 | /// @ref gtx_closest_point
2 | /// @file glm/gtx/closest_point.hpp
3 | ///
4 | /// @see core (dependence)
5 | ///
6 | /// @defgroup gtx_closest_point GLM_GTX_closest_point
7 | /// @ingroup gtx
8 | ///
9 | /// @brief Find the point on a straight line which is the closet of a point.
10 | ///
11 | /// need to be included to use these functionalities.
12 |
13 | #pragma once
14 |
15 | // Dependency:
16 | #include "../glm.hpp"
17 |
18 | #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED)
19 | # pragma message("GLM: GLM_GTX_closest_point extension included")
20 | #endif
21 |
22 | namespace glm
23 | {
24 | /// @addtogroup gtx_closest_point
25 | /// @{
26 |
27 | /// Find the point on a straight line which is the closet of a point.
28 | /// @see gtx_closest_point
29 | template
30 | GLM_FUNC_DECL tvec3 closestPointOnLine(
31 | tvec3 const & point,
32 | tvec3 const & a,
33 | tvec3 const & b);
34 |
35 | /// 2d lines work as well
36 | template
37 | GLM_FUNC_DECL tvec2 closestPointOnLine(
38 | tvec2 const & point,
39 | tvec2 const & a,
40 | tvec2 const & b);
41 |
42 | /// @}
43 | }// namespace glm
44 |
45 | #include "closest_point.inl"
46 |
--------------------------------------------------------------------------------
/glm/gtx/optimum_pow.hpp:
--------------------------------------------------------------------------------
1 | /// @ref gtx_optimum_pow
2 | /// @file glm/gtx/optimum_pow.hpp
3 | ///
4 | /// @see core (dependence)
5 | ///
6 | /// @defgroup gtx_optimum_pow GLM_GTX_optimum_pow
7 | /// @ingroup gtx
8 | ///
9 | /// @brief Integer exponentiation of power functions.
10 | ///
11 | /// need to be included to use these functionalities.
12 |
13 | #pragma once
14 |
15 | // Dependency:
16 | #include "../glm.hpp"
17 |
18 | #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED)
19 | # pragma message("GLM: GLM_GTX_optimum_pow extension included")
20 | #endif
21 |
22 | namespace glm{
23 | namespace gtx
24 | {
25 | /// @addtogroup gtx_optimum_pow
26 | /// @{
27 |
28 | /// Returns x raised to the power of 2.
29 | ///
30 | /// @see gtx_optimum_pow
31 | template
32 | GLM_FUNC_DECL genType pow2(genType const & x);
33 |
34 | /// Returns x raised to the power of 3.
35 | ///
36 | /// @see gtx_optimum_pow
37 | template
38 | GLM_FUNC_DECL genType pow3(genType const & x);
39 |
40 | /// Returns x raised to the power of 4.
41 | ///
42 | /// @see gtx_optimum_pow
43 | template
44 | GLM_FUNC_DECL genType pow4(genType const & x);
45 |
46 | /// @}
47 | }//namespace gtx
48 | }//namespace glm
49 |
50 | #include "optimum_pow.inl"
51 |
--------------------------------------------------------------------------------
/glm/gtc/functions.hpp:
--------------------------------------------------------------------------------
1 | /// @ref gtc_functions
2 | /// @file glm/gtc/functions.hpp
3 | ///
4 | /// @see core (dependence)
5 | /// @see gtc_half_float (dependence)
6 | /// @see gtc_quaternion (dependence)
7 | ///
8 | /// @defgroup gtc_functions GLM_GTC_functions
9 | /// @ingroup gtc
10 | ///
11 | /// @brief List of useful common functions.
12 | ///
13 | /// need to be included to use these functionalities.
14 |
15 | #pragma once
16 |
17 | // Dependencies
18 | #include "../detail/setup.hpp"
19 | #include "../detail/precision.hpp"
20 | #include "../detail/type_vec2.hpp"
21 |
22 | #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED)
23 | # pragma message("GLM: GLM_GTC_functions extension included")
24 | #endif
25 |
26 | namespace glm
27 | {
28 | /// @addtogroup gtc_functions
29 | /// @{
30 |
31 | /// 1D gauss function
32 | ///
33 | /// @see gtc_epsilon
34 | template
35 | GLM_FUNC_DECL T gauss(
36 | T x,
37 | T ExpectedValue,
38 | T StandardDeviation);
39 |
40 | /// 2D gauss function
41 | ///
42 | /// @see gtc_epsilon
43 | template
44 | GLM_FUNC_DECL T gauss(
45 | tvec2 const& Coord,
46 | tvec2 const& ExpectedValue,
47 | tvec2 const& StandardDeviation);
48 |
49 | /// @}
50 | }//namespace glm
51 |
52 | #include "functions.inl"
53 |
54 |
--------------------------------------------------------------------------------
/Lesson3/Lesson3/FLOpenGLView.swift:
--------------------------------------------------------------------------------
1 | //
2 | // FLOpenGLView.swift
3 | // CocoaOpenGl
4 | //
5 | // Created by fancymax on 12/22/2016.
6 | // Copyright © 2016年 fancy. All rights reserved.
7 | //
8 |
9 | import Cocoa
10 |
11 |
12 | class FLOpenGLView: NSOpenGLView {
13 |
14 | var texture1: Texture?
15 | var texture2: Texture?
16 |
17 | override func awakeFromNib()
18 | {
19 | let attr = [
20 | NSOpenGLPixelFormatAttribute(NSOpenGLPFAOpenGLProfile),
21 | NSOpenGLPixelFormatAttribute(NSOpenGLProfileVersion3_2Core),
22 | NSOpenGLPixelFormatAttribute(NSOpenGLPFAColorSize), 24,
23 | NSOpenGLPixelFormatAttribute(NSOpenGLPFAAlphaSize), 8,
24 | NSOpenGLPixelFormatAttribute(NSOpenGLPFADoubleBuffer),
25 | NSOpenGLPixelFormatAttribute(NSOpenGLPFADepthSize), 32,
26 | 0
27 | ]
28 |
29 | let format = NSOpenGLPixelFormat(attributes: attr)
30 | let context = NSOpenGLContext(format: format!, share: nil)
31 |
32 | self.openGLContext = context
33 | self.openGLContext?.makeCurrentContext()
34 | }
35 |
36 | override func reshape() {
37 | let frame = self.frame
38 | glViewport(0, 0, GLsizei(frame.width), GLsizei(frame.height))
39 | }
40 |
41 | func flush() {
42 | self.openGLContext?.flushBuffer()
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/glm/gtx/closest_point.inl:
--------------------------------------------------------------------------------
1 | /// @ref gtx_closest_point
2 | /// @file glm/gtx/closest_point.inl
3 |
4 | namespace glm
5 | {
6 | template
7 | GLM_FUNC_QUALIFIER tvec3 closestPointOnLine
8 | (
9 | tvec3 const & point,
10 | tvec3 const & a,
11 | tvec3 const & b
12 | )
13 | {
14 | T LineLength = distance(a, b);
15 | tvec3 Vector = point - a;
16 | tvec3 LineDirection = (b - a) / LineLength;
17 |
18 | // Project Vector to LineDirection to get the distance of point from a
19 | T Distance = dot(Vector, LineDirection);
20 |
21 | if(Distance <= T(0)) return a;
22 | if(Distance >= LineLength) return b;
23 | return a + LineDirection * Distance;
24 | }
25 |
26 | template
27 | GLM_FUNC_QUALIFIER tvec2 closestPointOnLine
28 | (
29 | tvec2 const & point,
30 | tvec2 const & a,
31 | tvec2 const & b
32 | )
33 | {
34 | T LineLength = distance(a, b);
35 | tvec2 Vector = point - a;
36 | tvec2 LineDirection = (b - a) / LineLength;
37 |
38 | // Project Vector to LineDirection to get the distance of point from a
39 | T Distance = dot(Vector, LineDirection);
40 |
41 | if(Distance <= T(0)) return a;
42 | if(Distance >= LineLength) return b;
43 | return a + LineDirection * Distance;
44 | }
45 |
46 | }//namespace glm
47 |
--------------------------------------------------------------------------------
/glm/gtx/matrix_decompose.hpp:
--------------------------------------------------------------------------------
1 | /// @ref gtx_matrix_decompose
2 | /// @file glm/gtx/matrix_decompose.hpp
3 | ///
4 | /// @see core (dependence)
5 | ///
6 | /// @defgroup gtx_matrix_decompose GLM_GTX_matrix_decompose
7 | /// @ingroup gtx
8 | ///
9 | /// @brief Decomposes a model matrix to translations, rotation and scale components
10 | ///
11 | /// need to be included to use these functionalities.
12 |
13 | #pragma once
14 |
15 | // Dependencies
16 | #include "../mat4x4.hpp"
17 | #include "../vec3.hpp"
18 | #include "../vec4.hpp"
19 | #include "../geometric.hpp"
20 | #include "../gtc/quaternion.hpp"
21 | #include "../gtc/matrix_transform.hpp"
22 |
23 | #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED)
24 | # pragma message("GLM: GLM_GTX_matrix_decompose extension included")
25 | #endif
26 |
27 | namespace glm
28 | {
29 | /// @addtogroup gtx_matrix_decompose
30 | /// @{
31 |
32 | /// Decomposes a model matrix to translations, rotation and scale components
33 | /// @see gtx_matrix_decompose
34 | template
35 | GLM_FUNC_DECL bool decompose(
36 | tmat4x4 const & modelMatrix,
37 | tvec3 & scale, tquat & orientation, tvec3 & translation, tvec3 & skew, tvec4 & perspective);
38 |
39 | /// @}
40 | }//namespace glm
41 |
42 | #include "matrix_decompose.inl"
43 |
--------------------------------------------------------------------------------
/glm/gtx/string_cast.hpp:
--------------------------------------------------------------------------------
1 | /// @ref gtx_string_cast
2 | /// @file glm/gtx/string_cast.hpp
3 | ///
4 | /// @see core (dependence)
5 | /// @see gtc_half_float (dependence)
6 | /// @see gtx_integer (dependence)
7 | /// @see gtx_quaternion (dependence)
8 | ///
9 | /// @defgroup gtx_string_cast GLM_GTX_string_cast
10 | /// @ingroup gtx
11 | ///
12 | /// @brief Setup strings for GLM type values
13 | ///
14 | /// need to be included to use these functionalities.
15 | /// This extension is not supported with CUDA
16 |
17 | #pragma once
18 |
19 | // Dependency:
20 | #include "../glm.hpp"
21 | #include "../gtc/type_precision.hpp"
22 | #include "../gtc/quaternion.hpp"
23 | #include "../gtx/dual_quaternion.hpp"
24 | #include
25 |
26 | #if(GLM_COMPILER & GLM_COMPILER_CUDA)
27 | # error "GLM_GTX_string_cast is not supported on CUDA compiler"
28 | #endif
29 |
30 | #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED)
31 | # pragma message("GLM: GLM_GTX_string_cast extension included")
32 | #endif
33 |
34 | namespace glm
35 | {
36 | /// @addtogroup gtx_string_cast
37 | /// @{
38 |
39 | /// Create a string from a GLM vector or matrix typed variable.
40 | /// @see gtx_string_cast extension.
41 | template class matType, typename T, precision P>
42 | GLM_FUNC_DECL std::string to_string(matType const & x);
43 |
44 | /// @}
45 | }//namespace glm
46 |
47 | #include "string_cast.inl"
48 |
--------------------------------------------------------------------------------
/glm/gtx/gradient_paint.hpp:
--------------------------------------------------------------------------------
1 | /// @ref gtx_gradient_paint
2 | /// @file glm/gtx/gradient_paint.hpp
3 | ///
4 | /// @see core (dependence)
5 | /// @see gtx_optimum_pow (dependence)
6 | ///
7 | /// @defgroup gtx_gradient_paint GLM_GTX_gradient_paint
8 | /// @ingroup gtx
9 | ///
10 | /// @brief Functions that return the color of procedural gradient for specific coordinates.
11 | /// need to be included to use these functionalities.
12 |
13 | #pragma once
14 |
15 | // Dependency:
16 | #include "../glm.hpp"
17 | #include "../gtx/optimum_pow.hpp"
18 |
19 | #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED)
20 | # pragma message("GLM: GLM_GTX_gradient_paint extension included")
21 | #endif
22 |
23 | namespace glm
24 | {
25 | /// @addtogroup gtx_gradient_paint
26 | /// @{
27 |
28 | /// Return a color from a radial gradient.
29 | /// @see - gtx_gradient_paint
30 | template
31 | GLM_FUNC_DECL T radialGradient(
32 | tvec2 const & Center,
33 | T const & Radius,
34 | tvec2 const & Focal,
35 | tvec2 const & Position);
36 |
37 | /// Return a color from a linear gradient.
38 | /// @see - gtx_gradient_paint
39 | template
40 | GLM_FUNC_DECL T linearGradient(
41 | tvec2 const & Point0,
42 | tvec2 const & Point1,
43 | tvec2 const & Position);
44 |
45 | /// @}
46 | }// namespace glm
47 |
48 | #include "gradient_paint.inl"
49 |
--------------------------------------------------------------------------------
/glm/gtx/wrap.hpp:
--------------------------------------------------------------------------------
1 | /// @ref gtx_wrap
2 | /// @file glm/gtx/wrap.hpp
3 | ///
4 | /// @see core (dependence)
5 | ///
6 | /// @defgroup gtx_wrap GLM_GTX_wrap
7 | /// @ingroup gtx
8 | ///
9 | /// @brief Wrapping mode of texture coordinates.
10 | ///
11 | /// need to be included to use these functionalities.
12 |
13 | #pragma once
14 |
15 | // Dependency:
16 | #include "../glm.hpp"
17 | #include "../gtc/vec1.hpp"
18 |
19 | #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED)
20 | # pragma message("GLM: GLM_GTX_wrap extension included")
21 | #endif
22 |
23 | namespace glm
24 | {
25 | /// @addtogroup gtx_wrap
26 | /// @{
27 |
28 | /// Simulate GL_CLAMP OpenGL wrap mode
29 | /// @see gtx_wrap extension.
30 | template
31 | GLM_FUNC_DECL genType clamp(genType const& Texcoord);
32 |
33 | /// Simulate GL_REPEAT OpenGL wrap mode
34 | /// @see gtx_wrap extension.
35 | template
36 | GLM_FUNC_DECL genType repeat(genType const& Texcoord);
37 |
38 | /// Simulate GL_MIRRORED_REPEAT OpenGL wrap mode
39 | /// @see gtx_wrap extension.
40 | template
41 | GLM_FUNC_DECL genType mirrorClamp(genType const& Texcoord);
42 |
43 | /// Simulate GL_MIRROR_REPEAT OpenGL wrap mode
44 | /// @see gtx_wrap extension.
45 | template
46 | GLM_FUNC_DECL genType mirrorRepeat(genType const& Texcoord);
47 |
48 | /// @}
49 | }// namespace glm
50 |
51 | #include "wrap.inl"
52 |
--------------------------------------------------------------------------------
/glm/gtc/matrix_access.inl:
--------------------------------------------------------------------------------
1 | /// @ref gtc_matrix_access
2 | /// @file glm/gtc/matrix_access.inl
3 |
4 | namespace glm
5 | {
6 | template
7 | GLM_FUNC_QUALIFIER genType row
8 | (
9 | genType const & m,
10 | length_t index,
11 | typename genType::row_type const & x
12 | )
13 | {
14 | assert(index >= 0 && index < m[0].length());
15 |
16 | genType Result = m;
17 | for(length_t i = 0; i < m.length(); ++i)
18 | Result[i][index] = x[i];
19 | return Result;
20 | }
21 |
22 | template
23 | GLM_FUNC_QUALIFIER typename genType::row_type row
24 | (
25 | genType const & m,
26 | length_t index
27 | )
28 | {
29 | assert(index >= 0 && index < m[0].length());
30 |
31 | typename genType::row_type Result;
32 | for(length_t i = 0; i < m.length(); ++i)
33 | Result[i] = m[i][index];
34 | return Result;
35 | }
36 |
37 | template
38 | GLM_FUNC_QUALIFIER genType column
39 | (
40 | genType const & m,
41 | length_t index,
42 | typename genType::col_type const & x
43 | )
44 | {
45 | assert(index >= 0 && index < m.length());
46 |
47 | genType Result = m;
48 | Result[index] = x;
49 | return Result;
50 | }
51 |
52 | template
53 | GLM_FUNC_QUALIFIER typename genType::col_type column
54 | (
55 | genType const & m,
56 | length_t index
57 | )
58 | {
59 | assert(index >= 0 && index < m.length());
60 |
61 | return m[index];
62 | }
63 | }//namespace glm
64 |
--------------------------------------------------------------------------------
/glm/gtx/handed_coordinate_space.hpp:
--------------------------------------------------------------------------------
1 | /// @ref gtx_handed_coordinate_space
2 | /// @file glm/gtx/handed_coordinate_space.hpp
3 | ///
4 | /// @see core (dependence)
5 | ///
6 | /// @defgroup gtx_handed_coordinate_space GLM_GTX_handed_coordinate_space
7 | /// @ingroup gtx
8 | ///
9 | /// @brief To know if a set of three basis vectors defines a right or left-handed coordinate system.
10 | ///
11 | /// need to be included to use these functionalities.
12 |
13 | #pragma once
14 |
15 | // Dependency:
16 | #include "../glm.hpp"
17 |
18 | #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED)
19 | # pragma message("GLM: GLM_GTX_handed_coordinate_space extension included")
20 | #endif
21 |
22 | namespace glm
23 | {
24 | /// @addtogroup gtx_handed_coordinate_space
25 | /// @{
26 |
27 | //! Return if a trihedron right handed or not.
28 | //! From GLM_GTX_handed_coordinate_space extension.
29 | template
30 | GLM_FUNC_DECL bool rightHanded(
31 | tvec3 const & tangent,
32 | tvec3 const & binormal,
33 | tvec3 const & normal);
34 |
35 | //! Return if a trihedron left handed or not.
36 | //! From GLM_GTX_handed_coordinate_space extension.
37 | template
38 | GLM_FUNC_DECL bool leftHanded(
39 | tvec3 const & tangent,
40 | tvec3 const & binormal,
41 | tvec3 const & normal);
42 |
43 | /// @}
44 | }// namespace glm
45 |
46 | #include "handed_coordinate_space.inl"
47 |
--------------------------------------------------------------------------------
/glm/gtx/scalar_relational.inl:
--------------------------------------------------------------------------------
1 | /// @ref gtx_scalar_relational
2 | /// @file glm/gtx/scalar_relational.inl
3 |
4 | namespace glm
5 | {
6 | template
7 | GLM_FUNC_QUALIFIER bool lessThan
8 | (
9 | T const & x,
10 | T const & y
11 | )
12 | {
13 | return x < y;
14 | }
15 |
16 | template
17 | GLM_FUNC_QUALIFIER bool lessThanEqual
18 | (
19 | T const & x,
20 | T const & y
21 | )
22 | {
23 | return x <= y;
24 | }
25 |
26 | template
27 | GLM_FUNC_QUALIFIER bool greaterThan
28 | (
29 | T const & x,
30 | T const & y
31 | )
32 | {
33 | return x > y;
34 | }
35 |
36 | template
37 | GLM_FUNC_QUALIFIER bool greaterThanEqual
38 | (
39 | T const & x,
40 | T const & y
41 | )
42 | {
43 | return x >= y;
44 | }
45 |
46 | template
47 | GLM_FUNC_QUALIFIER bool equal
48 | (
49 | T const & x,
50 | T const & y
51 | )
52 | {
53 | return x == y;
54 | }
55 |
56 | template