Nirtcpp 2.1.0
Nirtcpp is a high-performance c++ graphics engine.
Loading...
Searching...
No Matches
nirt::core::dimension2d< T > Class Template Reference

Specifies a 2 dimensional size. More...

#include <nirtcpp/core/engine/dimension2d.hpp>

Public Member Functions

 dimension2d ()
 Default constructor for empty dimension.
 
 dimension2d (const T &width, const T &height)
 Constructor with width and height.
 
 dimension2d (const vector2d< T > &other)
 
template<class U >
 dimension2d (const dimension2d< U > &other)
 Use this constructor only where you are sure that the conversion is valid.
 
template<class U >
dimension2d< T > & operator= (const dimension2d< U > &other)
 
bool operator== (const dimension2d< T > &other) const
 Equality operator.
 
bool operator!= (const dimension2d< T > &other) const
 Inequality operator.
 
bool operator== (const vector2d< T > &other) const
 
bool operator!= (const vector2d< T > &other) const
 
dimension2d< T > & set (const T &width, const T &height)
 Set to new values.
 
dimension2d< T > & operator/= (const T &scale)
 Divide width and height by scalar.
 
dimension2d< Toperator/ (const T &scale) const
 Divide width and height by scalar.
 
dimension2d< T > & operator*= (const T &scale)
 Multiply width and height by scalar.
 
dimension2d< Toperator* (const T &scale) const
 Multiply width and height by scalar.
 
dimension2d< T > & operator+= (const dimension2d< T > &other)
 Add another dimension to this one.
 
dimension2d< Toperator+ (const dimension2d< T > &other) const
 Add two dimensions.
 
dimension2d< T > & operator-= (const dimension2d< T > &other)
 Subtract a dimension from this one.
 
dimension2d< Toperator- (const dimension2d< T > &other) const
 Subtract one dimension from another.
 
T getArea () const
 Get area.
 
dimension2d< TgetOptimalSize (bool requirePowerOfTwo=true, bool requireSquare=false, bool larger=true, u32 maxValue=0) const
 Get the optimal size according to some properties.
 
dimension2d< TgetInterpolated (const dimension2d< T > &other, f32 d) const
 Get the interpolated dimension.
 

Public Attributes

T Width
 Width of the dimension.
 
T Height
 Height of the dimension.
 

Detailed Description

template<class T>
class nirt::core::dimension2d< T >

Specifies a 2 dimensional size.

Member Function Documentation

◆ getInterpolated()

template<class T >
dimension2d< T > nirt::core::dimension2d< T >::getInterpolated ( const dimension2d< T > &  other,
f32  d 
) const
inline

Get the interpolated dimension.

Parameters
otherOther dimension to interpolate with.
dValue between 0.0f and 1.0f. d=0 returns other, d=1 returns this, values between interpolate.
Returns
Interpolated dimension.

◆ getOptimalSize()

template<class T >
dimension2d< T > nirt::core::dimension2d< T >::getOptimalSize ( bool  requirePowerOfTwo = true,
bool  requireSquare = false,
bool  larger = true,
u32  maxValue = 0 
) const
inline

Get the optimal size according to some properties.

This is a function often used for texture dimension calculations. The function returns the next larger or smaller dimension which is a power-of-two dimension (2^n,2^m) and/or square (Width=Height).

Parameters
requirePowerOfTwoForces the result to use only powers of two as values.
requireSquareMakes width==height in the result
largerChoose whether the result is larger or smaller than the current dimension. If one dimension need not be changed it is kept with any value of larger.
maxValueMaximum texturesize. if value > 0 size is clamped to maxValue
Returns
The optimal dimension under the given constraints.

The documentation for this class was generated from the following files:

Nirtcpp    @cppfx.xyz

Utxcpp    utx::print