CrystalSpace

Public API Reference

Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

glhelper.h

00001 /*
00002   Copyright (C) 2002 by Marten Svanfeldt
00003                         Anders Stenberg
00004 
00005   This library is free software; you can redistribute it and/or
00006   modify it under the terms of the GNU Library General Public
00007   License as published by the Free Software Foundation; either
00008   version 2 of the License, or (at your option) any later version.
00009 
00010   This library is distributed in the hope that it will be useful,
00011   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00013   Library General Public License for more details.
00014 
00015   You should have received a copy of the GNU Library General Public
00016   License along with this library; if not, write to the Free
00017   Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00018 */
00019 
00020 #ifndef __CS_CSPLUGINCOMMON_OPENGL_GLHELPER_H__
00021 #define __CS_CSPLUGINCOMMON_OPENGL_GLHELPER_H__
00022 
00023 #include "csgeom/matrix3.h"
00024 #include "csgeom/transfrm.h"
00025 #include "csgeom/vector3.h"
00026 
00027 static inline void makeGLMatrix (const csReversibleTransform& t, 
00028   float matrix[16])
00029 {
00030   const csMatrix3 &orientation = t.GetO2T();
00031   const csVector3 &translation = t.GetO2TTranslation();
00032 
00033   matrix[0] = orientation.m11;
00034   matrix[1] = orientation.m12;
00035   matrix[2] = orientation.m13;
00036   matrix[3] = 0.0f;
00037 
00038   matrix[4] = orientation.m21;
00039   matrix[5] = orientation.m22;
00040   matrix[6] = orientation.m23;
00041   matrix[7] = 0.0f;
00042 
00043   matrix[8] = orientation.m31;
00044   matrix[9] = orientation.m32;
00045   matrix[10] = orientation.m33;
00046   matrix[11] = 0.0f;
00047 
00048   matrix[12] = translation.x;
00049   matrix[13] = translation.y;
00050   matrix[14] = translation.z;
00051   matrix[15] = 1.0f;
00052 }
00053 
00054 static inline void makeGLMatrix (const csMatrix3& m, float matrix[16])
00055 {
00056   matrix[0] = m.m11;
00057   matrix[1] = m.m12;
00058   matrix[2] = m.m13;
00059   matrix[3] = 0.0f;
00060 
00061   matrix[4] = m.m21;
00062   matrix[5] = m.m22;
00063   matrix[6] = m.m23;
00064   matrix[7] = 0.0f;
00065 
00066   matrix[8] = m.m31;
00067   matrix[9] = m.m32;
00068   matrix[10] = m.m33;
00069   matrix[11] = 0.0f;
00070 
00071   matrix[12] = 0.0f;
00072   matrix[13] = 0.0f;
00073   matrix[14] = 0.0f;
00074   matrix[15] = 1.0f;
00075 }
00076 
00077 #endif

Generated for Crystal Space by doxygen 1.4.4