Created
September 18, 2015 06:52
-
-
Save ThePhD/d69f971fb4a009489dde to your computer and use it in GitHub Desktop.
What am I even doing anymore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template <typename T> | |
TMatrix4<T> CreateOrthographicProjectionOffCenter( T left, T right, T bottom, T top, T nearplane, T farplane ) { | |
T verticaldiff = ( bottom - top ); | |
T horizontaldiff = ( right - left ); | |
verticaldiff = static_cast<T>( verticaldiff / normalizedevicecoordinatesrange ); | |
horizontaldiff = static_cast<T>( horizontaldiff / normalizedevicecoordinatesrange ); | |
top -= verticaldiff; | |
bottom -= verticaldiff; | |
left -= horizontaldiff; | |
right -= horizontaldiff; | |
T inversewidth = static_cast<T>(1) / (right - left); | |
T inverseheight = static_cast<T>( 1 ) / ( top - bottom ); | |
T farrange = | |
#ifdef FURROVINE_COORDINATE_SYSTEM_LEFT_HANDED | |
T( normalizedevicecoordinatesrange ) / ( farplane - nearplane ); | |
#else | |
T( normalizedevicecoordinatesrange ) / ( nearplane - farplane ); | |
#endif // FURROVINE_COORDINATE_SYSTEM_LEFT_HANDED || RIGHTHANDED | |
TMatrix4<T> r = CreateRowMajor( | |
inversewidth + inversewidth, | |
static_cast<T>( 0 ), | |
static_cast<T>( 0 ), | |
static_cast<T>( 0 ), | |
static_cast<T>( 0 ), | |
inverseheight + inverseheight, | |
static_cast<T>( 0 ), | |
static_cast<T>( 0 ), | |
static_cast<T>( 0 ), | |
static_cast<T>( 0 ), | |
farrange, | |
static_cast<T>( 0 ), | |
-( left + right ) * inversewidth, | |
-( top + bottom ) * inverseheight, | |
#ifdef FURROVINE_COORDINATE_SYSTEM_LEFT_HANDED | |
- farrange * nearplane, | |
#else | |
farrange * nearplane, | |
#endif // FURROVINE_COORDINATE_SYSTEM_LEFT_HANDED || RIGHTHANDED | |
static_cast<T>( 1 ) | |
); | |
return r; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment