mirror of
https://github.com/recp/cglm.git
synced 2026-02-17 03:39:05 +00:00
Compare commits
54 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1b0322e51c | ||
|
|
4a308dcd9e | ||
|
|
fec396950b | ||
|
|
981af0565e | ||
|
|
1d215ef5f3 | ||
|
|
2b7cfde64f | ||
|
|
c783c42101 | ||
|
|
bddcfedead | ||
|
|
34e7438271 | ||
|
|
485ff6bc46 | ||
|
|
4ab9ab4772 | ||
|
|
a5ff477fc8 | ||
|
|
254570d006 | ||
|
|
681f20d540 | ||
|
|
fd87f6e2c3 | ||
|
|
2c12c6dce5 | ||
|
|
5619527fd3 | ||
|
|
8b1c3c3fc4 | ||
|
|
ec852c7682 | ||
|
|
5433c9ed6c | ||
|
|
2a2d51624b | ||
|
|
5fa908602f | ||
|
|
9da74f9654 | ||
|
|
dddb077b13 | ||
|
|
6107287c9a | ||
|
|
7dccbef6e3 | ||
|
|
d920a62be2 | ||
|
|
73f32b9ef7 | ||
|
|
2e5257bcc1 | ||
|
|
65b0b461ab | ||
|
|
e34601f578 | ||
|
|
fa01a3077b | ||
|
|
54f805a62d | ||
|
|
a05b282fad | ||
|
|
66f6bbde6c | ||
|
|
4054d9a190 | ||
|
|
c1112f0063 | ||
|
|
b62e922f32 | ||
|
|
3c53bed709 | ||
|
|
a2b6d71558 | ||
|
|
fdfceb9f5b | ||
|
|
d273daecfe | ||
|
|
92b75a1345 | ||
|
|
640795a771 | ||
|
|
cad265ebcd | ||
|
|
387c33fb4d | ||
|
|
77585de397 | ||
|
|
a9b06e4b35 | ||
|
|
7976ac78f2 | ||
|
|
208f8073ad | ||
|
|
009fb966a6 | ||
|
|
09fd9f86b9 | ||
|
|
2ff4ae0b4c | ||
|
|
aa0a195e98 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -75,3 +75,4 @@ Default-568h@2x.png
|
|||||||
build/
|
build/
|
||||||
conftest.dir/*
|
conftest.dir/*
|
||||||
confdefs.h
|
confdefs.h
|
||||||
|
*.xcuserdatad
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
cmake_minimum_required(VERSION 3.8.2)
|
cmake_minimum_required(VERSION 3.8.2)
|
||||||
project(cglm VERSION 0.7.7 LANGUAGES C)
|
project(cglm VERSION 0.8.0 LANGUAGES C)
|
||||||
|
|
||||||
set(CMAKE_C_STANDARD 11)
|
set(CMAKE_C_STANDARD 11)
|
||||||
set(CMAKE_C_STANDARD_REQUIRED YES)
|
set(CMAKE_C_STANDARD_REQUIRED YES)
|
||||||
@@ -18,11 +18,11 @@ else(CGLM_STATIC)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(CGLM_USE_C99)
|
if(CGLM_USE_C99)
|
||||||
set(C_STANDARD 99)
|
set(CMAKE_C_STANDARD 99)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
add_definitions(-DNDEBUG -D_WINDOWS -D_USRDLL -DCGLM_EXPORTS -DCGLM_DLL)
|
add_definitions(-DNDEBUG -D_WINDOWS -D_USRDLL)
|
||||||
add_compile_options(/W3 /Ox /Gy /Oi /TC)
|
add_compile_options(/W3 /Ox /Gy /Oi /TC)
|
||||||
|
|
||||||
# Ref: https://skia.googlesource.com/third_party/sdl/+/refs/heads/master/CMakeLists.txt#225
|
# Ref: https://skia.googlesource.com/third_party/sdl/+/refs/heads/master/CMakeLists.txt#225
|
||||||
@@ -75,6 +75,12 @@ add_library(${PROJECT_NAME}
|
|||||||
src/affine2d.c
|
src/affine2d.c
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if(CGLM_SHARED)
|
||||||
|
add_definitions(-DCGLM_EXPORTS)
|
||||||
|
else()
|
||||||
|
target_compile_definitions(${PROJECT_NAME} PUBLIC -DCGLM_STATIC)
|
||||||
|
endif()
|
||||||
|
|
||||||
set_target_properties(${PROJECT_NAME} PROPERTIES
|
set_target_properties(${PROJECT_NAME} PROPERTIES
|
||||||
VERSION ${PROJECT_VERSION}
|
VERSION ${PROJECT_VERSION}
|
||||||
SOVERSION ${PROJECT_VERSION_MAJOR})
|
SOVERSION ${PROJECT_VERSION_MAJOR})
|
||||||
@@ -111,6 +117,7 @@ export(TARGETS ${PROJECT_NAME}
|
|||||||
)
|
)
|
||||||
|
|
||||||
install(EXPORT ${PROJECT_NAME}
|
install(EXPORT ${PROJECT_NAME}
|
||||||
|
FILE "${PROJECT_NAME}Config.cmake"
|
||||||
NAMESPACE ${PROJECT_NAME}::
|
NAMESPACE ${PROJECT_NAME}::
|
||||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}/cmake)
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME})
|
||||||
|
|
||||||
|
|||||||
5
CREDITS
5
CREDITS
@@ -70,4 +70,7 @@ Möller–Trumbore ray-triangle intersection algorithm, from "Fast, Minimum Stor
|
|||||||
Authors:
|
Authors:
|
||||||
Thomas Möller (tompa@clarus.se)
|
Thomas Möller (tompa@clarus.se)
|
||||||
Ben Trumbore (wbt@graphics.cornell.edu)
|
Ben Trumbore (wbt@graphics.cornell.edu)
|
||||||
Link to paper: http://webserver2.tecgraf.puc-rio.br/~mgattass/cg/trbRR/Fast%20MinimumStorage%20RayTriangle%20Intersection.pdf
|
Link to paper: http://webserver2.tecgraf.puc-rio.br/~mgattass/cg/trbRR/Fast%20MinimumStorage%20RayTriangle%20Intersection.pdf
|
||||||
|
|
||||||
|
14. ARM NEON: Matrix Vector Multiplication
|
||||||
|
https://stackoverflow.com/a/57793352/2676533
|
||||||
|
|||||||
44
Package.swift
Normal file
44
Package.swift
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
// swift-tools-version:5.2
|
||||||
|
|
||||||
|
import PackageDescription
|
||||||
|
|
||||||
|
let package = Package(
|
||||||
|
name: "cglm",
|
||||||
|
products: [
|
||||||
|
.library(name: "cglm", type: .static, targets: ["cglmHeader"]),
|
||||||
|
.library(name: "cglmc", targets: ["cglmCompiled"]),
|
||||||
|
],
|
||||||
|
dependencies: [],
|
||||||
|
targets: [
|
||||||
|
.target(
|
||||||
|
name: "cglmCompiled",
|
||||||
|
path: "./",
|
||||||
|
exclude: [
|
||||||
|
"./docs",
|
||||||
|
"./src/swift",
|
||||||
|
"./include",
|
||||||
|
"./test",
|
||||||
|
"./win",
|
||||||
|
],
|
||||||
|
sources: [
|
||||||
|
"./src",
|
||||||
|
],
|
||||||
|
publicHeadersPath: "./include"
|
||||||
|
),
|
||||||
|
.target(
|
||||||
|
name: "cglmHeader",
|
||||||
|
path: "./",
|
||||||
|
exclude: [
|
||||||
|
"./docs",
|
||||||
|
"./include",
|
||||||
|
"./test",
|
||||||
|
"./win",
|
||||||
|
],
|
||||||
|
sources: [
|
||||||
|
"./src/swift",
|
||||||
|
],
|
||||||
|
publicHeadersPath: "./include"
|
||||||
|
),
|
||||||
|
],
|
||||||
|
cLanguageStandard: .c11
|
||||||
|
)
|
||||||
62
README.md
62
README.md
@@ -25,6 +25,7 @@ you have the latest version
|
|||||||
- **[new option]** by starting v0.4.5, you can disable alignment requirement, check options in docs.
|
- **[new option]** by starting v0.4.5, you can disable alignment requirement, check options in docs.
|
||||||
- **[major change]** by starting v0.5.0, vec3 functions use **glm_vec3_** namespace, it was **glm_vec_** until v0.5.0
|
- **[major change]** by starting v0.5.0, vec3 functions use **glm_vec3_** namespace, it was **glm_vec_** until v0.5.0
|
||||||
- **[major change]** by starting v0.5.1, built-in alignment is removed from **vec3** and **mat3** types
|
- **[major change]** by starting v0.5.1, built-in alignment is removed from **vec3** and **mat3** types
|
||||||
|
- **[major change]** by starting v0.7.3, inline print functions are disabled in release/production mode to eliminate print costs (see options in documentation). Print output also improved. You can disable colors if you need (see documentation)
|
||||||
|
|
||||||
#### Note for C++ developers:
|
#### Note for C++ developers:
|
||||||
If you are not aware of the original GLM library yet, you may also want to look at:
|
If you are not aware of the original GLM library yet, you may also want to look at:
|
||||||
@@ -183,6 +184,67 @@ add_subdirectory(external/cglm/)
|
|||||||
# or you can use find_package to configure cglm
|
# or you can use find_package to configure cglm
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Meson (All platforms)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ meson build # [Optional] --default-library=static
|
||||||
|
$ cd build
|
||||||
|
$ ninja
|
||||||
|
$ sudo ninja install # [Optional]
|
||||||
|
```
|
||||||
|
|
||||||
|
##### Meson options with Defaults:
|
||||||
|
|
||||||
|
```meson
|
||||||
|
c_std=c11
|
||||||
|
buildtype=release
|
||||||
|
default_library=shared
|
||||||
|
enable_tests=false # to run tests: ninja test
|
||||||
|
```
|
||||||
|
#### Use with your Meson project
|
||||||
|
* Example:
|
||||||
|
```meson
|
||||||
|
# Clone cglm or create a cglm.wrap under <source_root>/subprojects
|
||||||
|
project('name', 'c')
|
||||||
|
|
||||||
|
cglm_dep = dependency('cglm', fallback : 'cglm', 'cglm_dep')
|
||||||
|
|
||||||
|
executable('exe', 'src/main.c', dependencies : cglm_dep)
|
||||||
|
```
|
||||||
|
|
||||||
|
### Swift (Swift Package Manager)
|
||||||
|
|
||||||
|
Currently only default build options are supported. Add **cglm** dependency to your project:
|
||||||
|
|
||||||
|
```swift
|
||||||
|
...
|
||||||
|
Package(
|
||||||
|
...
|
||||||
|
dependencies: [
|
||||||
|
...
|
||||||
|
.package(url: "https://github.com/recp/cglm", .branch("master")),
|
||||||
|
]
|
||||||
|
...
|
||||||
|
)
|
||||||
|
```
|
||||||
|
|
||||||
|
Now add **cgml** as a dependency to your target. Product choices are:
|
||||||
|
- **cglm** for inlined version of the library which can be linked only statically
|
||||||
|
- **cglmc** for a compiled version of the library with no linking limitation
|
||||||
|
|
||||||
|
```swift
|
||||||
|
...
|
||||||
|
.target(
|
||||||
|
...
|
||||||
|
dependencies: [
|
||||||
|
...
|
||||||
|
.product(name: "cglm", package: "cglm"),
|
||||||
|
]
|
||||||
|
...
|
||||||
|
)
|
||||||
|
...
|
||||||
|
```
|
||||||
|
|
||||||
### Unix (Autotools)
|
### Unix (Autotools)
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
|||||||
15
cglm.podspec
15
cglm.podspec
@@ -2,10 +2,10 @@ Pod::Spec.new do |s|
|
|||||||
|
|
||||||
# Description
|
# Description
|
||||||
s.name = "cglm"
|
s.name = "cglm"
|
||||||
s.version = "0.7.2"
|
s.version = "0.7.9"
|
||||||
s.summary = "📽 Optimized OpenGL/Graphics Math (glm) for C"
|
s.summary = "📽 Highly Optimized Graphics Math (glm) for C"
|
||||||
s.description = <<-DESC
|
s.description = <<-DESC
|
||||||
cglm is math library for graphics programming for C. It is similar to original glm but it is written for C instead of C++ (you can use here too). See the documentation or README for all features.
|
cglm is math library for graphics programming for C. See the documentation or README for all features.
|
||||||
DESC
|
DESC
|
||||||
|
|
||||||
s.documentation_url = "http://cglm.readthedocs.io"
|
s.documentation_url = "http://cglm.readthedocs.io"
|
||||||
@@ -25,4 +25,13 @@ cglm is math library for graphics programming for C. It is similar to original g
|
|||||||
|
|
||||||
# Linking
|
# Linking
|
||||||
s.library = "m"
|
s.library = "m"
|
||||||
|
|
||||||
|
# Configuration
|
||||||
|
s.pod_target_xcconfig = {
|
||||||
|
'CLANG_ENABLE_MODULES' => 'NO',
|
||||||
|
'CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES' => 'YES',
|
||||||
|
'CLANG_WARN_DOCUMENTATION_COMMENTS' => 'NO',
|
||||||
|
'GCC_C_LANGUAGE_STANDARD' => 'gnu11',
|
||||||
|
'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) GLM_TESTS_NO_COLORFUL_OUTPUT'
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
#*****************************************************************************
|
#*****************************************************************************
|
||||||
|
|
||||||
AC_PREREQ([2.69])
|
AC_PREREQ([2.69])
|
||||||
AC_INIT([cglm], [0.7.7], [info@recp.me])
|
AC_INIT([cglm], [0.8.0], [info@recp.me])
|
||||||
AM_INIT_AUTOMAKE([-Wall -Werror foreign subdir-objects serial-tests])
|
AM_INIT_AUTOMAKE([-Wall -Werror foreign subdir-objects serial-tests])
|
||||||
|
|
||||||
# Don't use the default cflags (-O2 -g), we set ours manually in Makefile.am.
|
# Don't use the default cflags (-O2 -g), we set ours manually in Makefile.am.
|
||||||
|
|||||||
@@ -47,6 +47,41 @@ If you don't want to install **cglm** to your system's folder you can get static
|
|||||||
|
|
||||||
add_subdirectory(external/cglm/)
|
add_subdirectory(external/cglm/)
|
||||||
|
|
||||||
|
Meson (All platforms):
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
.. code-block::
|
||||||
|
:linenos:
|
||||||
|
|
||||||
|
$ meson build # [Optional] --default-library=static
|
||||||
|
$ cd build
|
||||||
|
$ ninja
|
||||||
|
$ sudo ninja install # [Optional]
|
||||||
|
|
||||||
|
**Meson Options:**
|
||||||
|
|
||||||
|
.. code-block::
|
||||||
|
:linenos:
|
||||||
|
|
||||||
|
c_std=c11
|
||||||
|
buildtype=release
|
||||||
|
default_library=shared
|
||||||
|
enable_tests=false # to run tests: ninja test
|
||||||
|
|
||||||
|
|
||||||
|
**Use with your Meson project**
|
||||||
|
|
||||||
|
.. code-block::
|
||||||
|
:linenos:
|
||||||
|
|
||||||
|
# Clone cglm or create a cglm.wrap under <source_root>/subprojects
|
||||||
|
project('name', 'c')
|
||||||
|
|
||||||
|
cglm_dep = dependency('cglm', fallback : 'cglm', 'cglm_dep')
|
||||||
|
|
||||||
|
executable('exe', 'src/main.c', dependencies : cglm_dep)
|
||||||
|
|
||||||
|
|
||||||
Unix (Autotools):
|
Unix (Autotools):
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
# If your documentation needs a minimal Sphinx version, state it here.
|
# If your documentation needs a minimal Sphinx version, state it here.
|
||||||
#
|
#
|
||||||
# needs_sphinx = '1.0'
|
# needs_sphinx = '3.0'
|
||||||
|
|
||||||
# Add any Sphinx extension module names here, as strings. They can be
|
# Add any Sphinx extension module names here, as strings. They can be
|
||||||
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
|
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
|
||||||
@@ -62,9 +62,9 @@ author = u'Recep Aslantas'
|
|||||||
# built documents.
|
# built documents.
|
||||||
#
|
#
|
||||||
# The short X.Y version.
|
# The short X.Y version.
|
||||||
version = u'0.7.7'
|
version = u'0.8.0'
|
||||||
# The full version, including alpha/beta/rc tags.
|
# The full version, including alpha/beta/rc tags.
|
||||||
release = u'0.7.7'
|
release = u'0.8.0'
|
||||||
|
|
||||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||||
# for a list of supported languages.
|
# for a list of supported languages.
|
||||||
@@ -197,3 +197,7 @@ epub_exclude_files = ['search.html']
|
|||||||
|
|
||||||
# If true, `todo` and `todoList` produce output, else they produce nothing.
|
# If true, `todo` and `todoList` produce output, else they produce nothing.
|
||||||
todo_include_todos = True
|
todo_include_todos = True
|
||||||
|
|
||||||
|
# -- Options for the C domain ------------------------------------------------
|
||||||
|
|
||||||
|
c_id_attributes = ['__restrict']
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ versor: 16 byte
|
|||||||
By starting **v0.4.5** cglm provides an option to disable alignment requirement.
|
By starting **v0.4.5** cglm provides an option to disable alignment requirement.
|
||||||
To enable this option define **CGLM_ALL_UNALIGNED** macro before all headers.
|
To enable this option define **CGLM_ALL_UNALIGNED** macro before all headers.
|
||||||
You can define it in Xcode, Visual Studio (or other IDEs) or you can also prefer
|
You can define it in Xcode, Visual Studio (or other IDEs) or you can also prefer
|
||||||
to define it in build system. If you use pre-compiled verisons then you
|
to define it in build system. If you use pre-compiled versions then you
|
||||||
have to compile cglm with **CGLM_ALL_UNALIGNED** macro.
|
have to compile cglm with **CGLM_ALL_UNALIGNED** macro.
|
||||||
|
|
||||||
**VERY VERY IMPORTANT:** If you use cglm in multiple projects and
|
**VERY VERY IMPORTANT:** If you use cglm in multiple projects and
|
||||||
@@ -55,11 +55,20 @@ Print Options
|
|||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
1. **CGLM_DEFINE_PRINTS**
|
1. **CGLM_DEFINE_PRINTS**
|
||||||
2. **CGLM_NO_PRINTS_NOOP**
|
2. **CGLM_NO_PRINTS_NOOP** (use CGLM_DEFINE_PRINTS)
|
||||||
|
|
||||||
Inline prints are only enabled in DEBUG mode and if **CGLM_DEFINE_PRINTS** is defined.
|
Inline prints are only enabled in **DEBUG** mode or if **CGLM_DEFINE_PRINTS** is defined.
|
||||||
If DEBUG is not enabled then print function bodies will be emptied to eliminate print function calls.
|
**glmc_** versions will always print too.
|
||||||
You can disable this feature too by defining **CGLM_NO_PRINTS_NOOP** macro top of cglm headers.
|
|
||||||
|
Because **cglm** tried to enable print functions in debug mode and disable them in
|
||||||
|
release/production mode to eliminate printing costs when we do not need them.
|
||||||
|
|
||||||
|
**cglm** checks **DEBUG** or **_DEBUG** macros to test debug mode, if these are not working for you then you can use
|
||||||
|
**CGLM_DEFINE_PRINTS** to force enable, or create a PR to introduce new macro to test against debugging mode.
|
||||||
|
|
||||||
|
If DEBUG mode is not enabled then print functions will be emptied to eliminate print function calls.
|
||||||
|
You can disable this feature too by defining **CGLM_DEFINE_PRINTS** macro top of cglm header
|
||||||
|
or in project/build settings...
|
||||||
|
|
||||||
3. **CGLM_PRINT_PRECISION** 5
|
3. **CGLM_PRINT_PRECISION** 5
|
||||||
|
|
||||||
@@ -71,3 +80,6 @@ if a number is greater than this value then %g will be used, since this is short
|
|||||||
|
|
||||||
5. **CGLM_PRINT_COLOR** "\033[36m"
|
5. **CGLM_PRINT_COLOR** "\033[36m"
|
||||||
6. **CGLM_PRINT_COLOR_RESET** "\033[0m"
|
6. **CGLM_PRINT_COLOR_RESET** "\033[0m"
|
||||||
|
|
||||||
|
You can disable colorful print output by defining **CGLM_PRINT_COLOR** and **CGLM_PRINT_COLOR_RESET** as empty macro.
|
||||||
|
Because some terminals may not support colors.
|
||||||
|
|||||||
@@ -374,7 +374,7 @@ Functions documentation
|
|||||||
| *[in]* **q** quaternion
|
| *[in]* **q** quaternion
|
||||||
| *[in]* **pivot** pivot
|
| *[in]* **pivot** pivot
|
||||||
|
|
||||||
.. c:function:: void glm_quat_rotate(mat4 m, versor q, mat4 dest)
|
.. c:function:: void glm_quat_rotate_atm(mat4 m, versor q, vec3 pivot)
|
||||||
|
|
||||||
| rotate NEW transform matrix using quaternion at pivot point
|
| rotate NEW transform matrix using quaternion at pivot point
|
||||||
| this creates rotation matrix, it assumes you don't have a matrix
|
| this creates rotation matrix, it assumes you don't have a matrix
|
||||||
|
|||||||
@@ -55,12 +55,12 @@ Functions:
|
|||||||
Functions documentation
|
Functions documentation
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
.. c:function:: void glm_vec2(vec4 v4, vec2 dest)
|
.. c:function:: void glm_vec2(float * v, vec2 dest)
|
||||||
|
|
||||||
init vec2 using vec3
|
init vec2 using vec3 or vec4
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
| *[in]* **v3** vector3
|
| *[in]* **v** vector
|
||||||
| *[out]* **dest** destination
|
| *[out]* **dest** destination
|
||||||
|
|
||||||
.. c:function:: void glm_vec2_copy(vec2 a, vec2 dest)
|
.. c:function:: void glm_vec2_copy(vec2 a, vec2 dest)
|
||||||
|
|||||||
@@ -455,7 +455,7 @@ glm_decompose_rs(mat4 m, mat4 r, vec3 s) {
|
|||||||
glm_vec4_scale(r[1], 1.0f/s[1], r[1]);
|
glm_vec4_scale(r[1], 1.0f/s[1], r[1]);
|
||||||
glm_vec4_scale(r[2], 1.0f/s[2], r[2]);
|
glm_vec4_scale(r[2], 1.0f/s[2], r[2]);
|
||||||
|
|
||||||
/* Note from Apple Open Source (asume that the matrix is orthonormal):
|
/* Note from Apple Open Source (assume that the matrix is orthonormal):
|
||||||
check for a coordinate system flip. If the determinant
|
check for a coordinate system flip. If the determinant
|
||||||
is -1, then negate the matrix and the scaling factors. */
|
is -1, then negate the matrix and the scaling factors. */
|
||||||
glm_vec3_cross(m[0], m[1], v);
|
glm_vec3_cross(m[0], m[1], v);
|
||||||
|
|||||||
@@ -228,6 +228,8 @@ glm_aabb_aabb(vec3 box[2], vec3 other[2]) {
|
|||||||
* https://github.com/erich666/GraphicsGems/blob/master/gems/BoxSphere.c
|
* https://github.com/erich666/GraphicsGems/blob/master/gems/BoxSphere.c
|
||||||
* Solid Box - Solid Sphere test.
|
* Solid Box - Solid Sphere test.
|
||||||
*
|
*
|
||||||
|
* Sphere Representation in cglm: [center.x, center.y, center.z, radii]
|
||||||
|
*
|
||||||
* @param[in] box solid bounding box
|
* @param[in] box solid bounding box
|
||||||
* @param[in] s solid sphere
|
* @param[in] s solid sphere
|
||||||
*/
|
*/
|
||||||
@@ -237,13 +239,13 @@ glm_aabb_sphere(vec3 box[2], vec4 s) {
|
|||||||
float dmin;
|
float dmin;
|
||||||
int a, b, c;
|
int a, b, c;
|
||||||
|
|
||||||
a = s[0] >= box[0][0];
|
a = (s[0] < box[0][0]) + (s[0] > box[1][0]);
|
||||||
b = s[1] >= box[0][1];
|
b = (s[1] < box[0][1]) + (s[1] > box[1][1]);
|
||||||
c = s[2] >= box[0][2];
|
c = (s[2] < box[0][2]) + (s[2] > box[1][2]);
|
||||||
|
|
||||||
dmin = glm_pow2(s[0] - box[a][0])
|
dmin = glm_pow2((s[0] - box[!(a - 1)][0]) * (a != 0))
|
||||||
+ glm_pow2(s[1] - box[b][1])
|
+ glm_pow2((s[1] - box[!(b - 1)][1]) * (b != 0))
|
||||||
+ glm_pow2(s[2] - box[c][2]);
|
+ glm_pow2((s[2] - box[!(c - 1)][2]) * (c != 0));
|
||||||
|
|
||||||
return dmin <= glm_pow2(s[3]);
|
return dmin <= glm_pow2(s[3]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,9 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
# ifdef CGLM_DLL
|
# ifdef CGLM_STATIC
|
||||||
|
# define CGLM_EXPORT
|
||||||
|
# elif defined(CGLM_EXPORTS)
|
||||||
# define CGLM_EXPORT __declspec(dllexport)
|
# define CGLM_EXPORT __declspec(dllexport)
|
||||||
# else
|
# else
|
||||||
# define CGLM_EXPORT __declspec(dllimport)
|
# define CGLM_EXPORT __declspec(dllimport)
|
||||||
|
|||||||
@@ -15,20 +15,49 @@
|
|||||||
CGLM_INLINE void glm_versor_print(versor vec, FILE *ostream);
|
CGLM_INLINE void glm_versor_print(versor vec, FILE *ostream);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
cglm tried to enable print functions in debug mode and disable them in
|
||||||
|
release/production mode to eliminate printing costs.
|
||||||
|
|
||||||
|
if you need to force enable then define CGLM_DEFINE_PRINTS macro not DEBUG one
|
||||||
|
|
||||||
|
Print functions are enabled if:
|
||||||
|
|
||||||
|
- DEBUG or _DEBUG macro is defined (mostly defined automatically in debugging)
|
||||||
|
- CGLM_DEFINE_PRINTS macro is defined including release/production
|
||||||
|
which makes enabled printing always
|
||||||
|
- glmc_ calls for io are always prints
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* DEPRECATED: CGLM_NO_PRINTS_NOOP (use CGLM_DEFINE_PRINTS) */
|
||||||
|
|
||||||
#ifndef cglm_io_h
|
#ifndef cglm_io_h
|
||||||
#define cglm_io_h
|
#define cglm_io_h
|
||||||
#if defined(DEBUG) || defined(_DEBUG) \
|
#if defined(DEBUG) || defined(_DEBUG) \
|
||||||
|| defined(CGLM_DEFINE_PRINTS) || defined(CGLM_LIB_SRC)
|
|| defined(CGLM_DEFINE_PRINTS) || defined(CGLM_LIB_SRC) \
|
||||||
|
|| defined(CGLM_NO_PRINTS_NOOP)
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#define CGLM_PRINT_PRECISION 5
|
#ifndef CGLM_PRINT_PRECISION
|
||||||
#define CGLM_PRINT_MAX_TO_SHORT 1e5
|
# define CGLM_PRINT_PRECISION 5
|
||||||
#define CGLM_PRINT_COLOR "\033[36m"
|
#endif
|
||||||
#define CGLM_PRINT_COLOR_RESET "\033[0m"
|
|
||||||
|
#ifndef CGLM_PRINT_MAX_TO_SHORT
|
||||||
|
# define CGLM_PRINT_MAX_TO_SHORT 1e5
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef CGLM_PRINT_COLOR
|
||||||
|
# define CGLM_PRINT_COLOR "\033[36m"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef CGLM_PRINT_COLOR_RESET
|
||||||
|
# define CGLM_PRINT_COLOR_RESET "\033[0m"
|
||||||
|
#endif
|
||||||
|
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
@@ -293,7 +322,7 @@ glm_aabb_print(vec3 bbox[2],
|
|||||||
#undef m
|
#undef m
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif !defined(CGLM_NO_PRINTS_NOOP)
|
#else
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
@@ -301,15 +330,15 @@ glm_aabb_print(vec3 bbox[2],
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
/* NOOP: Remove print from DEBUG */
|
/* NOOP: Remove print from DEBUG */
|
||||||
#define glm_mat4_print(...)
|
#define glm_mat4_print(v, s) (void)v; (void)s;
|
||||||
#define glm_mat3_print(...)
|
#define glm_mat3_print(v, s) (void)v; (void)s;
|
||||||
#define glm_mat2_print(...)
|
#define glm_mat2_print(v, s) (void)v; (void)s;
|
||||||
#define glm_vec4_print(...)
|
#define glm_vec4_print(v, s) (void)v; (void)s;
|
||||||
#define glm_vec3_print(...)
|
#define glm_vec3_print(v, s) (void)v; (void)s;
|
||||||
#define glm_ivec3_print(...)
|
#define glm_ivec3_print(v, s) (void)v; (void)s;
|
||||||
#define glm_vec2_print(...)
|
#define glm_vec2_print(v, s) (void)v; (void)s;
|
||||||
#define glm_versor_print(...)
|
#define glm_versor_print(v, s) (void)v; (void)s;
|
||||||
#define glm_aabb_print(...)
|
#define glm_aabb_print(v, t, s) (void)v; (void)t; (void)s;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
#endif /* cglm_io_h */
|
#endif /* cglm_io_h */
|
||||||
|
|||||||
@@ -358,6 +358,8 @@ void
|
|||||||
glm_mat4_mulv(mat4 m, vec4 v, vec4 dest) {
|
glm_mat4_mulv(mat4 m, vec4 v, vec4 dest) {
|
||||||
#if defined( __SSE__ ) || defined( __SSE2__ )
|
#if defined( __SSE__ ) || defined( __SSE2__ )
|
||||||
glm_mat4_mulv_sse2(m, v, dest);
|
glm_mat4_mulv_sse2(m, v, dest);
|
||||||
|
#elif defined(CGLM_NEON_FP)
|
||||||
|
glm_mat4_mulv_neon(m, v, dest);
|
||||||
#else
|
#else
|
||||||
vec4 res;
|
vec4 res;
|
||||||
res[0] = m[0][0] * v[0] + m[1][0] * v[1] + m[2][0] * v[2] + m[3][0] * v[3];
|
res[0] = m[0][0] * v[0] + m[1][0] * v[1] + m[2][0] * v[2] + m[3][0] * v[3];
|
||||||
@@ -476,6 +478,8 @@ void
|
|||||||
glm_mat4_transpose_to(mat4 m, mat4 dest) {
|
glm_mat4_transpose_to(mat4 m, mat4 dest) {
|
||||||
#if defined( __SSE__ ) || defined( __SSE2__ )
|
#if defined( __SSE__ ) || defined( __SSE2__ )
|
||||||
glm_mat4_transp_sse2(m, dest);
|
glm_mat4_transp_sse2(m, dest);
|
||||||
|
#elif defined(CGLM_NEON_FP)
|
||||||
|
glm_mat4_transp_neon(m, dest);
|
||||||
#else
|
#else
|
||||||
dest[0][0] = m[0][0]; dest[1][0] = m[0][1];
|
dest[0][0] = m[0][0]; dest[1][0] = m[0][1];
|
||||||
dest[0][1] = m[1][0]; dest[1][1] = m[1][1];
|
dest[0][1] = m[1][0]; dest[1][1] = m[1][1];
|
||||||
@@ -498,6 +502,8 @@ void
|
|||||||
glm_mat4_transpose(mat4 m) {
|
glm_mat4_transpose(mat4 m) {
|
||||||
#if defined( __SSE__ ) || defined( __SSE2__ )
|
#if defined( __SSE__ ) || defined( __SSE2__ )
|
||||||
glm_mat4_transp_sse2(m, m);
|
glm_mat4_transp_sse2(m, m);
|
||||||
|
#elif defined(CGLM_NEON_FP)
|
||||||
|
glm_mat4_transp_neon(m, m);
|
||||||
#else
|
#else
|
||||||
mat4 d;
|
mat4 d;
|
||||||
glm_mat4_transpose_to(m, d);
|
glm_mat4_transpose_to(m, d);
|
||||||
@@ -536,12 +542,7 @@ glm_mat4_scale(mat4 m, float s) {
|
|||||||
#if defined( __SSE__ ) || defined( __SSE2__ )
|
#if defined( __SSE__ ) || defined( __SSE2__ )
|
||||||
glm_mat4_scale_sse2(m, s);
|
glm_mat4_scale_sse2(m, s);
|
||||||
#elif defined(CGLM_NEON_FP)
|
#elif defined(CGLM_NEON_FP)
|
||||||
float32x4_t v0;
|
glm_mat4_scale_neon(m, s);
|
||||||
v0 = vdupq_n_f32(s);
|
|
||||||
vst1q_f32(m[0], vmulq_f32(vld1q_f32(m[0]), v0));
|
|
||||||
vst1q_f32(m[1], vmulq_f32(vld1q_f32(m[1]), v0));
|
|
||||||
vst1q_f32(m[2], vmulq_f32(vld1q_f32(m[2]), v0));
|
|
||||||
vst1q_f32(m[3], vmulq_f32(vld1q_f32(m[3]), v0));
|
|
||||||
#else
|
#else
|
||||||
glm_mat4_scale_p(m, s);
|
glm_mat4_scale_p(m, s);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -12,6 +12,32 @@
|
|||||||
#include "../../common.h"
|
#include "../../common.h"
|
||||||
#include "../intrin.h"
|
#include "../intrin.h"
|
||||||
|
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_mat4_scale_neon(mat4 m, float s) {
|
||||||
|
float32x4_t v0;
|
||||||
|
|
||||||
|
v0 = vdupq_n_f32(s);
|
||||||
|
|
||||||
|
vst1q_f32(m[0], vmulq_f32(vld1q_f32(m[0]), v0));
|
||||||
|
vst1q_f32(m[1], vmulq_f32(vld1q_f32(m[1]), v0));
|
||||||
|
vst1q_f32(m[2], vmulq_f32(vld1q_f32(m[2]), v0));
|
||||||
|
vst1q_f32(m[3], vmulq_f32(vld1q_f32(m[3]), v0));
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_mat4_transp_neon(mat4 m, mat4 dest) {
|
||||||
|
float32x4x4_t vmat;
|
||||||
|
|
||||||
|
vmat = vld4q_f32(m[0]);
|
||||||
|
|
||||||
|
vst1q_f32(dest[0], vmat.val[0]);
|
||||||
|
vst1q_f32(dest[1], vmat.val[1]);
|
||||||
|
vst1q_f32(dest[2], vmat.val[2]);
|
||||||
|
vst1q_f32(dest[3], vmat.val[3]);
|
||||||
|
}
|
||||||
|
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_mat4_mul_neon(mat4 m1, mat4 m2, mat4 dest) {
|
glm_mat4_mul_neon(mat4 m1, mat4 m2, mat4 dest) {
|
||||||
@@ -53,5 +79,27 @@ glm_mat4_mul_neon(mat4 m1, mat4 m2, mat4 dest) {
|
|||||||
vst1q_f32(dest[3], d3);
|
vst1q_f32(dest[3], d3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_mat4_mulv_neon(mat4 m, vec4 v, vec4 dest) {
|
||||||
|
float32x4_t l0, l1, l2, l3;
|
||||||
|
float32x2_t vlo, vhi;
|
||||||
|
|
||||||
|
l0 = vld1q_f32(m[0]);
|
||||||
|
l1 = vld1q_f32(m[1]);
|
||||||
|
l2 = vld1q_f32(m[2]);
|
||||||
|
l3 = vld1q_f32(m[3]);
|
||||||
|
|
||||||
|
vlo = vld1_f32(&v[0]);
|
||||||
|
vhi = vld1_f32(&v[2]);
|
||||||
|
|
||||||
|
l0 = vmulq_lane_f32(l0, vlo, 0);
|
||||||
|
l0 = vmlaq_lane_f32(l0, l1, vlo, 1);
|
||||||
|
l0 = vmlaq_lane_f32(l0, l2, vhi, 0);
|
||||||
|
l0 = vmlaq_lane_f32(l0, l3, vhi, 1);
|
||||||
|
|
||||||
|
vst1q_f32(dest, l0);
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
#endif /* cglm_mat4_neon_h */
|
#endif /* cglm_mat4_neon_h */
|
||||||
|
|||||||
@@ -175,7 +175,7 @@ glmm_load3(float v[3]) {
|
|||||||
__m128i xy;
|
__m128i xy;
|
||||||
__m128 z;
|
__m128 z;
|
||||||
|
|
||||||
xy = _mm_loadl_epi64((const __m128i *)v);
|
xy = _mm_loadl_epi64(CGLM_CASTPTR_ASSUME_ALIGNED(v, const __m128i));
|
||||||
z = _mm_load_ss(&v[2]);
|
z = _mm_load_ss(&v[2]);
|
||||||
|
|
||||||
return _mm_movelh_ps(_mm_castsi128_ps(xy), z);
|
return _mm_movelh_ps(_mm_castsi128_ps(xy), z);
|
||||||
@@ -184,7 +184,7 @@ glmm_load3(float v[3]) {
|
|||||||
static inline
|
static inline
|
||||||
void
|
void
|
||||||
glmm_store3(float v[3], __m128 vx) {
|
glmm_store3(float v[3], __m128 vx) {
|
||||||
_mm_storel_pi((__m64 *)&v[0], vx);
|
_mm_storel_pi(CGLM_CASTPTR_ASSUME_ALIGNED(v, __m64), vx);
|
||||||
_mm_store_ss(&v[2], glmm_shuff1(vx, 2, 2, 2, 2));
|
_mm_store_ss(&v[2], glmm_shuff1(vx, 2, 2, 2, 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,6 +32,16 @@
|
|||||||
# define CGLM_ALIGN_MAT CGLM_ALIGN(16)
|
# define CGLM_ALIGN_MAT CGLM_ALIGN(16)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __GNUC__
|
||||||
|
# define CGLM_ASSUME_ALIGNED(expr, alignment) \
|
||||||
|
__builtin_assume_aligned((expr), (alignment))
|
||||||
|
#else
|
||||||
|
# define CGLM_ASSUME_ALIGNED(expr, alignment) (expr)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define CGLM_CASTPTR_ASSUME_ALIGNED(expr, type) \
|
||||||
|
((type*)CGLM_ASSUME_ALIGNED((expr), __alignof__(type)))
|
||||||
|
|
||||||
typedef float vec2[2];
|
typedef float vec2[2];
|
||||||
typedef float vec3[3];
|
typedef float vec3[3];
|
||||||
typedef int ivec3[3];
|
typedef int ivec3[3];
|
||||||
|
|||||||
@@ -237,9 +237,9 @@ glm_vec3_abs(vec3 v, vec3 dest) {
|
|||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_vec3_fract(vec3 v, vec3 dest) {
|
glm_vec3_fract(vec3 v, vec3 dest) {
|
||||||
dest[0] = fminf(v[0] - floorf(v[0]), 0x1.fffffep-1f);
|
dest[0] = fminf(v[0] - floorf(v[0]), 0.999999940395355224609375f);
|
||||||
dest[1] = fminf(v[1] - floorf(v[1]), 0x1.fffffep-1f);
|
dest[1] = fminf(v[1] - floorf(v[1]), 0.999999940395355224609375f);
|
||||||
dest[2] = fminf(v[2] - floorf(v[2]), 0x1.fffffep-1f);
|
dest[2] = fminf(v[2] - floorf(v[2]), 0.999999940395355224609375f);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|||||||
@@ -268,10 +268,10 @@ glm_vec4_abs(vec4 v, vec4 dest) {
|
|||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_vec4_fract(vec4 v, vec4 dest) {
|
glm_vec4_fract(vec4 v, vec4 dest) {
|
||||||
dest[0] = fminf(v[0] - floorf(v[0]), 0x1.fffffep-1f);
|
dest[0] = fminf(v[0] - floorf(v[0]), 0.999999940395355224609375f);
|
||||||
dest[1] = fminf(v[1] - floorf(v[1]), 0x1.fffffep-1f);
|
dest[1] = fminf(v[1] - floorf(v[1]), 0.999999940395355224609375f);
|
||||||
dest[2] = fminf(v[2] - floorf(v[2]), 0x1.fffffep-1f);
|
dest[2] = fminf(v[2] - floorf(v[2]), 0.999999940395355224609375f);
|
||||||
dest[3] = fminf(v[3] - floorf(v[3]), 0x1.fffffep-1f);
|
dest[3] = fminf(v[3] - floorf(v[3]), 0.999999940395355224609375f);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
#define cglm_version_h
|
#define cglm_version_h
|
||||||
|
|
||||||
#define CGLM_VERSION_MAJOR 0
|
#define CGLM_VERSION_MAJOR 0
|
||||||
#define CGLM_VERSION_MINOR 7
|
#define CGLM_VERSION_MINOR 8
|
||||||
#define CGLM_VERSION_PATCH 7
|
#define CGLM_VERSION_PATCH 0
|
||||||
|
|
||||||
#endif /* cglm_version_h */
|
#endif /* cglm_version_h */
|
||||||
|
|||||||
14
include/module.modulemap
Normal file
14
include/module.modulemap
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
module cglm {
|
||||||
|
header "cglm/cglm.h"
|
||||||
|
header "cglm/struct.h"
|
||||||
|
|
||||||
|
export *
|
||||||
|
}
|
||||||
|
|
||||||
|
module cglmc {
|
||||||
|
header "cglm/cglm.h"
|
||||||
|
header "cglm/struct.h"
|
||||||
|
header "cglm/call.h"
|
||||||
|
|
||||||
|
export *
|
||||||
|
}
|
||||||
108
meson.build
Normal file
108
meson.build
Normal file
@@ -0,0 +1,108 @@
|
|||||||
|
project('cglm', 'c',
|
||||||
|
version : '0.8.0',
|
||||||
|
license : 'mit',
|
||||||
|
default_options : [
|
||||||
|
'c_std=c11',
|
||||||
|
'werror=true',
|
||||||
|
'warning_level=2',
|
||||||
|
'buildtype=release'
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
cc = meson.get_compiler('c')
|
||||||
|
|
||||||
|
cglm_install = get_option('install')
|
||||||
|
cglm_deps = cc.find_library('m', required : false)
|
||||||
|
|
||||||
|
cglm_args = []
|
||||||
|
build_args = []
|
||||||
|
|
||||||
|
if get_option('default_library') == 'static'
|
||||||
|
cglm_args = '-DCGLM_STATIC'
|
||||||
|
endif
|
||||||
|
|
||||||
|
if host_machine.system() == 'windows'
|
||||||
|
build_args = '-DCGLM_EXPORTS'
|
||||||
|
endif
|
||||||
|
|
||||||
|
cglm_inc = include_directories('include')
|
||||||
|
|
||||||
|
cglm_src = files(
|
||||||
|
'src/affine.c',
|
||||||
|
'src/affine2d.c',
|
||||||
|
'src/bezier.c',
|
||||||
|
'src/box.c',
|
||||||
|
'src/cam.c',
|
||||||
|
'src/curve.c',
|
||||||
|
'src/ease.c',
|
||||||
|
'src/euler.c',
|
||||||
|
'src/frustum.c',
|
||||||
|
'src/io.c',
|
||||||
|
'src/mat2.c',
|
||||||
|
'src/mat3.c',
|
||||||
|
'src/mat4.c',
|
||||||
|
'src/plane.c',
|
||||||
|
'src/project.c',
|
||||||
|
'src/quat.c',
|
||||||
|
'src/ray.c',
|
||||||
|
'src/sphere.c',
|
||||||
|
'src/vec2.c',
|
||||||
|
'src/vec3.c',
|
||||||
|
'src/vec4.c'
|
||||||
|
)
|
||||||
|
|
||||||
|
cglm_lib = library('cglm',
|
||||||
|
cglm_src,
|
||||||
|
install : cglm_install,
|
||||||
|
dependencies : cglm_deps,
|
||||||
|
c_args : [ build_args, cglm_args ]
|
||||||
|
)
|
||||||
|
|
||||||
|
cglm_dep = declare_dependency(
|
||||||
|
link_with : cglm_lib,
|
||||||
|
dependencies : cglm_deps,
|
||||||
|
compile_args : cglm_args,
|
||||||
|
include_directories : cglm_inc,
|
||||||
|
version : meson.project_version()
|
||||||
|
)
|
||||||
|
|
||||||
|
if meson.version().version_compare('>= 0.54.0')
|
||||||
|
meson.override_dependency('cglm', cglm_dep)
|
||||||
|
endif
|
||||||
|
|
||||||
|
if cglm_install
|
||||||
|
install_subdir('include/cglm', install_dir : get_option('includedir'))
|
||||||
|
|
||||||
|
pkg = import('pkgconfig')
|
||||||
|
pkg.generate(
|
||||||
|
name : 'cglm',
|
||||||
|
libraries : cglm_lib,
|
||||||
|
extra_cflags : cglm_args,
|
||||||
|
version : meson.project_version(),
|
||||||
|
url : 'https://github.com/recp/cglm',
|
||||||
|
description : 'OpenGL Mathematics (glm) for C'
|
||||||
|
)
|
||||||
|
endif
|
||||||
|
|
||||||
|
if get_option('build_tests') == true
|
||||||
|
|
||||||
|
test_src = files(
|
||||||
|
'test/runner.c',
|
||||||
|
'test/src/test_euler.c',
|
||||||
|
'test/src/test_bezier.c',
|
||||||
|
'test/src/test_cam.c',
|
||||||
|
'test/src/test_struct.c',
|
||||||
|
'test/src/test_clamp.c',
|
||||||
|
'test/src/test_common.c',
|
||||||
|
'test/src/tests.c'
|
||||||
|
)
|
||||||
|
|
||||||
|
test_exe = executable('tests',
|
||||||
|
test_src,
|
||||||
|
dependencies : cglm_dep,
|
||||||
|
c_args : '-DGLM_TESTS_NO_COLORFUL_OUTPUT'
|
||||||
|
)
|
||||||
|
|
||||||
|
test('cglm.tests', test_exe)
|
||||||
|
|
||||||
|
endif
|
||||||
2
meson_options.txt
Normal file
2
meson_options.txt
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
option('build_tests', type : 'boolean', value : false, description : 'Build tests')
|
||||||
|
option('install', type : 'boolean', value : true, description : 'Include the library, headers, and pkg-config file in the install target')
|
||||||
1
src/swift/empty.c
Normal file
1
src/swift/empty.c
Normal file
@@ -0,0 +1 @@
|
|||||||
|
// This empty file is needed to trick swiftpm to build the header-only version of cglm as swiftpm itself does not support C targets that have no source code files
|
||||||
@@ -18,7 +18,11 @@ set(TEST_RUNNER_PARAMS "")
|
|||||||
add_executable(${TEST_MAIN} ${TESTFILES})
|
add_executable(${TEST_MAIN} ${TESTFILES})
|
||||||
target_compile_definitions(${TEST_MAIN} PRIVATE CGLM_DEFINE_PRINTS=1)
|
target_compile_definitions(${TEST_MAIN} PRIVATE CGLM_DEFINE_PRINTS=1)
|
||||||
|
|
||||||
target_link_libraries(${TEST_MAIN} PRIVATE cglm m)
|
if(NOT MSVC)
|
||||||
|
target_link_libraries(${TEST_MAIN} PRIVATE m)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
target_link_libraries(${TEST_MAIN} PRIVATE cglm)
|
||||||
target_include_directories(${TEST_MAIN} PRIVATE
|
target_include_directories(${TEST_MAIN} PRIVATE
|
||||||
${CMAKE_CURRENT_LIST_DIR}/include
|
${CMAKE_CURRENT_LIST_DIR}/include
|
||||||
${CMAKE_CURRENT_LIST_DIR}/src
|
${CMAKE_CURRENT_LIST_DIR}/src
|
||||||
|
|||||||
@@ -16,6 +16,10 @@
|
|||||||
# define _CRT_SECURE_NO_WARNINGS /* for windows */
|
# define _CRT_SECURE_NO_WARNINGS /* for windows */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef _GNU_SOURCE
|
||||||
|
# define _GNU_SOURCE /* for drand48() */
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ main(int argc, const char * argv[]) {
|
|||||||
test_status_t st;
|
test_status_t st;
|
||||||
int32_t i, count, passed, failed, maxlen;
|
int32_t i, count, passed, failed, maxlen;
|
||||||
double start, end, elapsed, total;
|
double start, end, elapsed, total;
|
||||||
|
(void)argc;
|
||||||
|
(void)argv;
|
||||||
|
|
||||||
passed = failed = maxlen = 0;
|
passed = failed = maxlen = 0;
|
||||||
total = 0.0;
|
total = 0.0;
|
||||||
|
|||||||
@@ -209,7 +209,7 @@
|
|||||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<Optimization>MaxSpeed</Optimization>
|
<Optimization>MaxSpeed</Optimization>
|
||||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;CGLM_EXPORTS;CGLM_DLL;%(PreprocessorDefinitions);CGLM_DLL</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;CGLM_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<DebugInformationFormat>None</DebugInformationFormat>
|
<DebugInformationFormat>None</DebugInformationFormat>
|
||||||
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
|
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
|
||||||
<PrecompiledHeaderFile />
|
<PrecompiledHeaderFile />
|
||||||
@@ -225,7 +225,7 @@
|
|||||||
<ClCompile>
|
<ClCompile>
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<Optimization>MaxSpeed</Optimization>
|
<Optimization>MaxSpeed</Optimization>
|
||||||
<PreprocessorDefinitions>_DEBUG;_WINDOWS;_USRDLL;CGLM_EXPORTS;CGLM_DLL;%(PreprocessorDefinitions);CGLM_DLL</PreprocessorDefinitions>
|
<PreprocessorDefinitions>_DEBUG;_WINDOWS;_USRDLL;CGLM_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
@@ -246,7 +246,7 @@
|
|||||||
<Optimization>MaxSpeed</Optimization>
|
<Optimization>MaxSpeed</Optimization>
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;CGLM_EXPORTS;CGLM_DLL;%(PreprocessorDefinitions);CGLM_DLL</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;CGLM_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<DebugInformationFormat>None</DebugInformationFormat>
|
<DebugInformationFormat>None</DebugInformationFormat>
|
||||||
<PrecompiledHeaderFile />
|
<PrecompiledHeaderFile />
|
||||||
<CompileAs>CompileAsC</CompileAs>
|
<CompileAs>CompileAsC</CompileAs>
|
||||||
@@ -266,7 +266,7 @@
|
|||||||
<Optimization>MaxSpeed</Optimization>
|
<Optimization>MaxSpeed</Optimization>
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<PreprocessorDefinitions>NDEBUG;_WINDOWS;_USRDLL;CGLM_EXPORTS;CGLM_DLL;%(PreprocessorDefinitions);CGLM_DLL</PreprocessorDefinitions>
|
<PreprocessorDefinitions>NDEBUG;_WINDOWS;_USRDLL;CGLM_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<DebugInformationFormat>None</DebugInformationFormat>
|
<DebugInformationFormat>None</DebugInformationFormat>
|
||||||
<PrecompiledHeaderFile />
|
<PrecompiledHeaderFile />
|
||||||
<CompileAs>CompileAsC</CompileAs>
|
<CompileAs>CompileAsC</CompileAs>
|
||||||
|
|||||||
Reference in New Issue
Block a user