diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 216bc78..b323010 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -2,7 +2,6 @@ set(hdrs include/pw/core/debug.hpp include/pw/core/axisangle.hpp -# include/pw/core/buffer.hpp include/pw/core/core.hpp include/pw/core/math.hpp include/pw/core/matrixbase.hpp @@ -12,7 +11,8 @@ set(hdrs include/pw/core/serialize.hpp include/pw/core/image.hpp include/pw/core/point.hpp - include/pw/core/size.hpp + include/pw/core/rect.hpp + include/pw/core/size.hpp include/pw/core/timer.hpp include/pw/core/mesh.hpp include/pw/core/globals.hpp diff --git a/src/core/include/pw/core/axisangle.hpp b/src/core/include/pw/core/axisangle.hpp index 64175e4..36144ff 100644 --- a/src/core/include/pw/core/axisangle.hpp +++ b/src/core/include/pw/core/axisangle.hpp @@ -1,3 +1,25 @@ +/* + * Copyright (c) 1999-2019 Hartmut Seichter + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ #ifndef PW_CORE_AXISANGLE_HPP #define PW_CORE_AXISANGLE_HPP diff --git a/src/core/include/pw/core/core.hpp b/src/core/include/pw/core/core.hpp index d6cf912..5c99aca 100644 --- a/src/core/include/pw/core/core.hpp +++ b/src/core/include/pw/core/core.hpp @@ -1,5 +1,31 @@ +/* + * Copyright (c) 1999-2019 Hartmut Seichter + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + #ifndef PW_CORE_CORE_HPP #define PW_CORE_CORE_HPP +namespace pw { + +} #endif diff --git a/src/core/include/pw/core/debug.hpp b/src/core/include/pw/core/debug.hpp index 41a4571..899c133 100644 --- a/src/core/include/pw/core/debug.hpp +++ b/src/core/include/pw/core/debug.hpp @@ -1,30 +1,28 @@ /* - * Copyright (C) 1999-2017 Hartmut Seichter + * Copyright (c) 1999-2019 Hartmut Seichter * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. * - * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. */ -#ifndef PW_CORE_LOG_HPP_ -#define PW_CORE_LOG_HPP_ +#ifndef PW_CORE_LOG_HPP +#define PW_CORE_LOG_HPP #include diff --git a/src/core/include/pw/core/globals.hpp b/src/core/include/pw/core/globals.hpp index 765e6f4..877cb9b 100644 --- a/src/core/include/pw/core/globals.hpp +++ b/src/core/include/pw/core/globals.hpp @@ -1,3 +1,25 @@ +/* + * Copyright (c) 1999-2019 Hartmut Seichter + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ #ifndef PW_CORE_GLOBALS_HPP #define PW_CORE_GLOBALS_HPP diff --git a/src/core/include/pw/core/image.hpp b/src/core/include/pw/core/image.hpp index 7475527..1fc9107 100644 --- a/src/core/include/pw/core/image.hpp +++ b/src/core/include/pw/core/image.hpp @@ -1,3 +1,25 @@ +/* + * Copyright (c) 1999-2019 Hartmut Seichter + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ #ifndef PW_CORE_IMAGE_HPP #define PW_CORE_IMAGE_HPP diff --git a/src/core/include/pw/core/math.hpp b/src/core/include/pw/core/math.hpp index 1a10a3b..b9a9efe 100644 --- a/src/core/include/pw/core/math.hpp +++ b/src/core/include/pw/core/math.hpp @@ -1,3 +1,25 @@ +/* + * Copyright (c) 1999-2019 Hartmut Seichter + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ #ifndef PW_CORE_MATH_HPP #define PW_CORE_MATH_HPP diff --git a/src/core/include/pw/core/matrix.hpp b/src/core/include/pw/core/matrix.hpp index 202ed78..a2de3b7 100644 --- a/src/core/include/pw/core/matrix.hpp +++ b/src/core/include/pw/core/matrix.hpp @@ -1,28 +1,25 @@ /* - * Copyright (C) 1999-2017 Hartmut Seichter + * Copyright (c) 1999-2019 Hartmut Seichter * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. * - * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. */ - #ifndef PW_CORE_MATRIX_HPP #define PW_CORE_MATRIX_HPP diff --git a/src/core/include/pw/core/matrixbase.hpp b/src/core/include/pw/core/matrixbase.hpp index 89330aa..327a88e 100644 --- a/src/core/include/pw/core/matrixbase.hpp +++ b/src/core/include/pw/core/matrixbase.hpp @@ -1,28 +1,25 @@ /* - * Copyright (C) 1999-2017 Hartmut Seichter + * Copyright (c) 1999-2019 Hartmut Seichter * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. * - * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. */ - #ifndef PW_CORE_MATRIXBASE_HPP #define PW_CORE_MATRIXBASE_HPP diff --git a/src/core/include/pw/core/mesh.hpp b/src/core/include/pw/core/mesh.hpp index 0d40f7e..e2b5852 100644 --- a/src/core/include/pw/core/mesh.hpp +++ b/src/core/include/pw/core/mesh.hpp @@ -1,6 +1,28 @@ #ifndef PW_CORE_MESH_HPP #define PW_CORE_MESH_HPP +/* + * Copyright (c) 1999-2019 Hartmut Seichter + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ #include #include diff --git a/src/core/include/pw/core/point.hpp b/src/core/include/pw/core/point.hpp index 62c49e8..897a6d3 100644 --- a/src/core/include/pw/core/point.hpp +++ b/src/core/include/pw/core/point.hpp @@ -1,3 +1,25 @@ +/* + * Copyright (c) 1999-2019 Hartmut Seichter + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ #ifndef PW_CORE_POINT_HPP #define PW_CORE_POINT_HPP diff --git a/src/core/include/pw/core/quaternion.hpp b/src/core/include/pw/core/quaternion.hpp index d27b5af..b0e6767 100644 --- a/src/core/include/pw/core/quaternion.hpp +++ b/src/core/include/pw/core/quaternion.hpp @@ -1,28 +1,25 @@ /* - * Copyright (C) 1999-2017 Hartmut Seichter + * Copyright (c) 1999-2019 Hartmut Seichter * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. * - * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. */ - #ifndef TP_CORE_QUATERNION_HPP #define TP_CORE_QUATERNION_HPP diff --git a/src/core/include/pw/core/rect.hpp b/src/core/include/pw/core/rect.hpp new file mode 100644 index 0000000..418b85f --- /dev/null +++ b/src/core/include/pw/core/rect.hpp @@ -0,0 +1,51 @@ +/* + * Copyright (c) 1999-2019 Hartmut Seichter + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ +#ifndef PW_CORE_RECT_HPP +#define PW_CORE_RECT_HPP + +#include +#include + +namespace pw { + +template +struct rect_ { + + size_ size; + point_ position; + + rect_() = default; + + rect_(point_ const & p,size_ const & s) : size(s), position(p) {} + +}; + +typedef rect_ rect; + +typedef rect_ recti; +typedef rect_ rectf; +typedef rect_ rectd; + +} + +#endif diff --git a/src/core/include/pw/core/serialize.hpp b/src/core/include/pw/core/serialize.hpp index 7a6b2db..e63bfef 100644 --- a/src/core/include/pw/core/serialize.hpp +++ b/src/core/include/pw/core/serialize.hpp @@ -1,3 +1,25 @@ +/* + * Copyright (c) 1999-2019 Hartmut Seichter + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ #ifndef PW_CORE_SERIALIZE_HPP #define PW_CORE_SERIALIZE_HPP diff --git a/src/core/include/pw/core/size.hpp b/src/core/include/pw/core/size.hpp index 1e0dfa3..6cf4e9e 100644 --- a/src/core/include/pw/core/size.hpp +++ b/src/core/include/pw/core/size.hpp @@ -1,28 +1,25 @@ /* - * Copyright (C) 1999-2017 Hartmut Seichter + * Copyright (c) 1999-2019 Hartmut Seichter * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. * - * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. */ - #ifndef PW_CORE_SIZE_HPP #define PW_CORE_SIZE_HPP diff --git a/src/core/include/pw/core/timer.hpp b/src/core/include/pw/core/timer.hpp index 2520d1a..e32c2cb 100644 --- a/src/core/include/pw/core/timer.hpp +++ b/src/core/include/pw/core/timer.hpp @@ -1,10 +1,25 @@ -/* vim: set tabstop=4:softtabstop=4:shiftwidth=4:noexpandtab */ /* - * SSTT - Simplified Spatial Target Tracker + * Copyright (c) 1999-2019 Hartmut Seichter + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. * - * (c) Copyrights 2007-2018 Hartmut Seichter */ - #ifndef PW_CORE_TIMER_HPP_ #define PW_CORE_TIMER_HPP_ diff --git a/src/core/include/pw/core/vector.hpp b/src/core/include/pw/core/vector.hpp index 400b1f9..9875df1 100644 --- a/src/core/include/pw/core/vector.hpp +++ b/src/core/include/pw/core/vector.hpp @@ -1,28 +1,25 @@ /* - * Copyright (C) 1999-2017 Hartmut Seichter + * Copyright (c) 1999-2019 Hartmut Seichter * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. * - * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. */ - #ifndef PW_CORE_VECTOR_HPP #define PW_CORE_VECTOR_HPP diff --git a/src/system/src/window.cpp b/src/system/src/window.cpp index 0c5c18e..80e3aea 100644 --- a/src/system/src/window.cpp +++ b/src/system/src/window.cpp @@ -5,6 +5,7 @@ #include "pw/visual/context.hpp" #include "pw/system/input.hpp" +#include "pw/core/debug.hpp" #include #include @@ -98,10 +99,36 @@ struct window::impl { impl() { + // initialize glfwInit(); + // request specific version 3.2 + glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); + glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2); + glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); + glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); + + + // _window = glfwCreateWindow(640, 480, "pixwerxs", nullptr, nullptr); + // check Version + int major, minor, rev; + major = glfwGetWindowAttrib(_window, GLFW_CONTEXT_VERSION_MAJOR); + minor = glfwGetWindowAttrib(_window, GLFW_CONTEXT_VERSION_MINOR); + rev = glfwGetWindowAttrib(_window, GLFW_CONTEXT_REVISION); + + + // maybe something to pass to the outside +// debug::d() << "OpenGL " << major << "." << minor << "." << rev; + + +// if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)) +// { +// debug::e() << "G"; +// return -1; +// } + glfwSetWindowUserPointer(_window,this); glfwSetFramebufferSizeCallback(_window, window::impl::framebuffer_size_callback); @@ -117,7 +144,6 @@ struct window::impl { glfwSetScrollCallback(_window, scroll_callback); - #if 0 glfwMakeContextCurrent(_window); diff --git a/src/visual/CMakeLists.txt b/src/visual/CMakeLists.txt index 23eec8b..3e89d52 100644 --- a/src/visual/CMakeLists.txt +++ b/src/visual/CMakeLists.txt @@ -1,12 +1,12 @@ set(hdrs - include/pw/visual/renderer.hpp + include/pw/visual/mesh_renderer.hpp include/pw/visual/shader.hpp include/pw/visual/context.hpp ) set(srcs - src/renderer.cpp + src/mesh_renderer.cpp src/shader.cpp src/context.cpp ) diff --git a/src/visual/include/pw/visual/context.hpp b/src/visual/include/pw/visual/context.hpp index fd0bbc2..089bb02 100644 --- a/src/visual/include/pw/visual/context.hpp +++ b/src/visual/include/pw/visual/context.hpp @@ -1,17 +1,36 @@ +/* + * Copyright (c) 1999-2019 Hartmut Seichter + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + #ifndef PW_VISUAL_CONTEXT_HPP #define PW_VISUAL_CONTEXT_HPP -#include +#include namespace pw { class context { public: - struct size { - int width,height; - }; - virtual bool make_current() = 0; virtual void resize() = 0; virtual size size() = 0; diff --git a/src/visual/include/pw/visual/renderer.hpp b/src/visual/include/pw/visual/mesh_renderer.hpp similarity index 81% rename from src/visual/include/pw/visual/renderer.hpp rename to src/visual/include/pw/visual/mesh_renderer.hpp index 547102f..f923321 100644 --- a/src/visual/include/pw/visual/renderer.hpp +++ b/src/visual/include/pw/visual/mesh_renderer.hpp @@ -1,9 +1,6 @@ #ifndef PW_VISUAL_RENDERER_HPP #define PW_VISUAL_RENDERER_HPP -//#include -//#include - #include #include @@ -11,7 +8,7 @@ namespace pw { -class renderer { +class mesh_renderer { public: void render(const mesh& mesh, @@ -29,5 +26,4 @@ protected: } - #endif diff --git a/src/visual/include/pw/visual/shader.hpp b/src/visual/include/pw/visual/shader.hpp index 84d58df..95c91cc 100644 --- a/src/visual/include/pw/visual/shader.hpp +++ b/src/visual/include/pw/visual/shader.hpp @@ -3,6 +3,7 @@ #include #include +#include #include @@ -27,6 +28,19 @@ public: bool ready() const; + shader& bind(int location,float v); + shader& bind(int location,matrix4x4f const & v); + + int uniform_location(std::string const & name); + + template shader & bind(std::string const & name, T&& value) + { + int location = uniform_location(name); + if (location == -1) debug::e() << "missing uniform: "<< name; + else bind(location, std::forward(value)); + return *this; + } + protected: std::map _source; diff --git a/src/visual/src/mesh_renderer.cpp b/src/visual/src/mesh_renderer.cpp new file mode 100644 index 0000000..163dee4 --- /dev/null +++ b/src/visual/src/mesh_renderer.cpp @@ -0,0 +1,178 @@ +#include "pw/visual/mesh_renderer.hpp" + +#include "pw/core/mesh.hpp" +#include "pw/core/size.hpp" + +#include "glad/glad.h" + +#include + +namespace pw { + + +struct mesh_renderer::impl { + + GLuint _vao = 0; + std::vector _vbos; + + impl(mesh_renderer& ) + { + } + + void create(std::shared_ptr mesh) + { + glGenVertexArrays(1,&_vao); + glBindVertexArray(_vao); + + size_t arrays_needed = 0; + + // should bail out here + if (!mesh->vertices().empty()) arrays_needed++; + if (!mesh->indices().empty()) arrays_needed++; + + // TODO: implement the other arrays + + _vbos.resize(arrays_needed); + + glGenBuffers(_vbos.size(), _vbos.data()); + + // vertices + glBindBuffer(GL_ARRAY_BUFFER, _vbos[0]); + glBufferData(GL_ARRAY_BUFFER, sizeof(mesh->vertices().front()) * mesh->vertices().size(), mesh->vertices().data(), + GL_STATIC_DRAW); + glEnableVertexAttribArray(0); + glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, nullptr); + + // indices + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _vbos[1]); + glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(mesh->indices().front()) * mesh->indices().size(), mesh->indices().data(), + GL_STATIC_DRAW); + + + // stop binding + glBindVertexArray(0); + + } + + void destroy() + { + glDeleteVertexArrays(1,&_vao); + for (auto vbo : _vbos) + glDeleteBuffers(1,&vbo); + + _vbos.clear(); + } +}; + + +struct renderer { + + sizei _size; + + GLuint _fbo_draw; + GLuint _fbo_msaa; + + GLuint rboColorId; + GLuint rboDepthId; + + bool create() + { + int max_msaa; + + // query actual maximum MSAA + glGetIntegerv(GL_MAX_SAMPLES,&max_msaa); + + // create a 4x MSAA renderbuffer object for colorbuffer + int msaa = 4; + +// msaa = std::clamp(msaa,max_msaa); + + glGenRenderbuffers(1, &rboColorId); + glBindRenderbuffer(GL_RENDERBUFFER, rboColorId); + glRenderbufferStorageMultisample(GL_RENDERBUFFER, msaa, GL_RGB8, _size.width, _size.height); + + // create a 4x MSAA renderbuffer object for depthbuffer + + glGenRenderbuffers(1, &rboDepthId); + glBindRenderbuffer(GL_RENDERBUFFER, rboDepthId); + glRenderbufferStorageMultisample(GL_RENDERBUFFER, msaa, GL_DEPTH_COMPONENT, _size.width, _size.height); + + // create a 4x MSAA framebuffer object + glGenFramebuffers(1, &_fbo_msaa); + glBindFramebuffer(GL_FRAMEBUFFER, _fbo_msaa); + + // attach colorbuffer image to FBO + glFramebufferRenderbuffer(GL_FRAMEBUFFER, // 1. fbo target: GL_FRAMEBUFFER + GL_COLOR_ATTACHMENT0, // 2. color attachment point + GL_RENDERBUFFER, // 3. rbo target: GL_RENDERBUFFER + rboColorId); // 4. rbo ID + + // attach depthbuffer image to FBO + glFramebufferRenderbuffer(GL_FRAMEBUFFER, // 1. fbo target: GL_FRAMEBUFFER + GL_DEPTH_ATTACHMENT, // 2. depth attachment point + GL_RENDERBUFFER, // 3. rbo target: GL_RENDERBUFFER + rboDepthId); // 4. rbo ID + + // check FBO status + if(glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) + return false; + + return true; + } + + void draw() + { + /* We are going to blit into the window (default framebuffer) */ + glBindFramebuffer (GL_DRAW_FRAMEBUFFER, 0); + glDrawBuffer (GL_BACK); /* Use backbuffer as color dst. */ + + /* Read from your FBO */ + glBindFramebuffer (GL_READ_FRAMEBUFFER, _fbo_draw ); + glReadBuffer (GL_COLOR_ATTACHMENT0); /* Use Color Attachment 0 as color src. */ + + /* Copy the color and depth buffer from your FBO to the default framebuffer */ + glBlitFramebuffer (0,0, _size.width, _size.height, + 0,0, _size.width, _size.height, + GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT, + GL_NEAREST); + } + +}; + + +class pipeline; + +class pass +{ +public: + virtual void apply(pipeline& p); +}; + +class pipeline +{ + +public: + void apply() + { + for (auto p : _passes) p.apply(*this); + } + +protected: + std::vector _passes; +}; + + + +//pipeline > +// n*pass +// shadow_pass +// lighting_pass +// mesh_pass +// compositor_pass + +//compositor +// render to fbo > add a +// glBlitFramebuffer .. https://stackoverflow.com/questions/29254574/using-glblitframebuffer-to-display-a-texture + + +} diff --git a/src/visual/src/renderer.cpp b/src/visual/src/renderer.cpp deleted file mode 100644 index a79227d..0000000 --- a/src/visual/src/renderer.cpp +++ /dev/null @@ -1,69 +0,0 @@ -#include "pw/visual/renderer.hpp" - -#include "pw/core/mesh.hpp" - -#include "glad/glad.h" - -namespace pw { - - -struct renderer::impl { - - GLuint _vao = 0; - std::vector _vbos; - - impl(renderer& ) - { - } - - void create(std::shared_ptr mesh) - { - glGenVertexArrays(1,&_vao); - glBindVertexArray(_vao); - - size_t arrays_needed = 0; - - // should bail out here - if (!mesh->vertices().empty()) arrays_needed++; - if (!mesh->indices().empty()) arrays_needed++; - - // TODO: implement the other arrays - - _vbos.resize(arrays_needed); - - glGenBuffers(_vbos.size(), _vbos.data()); - - // vertices - glBindBuffer(GL_ARRAY_BUFFER, _vbos[0]); - glBufferData(GL_ARRAY_BUFFER, sizeof(mesh->vertices().front()) * mesh->vertices().size(), mesh->vertices().data(), - GL_STATIC_DRAW); - glEnableVertexAttribArray(0); - glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, nullptr); - - // indices - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _vbos[1]); - glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(mesh->indices().front()) * mesh->indices().size(), mesh->indices().data(), - GL_STATIC_DRAW); - - - // stop binding - glBindVertexArray(0); - - } - - void destroy() - { - glDeleteVertexArrays(1,&_vao); - for (auto vbo : _vbos) - glDeleteBuffers(1,&vbo); - - _vbos.clear(); - } -}; - -//pipeline > n*pass -//compositor -// render to fbo > - - -} diff --git a/src/visual/src/shader.cpp b/src/visual/src/shader.cpp index 29560e4..0883a2a 100644 --- a/src/visual/src/shader.cpp +++ b/src/visual/src/shader.cpp @@ -70,17 +70,12 @@ struct shader::impl glGetShaderiv(shaderId, GL_INFO_LOG_LENGTH, &log_length); - char* log_buffer = new char[log_length]; + std::unique_ptr log_buffer(new char[log_length]); - glGetShaderInfoLog(shaderId, log_length, &log_length, log_buffer); + glGetShaderInfoLog(shaderId, log_length, &log_length, log_buffer.get()); // TODO - handle errors! - - std::string info_log_string(log_buffer); - - delete [] log_buffer; - - debug::e() << info_log_string; + debug::e() << log_buffer.get(); break; } @@ -99,9 +94,9 @@ struct shader::impl // attribute binding ... /* Bind attribute index 0 (coordinates) to in_Position and attribute index 1 (color) to in_Color */ - /* Attribute locations must be setup before calling glLinkProgram. */ -// glBindAttribLocation(shaderprogram, 0, "in_Position"); -// glBindAttribLocation(shaderprogram, 1, "in_Color"); + /* Attribute locations must be setup before calling glLinkProgram. */ + // glBindAttribLocation(shaderprogram, 0, "in_Position"); + // glBindAttribLocation(shaderprogram, 1, "in_Color"); glLinkProgram(_shader_program); @@ -116,20 +111,16 @@ struct shader::impl glGetProgramiv(_shader_program, GL_INFO_LOG_LENGTH, &log_length); /* The maxLength includes the NULL character */ - char* info_log = new char[log_length]; + std::unique_ptr info_log(new char[log_length]); /* Notice that glGetProgramInfoLog, not glGetShaderInfoLog. */ - glGetProgramInfoLog(_shader_program, log_length, &log_length, info_log); + glGetProgramInfoLog(_shader_program, log_length, &log_length, info_log.get()); - - std::string info_log_string; - - debug::e() << info_log_string; + debug::e() << info_log.get(); /* Handle the error in an appropriate way such as displaying a message or writing to a log file. */ /* In this simple program, we'll just leave */ - delete [] info_log; return; } @@ -153,12 +144,15 @@ struct shader::impl } } - void set_uniform(const std::string& name,const matrix4x4f& m) + int uniform_location(std::string const& name) { - GLint l = glGetUniformLocation(_shader_program,name.c_str()); - glUniformMatrix4fv(l,1,GL_FALSE,m.data()); // TODO transpose? + return glGetUniformLocation(_shader_program,name.c_str()); } + void bind(int location,const matrix4x4f& m) + { + glUniformMatrix4fv(location,1,GL_FALSE,m.data()); // TODO transpose? + } }; @@ -173,5 +167,10 @@ bool shader::ready() const return _impl->is_valid(); } +int shader::uniform_location(const std::string &name) +{ + return _impl->uniform_location(name); +} + }