mirror of
https://github.com/recp/cglm.git
synced 2026-02-17 03:39:05 +00:00
Compare commits
24 Commits
neon-updat
...
flt-epsilo
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6626d2b74f | ||
|
|
5bda762df6 | ||
|
|
f9824a8dc6 | ||
|
|
ccd3058adc | ||
|
|
4ab9ab4772 | ||
|
|
a5ff477fc8 | ||
|
|
254570d006 | ||
|
|
681f20d540 | ||
|
|
fd87f6e2c3 | ||
|
|
2c12c6dce5 | ||
|
|
5619527fd3 | ||
|
|
8b1c3c3fc4 | ||
|
|
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/
|
||||
conftest.dir/*
|
||||
confdefs.h
|
||||
*.xcuserdatad
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
cmake_minimum_required(VERSION 3.8.2)
|
||||
project(cglm VERSION 0.7.9 LANGUAGES C)
|
||||
project(cglm VERSION 0.8.0 LANGUAGES C)
|
||||
|
||||
set(CMAKE_C_STANDARD 11)
|
||||
set(CMAKE_C_STANDARD_REQUIRED YES)
|
||||
|
||||
3
CREDITS
3
CREDITS
@@ -71,3 +71,6 @@ Authors:
|
||||
Thomas Möller (tompa@clarus.se)
|
||||
Ben Trumbore (wbt@graphics.cornell.edu)
|
||||
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)
|
||||
```
|
||||
|
||||
### 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)
|
||||
|
||||
|
||||
15
cglm.podspec
15
cglm.podspec
@@ -2,10 +2,10 @@ Pod::Spec.new do |s|
|
||||
|
||||
# Description
|
||||
s.name = "cglm"
|
||||
s.version = "0.7.2"
|
||||
s.summary = "📽 Optimized OpenGL/Graphics Math (glm) for C"
|
||||
s.version = "0.7.9"
|
||||
s.summary = "📽 Highly Optimized Graphics Math (glm) for C"
|
||||
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
|
||||
|
||||
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
|
||||
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
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#*****************************************************************************
|
||||
|
||||
AC_PREREQ([2.69])
|
||||
AC_INIT([cglm], [0.7.9], [info@recp.me])
|
||||
AC_INIT([cglm], [0.8.0], [info@recp.me])
|
||||
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.
|
||||
|
||||
@@ -50,7 +50,7 @@ If you don't want to install **cglm** to your system's folder you can get static
|
||||
Meson (All platforms):
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. code-block:: bash
|
||||
.. code-block::
|
||||
:linenos:
|
||||
|
||||
$ meson build # [Optional] --default-library=static
|
||||
@@ -60,7 +60,7 @@ Meson (All platforms):
|
||||
|
||||
**Meson Options:**
|
||||
|
||||
.. code-block:: CMake
|
||||
.. code-block::
|
||||
:linenos:
|
||||
|
||||
c_std=c11
|
||||
@@ -69,9 +69,9 @@ Meson (All platforms):
|
||||
enable_tests=false # to run tests: ninja test
|
||||
|
||||
|
||||
**Use with your CMake project example**
|
||||
**Use with your Meson project**
|
||||
|
||||
.. code-block:: CMake
|
||||
.. code-block::
|
||||
:linenos:
|
||||
|
||||
# Clone cglm or create a cglm.wrap under <source_root>/subprojects
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
# 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
|
||||
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
|
||||
@@ -62,9 +62,9 @@ author = u'Recep Aslantas'
|
||||
# built documents.
|
||||
#
|
||||
# The short X.Y version.
|
||||
version = u'0.7.9'
|
||||
version = u'0.8.0'
|
||||
# The full version, including alpha/beta/rc tags.
|
||||
release = u'0.7.9'
|
||||
release = u'0.8.0'
|
||||
|
||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||
# 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.
|
||||
todo_include_todos = True
|
||||
|
||||
# -- Options for the C domain ------------------------------------------------
|
||||
|
||||
c_id_attributes = ['__restrict']
|
||||
|
||||
@@ -374,7 +374,7 @@ Functions documentation
|
||||
| *[in]* **q** quaternion
|
||||
| *[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
|
||||
| this creates rotation matrix, it assumes you don't have a matrix
|
||||
|
||||
@@ -55,12 +55,12 @@ Functions:
|
||||
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:
|
||||
| *[in]* **v3** vector3
|
||||
| *[in]* **v** vector
|
||||
| *[out]* **dest** destination
|
||||
|
||||
.. c:function:: void glm_vec2_copy(vec2 a, vec2 dest)
|
||||
|
||||
@@ -425,7 +425,7 @@ bool
|
||||
glm_uniscaled(mat4 m) {
|
||||
CGLM_ALIGN(8) vec3 s;
|
||||
glm_decompose_scalev(m, s);
|
||||
return glm_vec3_eq_all(s);
|
||||
return glm_vec3_eq_eps(s, s[0]);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
||||
@@ -42,12 +42,18 @@
|
||||
#include "types.h"
|
||||
#include "simd/intrin.h"
|
||||
|
||||
#ifndef CGLM_USE_DEFAULT_EPSILON
|
||||
# ifndef GLM_FLT_EPSILON
|
||||
# define GLM_FLT_EPSILON 1e-6
|
||||
/** CGLM_USE_DEFAULT_EPSILON is removed, to override float epsilon,
|
||||
* just define GLM_FLT_EPSILON with epsilon value like below
|
||||
*
|
||||
* #define GLM_FLT_EPSILON 1e-6f
|
||||
*/
|
||||
|
||||
#ifndef GLM_FLT_EPSILON
|
||||
# ifndef FLT_EPSILON
|
||||
# define GLM_FLT_EPSILON 1e-6f
|
||||
# else
|
||||
# define GLM_FLT_EPSILON FLT_EPSILON
|
||||
# endif
|
||||
#else
|
||||
# define GLM_FLT_EPSILON FLT_EPSILON
|
||||
#endif
|
||||
|
||||
#endif /* cglm_common_h */
|
||||
|
||||
@@ -175,7 +175,7 @@ glmm_load3(float v[3]) {
|
||||
__m128i xy;
|
||||
__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]);
|
||||
|
||||
return _mm_movelh_ps(_mm_castsi128_ps(xy), z);
|
||||
@@ -184,7 +184,7 @@ glmm_load3(float v[3]) {
|
||||
static inline
|
||||
void
|
||||
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));
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,16 @@
|
||||
# define CGLM_ALIGN_MAT CGLM_ALIGN(16)
|
||||
#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 vec3[3];
|
||||
typedef int ivec3[3];
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#define cglm_version_h
|
||||
|
||||
#define CGLM_VERSION_MAJOR 0
|
||||
#define CGLM_VERSION_MINOR 7
|
||||
#define CGLM_VERSION_PATCH 9
|
||||
#define CGLM_VERSION_MINOR 8
|
||||
#define CGLM_VERSION_PATCH 0
|
||||
|
||||
#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 *
|
||||
}
|
||||
29
meson.build
29
meson.build
@@ -1,5 +1,5 @@
|
||||
project('cglm', 'c',
|
||||
version : '0.7.9',
|
||||
version : '0.8.0',
|
||||
license : 'mit',
|
||||
default_options : [
|
||||
'c_std=c11',
|
||||
@@ -11,6 +11,7 @@ project('cglm', 'c',
|
||||
|
||||
cc = meson.get_compiler('c')
|
||||
|
||||
cglm_install = get_option('install')
|
||||
cglm_deps = cc.find_library('m', required : false)
|
||||
|
||||
cglm_args = []
|
||||
@@ -50,11 +51,9 @@ cglm_src = files(
|
||||
'src/vec4.c'
|
||||
)
|
||||
|
||||
install_subdir('include/cglm', install_dir : get_option('includedir'))
|
||||
|
||||
cglm_lib = library('cglm',
|
||||
cglm_src,
|
||||
install : true,
|
||||
install : cglm_install,
|
||||
dependencies : cglm_deps,
|
||||
c_args : [ build_args, cglm_args ]
|
||||
)
|
||||
@@ -71,17 +70,19 @@ 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'
|
||||
)
|
||||
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
|
||||
|
||||
|
||||
@@ -1 +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
|
||||
@@ -35,9 +35,9 @@ TEST_IMPL(camera_decomp) {
|
||||
farVal = 100.0f;
|
||||
|
||||
glm_perspective(fovy, aspect, nearVal, farVal, proj);
|
||||
ASSERT(fabsf(aspect - glm_persp_aspect(proj)) < GLM_FLT_EPSILON)
|
||||
ASSERT(fabsf(fovy - glm_persp_fovy(proj)) < GLM_FLT_EPSILON)
|
||||
ASSERT(fabsf(49.984f - glm_deg(glm_persp_fovy(proj))) < GLM_FLT_EPSILON)
|
||||
ASSERT(fabsf(aspect - glm_persp_aspect(proj)) < 1e-5f)
|
||||
ASSERT(fabsf(fovy - glm_persp_fovy(proj)) < 1e-5f)
|
||||
ASSERT(fabsf(49.984f - glm_deg(glm_persp_fovy(proj))) < 1e-5f)
|
||||
|
||||
glm_persp_sizes(proj, fovy, sizes);
|
||||
|
||||
|
||||
@@ -106,7 +106,7 @@ test_rand_quat(versor q);
|
||||
CGLM_INLINE
|
||||
bool
|
||||
test_eq(float a, float b) {
|
||||
return fabsf(a - b) <= GLM_FLT_EPSILON * 10;
|
||||
return fabsf(a - b) <= 1e-5f;
|
||||
}
|
||||
|
||||
CGLM_INLINE
|
||||
|
||||
Reference in New Issue
Block a user