working mesh rendering and shader uniforms

This commit is contained in:
Hartmut Seichter 2019-01-30 23:52:38 +01:00
parent ad13cea0ca
commit d9bbef876e
19 changed files with 262 additions and 83 deletions

View file

@ -1,6 +1,7 @@
set(hdrs
include/pw/core/axisangle.hpp
include/pw/core/color.hpp
include/pw/core/core.hpp
include/pw/core/debug.hpp
include/pw/core/globals.hpp
@ -10,7 +11,7 @@ set(hdrs
include/pw/core/quaternion.hpp
include/pw/core/image.hpp
include/pw/core/point.hpp
include/pw/core/rect.hpp
include/pw/core/rectangle.hpp
include/pw/core/serialize.hpp
include/pw/core/size.hpp
include/pw/core/timer.hpp

View file

@ -0,0 +1,55 @@
/*
* 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_COLOR_HPP
#define PW_CORE_COLOR_HPP
#include <pw/core/vector.hpp>
#include <limits>
namespace pw {
struct color {
vector4 components;
color(uint8_t r8,uint8_t g8,uint8_t b8,uint8_t a8)
: color(static_cast<real_t>(r8 / std::numeric_limits<uint8_t>::max()),
static_cast<real_t>(g8 / std::numeric_limits<uint8_t>::max()),
static_cast<real_t>(b8 / std::numeric_limits<uint8_t>::max()),
static_cast<real_t>(a8 / std::numeric_limits<uint8_t>::max()))
{
}
color(real_t r,real_t g,real_t b,real_t a)
: components({r,g,b,a})
{
}
uint32_t to_rgb8888() const {
return 0;
}
};
}
#endif

View file

@ -43,6 +43,7 @@ struct quaternion_ : vector4_<T> {
using base_type::z;
using base_type::w;
using base_type::lerp;
using base_type::xyz;
// using base_type::operator*;
// using base_type::operator/;

View file

@ -29,32 +29,31 @@
namespace pw {
template <typename T_>
struct rect_ {
struct rectangle_ {
size_<T_> size;
point_<T_> position;
rect_() = default;
rectangle_() = default;
rect_(point_<T_> const & p,size_<T_> const & s) : size(s), position(p) {}
rectangle_(point_<T_> const & p,size_<T_> const & s) : size(s), position(p) {}
bool contains(const point_<T_>& p) const
{
return p.x >= position.x && p.x <= position.x + size.width &&
p.y >= position.y && p.y <= position.y + size.height;
p.y >= position.y && p.y <= position.y + size.height;
}
template <typename To_>
rect_<To_> cast() const { return rect_<To_>(position.template cast<To_>(),size.template cast<To_>()); }
rectangle_<To_> cast() const { return rectangle_<To_>(position.template cast<To_>(),size.template cast<To_>()); }
};
typedef rect_<real_t> rect;
typedef rectangle_<real_t> rectangle;
typedef rect_<int> recti;
typedef rect_<float> rectf;
typedef rect_<float> rectd;
typedef rectangle_<int> rectanglei;
typedef rectangle_<float> rectanglef;
typedef rectangle_<double> rectangled;
}

View file

@ -30,7 +30,7 @@ int main(int argc,char **argv) {
auto v3_h = v.homogenous();
// auto v3_lerp = vector4f::lerp()
// auto v3_lerp = vector4f::
std::cout << "v3 = " << pw::serialize::matrix(v3) << std::endl;