summaryrefslogtreecommitdiff
path: root/es_1_1/gl_real.h
diff options
context:
space:
mode:
Diffstat (limited to 'es_1_1/gl_real.h')
-rwxr-xr-xes_1_1/gl_real.h219
1 files changed, 219 insertions, 0 deletions
diff --git a/es_1_1/gl_real.h b/es_1_1/gl_real.h
new file mode 100755
index 0000000..c9cc641
--- /dev/null
+++ b/es_1_1/gl_real.h
@@ -0,0 +1,219 @@
+/*
+ * Copyright (C) 2010 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * DongKyun Yun <dk77.yun@samsung.com>
+ * SangJin Kim <sangjin3.kim@samsung.com>
+ * HyunGoo Kang <hyungoo1.kang@samsung.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is furnished to do
+ * so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+type conventions:
+bool boolean
+enum enumerated
+b byte
+ub unsinged byte
+s short
+us unsigned short
+i int
+ui unsigned int
+x fixed
+clampx clamped fixed [0,1] (for color and normal)
+f float
+clampf clamped float [0,1] (for color and normal)
+d double (only for OpenGL emulation)
+*/
+
+#define __GL_X_FRAC_BITS 16
+
+#define FIXED_ZERO 0
+#define FIXED_ONE (1 << __GL_X_FRAC_BITS)
+
+#define FLOAT_ZERO 0.0F
+#define FLOAT_ONE 1.0F
+
+#if defined(ALEXGL_FIXED_CORE)
+typedef GLfixed GLreal;
+#define REAL_ZERO FIXED_ZERO
+#define REAL_ONE FIXED_ONE
+#else
+typedef GLfloat GLreal;
+#define REAL_ZERO FLOAT_ZERO
+#define REAL_ONE FLOAT_ONE
+#endif
+
+typedef GLreal GLrealVec3[3];
+typedef GLreal GLrealVec4[4];
+typedef GLreal GLrealMat4[16];
+
+#define x2x(a) (a)
+#define x2f(a) ((float)(a)/(1<<__GL_X_FRAC_BITS))
+#define x2d(a) ((double)(a)/(1<<__GL_X_FRAC_BITS))
+#define f2x(a) ((int)((a)*(1<<__GL_X_FRAC_BITS)))
+#define f2f(a) ((float)(a))
+#define f2d(a) ((double)(a))
+#define d2x(a) ((int)((a)*(1<<__GL_X_FRAC_BITS)))
+#define d2f(a) ((float)(a))
+void xv2xv(const GLfixed* src, GLfixed* dst, int n);
+void xv2fv(const GLfixed* src, GLfloat* dst, int n);
+void xv2dv(const GLfixed* src, GLdouble* dst, int n);
+void fv2xv(const GLfloat* src, GLfixed* dst, int n);
+void fv2fv(const GLfloat* src, GLfloat* dst, int n);
+void fv2dv(const GLfloat* src, GLdouble* dst, int n);
+void dv2xv(const GLdouble* src, GLfixed* dst, int n);
+void dv2fv(const GLdouble* src, GLfloat* dst, int n);
+
+#if defined(ALEXGL_FIXED_CORE)
+#define x2r(a) x2x(a)
+#define f2r(a) f2x(a)
+#define r2x(a) x2x(a)
+#define r2f(a) x2f(a)
+#define rv2xv(s,d,n) xv2xv(s,d,n)
+#define rv2fv(s,d,n) xv2fv(s,d,n)
+#define xv2rv(s,d,n) xv2xv(s,d,n)
+#define fv2rv(s,d,n) fv2xv(s,d,n)
+#define clamprv2xv(s,d,n) xv2xv(s,d,n)
+#define clamprv2fv(s,d,n) xv2fv(s,d,n)
+#define xv2clamprv(s,d,n) xv2xv(s,d,n)
+#define fv2clamprv(s,d,n) fv2xv(s,d,n)
+#else
+#define x2r(a) x2f(a)
+#define f2r(a) f2f(a)
+#define r2x(a) f2x(a)
+#define r2f(a) f2f(a)
+#define rv2xv(s,d,n) fv2xv(s,d,n)
+#define rv2fv(s,d,n) fv2fv(s,d,n)
+#define xv2rv(s,d,n) xv2fv(s,d,n)
+#define fv2rv(s,d,n) fv2fv(s,d,n)
+#define clamprv2xv(s,d,n) fv2xv(s,d,n)
+#define clamprv2fv(s,d,n) fv2fv(s,d,n)
+#define xv2clamprv(s,d,n) xv2fv(s,d,n)
+#define fv2clamprv(s,d,n) fv2fv(s,d,n)
+#endif
+
+#define enum2bool(a) ((a) != 0)
+#define i2bool(a) ((a) != 0)
+#define x2bool(a) ((a) != 0)
+#define f2bool(a) ((a) != 0.0F)
+#define clampx2bool(a) ((a) != 0)
+#define clampf2bool(a) ((a) != 0.0F)
+void xv2boolv(const GLfixed* src, GLboolean* dst, int n);
+void fv2boolv(const GLfloat* src, GLboolean* dst, int n);
+void clampxv2boolv(const GLfixed* src, GLboolean* dst, int n);
+void clampfv2boolv(const GLfloat* src, GLboolean* dst, int n);
+
+#if defined(ALEXGL_FIXED_CORE)
+#define rv2boolv(s,d,n) xv2boolv(s,d,n)
+#define clamprv2boolv(s,d,n) clampxv2boolv(s,d,n)
+#else
+#define rv2boolv(s,d,n) fv2boolv(s,d,n)
+#define clamprv2boolv(s,d,n) clampfv2boolv(s,d,n)
+#endif
+
+#define enum2i(a) (a)
+#define enum2x(a) (a)
+#define enum2f(a) ((float)(a))
+
+#if defined(ALEXGL_FIXED_CORE)
+#else
+#endif
+
+#define b2x(a) ((a) << __GL_X_FRAC_BITS)
+#define b2f(a) ((float)(a))
+#define b2clampx(a) ((((GLint)(a)*2+1)<<__GL_X_FRAC_BITS)/255)
+#define b2clampf(a) (((float)(a)*2.0F+1.0F)/255.0F)
+#define ub2clampx(a) (((GLuint)(a)<<__GL_X_FRAC_BITS)/255)
+#define ub2clampf(a) ((float)(a)/255.0F)
+void bv2xv(const GLbyte* src, GLfixed* dst, int n);
+void bv2fv(const GLbyte* src, GLfloat* dst, int n);
+void bv2clampxv(const GLbyte* src, GLfixed* dst, int n);
+void bv2clampfv(const GLbyte* src, GLfloat* dst, int n);
+void ubv2clampxv(const GLbyte* src, GLfixed* dst, int n);
+void ubv2clampfv(const GLbyte* src, GLfloat* dst, int n);
+
+#if defined(ALEXGL_FIXED_CORE)
+#define ub2clampr(a) ub2clampx(a)
+#define bv2rv(s,d,n) bv2xv(s,d,n)
+#define bv2clamprv(s,d,n) bv2clampxv(s,d,n)
+#define ubv2clamprv(s,d,n) ubv2clampxv(s,d,n)
+#else
+#define ub2clampr(a) ub2clampf(a)
+#define bv2rv(s,d,n) bv2fv(s,d,n)
+#define bv2clamprv(s,d,n) bv2clampfv(s,d,n)
+#define ubv2clamprv(s,d,n) ubv2clampfv(s,d,n)
+#endif
+
+#define s2x(a) ((a) << __GL_X_FRAC_BITS)
+#define s2f(a) ((float)(a))
+#define s2clampx(a) (GLfixed)((((long long)(a)*2+1)<<__GL_X_FRAC_BITS)/65535)
+#define s2clampf(a) (((float)(a)*2.0F+1.0F)/65535.0F)
+void sv2xv(const GLshort* src, GLfixed* dst, int n);
+void sv2fv(const GLshort* src, GLfloat* dst, int n);
+void sv2clampxv(const GLshort* src, GLfixed* dst, int n);
+void sv2clampfv(const GLshort* src, GLfloat* dst, int n);
+
+#if defined(ALEXGL_FIXED_CORE)
+#define sv2rv(s,d,n) sv2xv(s,d,n)
+#define sv2clamprv(s,d,n) sv2clampxv(s,d,n)
+#else
+#define sv2rv(s,d,n) sv2fv(s,d,n)
+#define sv2clamprv(s,d,n) sv2clampfv(s,d,n)
+#endif
+
+#define i2i(a) (GLint)(a)
+#define i2x(a) ((a)<<__GL_X_FRAC_BITS)
+#define i2f(a) ((float)(a))
+#define x2i(a) (GLint)(((a) + (1 << (__GL_X_FRAC_BITS - 1))) >> __GL_X_FRAC_BITS)
+#define f2i(a) (GLint)((a)+.5F)
+#define clampx2i(a) (GLint)((0x7FFFFFFFFLL * (long long)(a)) >> __GL_X_FRAC_BITS)
+#define clampf2i(a) (GLint)((65536.0F * 65536.0F * (a) - 1.0F) / 2.0F);
+void xv2iv(const GLfixed* src, GLint* dst, int n);
+void fv2iv(const GLfloat* src, GLint* dst, int n);
+void clampxv2iv(const GLfixed* src, GLint* dst, int n);
+void clampfv2iv(const GLfloat* src, GLint* dst, int n);
+
+#if defined(ALEXGL_FIXED_CORE)
+#define rv2iv(s,d,n) xv2iv(s,d,n)
+#define clamprv2iv(s,d,n) clampxv2iv(s,d,n)
+#else
+#define rv2iv(s,d,n) fv2iv(s,d,n)
+#define clamprv2iv(s,d,n) clampfv2iv(s,d,n)
+#endif
+
+/* print */
+extern int xprintf(const char* format, ...);
+extern int xfprintf(FILE* file, const char* format, ...);
+extern int xsprintf(const char* string, const char* format, ...);
+extern int xvprintf(const char* format, va_list arg);
+extern int xvfprintf(FILE* file, const char* format, va_list arg);
+extern int xvsprintf(const char* string, const char* format, va_list arg);
+
+#ifdef __cplusplus
+}
+#endif