|
Blender
V2.59
|
00001 /* 00002 * $Id: Common.h 36546 2011-05-08 09:05:52Z jesterking $ 00003 * 00004 * ***** BEGIN GPL LICENSE BLOCK ***** 00005 * 00006 * This program is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU General Public License 00008 * as published by the Free Software Foundation; either version 2 00009 * of the License, or (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software Foundation, 00018 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00019 * 00020 * Contributors: Amorilia (amorilia@users.sourceforge.net) 00021 * 00022 * ***** END GPL LICENSE BLOCK ***** 00023 */ 00024 00030 #ifndef _DDS_COMMON_H 00031 #define _DDS_COMMON_H 00032 00033 #ifndef min 00034 #define min(a,b) ((a) <= (b) ? (a) : (b)) 00035 #endif 00036 #ifndef max 00037 #define max(a,b) ((a) >= (b) ? (a) : (b)) 00038 #endif 00039 #ifndef clamp 00040 #define clamp(x,a,b) min(max((x), (a)), (b)) 00041 #endif 00042 00043 template<typename T> 00044 inline void 00045 swap(T & a, T & b) 00046 { 00047 T tmp = a; 00048 a = b; 00049 b = tmp; 00050 } 00051 00052 typedef unsigned char uint8; 00053 typedef unsigned short uint16; 00054 typedef unsigned int uint; 00055 typedef unsigned int uint32; 00056 typedef unsigned long long uint64; 00057 00058 // copied from nvtt src/nvimage/nvimage.h 00059 inline uint computePitch(uint w, uint bitsize, uint alignment) 00060 { 00061 return ((w * bitsize + 8 * alignment - 1) / (8 * alignment)) * alignment; 00062 } 00063 00064 #endif