mirror of
https://github.com/recp/cglm.git
synced 2026-02-17 03:39:05 +00:00
Compare commits
12 Commits
neon-updat
...
v0.7.9
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ec852c7682 | ||
|
|
5433c9ed6c | ||
|
|
2a2d51624b | ||
|
|
5fa908602f | ||
|
|
9da74f9654 | ||
|
|
dddb077b13 | ||
|
|
6107287c9a | ||
|
|
7dccbef6e3 | ||
|
|
d920a62be2 | ||
|
|
73f32b9ef7 | ||
|
|
2e5257bcc1 | ||
|
|
65b0b461ab |
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
|
||||||
|
|||||||
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
|
||||||
|
)
|
||||||
32
README.md
32
README.md
@@ -212,6 +212,38 @@ cglm_dep = dependency('cglm', fallback : 'cglm', 'cglm_dep')
|
|||||||
executable('exe', 'src/main.c', dependencies : 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)
|
||||||
|
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
@@ -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];
|
||||||
|
|||||||
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 *
|
||||||
|
}
|
||||||
27
meson.build
27
meson.build
@@ -11,6 +11,7 @@ project('cglm', 'c',
|
|||||||
|
|
||||||
cc = meson.get_compiler('c')
|
cc = meson.get_compiler('c')
|
||||||
|
|
||||||
|
cglm_install = get_option('install')
|
||||||
cglm_deps = cc.find_library('m', required : false)
|
cglm_deps = cc.find_library('m', required : false)
|
||||||
|
|
||||||
cglm_args = []
|
cglm_args = []
|
||||||
@@ -50,11 +51,9 @@ cglm_src = files(
|
|||||||
'src/vec4.c'
|
'src/vec4.c'
|
||||||
)
|
)
|
||||||
|
|
||||||
install_subdir('include/cglm', install_dir : get_option('includedir'))
|
|
||||||
|
|
||||||
cglm_lib = library('cglm',
|
cglm_lib = library('cglm',
|
||||||
cglm_src,
|
cglm_src,
|
||||||
install : true,
|
install : cglm_install,
|
||||||
dependencies : cglm_deps,
|
dependencies : cglm_deps,
|
||||||
c_args : [ build_args, cglm_args ]
|
c_args : [ build_args, cglm_args ]
|
||||||
)
|
)
|
||||||
@@ -71,17 +70,19 @@ if meson.version().version_compare('>= 0.54.0')
|
|||||||
meson.override_dependency('cglm', cglm_dep)
|
meson.override_dependency('cglm', cglm_dep)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
if cglm_install
|
||||||
|
install_subdir('include/cglm', install_dir : get_option('includedir'))
|
||||||
|
|
||||||
pkg = import('pkgconfig')
|
pkg = import('pkgconfig')
|
||||||
|
pkg.generate(
|
||||||
pkg.generate(
|
name : 'cglm',
|
||||||
name : 'cglm',
|
libraries : cglm_lib,
|
||||||
libraries : cglm_lib,
|
extra_cflags : cglm_args,
|
||||||
extra_cflags : cglm_args,
|
version : meson.project_version(),
|
||||||
version : meson.project_version(),
|
url : 'https://github.com/recp/cglm',
|
||||||
url : 'https://github.com/recp/cglm',
|
description : 'OpenGL Mathematics (glm) for C'
|
||||||
description : 'OpenGL Mathematics (glm) for C'
|
)
|
||||||
)
|
endif
|
||||||
|
|
||||||
if get_option('build_tests') == true
|
if get_option('build_tests') == true
|
||||||
|
|
||||||
|
|||||||
@@ -1 +1,2 @@
|
|||||||
option('build_tests', type : 'boolean', value : false, description : 'Build tests')
|
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
|
||||||
Reference in New Issue
Block a user