Browse code

Add implementation

Robert Cranston authored on 22/12/2021 14:14:41
Showing 1 changed files
... ...
@@ -2,11 +2,49 @@
2 2
 
3 3
 A [GLSL][]/[OpenGL][] [\>=3.2][] [normal][] visualization library.
4 4
 
5
+A [geometry shader][] is used to visualize the normals from the same geometry
6
+as when drawing normally.
7
+
5 8
 [`glvisnormals`]: https://git.rcrnstn.net/rcrnstn/glvisnormals
6 9
 [GLSL]: https://en.wikipedia.org/wiki/OpenGL_Shading_Language
7 10
 [OpenGL]: https://en.wikipedia.org/wiki/OpenGL
8 11
 [\>=3.2]: https://en.wikipedia.org/wiki/OpenGL#Version_history
9 12
 [normal]: https://en.wikipedia.org/wiki/Normal_(geometry)
13
+[geometry shader]: https://www.khronos.org/opengl/wiki/Geometry_Shader
14
+
15
+## Requirements
16
+
17
+[Geometry shader][]s require OpenGL [\>=3.2][] or the
18
+[`ARB_geometry_shader4`][] extension.
19
+
20
+[`ARB_geometry_shader4`]: https://www.khronos.org/registry/OpenGL/extensions/ARB/ARB_geometry_shader4.txt
21
+
22
+## Usage
23
+
24
+Link the shader program with:
25
+
26
+-   `visnormals.vert`
27
+-   `visnormals.geom`
28
+-   `visnormals.frag`
29
+
30
+The following vertex attributes need to be set:
31
+
32
+-   `vec3 vert_position`
33
+-   `vec3 vert_normal` (assumed to be of unit length)
34
+-   `mat4 vert_model` (assumed to be an isometry, i.e. no scaling or skewing)
35
+
36
+The following uniforms need to be set:
37
+
38
+-   `mat4  view_projection`
39
+-   `float scale`
40
+-   `vec4  color`
41
+
42
+The following outputs are written by the fragment shader:
43
+
44
+-   ` vec4 frag_color`
45
+
46
+Make the shader program current and issue the same draw call as would be done
47
+when drawing normally.
10 48
 
11 49
 ## Build system
12 50
 
Browse code

Add project

Robert Cranston authored on 22/12/2021 10:45:13
Showing 1 changed files
... ...
@@ -8,6 +8,94 @@ A [GLSL][]/[OpenGL][] [\>=3.2][] [normal][] visualization library.
8 8
 [\>=3.2]: https://en.wikipedia.org/wiki/OpenGL#Version_history
9 9
 [normal]: https://en.wikipedia.org/wiki/Normal_(geometry)
10 10
 
11
+## Build system
12
+
13
+This project has support for [CMake][], and uses [`cmake-cxx`][].
14
+
15
+There are several ways to use this project in another CMake-based project:
16
+
17
+-   Use [`FetchContent`][] to download it and import the targets automatically
18
+    as part of the configure step:
19
+
20
+    ```cmake
21
+    include(FetchContent)
22
+    FetchContent_Declare(project-name
23
+        GIT_REPOSITORY https://example.com/user/project-name
24
+    )
25
+    FetchContent_MakeAvailable(
26
+        project-name
27
+    )
28
+    ```
29
+
30
+-   Bundle it and import the targets with [`add_subdirectory`][].
31
+
32
+-   Use [`find_package`][] (requires that the project is [packaged](#packaging)
33
+    or [installed](#installing)).
34
+
35
+As usual, use [`add_dependencies`][]/[`target_link_libraries`][] to declare the
36
+dependency.
37
+
38
+[CMake]: https://cmake.org
39
+[`cmake-cxx`]: https://git.rcrnstn.net/rcrnstn/cmake-cxx
40
+[`FetchContent`]: https://cmake.org/cmake/help/v3.14/module/FetchContent.html
41
+[`add_subdirectory`]: https://cmake.org/cmake/help/v3.14/command/add_subdirectory.html
42
+[`find_package`]: https://cmake.org/cmake/help/v3.14/command/find_package.html
43
+[`add_dependencies`]: https://cmake.org/cmake/help/v3.14/command/add_dependencies.html
44
+[`target_link_libraries`]: https://cmake.org/cmake/help/v3.14/command/target_link_libraries.html
45
+
46
+### Configure and generate
47
+
48
+To configure and generate a build tree, use `cmake`:
49
+
50
+```sh
51
+cmake -B build
52
+```
53
+
54
+To set the [`CMAKE_BUILD_TYPE`][], pass e.g. `-DCMAKE_BUILD_TYPE=Release`.
55
+
56
+[`cmake`]: https://cmake.org/cmake/help/v3.14/manual/cmake.1.html#generate-a-project-buildsystem
57
+[`CMAKE_BUILD_TYPE`]: https://cmake.org/cmake/help/v3.14/variable/CMAKE_BUILD_TYPE.html
58
+
59
+### Build
60
+
61
+To build, use [`cmake --build`][]:
62
+
63
+```sh
64
+cmake --build build
65
+```
66
+
67
+[`cmake --build`]: https://cmake.org/cmake/help/v3.14/manual/cmake.1.html#build-a-project
68
+
69
+### Test
70
+
71
+To run tests, use [`ctest`][]:
72
+
73
+```sh
74
+(cd build && ctest --output-on-failure)
75
+```
76
+
77
+[`ctest`]: https://cmake.org/cmake/help/v3.14/manual/ctest.1.html
78
+
79
+### Package
80
+
81
+To package, use [`cpack`][]:
82
+
83
+```sh
84
+(cd build && cpack)
85
+```
86
+
87
+[`cpack`]: https://cmake.org/cmake/help/v3.14/manual/cpack.1.html
88
+
89
+### Install
90
+
91
+To install onto the current system, use [`cmake --install`][]:
92
+
93
+```sh
94
+cmake --install build
95
+```
96
+
97
+[`cmake --install`]: https://cmake.org/cmake/help/v3.14/manual/cmake.1.html#install-a-project
98
+
11 99
 ## License
12 100
 
13 101
 Licensed under the [ISC License][] unless otherwise noted, see the
Browse code

Add license

Robert Cranston authored on 22/12/2021 07:30:28
Showing 1 changed files
... ...
@@ -7,3 +7,10 @@ A [GLSL][]/[OpenGL][] [\>=3.2][] [normal][] visualization library.
7 7
 [OpenGL]: https://en.wikipedia.org/wiki/OpenGL
8 8
 [\>=3.2]: https://en.wikipedia.org/wiki/OpenGL#Version_history
9 9
 [normal]: https://en.wikipedia.org/wiki/Normal_(geometry)
10
+
11
+## License
12
+
13
+Licensed under the [ISC License][] unless otherwise noted, see the
14
+[`LICENSE`](LICENSE) file.
15
+
16
+[ISC License]: https://choosealicense.com/licenses/isc/
Browse code

Add readme

Robert Cranston authored on 22/12/2021 07:29:57
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,9 @@
1
+# [`glvisnormals`][]
2
+
3
+A [GLSL][]/[OpenGL][] [\>=3.2][] [normal][] visualization library.
4
+
5
+[`glvisnormals`]: https://git.rcrnstn.net/rcrnstn/glvisnormals
6
+[GLSL]: https://en.wikipedia.org/wiki/OpenGL_Shading_Language
7
+[OpenGL]: https://en.wikipedia.org/wiki/OpenGL
8
+[\>=3.2]: https://en.wikipedia.org/wiki/OpenGL#Version_history
9
+[normal]: https://en.wikipedia.org/wiki/Normal_(geometry)