Skip to content

Commit 4db9e62

Browse files
committed
v1.0.0 released
1 parent 372fb0c commit 4db9e62

File tree

3 files changed

+52
-30
lines changed

3 files changed

+52
-30
lines changed

README.md

Lines changed: 44 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@
22

33
**dsga** is a single header-only **c++20 library** that implements the **vectors** and **matrices** from the OpenGL Shading Language 4.6 specification ([pdf](https://www.khronos.org/registry/OpenGL/specs/gl/GLSLangSpec.4.60.pdf) | [html](https://registry.khronos.org/OpenGL/specs/gl/GLSLangSpec.4.60.html)). It is inspired by the spec, but does deviate in some small ways, mostly to make it work well in c++20. It is not intended to be used for rendering, just for sharing the fundamental data structures and associated functions. Our requirements in general are for things like 3D CAD/CAM applications and other geometric and algebraic things. See [motivation](docs/MOTIVATION.md) for more details. This library does not use SIMD instructions or types under the hood, beyond whatever the compiler provides through optimization.
44

5+
## Current Version
6+
v1.0.0
7+
58
## Contents
69
* [Some Quick Examples](#some-quick-examples)
710
* [Relevant GLSL Overview](#relevant-glsl-overview)
11+
* [Implemented Interfaces](#implemented-interfaces)
812
* [Installation](#installation)
913
* [Status](#status)
1014
* [Usage](#usage)
@@ -222,6 +226,43 @@ The following links to the shading specification should help with understanding
222226
223227
In addtion, we have added the non-GLSL convenience function ```none()```, which returns ```!any()```.
224228
229+
## Implemented Interfaces
230+
231+
To make the vectors and matrices as useful as possible in a c++ context, various c++ customization points were implemented or interfaces partially emulated, e.g., ```std::valarray<>```. For ```dsga``` vectors and matrices, we have:
232+
233+
* swizzling from GLSL (just vector)
234+
* just from the set of {x, y, z, w}, e.g., ```foo.wyxz```
235+
* ```std::valarray<>``` (just vector)
236+
* ```apply()```
237+
* ```shift()```
238+
* ```cshift()```
239+
* ```min()```
240+
* ```max()```
241+
* ```sum()```
242+
* ```std::tuple```, structured bindings
243+
* ```tuple_size<>```
244+
* ```tuple_element<>```
245+
* ```get<>()```
246+
* iterators, ranges, range-for loop
247+
* ```begin()```
248+
* ```cbegin()```
249+
* ```rbegin()```
250+
* ```crbegin()```
251+
* ```end()```
252+
* ```cend()```
253+
* ```rend()```
254+
* ```crend()```
255+
* indexing
256+
* ```operator []```
257+
* pointer (just vector)
258+
* ```data()```
259+
* ```offsets```
260+
* ```sequence()```
261+
* output
262+
* [```std::ostream<>``` example](examples/ostream_output.hxx)
263+
* [```std::formatter<>``` example](examples/format_output.hxx)
264+
265+
225266
## Installation
226267
227268
This is a **single header library**, where you just need the file [dsga.hxx](include/dsga.hxx). Things are defined in the ```dsga``` namespace. The types provided by this library can be seen summarized in the [documentation](docs/DOCUMENTATION.md), [using directives](docs/DOCUMENTATION.md#types-and-functions).
@@ -238,18 +279,15 @@ Remember, this is a c++20 library, so that needs to be the minimum standard that
238279
239280
## Status
240281
241-
Current version: `v0.11.0`
282+
Current version: `v1.0.0`
242283
243-
* **All the intended vector and matrix functionality from the GLSL specification is implemented.** We keep refining the implementation, and we keep expanding the API to better support ```c++20``` idioms and usage as we go.
244-
* First pass at test coverage. Everything major has some tests, but code coverage is not 100%.
245-
* [Released v0.11.0](https://github.com/davidbrowne/dsga/releases/tag/v0.11.0)
284+
* Everything major has some tests, but code coverage is not 100%.
285+
* [Released v1.0.0](https://github.com/davidbrowne/dsga/releases/tag/v1.0.0)
246286
247287
### The next steps
248288
* Working on much better API documentation.
249289
* Working on better ```cmake``` support.
250290
251-
Once we have detailed API documentation and better ```cmake``` support, we can think about releasing a v1.0 version.
252-
253291
## Usage
254292
255293
Use it more or less like you would use vectors and matrices in a shader program, but not necessarily for shading. We hope to be able to use it for rapid development of geometric algorithms. See the [examples](examples) directory.

include/dsga.hxx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ inline void dsga_constexpr_assert_failed(Assert &&a) noexcept
5858

5959
// version info
6060

61-
constexpr inline int DSGA_MAJOR_VERSION = 0;
62-
constexpr inline int DSGA_MINOR_VERSION = 11;
61+
constexpr inline int DSGA_MAJOR_VERSION = 1;
62+
constexpr inline int DSGA_MINOR_VERSION = 0;
6363
constexpr inline int DSGA_PATCH_VERSION = 0;
6464

6565
namespace dsga
@@ -1240,13 +1240,13 @@ namespace dsga
12401240
{
12411241
int count = by > max_val ? max_val : by;
12421242
auto shifted_end = std::shift_left(copy.begin(), copy.end(), count);
1243-
std::fill_n(shifted_end, count, T(0));
1243+
std::ranges::fill_n(shifted_end, count, T(0));
12441244
}
12451245
else if (by < 0)
12461246
{
12471247
int count = -by > max_val ? max_val : -by;
12481248
std::shift_right(copy.begin(), copy.end(), count);
1249-
std::fill_n(copy.begin(), count, T(0));
1249+
std::ranges::fill_n(copy.begin(), count, T(0));
12501250
}
12511251

12521252
return copy;
@@ -1261,22 +1261,22 @@ namespace dsga
12611261
if (by > 0)
12621262
{
12631263
int count = by > max_val ? max_val : by;
1264-
std::rotate(copy.begin(), copy.begin() + count, copy.end());
1264+
std::ranges::rotate(copy, copy.begin() + count);
12651265
}
12661266
else if (by < 0)
12671267
{
12681268
int count = -by > max_val ? max_val : -by;
1269-
std::rotate(copy.begin(), copy.begin() + max_val - count, copy.end());
1269+
std::ranges::rotate(copy, copy.begin() + max_val - count);
12701270
}
12711271

12721272
return copy;
12731273
}
12741274

12751275
// min value in vector
1276-
[[nodiscard]] constexpr T min() const noexcept requires non_bool_scalar<T> { return *std::min_element(begin(), end()); }
1276+
[[nodiscard]] constexpr T min() const noexcept requires non_bool_scalar<T> { return *std::ranges::min_element(*this); }
12771277

12781278
// max value in vector
1279-
[[nodiscard]] constexpr T max() const noexcept requires non_bool_scalar<T> { return *std::max_element(begin(), end()); }
1279+
[[nodiscard]] constexpr T max() const noexcept requires non_bool_scalar<T> { return *std::ranges::max_element(*this); }
12801280

12811281
// sum of values in vector
12821282
[[nodiscard]] constexpr T sum() const noexcept requires non_bool_scalar<T> { return std::accumulate(begin(), end(), T(0)); }

src/main.cxx

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
//#include "nanobench.h"
88
#include "dsga.hxx"
9-
#include "../examples/format_output.hxx"
109

1110
//
1211
//
@@ -22,21 +21,6 @@ void sandbox_function()
2221
{
2322
// put fun code here
2423

25-
#if defined(__cpp_lib_format)
26-
auto fmt_arr = std::array<double, 4>{1, 2, 3, 4};
27-
auto empty_arr = std::array<double, 0>{};
28-
auto one_arr = std::array<double, 1>{99};
29-
auto fmt_vec = dsga::dvec4(10, 20, 30, 40);
30-
auto fmt_mat = dsga::dmat3x2(1, 2, 3, 4, 5, 6);
31-
test_format_array(empty_arr);
32-
test_format_array(one_arr);
33-
test_format_array(fmt_arr);
34-
test_format_vector(fmt_vec);
35-
test_format_vector_base(fmt_vec);
36-
test_format_vector_base(fmt_vec.wzyx);
37-
test_format_indexed_vector(fmt_vec.wzyx);
38-
test_format_matrix(fmt_mat);
39-
#endif
4024
}
4125

4226
#if defined(__clang__) && (__clang_major__ < 13)

0 commit comments

Comments
 (0)