summaryrefslogtreecommitdiff
path: root/es_2_0/VertexPointer.c
diff options
context:
space:
mode:
Diffstat (limited to 'es_2_0/VertexPointer.c')
-rwxr-xr-xes_2_0/VertexPointer.c211
1 files changed, 211 insertions, 0 deletions
diff --git a/es_2_0/VertexPointer.c b/es_2_0/VertexPointer.c
new file mode 100755
index 0000000..8150641
--- /dev/null
+++ b/es_2_0/VertexPointer.c
@@ -0,0 +1,211 @@
+/*
+ * 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 "es2front.h"
+
+
+void GL_APIENTRY ES2INTER(VertexAttribInit)(struct VertexAttribUnit* pUnit) {
+ pUnit->bEnabled = GL_FALSE;
+ pUnit->iSize = 4;
+ pUnit->eType = GL_FLOAT;
+ pUnit->bNormalized = GL_FALSE;
+ pUnit->uStride = 0;
+ pUnit->pData = NULL;
+ pUnit->pConverted = NULL;
+ pUnit->uBufferBinding = 0;
+}
+
+void GL_APIENTRY ES2INTER(VertexAttribRelease)(struct VertexAttribUnit* pUnit) {
+ if (pUnit->pConverted != NULL) {
+ free(pUnit->pConverted);
+ pUnit->pConverted = NULL;
+ }
+}
+
+void GL_APIENTRY ES2ENTRY(VertexAttribPointer)(GLuint indx,
+ GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr) {
+ struct VertexAttribUnit* pVertexAttrib;
+ if (CCV(nMaxVertexAttribs) <= indx) {
+ ES2INTER(SetError)(GL_INVALID_VALUE);
+ return;
+ }
+ if (size < 1 || 4 < size) {
+ ES2INTER(SetError)(GL_INVALID_VALUE);
+ return;
+ }
+ if (stride < 0) {
+ ES2INTER(SetError)(GL_INVALID_VALUE);
+ return;
+ }
+ switch (type) {
+ default:
+ ES2INTER(SetError)(GL_INVALID_ENUM);
+ return;
+ case GL_BYTE:
+ case GL_UNSIGNED_BYTE:
+ case GL_SHORT:
+ case GL_UNSIGNED_SHORT:
+ case GL_FIXED:
+ case GL_FLOAT:
+ break;
+ }
+ pVertexAttrib = &(CCV(pVertexAttrib[indx]));
+ pVertexAttrib->iSize = size;
+ pVertexAttrib->eType = type;
+ pVertexAttrib->bNormalized = normalized;
+ if (stride == 0) {
+ switch (type) {
+ case GL_BYTE: pVertexAttrib->uStride = size * sizeof(GLbyte); break;
+ case GL_UNSIGNED_BYTE: pVertexAttrib->uStride = size * sizeof(GLubyte); break;
+ case GL_SHORT: pVertexAttrib->uStride = size * sizeof(GLshort); break;
+ case GL_UNSIGNED_SHORT: pVertexAttrib->uStride = size * sizeof(GLushort); break;
+ case GL_FIXED: pVertexAttrib->uStride = size * sizeof(GLfixed); break;
+ case GL_FLOAT: pVertexAttrib->uStride = size * sizeof(GLfloat); break;
+ }
+ } else {
+ pVertexAttrib->uStride = stride;
+ }
+ pVertexAttrib->pData = ptr;
+ pVertexAttrib->uBufferBinding = CCV(uArrayBufferBinding);
+ if (type == GL_FIXED) {
+ FNPTR(VertexAttribPointer)(indx, size, GL_FLOAT, normalized, stride, ptr);
+ } else {
+ FNPTR(VertexAttribPointer)(indx, size, type, normalized, stride, ptr);
+ }
+}
+
+void GL_APIENTRY ES2ENTRY(EnableVertexAttribArray)(GLuint index) {
+ if (CCV(nMaxVertexAttribs) <= index) {
+ ES2INTER(SetError)(GL_INVALID_VALUE);
+ return;
+ }
+ CCV(pVertexAttrib[index].bEnabled) = GL_TRUE;
+ FNPTR(EnableVertexAttribArray)(index);
+}
+
+void GL_APIENTRY ES2ENTRY(DisableVertexAttribArray)(GLuint index) {
+ if (CCV(nMaxVertexAttribs) <= index) {
+ ES2INTER(SetError)(GL_INVALID_VALUE);
+ return;
+ }
+ CCV(pVertexAttrib[index].bEnabled) = GL_FALSE;
+ FNPTR(DisableVertexAttribArray)(index);
+}
+
+void GL_APIENTRY ES2ENTRY(GetVertexAttribPointerv)(GLuint index, GLenum pname, void** pointer) {
+ if (pname != GL_VERTEX_ATTRIB_ARRAY_POINTER) {
+ ES2INTER(SetError)(GL_INVALID_ENUM);
+ return;
+ }
+ if (CCV(nMaxVertexAttribs) <= index) {
+ ES2INTER(SetError)(GL_INVALID_VALUE);
+ return;
+ }
+ *pointer = (void*)CCV(pVertexAttrib[index].pData);
+}
+
+void GL_APIENTRY ES2ENTRY(GetVertexAttribfv)(GLuint index, GLenum pname, GLfloat* params) {
+ struct VertexAttribUnit* pVertexAttrib;
+ if (CCV(nMaxVertexAttribs) <= index) {
+ ES2INTER(SetError)(GL_INVALID_VALUE);
+ return;
+ }
+ pVertexAttrib = &(CCV(pVertexAttrib[index]));
+ switch (pname) {
+ default:
+ ES2INTER(SetError)(GL_INVALID_ENUM);
+ return;
+ case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING:
+ *params = (GLfloat)(pVertexAttrib->uBufferBinding);
+ break;
+ case GL_VERTEX_ATTRIB_ARRAY_ENABLED:
+ *params = (GLfloat)(pVertexAttrib->bEnabled);
+ break;
+ case GL_VERTEX_ATTRIB_ARRAY_SIZE:
+ *params = (GLfloat)(pVertexAttrib->iSize);
+ break;
+ case GL_VERTEX_ATTRIB_ARRAY_STRIDE:
+ *params = (GLfloat)(pVertexAttrib->uStride);
+ break;
+ case GL_VERTEX_ATTRIB_ARRAY_TYPE:
+ *params = (GLfloat)(pVertexAttrib->eType);
+ break;
+ case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED:
+ *params = (GLfloat)(pVertexAttrib->bNormalized);
+ break;
+ case GL_CURRENT_VERTEX_ATTRIB:
+ if (index == 0) {
+ ES2INTER(SetError)(GL_INVALID_OPERATION);
+ return;
+ }
+ FNPTR(GetVertexAttribfv)(index, pname, params);
+ break;
+ }
+}
+
+void GL_APIENTRY ES2ENTRY(GetVertexAttribiv)(GLuint index, GLenum pname, GLint* params) {
+ struct VertexAttribUnit* pVertexAttrib;
+ if (CCV(nMaxVertexAttribs) <= index) {
+ ES2INTER(SetError)(GL_INVALID_VALUE);
+ return;
+ }
+ pVertexAttrib = &(CCV(pVertexAttrib[index]));
+ switch (pname) {
+ default:
+ ES2INTER(SetError)(GL_INVALID_ENUM);
+ return;
+ case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING:
+ *params = (GLint)(pVertexAttrib->uBufferBinding);
+ break;
+ case GL_VERTEX_ATTRIB_ARRAY_ENABLED:
+ *params = (GLint)(pVertexAttrib->bEnabled);
+ break;
+ case GL_VERTEX_ATTRIB_ARRAY_SIZE:
+ *params = (GLint)(pVertexAttrib->iSize);
+ break;
+ case GL_VERTEX_ATTRIB_ARRAY_STRIDE:
+ *params = (GLint)(pVertexAttrib->uStride);
+ break;
+ case GL_VERTEX_ATTRIB_ARRAY_TYPE:
+ *params = (GLint)(pVertexAttrib->eType);
+ break;
+ case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED:
+ *params = (GLint)(pVertexAttrib->bNormalized);
+ break;
+ case GL_CURRENT_VERTEX_ATTRIB:
+ if (index == 0) {
+ ES2INTER(SetError)(GL_INVALID_OPERATION);
+ return;
+ }
+ FNPTR(GetVertexAttribiv)(index, pname, params);
+ break;
+ }
+}