added proper license in core various poking into getting context > system > renderer properly setup

This commit is contained in:
Hartmut Seichter 2019-01-12 22:55:09 +01:00
parent c7c7d5af77
commit 3cc0fde1e1
25 changed files with 628 additions and 236 deletions

View file

@ -2,7 +2,6 @@
set(hdrs set(hdrs
include/pw/core/debug.hpp include/pw/core/debug.hpp
include/pw/core/axisangle.hpp include/pw/core/axisangle.hpp
# include/pw/core/buffer.hpp
include/pw/core/core.hpp include/pw/core/core.hpp
include/pw/core/math.hpp include/pw/core/math.hpp
include/pw/core/matrixbase.hpp include/pw/core/matrixbase.hpp
@ -12,7 +11,8 @@ set(hdrs
include/pw/core/serialize.hpp include/pw/core/serialize.hpp
include/pw/core/image.hpp include/pw/core/image.hpp
include/pw/core/point.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/timer.hpp
include/pw/core/mesh.hpp include/pw/core/mesh.hpp
include/pw/core/globals.hpp include/pw/core/globals.hpp

View file

@ -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 #ifndef PW_CORE_AXISANGLE_HPP
#define PW_CORE_AXISANGLE_HPP #define PW_CORE_AXISANGLE_HPP

View file

@ -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 #ifndef PW_CORE_CORE_HPP
#define PW_CORE_CORE_HPP #define PW_CORE_CORE_HPP
namespace pw {
}
#endif #endif

View file

@ -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 * Permission is hereby granted, free of charge, to any person obtaining a copy
* modification, are permitted provided that the following conditions * of this software and associated documentation files (the "Software"), to deal
* are met: * in the Software without restriction, including without limitation the rights
* 1. Redistributions of source code must retain the above copyright * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* notice, this list of conditions and the following disclaimer. * copies of the Software, and to permit persons to whom the Software is
* 2. Redistributions in binary form must reproduce the above copyright * furnished to do so, subject to the following conditions:
* notice, this list of conditions and the following disclaimer in the *
* documentation and/or other materials provided with the distribution. * 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_ #ifndef PW_CORE_LOG_HPP
#define PW_CORE_LOG_HPP_ #define PW_CORE_LOG_HPP
#include <pw/core/globals.hpp> #include <pw/core/globals.hpp>

View file

@ -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 #ifndef PW_CORE_GLOBALS_HPP
#define PW_CORE_GLOBALS_HPP #define PW_CORE_GLOBALS_HPP

View file

@ -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 #ifndef PW_CORE_IMAGE_HPP
#define PW_CORE_IMAGE_HPP #define PW_CORE_IMAGE_HPP

View file

@ -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 #ifndef PW_CORE_MATH_HPP
#define PW_CORE_MATH_HPP #define PW_CORE_MATH_HPP

View file

@ -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 * Permission is hereby granted, free of charge, to any person obtaining a copy
* modification, are permitted provided that the following conditions * of this software and associated documentation files (the "Software"), to deal
* are met: * in the Software without restriction, including without limitation the rights
* 1. Redistributions of source code must retain the above copyright * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* notice, this list of conditions and the following disclaimer. * copies of the Software, and to permit persons to whom the Software is
* 2. Redistributions in binary form must reproduce the above copyright * furnished to do so, subject to the following conditions:
* notice, this list of conditions and the following disclaimer in the *
* documentation and/or other materials provided with the distribution. * 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 #ifndef PW_CORE_MATRIX_HPP
#define PW_CORE_MATRIX_HPP #define PW_CORE_MATRIX_HPP

View file

@ -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 * Permission is hereby granted, free of charge, to any person obtaining a copy
* modification, are permitted provided that the following conditions * of this software and associated documentation files (the "Software"), to deal
* are met: * in the Software without restriction, including without limitation the rights
* 1. Redistributions of source code must retain the above copyright * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* notice, this list of conditions and the following disclaimer. * copies of the Software, and to permit persons to whom the Software is
* 2. Redistributions in binary form must reproduce the above copyright * furnished to do so, subject to the following conditions:
* notice, this list of conditions and the following disclaimer in the *
* documentation and/or other materials provided with the distribution. * 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 #ifndef PW_CORE_MATRIXBASE_HPP
#define PW_CORE_MATRIXBASE_HPP #define PW_CORE_MATRIXBASE_HPP

View file

@ -1,6 +1,28 @@
#ifndef PW_CORE_MESH_HPP #ifndef PW_CORE_MESH_HPP
#define 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 <pw/core/globals.hpp> #include <pw/core/globals.hpp>
#include <pw/core/vector.hpp> #include <pw/core/vector.hpp>

View file

@ -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 #ifndef PW_CORE_POINT_HPP
#define PW_CORE_POINT_HPP #define PW_CORE_POINT_HPP

View file

@ -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 * Permission is hereby granted, free of charge, to any person obtaining a copy
* modification, are permitted provided that the following conditions * of this software and associated documentation files (the "Software"), to deal
* are met: * in the Software without restriction, including without limitation the rights
* 1. Redistributions of source code must retain the above copyright * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* notice, this list of conditions and the following disclaimer. * copies of the Software, and to permit persons to whom the Software is
* 2. Redistributions in binary form must reproduce the above copyright * furnished to do so, subject to the following conditions:
* notice, this list of conditions and the following disclaimer in the *
* documentation and/or other materials provided with the distribution. * 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 #ifndef TP_CORE_QUATERNION_HPP
#define TP_CORE_QUATERNION_HPP #define TP_CORE_QUATERNION_HPP

View file

@ -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 <pw/core/size.hpp>
#include <pw/core/point.hpp>
namespace pw {
template <typename T_>
struct rect_ {
size_<T_> size;
point_<T_> position;
rect_() = default;
rect_(point_<T_> const & p,size_<T_> const & s) : size(s), position(p) {}
};
typedef rect_<real_t> rect;
typedef rect_<int> recti;
typedef rect_<float> rectf;
typedef rect_<float> rectd;
}
#endif

View file

@ -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 #ifndef PW_CORE_SERIALIZE_HPP
#define PW_CORE_SERIALIZE_HPP #define PW_CORE_SERIALIZE_HPP

View file

@ -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 * Permission is hereby granted, free of charge, to any person obtaining a copy
* modification, are permitted provided that the following conditions * of this software and associated documentation files (the "Software"), to deal
* are met: * in the Software without restriction, including without limitation the rights
* 1. Redistributions of source code must retain the above copyright * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* notice, this list of conditions and the following disclaimer. * copies of the Software, and to permit persons to whom the Software is
* 2. Redistributions in binary form must reproduce the above copyright * furnished to do so, subject to the following conditions:
* notice, this list of conditions and the following disclaimer in the *
* documentation and/or other materials provided with the distribution. * 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 #ifndef PW_CORE_SIZE_HPP
#define PW_CORE_SIZE_HPP #define PW_CORE_SIZE_HPP

View file

@ -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_ #ifndef PW_CORE_TIMER_HPP_
#define PW_CORE_TIMER_HPP_ #define PW_CORE_TIMER_HPP_

View file

@ -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 * Permission is hereby granted, free of charge, to any person obtaining a copy
* modification, are permitted provided that the following conditions * of this software and associated documentation files (the "Software"), to deal
* are met: * in the Software without restriction, including without limitation the rights
* 1. Redistributions of source code must retain the above copyright * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* notice, this list of conditions and the following disclaimer. * copies of the Software, and to permit persons to whom the Software is
* 2. Redistributions in binary form must reproduce the above copyright * furnished to do so, subject to the following conditions:
* notice, this list of conditions and the following disclaimer in the *
* documentation and/or other materials provided with the distribution. * 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 #ifndef PW_CORE_VECTOR_HPP
#define PW_CORE_VECTOR_HPP #define PW_CORE_VECTOR_HPP

View file

@ -5,6 +5,7 @@
#include "pw/visual/context.hpp" #include "pw/visual/context.hpp"
#include "pw/system/input.hpp" #include "pw/system/input.hpp"
#include "pw/core/debug.hpp"
#include <cmath> #include <cmath>
#include <locale> #include <locale>
@ -98,10 +99,36 @@ struct window::impl {
impl() impl()
{ {
// initialize
glfwInit(); 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); _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); glfwSetWindowUserPointer(_window,this);
glfwSetFramebufferSizeCallback(_window, window::impl::framebuffer_size_callback); glfwSetFramebufferSizeCallback(_window, window::impl::framebuffer_size_callback);
@ -117,7 +144,6 @@ struct window::impl {
glfwSetScrollCallback(_window, scroll_callback); glfwSetScrollCallback(_window, scroll_callback);
#if 0 #if 0
glfwMakeContextCurrent(_window); glfwMakeContextCurrent(_window);

View file

@ -1,12 +1,12 @@
set(hdrs set(hdrs
include/pw/visual/renderer.hpp include/pw/visual/mesh_renderer.hpp
include/pw/visual/shader.hpp include/pw/visual/shader.hpp
include/pw/visual/context.hpp include/pw/visual/context.hpp
) )
set(srcs set(srcs
src/renderer.cpp src/mesh_renderer.cpp
src/shader.cpp src/shader.cpp
src/context.cpp src/context.cpp
) )

View file

@ -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 #ifndef PW_VISUAL_CONTEXT_HPP
#define PW_VISUAL_CONTEXT_HPP #define PW_VISUAL_CONTEXT_HPP
#include <pw/scene/component.hpp> #include <pw/core/size.hpp>
namespace pw { namespace pw {
class context { class context {
public: public:
struct size {
int width,height;
};
virtual bool make_current() = 0; virtual bool make_current() = 0;
virtual void resize() = 0; virtual void resize() = 0;
virtual size size() = 0; virtual size size() = 0;

View file

@ -1,9 +1,6 @@
#ifndef PW_VISUAL_RENDERER_HPP #ifndef PW_VISUAL_RENDERER_HPP
#define PW_VISUAL_RENDERER_HPP #define PW_VISUAL_RENDERER_HPP
//#include <pw/scene/component.hpp>
//#include <pw/scene/camera.hpp>
#include <pw/core/matrix.hpp> #include <pw/core/matrix.hpp>
#include <pw/core/mesh.hpp> #include <pw/core/mesh.hpp>
@ -11,7 +8,7 @@
namespace pw { namespace pw {
class renderer { class mesh_renderer {
public: public:
void render(const mesh& mesh, void render(const mesh& mesh,
@ -29,5 +26,4 @@ protected:
} }
#endif #endif

View file

@ -3,6 +3,7 @@
#include <pw/core/globals.hpp> #include <pw/core/globals.hpp>
#include <pw/core/matrix.hpp> #include <pw/core/matrix.hpp>
#include <pw/core/debug.hpp>
#include <map> #include <map>
@ -27,6 +28,19 @@ public:
bool ready() const; bool ready() const;
shader& bind(int location,float v);
shader& bind(int location,matrix4x4f const & v);
int uniform_location(std::string const & name);
template<typename T> 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<T>(value));
return *this;
}
protected: protected:
std::map<code_type,std::string> _source; std::map<code_type,std::string> _source;

View file

@ -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 <algorithm>
namespace pw {
struct mesh_renderer::impl {
GLuint _vao = 0;
std::vector<GLuint> _vbos;
impl(mesh_renderer& )
{
}
void create(std::shared_ptr<mesh> 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<pass> _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
}

View file

@ -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<GLuint> _vbos;
impl(renderer& )
{
}
void create(std::shared_ptr<mesh> 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 >
}

View file

@ -70,17 +70,12 @@ struct shader::impl
glGetShaderiv(shaderId, GL_INFO_LOG_LENGTH, &log_length); glGetShaderiv(shaderId, GL_INFO_LOG_LENGTH, &log_length);
char* log_buffer = new char[log_length]; std::unique_ptr<char[]> 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! // TODO - handle errors!
debug::e() << log_buffer.get();
std::string info_log_string(log_buffer);
delete [] log_buffer;
debug::e() << info_log_string;
break; break;
} }
@ -99,9 +94,9 @@ struct shader::impl
// attribute binding ... // attribute binding ...
/* Bind attribute index 0 (coordinates) to in_Position and attribute index 1 (color) to in_Color */ /* Bind attribute index 0 (coordinates) to in_Position and attribute index 1 (color) to in_Color */
/* Attribute locations must be setup before calling glLinkProgram. */ /* Attribute locations must be setup before calling glLinkProgram. */
// glBindAttribLocation(shaderprogram, 0, "in_Position"); // glBindAttribLocation(shaderprogram, 0, "in_Position");
// glBindAttribLocation(shaderprogram, 1, "in_Color"); // glBindAttribLocation(shaderprogram, 1, "in_Color");
glLinkProgram(_shader_program); glLinkProgram(_shader_program);
@ -116,20 +111,16 @@ struct shader::impl
glGetProgramiv(_shader_program, GL_INFO_LOG_LENGTH, &log_length); glGetProgramiv(_shader_program, GL_INFO_LOG_LENGTH, &log_length);
/* The maxLength includes the NULL character */ /* The maxLength includes the NULL character */
char* info_log = new char[log_length]; std::unique_ptr<char []> info_log(new char[log_length]);
/* Notice that glGetProgramInfoLog, not glGetShaderInfoLog. */ /* Notice that glGetProgramInfoLog, not glGetShaderInfoLog. */
glGetProgramInfoLog(_shader_program, log_length, &log_length, info_log); glGetProgramInfoLog(_shader_program, log_length, &log_length, info_log.get());
debug::e() << info_log.get();
std::string info_log_string;
debug::e() << info_log_string;
/* Handle the error in an appropriate way such as displaying a message or writing to a log file. */ /* 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 */ /* In this simple program, we'll just leave */
delete [] info_log;
return; 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()); return glGetUniformLocation(_shader_program,name.c_str());
glUniformMatrix4fv(l,1,GL_FALSE,m.data()); // TODO transpose?
} }
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(); return _impl->is_valid();
} }
int shader::uniform_location(const std::string &name)
{
return _impl->uniform_location(name);
}
} }