Initial import
@@ -0,0 +1,31 @@
|
||||
cmake_minimum_required (VERSION 2.8.12)
|
||||
|
||||
# Create header for C file
|
||||
file(WRITE ${OUTPUT_C} "/* Autogenerated by bin2c */\n\n")
|
||||
file(APPEND ${OUTPUT_C} "#include <stdint.h>\n\n")
|
||||
|
||||
# Create header of H file
|
||||
file(WRITE ${OUTPUT_H} "/* Autogenerated by bin2c */\n\n")
|
||||
file(APPEND ${OUTPUT_H} "#pragma once\n")
|
||||
file(APPEND ${OUTPUT_H} "#include <stdint.h>\n\n")
|
||||
|
||||
string(REPLACE "," ";" INPUT_LIST ${INPUT_FILES})
|
||||
|
||||
|
||||
# Iterate through binary files files
|
||||
foreach(bin ${INPUT_LIST})
|
||||
# Get short filename
|
||||
string(REGEX MATCH "([^/]+)$" filename ${bin})
|
||||
# Replace filename spaces & extension separator for C compatibility
|
||||
string(REGEX REPLACE "\\.| |-" "_" filename ${filename})
|
||||
# Convert to lower case
|
||||
string(TOLOWER ${filename} filename)
|
||||
# Read hex data from file
|
||||
file(READ ${bin} filedata HEX)
|
||||
# Convert hex data for C compatibility
|
||||
string(REGEX REPLACE "([0-9a-f][0-9a-f])" "0x\\1," filedata "${filedata}")
|
||||
# Append data to c file
|
||||
file(APPEND ${OUTPUT_C} "extern const uint8_t ${filename}[] = {${filedata}0x00};\n\nuint32_t ${filename}_size = sizeof(${filename}) - 1;\n\n")
|
||||
# Append extern definitions to h file
|
||||
file(APPEND ${OUTPUT_H} "extern const uint8_t ${filename}[];\n\nextern uint32_t ${filename}_size;\n\n")
|
||||
endforeach()
|
||||
@@ -0,0 +1,83 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Script to check include/test code for common pybind11 code style errors.
|
||||
#
|
||||
# This script currently checks for
|
||||
#
|
||||
# 1. use of tabs instead of spaces
|
||||
# 2. MSDOS-style CRLF endings
|
||||
# 3. trailing spaces
|
||||
# 4. missing space between keyword and parenthesis, e.g.: for(, if(, while(
|
||||
# 5. Missing space between right parenthesis and brace, e.g. 'for (...){'
|
||||
# 6. opening brace on its own line. It should always be on the same line as the
|
||||
# if/while/for/do statment.
|
||||
#
|
||||
# Invoke as: tools/check-style.sh
|
||||
#
|
||||
|
||||
errors=0
|
||||
IFS=$'\n'
|
||||
found=
|
||||
# The mt=41 sets a red background for matched tabs:
|
||||
exec 3< <(GREP_COLORS='mt=41' grep $'\t' include/ src/ python/*.{h,cpp} docs/*.rst -rn --color=always)
|
||||
while read -u 3 f; do
|
||||
if [ -z "$found" ]; then
|
||||
echo -e '\e[31m\e[01mError: found tabs instead of spaces in the following files:\e[0m'
|
||||
found=1
|
||||
errors=1
|
||||
fi
|
||||
|
||||
echo " $f"
|
||||
done
|
||||
|
||||
found=
|
||||
# The mt=41 sets a red background for matched MS-DOS CRLF characters
|
||||
exec 3< <(GREP_COLORS='mt=41' grep -IUlr $'\r' include/ src/ python/*.{h,cpp} docs/*.rst --color=always)
|
||||
while read -u 3 f; do
|
||||
if [ -z "$found" ]; then
|
||||
echo -e '\e[31m\e[01mError: found CRLF characters in the following files:\e[0m'
|
||||
found=1
|
||||
errors=1
|
||||
fi
|
||||
|
||||
echo " $f"
|
||||
done
|
||||
|
||||
found=
|
||||
# The mt=41 sets a red background for matched trailing spaces
|
||||
exec 3< <(GREP_COLORS='mt=41' grep '\s\+$' include/ src/ python/*.{h,cpp} docs/*.rst -rn --color=always)
|
||||
while read -u 3 f; do
|
||||
if [ -z "$found" ]; then
|
||||
echo -e '\e[31m\e[01mError: found trailing spaces in the following files:\e[0m'
|
||||
found=1
|
||||
errors=1
|
||||
fi
|
||||
|
||||
echo " $f"
|
||||
done
|
||||
|
||||
found=
|
||||
exec 3< <(grep '\<\(if\|for\|while\|catch\)(\|){' include/ src/ python/*.{h,cpp} -rn --color=always)
|
||||
while read -u 3 line; do
|
||||
if [ -z "$found" ]; then
|
||||
echo -e '\e[31m\e[01mError: found the following coding style problems:\e[0m'
|
||||
found=1
|
||||
errors=1
|
||||
fi
|
||||
|
||||
echo " $line"
|
||||
done
|
||||
|
||||
found=
|
||||
exec 3< <(GREP_COLORS='mt=41' grep '^\s*{\s*$' include/ src/ -rn --color=always)
|
||||
while read -u 3 f; do
|
||||
if [ -z "$found" ]; then
|
||||
echo -e '\e[31m\e[01mError: braces should occur on the same line as the if/while/.. statement. Found issues in the following files: \e[0m'
|
||||
found=1
|
||||
errors=1
|
||||
fi
|
||||
|
||||
echo " $f"
|
||||
done
|
||||
|
||||
exit $errors
|
||||
@@ -0,0 +1,132 @@
|
||||
# Imports FontAwesome's 'all.css' and creates the 'icons.h' header file
|
||||
|
||||
import yaml
|
||||
|
||||
with open("icons.yml", 'r') as stream:
|
||||
try:
|
||||
data = yaml.safe_load(stream)
|
||||
except yaml.YAMLError as exc:
|
||||
print(exc)
|
||||
|
||||
icons = []
|
||||
for key, value in data.items():
|
||||
if 'solid' in value['styles']:
|
||||
key = 'fa-' + key
|
||||
name = key.replace('-', '_').upper()
|
||||
spacer = " " * (40-len(name))
|
||||
icons.append((key, name, spacer, value['unicode']))
|
||||
|
||||
|
||||
with open("icons.h", 'w') as f:
|
||||
f.write('''/*
|
||||
NanoGUI was developed by Wenzel Jakob <wenzel.jakob@epfl.ch>.
|
||||
The widget drawing code is based on the NanoVG demo application
|
||||
by Mikko Mononen.
|
||||
|
||||
All rights reserved. Use of this source code is governed by a
|
||||
BSD-style license that can be found in the LICENSE.txt file.
|
||||
*/
|
||||
|
||||
/* Developer note: need to make a change to this file?
|
||||
* Please raise an Issue on GitHub describing what needs to change. This file
|
||||
* was generated, so the scripts that generated it needs to update as well.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \\file nanogui/icons.h
|
||||
*
|
||||
* \\brief This is a list of icon codes for the free variant of the
|
||||
* FontAwesome 5.10.1 font.
|
||||
*
|
||||
* \\rst
|
||||
*
|
||||
* This file defines the full listing of
|
||||
* `FontAwesome <https://raw.githubusercontent.com/FortAwesome/Font-Awesome>`_
|
||||
* icons available in NanoGUI. Please note that if viewing the documentation
|
||||
* on the web, your browser may display the icons differently than what they
|
||||
* look like in NanoGUI. Run the one of the :ref:`nanogui_example_icons`
|
||||
* executables to see what they all look like in NanoGUI.
|
||||
*
|
||||
* .. tip::
|
||||
*
|
||||
* In C++, ``#include <nanogui/icons.h>`` to gain access to the ``#define``
|
||||
* shown in these docs and simply reference the names as listed in the
|
||||
* documentation. To use the icons from Python, declare
|
||||
* ``from nanogui import icons`` and reference the icons as follows:
|
||||
* ``icons.FA_ASTERISK``.
|
||||
*
|
||||
* The following icons are available:
|
||||
*
|
||||
* .. raw:: html
|
||||
*
|
||||
* <center>
|
||||
* <div class="wy-table-responsive">
|
||||
* <table class="docutils" border=1>
|
||||
* <colgroup>
|
||||
* <col width="90%" align="center"/>
|
||||
* <col width="10%" align="center" />
|
||||
* </colgroup>
|
||||
* <thead valign="bottom">
|
||||
* <tr class="row-odd">
|
||||
* <th class="head" align="center">Definition</th>
|
||||
* <th class="head" align="center">Icon</th>
|
||||
* </tr>
|
||||
* </thead>
|
||||
* <tbody valign="top">
|
||||
''')
|
||||
|
||||
for i, icon in enumerate(icons):
|
||||
evenodd = 'even' if i % 2 == 0 else 'odd'
|
||||
name_orig = icon[0]
|
||||
name_new = icon[1]
|
||||
f.write(f''' * <tr class="row-{evenodd}">
|
||||
* <td align="right"><code>{name_new}</code></td>
|
||||
* <td align="center"><span class="{name_orig}"></span></td>
|
||||
* </tr>
|
||||
''')
|
||||
f.write(''' * </tbody>
|
||||
* </table>
|
||||
* </div><!-- wy-table-responsive -->
|
||||
* </center>
|
||||
*
|
||||
* \endrst
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
// prevent individual pages from being generated for all of these
|
||||
#if !defined(DOXYGEN_SHOULD_SKIP_THIS)
|
||||
|
||||
''')
|
||||
for name_orig, name_new, spacer, hexcode in icons:
|
||||
f.write(f'#define {name_new}{spacer}0x{hexcode}\n')
|
||||
f.write('\n#endif // DOXYGEN_SHOULD_SKIP_THIS\n')
|
||||
|
||||
|
||||
with open('icons.cpp', 'w') as f:
|
||||
f.write('''#ifdef NANOGUI_PYTHON
|
||||
|
||||
#include "python.h"
|
||||
|
||||
/* Developer note: need to make a change to this file?
|
||||
* Please raise an Issue on GitHub describing what needs to change. This file
|
||||
* was generated, so the scripts that generated it needs to update as well.
|
||||
*/
|
||||
|
||||
void register_entypo(py::module &m) {
|
||||
/* Entypo constants */
|
||||
{
|
||||
#define C(name) g.attr(#name) = py::int_(name);
|
||||
py::module g = m.def_submodule("icons");
|
||||
''')
|
||||
for name_orig, name_new, spacer, hexcode in icons:
|
||||
f.write(f' C({name_new});\n')
|
||||
f.write(''' #undef C
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
''')
|
||||
with open('example_icons.cpp', 'w') as f:
|
||||
for name_orig, name_new, spacer, hexcode in icons:
|
||||
f.write(f' ADD_BUTTON({name_new});\n')
|
||||
|
After Width: | Height: | Size: 101 KiB |
|
After Width: | Height: | Size: 101 KiB |
|
After Width: | Height: | Size: 107 KiB |
|
After Width: | Height: | Size: 110 KiB |
|
After Width: | Height: | Size: 116 KiB |
|
After Width: | Height: | Size: 4.2 KiB |
|
After Width: | Height: | Size: 108 KiB |
|
After Width: | Height: | Size: 96 KiB |
|
After Width: | Height: | Size: 103 KiB |
@@ -0,0 +1,18 @@
|
||||
#version 330
|
||||
|
||||
in vec2 uv;
|
||||
in vec2 position_background;
|
||||
out vec4 frag_color;
|
||||
uniform sampler2D image;
|
||||
uniform vec4 background_color;
|
||||
|
||||
void main() {
|
||||
vec2 frac = position_background - floor(position_background);
|
||||
float checkerboard = ((frac.x > .5) == (frac.y > .5)) ? 0.4 : 0.5;
|
||||
|
||||
vec4 background = (1.0 - background_color.a) * vec4(vec3(checkerboard), 1.0) +
|
||||
background_color.a * vec4(background_color.rgb, 1.0);
|
||||
|
||||
vec4 value = texture(image, uv);
|
||||
frag_color = (1.0 - value.a) * background + value.a * vec4(value.rgb, 1.0);
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
precision highp float;
|
||||
|
||||
varying vec2 uv;
|
||||
varying vec2 position_background;
|
||||
uniform sampler2D image;
|
||||
uniform vec4 background_color;
|
||||
|
||||
void main() {
|
||||
vec2 frac = position_background - floor(position_background);
|
||||
float checkerboard = ((frac.x > .5) == (frac.y > .5)) ? 0.4 : 0.5;
|
||||
|
||||
vec4 background = (1.0 - background_color.a) * vec4(vec3(checkerboard), 1.0) +
|
||||
background_color.a * vec4(background_color.rgb, 1.0);
|
||||
|
||||
vec4 value = texture2D(image, uv);
|
||||
gl_FragColor = (1.0 - value.a) * background + value.a * vec4(value.rgb, 1.0);
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
#include <metal_stdlib>
|
||||
|
||||
using namespace metal;
|
||||
|
||||
struct VertexOut {
|
||||
float4 position_image [[position]];
|
||||
float2 position_background;
|
||||
float2 uv;
|
||||
};
|
||||
|
||||
fragment float4 fragment_main(VertexOut vert [[stage_in]],
|
||||
texture2d<float, access::sample> image,
|
||||
constant float4 &background_color,
|
||||
sampler image_sampler) {
|
||||
float2 frac = vert.position_background - floor(vert.position_background);
|
||||
float checkerboard = ((frac.x > .5f) == (frac.y > .5f)) ? .4f : .5f;
|
||||
|
||||
float4 background = (1.f - background_color.a) * float4(float3(checkerboard), 1.f) +
|
||||
background_color.a * float4(background_color.rgb, 1.f);
|
||||
|
||||
float4 value = image.sample(image_sampler, vert.uv);
|
||||
return (1.f - value.a) * background + value.a * float4(value.rgb, 1.f);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
#version 330
|
||||
|
||||
uniform mat4 matrix_image;
|
||||
uniform mat4 matrix_background;
|
||||
in vec2 position;
|
||||
out vec2 position_background;
|
||||
out vec2 uv;
|
||||
|
||||
void main() {
|
||||
vec4 p = vec4(position, 0.0, 1.0);
|
||||
gl_Position = matrix_image * p;
|
||||
position_background = (matrix_background * p).xy;
|
||||
uv = position;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
precision highp float;
|
||||
|
||||
uniform mat4 matrix_image;
|
||||
uniform mat4 matrix_background;
|
||||
attribute vec2 position;
|
||||
varying vec2 position_background;
|
||||
varying vec2 uv;
|
||||
|
||||
void main() {
|
||||
vec4 p = vec4(position, 0.0, 1.0);
|
||||
gl_Position = matrix_image * p;
|
||||
position_background = (matrix_background * p).xy;
|
||||
uv = position;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
#include <metal_stdlib>
|
||||
|
||||
using namespace metal;
|
||||
|
||||
struct VertexOut {
|
||||
float4 position_image [[position]];
|
||||
float2 position_background;
|
||||
float2 uv;
|
||||
};
|
||||
|
||||
vertex VertexOut vertex_main(const device float2 *position,
|
||||
constant float4x4 &matrix_image,
|
||||
constant float4x4 &matrix_background,
|
||||
uint id [[vertex_id]]) {
|
||||
float4 p = float4(position[id], 0.f, 1.f);
|
||||
VertexOut vert;
|
||||
vert.position_image = matrix_image * p;
|
||||
vert.position_background = (matrix_background * p).xy;
|
||||
vert.uv = p.xy;
|
||||
return vert;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
@PACKAGE_INIT@
|
||||
|
||||
set(nanogui_INCLUDE_DIR "${PACKAGE_PREFIX_DIR}/@CMAKE_INSTALL_INCLUDEDIR@")
|
||||
set(nanogui_VERSION_TYPE "@ENOKI_VERSION_TYPE@")
|
||||
set(nanogui_LIBRARY "")
|
||||
|
||||
check_required_components(nanogui)
|
||||
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/nanoguiTargets.cmake")
|
||||
|
||||
if(NOT nanogui_FIND_QUIETLY)
|
||||
message(STATUS "Found nanogui: ${nanogui_INCLUDE_DIR} (found version \"${nanogui_VERSION}\" ${nanogui_VERSION_TYPE})")
|
||||
endif()
|
||||
|
||||
|
After Width: | Height: | Size: 1.1 MiB |
|
After Width: | Height: | Size: 47 KiB |