Gamp v0.0.7-54-gccdc599
Gamp: Graphics, Audio, Multimedia and Processing
Loading...
Searching...
No Matches
TextureCoords.hpp
Go to the documentation of this file.
1/*
2 * Author: Sven Gothel <sgothel@jausoft.com>
3 * Copyright Gothel Software e.K.
4 *
5 * SPDX-License-Identifier: MIT
6 *
7 * This Source Code Form is subject to the terms of the MIT License
8 * If a copy of the MIT was not distributed with this file,
9 * you can obtain one at https://opensource.org/license/mit/.
10 */
11#ifndef GAMP_RENDER_GL_TEXTURE_TEXTURECOORDS_HPP_
12#define GAMP_RENDER_GL_TEXTURE_TEXTURECOORDS_HPP_
13
14#include <jau/math/recti.hpp>
15#include <jau/string_util.hpp>
16
17#include <gamp/GampTypes.hpp>
18
20 /** \addtogroup Gamp_GL
21 *
22 * @{
23 */
24
25 /** Rectangular texture coordinates.
26
27 Note that some textures are inherently flipped vertically
28 from OpenGL's standard coordinate system. This class takes care of
29 this vertical flip so that the "bottom" and "top" coordinates may
30 sometimes be reversed. From the point of view of code rendering
31 textured polygons, it can always map the bottom and left texture
32 coordinates from the TextureCoords to the lower left point of the
33 textured polygon and achieve correct results. */
35 private:
36 jau::math::Point2f m_bl; /// <Bottom Left
37 jau::math::Point2f m_tr; /// <Top right
38
39 public:
40 TextureCoords() noexcept
41 : m_bl(), m_tr()
42 { }
43 TextureCoords(float left, float bottom,
44 float right, float top) noexcept
45 : m_bl(left, bottom), m_tr(right, top)
46 { }
47
49 : m_bl(bl), m_tr(tr)
50 { }
51
53 : m_bl(float(bl.x), float(bl.y)), m_tr(float(tr.x), float(tr.y))
54 { }
55
56 /// Returns the bottom-left texture coordinate
57 const jau::math::Point2f& bl() const noexcept { return m_bl; }
58 /// Returns the top-right texture coordinate
59 const jau::math::Point2f& tr() const noexcept { return m_tr; }
60
61 std::string toString() const noexcept { return "TexCoord[bl: "+m_bl.toString()+", tr: "+m_tr.toString()+"]"; }
62 };
63
64 /**@}*/
65
66} // namespace gamp::render::gl
67
68#endif /* GAMP_RENDER_GL_TEXTURE_TEXTURECOORDS_HPP_ */
TextureCoords(const jau::math::Point2i &bl, const jau::math::Point2i &tr) noexcept
TextureCoords(float left, float bottom, float right, float top) noexcept
std::string toString() const noexcept
const jau::math::Point2f & tr() const noexcept
Returns the top-right texture coordinate.
TextureCoords(const jau::math::Point2f &bl, const jau::math::Point2f &tr) noexcept
const jau::math::Point2f & bl() const noexcept
Returns the bottom-left texture coordinate.
Point2I< int > Point2i
Definition vec2i.hpp:334
Point2F< float > Point2f
Definition vec2f.hpp:417