60 lines
1.4 KiB
C++
60 lines
1.4 KiB
C++
#pragma once
|
|
#ifndef REAL_BUILD
|
|
# include "externals.hh"
|
|
#endif
|
|
|
|
/*= Utilities ================================================================*/
|
|
|
|
// Disable next ImGui button(s)
|
|
void disableButton( );
|
|
// Re-enable ImGui buttons
|
|
inline void reenableButtons( )
|
|
{
|
|
ImGui::PopStyleColor( 3 );
|
|
}
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
#define GL_CHECK( FAIL ) \
|
|
do { \
|
|
auto err_( glGetError( ) ); \
|
|
if ( err_ != GL_NO_ERROR ) FAIL; \
|
|
} while ( 0 )
|
|
|
|
#define GL_ASSERT( ) \
|
|
GL_CHECK({ \
|
|
fprintf( stderr , "GL error %x in %s:%d\n" , \
|
|
err_ , __FILE__ , __LINE__ ); \
|
|
abort( ); \
|
|
})
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
// Add some value to an angle, keeping it in [-180;180]
|
|
void updateAngle(
|
|
__rw__ float& initial ,
|
|
__rd__ const float delta
|
|
);
|
|
// Make a rotation matrix from three YPR angles (in degrees)
|
|
void anglesToMatrix(
|
|
__rd__ float const* angles ,
|
|
__wr__ float* matrix );
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
// Helpers for finding entries in collections
|
|
template< typename T , typename I >
|
|
inline auto find(
|
|
__rd__ T const& collection ,
|
|
__rd__ I const& item )
|
|
{
|
|
return std::find( collection.begin( ) , collection.end( ) , item );
|
|
}
|
|
|
|
template< typename T , typename I >
|
|
inline auto find(
|
|
__rw__ T& collection ,
|
|
__rd__ I const& item )
|
|
{
|
|
return std::find( collection.begin( ) , collection.end( ) , item );
|
|
}
|