2 * Copyright (c) 2007 Ivan Leben
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library in the file COPYING;
16 * if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 /* Standard headers */
37 #if !defined(VG_API_MACOSX) && !defined(__FreeBSD__)
41 /* Disable VGHandle-pointer conversion warnings since we
42 do deal with it by defining VGHandle properly */
45 # pragma warning(disable:4311)
46 # pragma warning(disable:4312)
49 /* Type definitions */
58 #define uint8_t unsigned char
60 #define uint16_t unsigned short
62 #define uint32_t unsigned int
63 #define int64_t long long
64 #define uint64_t unsigned long long
68 typedef int8_t SHint8;
69 typedef uint8_t SHuint8;
70 typedef int16_t SHint16;
71 typedef uint16_t SHuint16;
72 typedef int32_t SHint32;
73 typedef uint32_t SHuint32;
74 typedef float SHfloat32;
77 #define SHuint SHuint32
78 #define SHfloat SHfloat32
80 /* Maximum / minimum values */
82 #define SH_MAX_INT (0x7fffffff)
83 #define SH_MIN_INT (-0x7fffffff-1)
85 #define SH_MANTISSA_BITS 23
86 #define SH_EXPONENT_BITS 8
88 /* all 1s in exponent yields NaN in IEEE 754 so we take
89 1 less then maximum representable with exponent bits */
90 #define SH_MAX_EXPONENT ((1 << SH_EXPONENT_BITS) - 2)
91 /* maximum representable with mantissa bits */
92 #define SH_MAX_MANTISSA ((1 << SH_MANTISSA_BITS) - 1)
93 /* compose into IEEE754 floating point bit value */
94 #define SH_MAX_FLOAT_BITS (SH_MAX_EXPONENT << SH_MANTISSA_BITS) | SH_MAX_MANTISSA
101 SHfloat getMaxFloat();
103 /* Portable function definitions */
105 #define SH_SQRT (float)sqrt
106 #define SH_COS (float)cos
107 #define SH_SIN (float)sin
108 #define SH_ACOS (float)acos
109 #define SH_ASIN (float)asin
110 #define SH_ATAN (float)atan
111 #define SH_FLOOR (float)floor
112 #define SH_CEIL (float)ceil
113 #define SH_ASSERT assert
115 #if defined(__isnan) || (defined(__APPLE__) && (__GNUC__ == 3))
116 # define SH_ISNAN __isnan
117 #elif defined(_isnan) || defined(WIN32)
118 # define SH_ISNAN _isnan
120 # define SH_ISNAN isnan
126 #define PI 3.141592654f
127 #define SH_DEG2RAD(a) (a * PI / 180.0f)
128 #define SH_RAD2DEG(a) (a * 180.0f / PI)
129 #define SH_ABS(a) ((a < 0.0f) ? -a : a)
130 #define SH_MAX(a,b) ((a > b) ? a : b)
131 #define SH_MIN(a,b) ((a < b) ? a : b)
132 #define SH_NEARZERO(a) (a >= -0.0001 && a < 0.0001)
133 #define SH_SWAP(a,b) {SHfloat t=a; a=b; b=t;}
134 #define SH_CLAMP(a,min,max) {if (a<min) a=min; if (a>max) a=max; }
136 #define SH_NEWOBJ(type,obj) { obj = (type*)malloc(sizeof(type)); if(obj) type ## _ctor(obj); }
137 #define SH_INITOBJ(type,obj){ type ## _ctor(&obj); }
138 #define SH_DEINITOBJ(type,obj) { type ## _dtor(&obj); }
139 #define SH_DELETEOBJ(type,obj) { if(obj) type ## _dtor(obj); free(obj); }
141 /* Implementation limits */
143 #define SH_MAX_SCISSOR_RECTS 1
144 #define SH_MAX_DASH_COUNT VG_MAXINT
145 #define SH_MAX_IMAGE_WIDTH VG_MAXINT
146 #define SH_MAX_IMAGE_HEIGHT VG_MAXINT
147 #define SH_MAX_IMAGE_PIXELS VG_MAXINT
148 #define SH_MAX_IMAGE_BYTES VG_MAXINT
149 #define SH_MAX_COLOR_RAMP_STOPS 256
151 #define SH_MAX_VERTICES 999999999
152 #define SH_MAX_RECURSE_DEPTH 16
154 #define SH_GRADIENT_TEX_SIZE 1024
155 #define SH_GRADIENT_TEX_COORDSIZE 4096 /* 1024 * RGBA */
159 #if defined(VG_API_LINUX)
162 #elif defined(VG_API_MACOSX)
163 #include <OpenGL/gl.h>
164 #elif defined(VG_API_WINDOWS)
167 #define GL_GLEXT_LEGACY /* don't include glext.h */
172 #include "shExtensions.h"
175 #endif /* __SHDEFS_H */