# Visualization Library

A lightweight C++ OpenGL middleware for 2D/3D graphics

[Home] [Tutorials] [All Classes] [Grouped Classes]

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List
- File Members

# D:/VL/BuildSystem/VL_DISTRO/Visualization_Library_SDK/src/vlCore/std_types.hpp

Go to the documentation of this file.

    00001 /**************************************************************************************/
    00002 /*                                                                                    */
    00003 /*  Visualization Library                                                             */
    00004 /*  http://www.visualizationlibrary.org                                               */
    00005 /*                                                                                    */
    00006 /*  Copyright (c) 2005-2010, Michele Bosi                                             */
    00007 /*  All rights reserved.                                                              */
    00008 /*                                                                                    */
    00009 /*  Redistribution and use in source and binary forms, with or without modification,  */
    00010 /*  are permitted provided that the following conditions are met:                     */
    00011 /*                                                                                    */
    00012 /*  - Redistributions of source code must retain the above copyright notice, this     */
    00013 /*  list of conditions and the following disclaimer.                                  */
    00014 /*                                                                                    */
    00015 /*  - Redistributions in binary form must reproduce the above copyright notice, this  */
    00016 /*  list of conditions and the following disclaimer in the documentation and/or       */
    00017 /*  other materials provided with the distribution.                                   */
    00018 /*                                                                                    */
    00019 /*  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND   */
    00020 /*  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED     */
    00021 /*  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE            */
    00022 /*  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR  */
    00023 /*  ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES    */
    00024 /*  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;      */
    00025 /*  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON    */
    00026 /*  ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT           */
    00027 /*  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS     */
    00028 /*  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.                      */
    00029 /*                                                                                    */
    00030 /**************************************************************************************/
    00031
    00032 #ifndef stdtypes_INCLUDE_ONCE
    00033 #define stdtypes_INCLUDE_ONCE
    00034
    00035 #include <vlCore/config.hpp>
    00036 #include <vlCore/checks.hpp>
    00037
    00038 namespace vl
    00039 {
    00041   typedef char i8;
    00043   typedef unsigned char u8;
    00045   typedef short i16;
    00047   typedef unsigned short u16;
    00049   typedef int i32;
    00051   typedef unsigned int u32;
    00053   typedef long long i64;
    00055   typedef unsigned long long u64;
    00057   typedef float f32;
    00059   typedef double f64;
    00060
    00061   // trigonometric constants
    00062
    00064   const double dPi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117067982148086513282306647093845;
    00066   const double dDEG_TO_RAD = dPi / 180.0;
    00068   const double dRAD_TO_DEG = 180.0 / dPi;
    00069
    00071   const float fPi = (float)3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117067982148086513282306647093845;
    00073   const float fDEG_TO_RAD = float(dPi / 180.0);
    00075   const float fRAD_TO_DEG = float(180.0 / dPi);
    00076
    00077   class degree;
    00078
    00080   class radian
    00081   {
    00082   public:
    00083     radian(real val): mValue(val) {}
    00084     operator real() { return mValue; }
    00085     operator degree();
    00086
    00087   private:
    00088     real mValue;
    00089   };
    00090
    00092   class degree
    00093   {
    00094   public:
    00095     degree(real val): mValue(val) {}
    00096     operator real() { return mValue; }
    00097     operator radian();
    00098
    00099   private:
    00100     real mValue;
    00101   };
    00102
    00103   inline radian::operator degree() { return mValue*(real)dRAD_TO_DEG; }
    00104   inline degree::operator radian() { return mValue*(real)dDEG_TO_RAD; }
    00105
    00107   template<typename T>
    00108   void swapBytes(T& value)
    00109   {
    00110     union
    00111     {
    00112       T* value;
    00113       char* ptr;
    00114     } u;
    00115     u.value = &value;
    00116     char* a = u.ptr;
    00117     char* b = u.ptr + sizeof(T) - 1;
    00118     while(a<b)
    00119     {
    00120       char tmp = *a;
    00121       *a = *b;
    00122       *b = tmp;
    00123       ++a;
    00124       --b;
    00125     }
    00126   }
    00127
    00128   VL_COMPILE_TIME_CHECK( sizeof(i8)*8  == 8 );
    00129   VL_COMPILE_TIME_CHECK( sizeof(u8)*8  == 8 );
    00130   VL_COMPILE_TIME_CHECK( sizeof(i16)*8 == 16 );
    00131   VL_COMPILE_TIME_CHECK( sizeof(u16)*8 == 16 );
    00132   VL_COMPILE_TIME_CHECK( sizeof(i32)*8 == 32 );
    00133   VL_COMPILE_TIME_CHECK( sizeof(u32)*8 == 32 );
    00134   VL_COMPILE_TIME_CHECK( sizeof(i64)*8 == 64 );
    00135   VL_COMPILE_TIME_CHECK( sizeof(u64)*8 == 64 );
    00136   VL_COMPILE_TIME_CHECK( sizeof(f32)*8 == 32 );
    00137   VL_COMPILE_TIME_CHECK( sizeof(f64)*8 == 64 );
    00138 }
    00139
    00140 #endif

Visualization Library v2011.09.1162 Reference Documentation
Copyright 2005-2011 Michele Bosi. All rights reserved.
Updated on Thu Jan 26 2012 00:43:31.
Permission is granted to use this page to write and publish articles regarding Visualization Library.