summaryrefslogtreecommitdiff
path: root/es_1_1/28array.c
diff options
context:
space:
mode:
Diffstat (limited to 'es_1_1/28array.c')
-rwxr-xr-xes_1_1/28array.c286
1 files changed, 286 insertions, 0 deletions
diff --git a/es_1_1/28array.c b/es_1_1/28array.c
new file mode 100755
index 0000000..11ea2c4
--- /dev/null
+++ b/es_1_1/28array.c
@@ -0,0 +1,286 @@
+/*
+ * 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
+ *
+ */
+
+#include "gl_imp.h"
+
+GL_API int GL_APIENTRY INTFN(GetTightStride)(GLint size, GLenum type) {
+ switch (type) {
+ case GL_BYTE:
+ case GL_UNSIGNED_BYTE:
+ return size;
+ case GL_SHORT:
+ case GL_UNSIGNED_SHORT:
+ return size * 2;
+ case GL_FLOAT:
+ case GL_FIXED:
+ return size * 4;
+ }
+ assert(0);
+ return 0;
+}
+
+GL_API void GL_APIENTRY INTFN(Fetch)(GLvoid* src, GLreal* dst, GLint size, GLenum type) {
+ switch (type) {
+ case GL_BYTE: bv2rv((GLbyte*)src, dst, size); break;
+ case GL_SHORT: sv2rv((GLshort*)src, dst, size); break;
+ case GL_FLOAT: fv2rv((GLfloat*)src, dst, size); break;
+ case GL_FIXED: xv2rv((GLfixed*)src, dst, size); break;
+ default: assert(0); break;
+ }
+}
+
+GL_API void GL_APIENTRY INTFN(FetchClamp)(GLvoid* src, GLreal* dst, GLint size, GLenum type) {
+ switch (type) {
+ case GL_BYTE: bv2clamprv((GLbyte*)src, dst, size); break;
+ case GL_UNSIGNED_BYTE: ubv2clamprv((GLbyte*)src, dst, size); break;
+ case GL_SHORT: sv2clamprv((GLshort*)src, dst, size); break;
+ case GL_FLOAT: fv2clamprv((GLfloat*)src, dst, size); break;
+ case GL_FIXED: xv2clamprv((GLfixed*)src, dst, size); break;
+ default: assert(0); break;
+ }
+}
+
+
+GL_API void GL_APIENTRY EXTFN(ClientActiveTexture)(GLenum texture) {
+ GLint tex;
+ FNPTR(ClientActiveTexture)(texture);
+ FNPTR(GetIntegerv)(GL_CLIENT_ACTIVE_TEXTURE, &tex);
+ CCV(clientActiveTexture) = tex - GL_TEXTURE0;
+}
+
+GL_API void GL_APIENTRY EXTFN(VertexPointer)(GLint size,
+ GLenum type, GLsizei stride, const GLvoid* pointer) {
+ GLenum code;
+ if (CCV(curErrCode) == GL_NO_ERROR && (code = FNPTR(GetError)()) != GL_NO_ERROR) {
+ CCV(curErrCode) = code;
+ }
+ switch (type) {
+ case GL_SHORT:
+#ifdef ALEXGL_PROVIDE_COMMON
+ case GL_FLOAT:
+#endif
+ FNPTR(VertexPointer)(size, type, stride, pointer);
+ break;
+#if defined(PROVIDING_OES_byte_coordinates)
+ case GL_BYTE:
+#endif
+ case GL_FIXED:
+ FNPTR(VertexPointer)(size, GL_INT, stride, pointer);
+ break;
+ default:
+ INTFN(SetError)(GL_INVALID_ENUM);
+ return;
+ }
+ if ((code = FNPTR(GetError)()) != GL_NO_ERROR) {
+ if (CCV(curErrCode) == GL_NO_ERROR) CCV(curErrCode) = code;
+ return;
+ }
+ CCV(vertexArraySize) = size;
+ CCV(vertexArrayType) = type;
+ CCV(vertexArrayStride) = (stride == 0) ? INTFN(GetTightStride)(size, type) : stride;
+ CCV(vertexArrayPointer) = (GLvoid*)pointer;
+#if ALEXGL_PROVIDE_1_1
+ GLint bind;
+ FNPTR(GetIntegerv)(GL_ARRAY_BUFFER_BINDING, &bind);
+ CCV(vertexArrayBufferBinding) = bind;
+#endif
+}
+
+GL_API void GL_APIENTRY EXTFN(NormalPointer)(GLenum type, GLsizei stride, const GLvoid* pointer) {
+ GLenum code;
+ if (CCV(curErrCode) == GL_NO_ERROR && (code = FNPTR(GetError)()) != GL_NO_ERROR) {
+ CCV(curErrCode) = code;
+ }
+ switch (type) {
+ case GL_BYTE:
+ case GL_SHORT:
+#ifdef ALEXGL_PROVIDE_COMMON
+ case GL_FLOAT:
+#endif
+ FNPTR(NormalPointer)(type, stride, pointer);
+ break;
+ case GL_FIXED:
+ FNPTR(NormalPointer)(GL_INT, stride, pointer);
+ break;
+ default:
+ INTFN(SetError)(GL_INVALID_ENUM);
+ return;
+ }
+ if ((code = FNPTR(GetError)()) != GL_NO_ERROR) {
+ if (CCV(curErrCode) == GL_NO_ERROR) CCV(curErrCode) = code;
+ return;
+ }
+ CCV(normalArrayType) = type;
+ CCV(normalArrayStride) = (stride == 0) ? INTFN(GetTightStride)(3, type) : stride;
+ CCV(normalArrayPointer) = (GLvoid*)pointer;
+#if ALEXGL_PROVIDE_1_1
+ GLint bind;
+ FNPTR(GetIntegerv)(GL_ARRAY_BUFFER_BINDING, &bind);
+ CCV(normalArrayBufferBinding) = bind;
+#endif
+}
+
+GL_API void GL_APIENTRY EXTFN(ColorPointer)(GLint size,
+ GLenum type, GLsizei stride, const GLvoid* pointer) {
+ GLenum code;
+ if (size != 4) {
+ INTFN(SetError)(GL_INVALID_VALUE);
+ return ;
+ }
+ if (CCV(curErrCode) == GL_NO_ERROR && (code = FNPTR(GetError)()) != GL_NO_ERROR) {
+ CCV(curErrCode) = code;
+ }
+ switch (type) {
+ case GL_UNSIGNED_BYTE:
+#ifdef ALEXGL_PROVIDE_COMMON
+ case GL_FLOAT:
+#endif
+ FNPTR(ColorPointer)(size, type, stride, pointer);
+ break;
+ case GL_FIXED:
+ FNPTR(ColorPointer)(size, GL_FLOAT, stride, pointer);
+ break;
+ default:
+ INTFN(SetError)(GL_INVALID_ENUM);
+ return;
+ }
+ if ((code = FNPTR(GetError)()) != GL_NO_ERROR) {
+ if (CCV(curErrCode) == GL_NO_ERROR) CCV(curErrCode) = code;
+ return;
+ }
+ CCV(colorArrayType) = type;
+ CCV(colorArrayStride) = (stride == 0) ? INTFN(GetTightStride)(size, type) : stride;
+ CCV(colorArrayPointer) = (GLvoid*)pointer;
+#if ALEXGL_PROVIDE_1_1
+ GLint bind;
+ FNPTR(GetIntegerv)(GL_ARRAY_BUFFER_BINDING, &bind);
+ CCV(colorArrayBufferBinding) = bind;
+#endif
+}
+
+GL_API void GL_APIENTRY EXTFN(TexCoordPointer)(GLint size,
+ GLenum type, GLsizei stride, const GLvoid* pointer) {
+ register GLuint index;
+ GLenum code;
+ if (size < 2 || 4 < size) {
+ INTFN(SetError)(GL_INVALID_VALUE);
+ return ;
+ }
+ if (CCV(curErrCode) == GL_NO_ERROR && (code = FNPTR(GetError)()) != GL_NO_ERROR) {
+ CCV(curErrCode) = code;
+ }
+ switch (type) {
+ case GL_SHORT:
+#ifdef ALEXGL_PROVIDE_COMMON
+ case GL_FLOAT:
+#endif
+ FNPTR(TexCoordPointer)(size, type, stride, pointer);
+ break;
+#if defined(PROVIDING_OES_byte_coordinates)
+ case GL_BYTE:
+#endif
+ case GL_FIXED:
+ FNPTR(TexCoordPointer)(size, GL_INT, stride, pointer);
+ break;
+ default:
+ INTFN(SetError)(GL_INVALID_ENUM);
+ return;
+ }
+ if ((code = FNPTR(GetError)()) != GL_NO_ERROR) {
+ if (CCV(curErrCode) == GL_NO_ERROR) CCV(curErrCode) = code;
+ return;
+ }
+ index = CCV(clientActiveTexture);
+ assert(0 <= index && index < ALEXGL_MAX_TEXTURE_UNITS);
+ CCV(texCoordArraySize[index]) = size;
+ CCV(texCoordArrayType[index]) = type;
+ CCV(texCoordArrayStride[index]) = (stride == 0) ? INTFN(GetTightStride)(size, type) : stride;
+ CCV(texCoordArrayPointer[index]) = (GLvoid*)pointer;
+#if ALEXGL_PROVIDE_1_1
+ GLint bind;
+ FNPTR(GetIntegerv)(GL_ARRAY_BUFFER_BINDING, &bind);
+ CCV(texCoordArrayBufferBinding[index]) = bind;
+#endif
+}
+
+#if defined(PROVIDING_OES_point_size_array)
+GL_API void GL_APIENTRY EXTFN(PointSizePointerOES)(GLenum type,
+ GLsizei stride, const GLvoid* pointer) {
+#ifdef ALEXGL_PROVIDE_COMMON
+ if (type != GL_FIXED && type != GL_FLOAT) {
+#else
+ if (type != GL_FIXED) {
+#endif
+ INTFN(SetError)(GL_INVALID_ENUM);
+ return ;
+ }
+ if (stride < 0) {
+ INTFN(SetError)(GL_INVALID_VALUE);
+ return ;
+ }
+ CCV(pointSizeArrayTypeOES) = type;
+ CCV(pointSizeArrayStrideOES) = (stride == 0) ? INTFN(GetTightStride)(1, type) : stride;
+ CCV(pointSizeArrayStrideOESGiven) = stride;
+ CCV(pointSizeArrayPointerOES) = (GLvoid*)pointer;
+#if ALEXGL_PROVIDE_1_1
+ GLint bind;
+ FNPTR(GetIntegerv)(GL_ARRAY_BUFFER_BINDING, &bind);
+ CCV(pointSizeArrayBufferBindingOES) = bind;
+#endif
+}
+#endif
+
+#ifdef ALEXGL_PROVIDE_1_1
+GL_API void GL_APIENTRY EXTFN(GetPointerv)(GLenum pname, void** params) {
+ switch (pname) {
+ default:
+ INTFN(SetError)(GL_INVALID_ENUM);
+ return;
+ case GL_VERTEX_ARRAY_POINTER:
+ *params = (void*)(CCV(vertexArrayPointer));
+ break;
+ case GL_NORMAL_ARRAY_POINTER:
+ *params = (void*)(CCV(normalArrayPointer));
+ break;
+ case GL_COLOR_ARRAY_POINTER:
+ *params = (void*)(CCV(colorArrayPointer));
+ break;
+ case GL_TEXTURE_COORD_ARRAY_POINTER:
+ *params = (void*)(CCV(texCoordArrayPointer[CCV(clientActiveTexture)]));
+ break;
+#if defined(PROVIDING_OES_point_size_array)
+ case GL_POINT_SIZE_ARRAY_POINTER_OES:
+ *params = (void*)(CCV(pointSizeArrayPointerOES));
+ break;
+#endif
+ }
+}
+#endif