summaryrefslogtreecommitdiff
path: root/es_2_0/Texture.c
diff options
context:
space:
mode:
Diffstat (limited to 'es_2_0/Texture.c')
-rwxr-xr-xes_2_0/Texture.c246
1 files changed, 246 insertions, 0 deletions
diff --git a/es_2_0/Texture.c b/es_2_0/Texture.c
new file mode 100755
index 0000000..5529ee6
--- /dev/null
+++ b/es_2_0/Texture.c
@@ -0,0 +1,246 @@
+/*
+ * 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"
+#include <GLES2/gl2ext.h>
+
+
+void GL_APIENTRY ES2ENTRY(GenTextures)(GLsizei n, GLuint* textures) {
+ if (n < 0) {
+ ES2INTER(SetError)(GL_INVALID_VALUE);
+ return;
+ } else if (n == 0) {
+ ES2INTER(SetError)(GL_NO_ERROR);
+ return;
+ }
+ FNPTR(GenTextures)(n, textures);
+}
+
+void GL_APIENTRY ES2ENTRY(DeleteTextures)(GLsizei n, const GLuint* textures) {
+ if (n < 0) {
+ ES2INTER(SetError)(GL_INVALID_VALUE);
+ return;
+ }
+ FNPTR(DeleteTextures)(n, textures);
+}
+
+GLboolean GL_APIENTRY ES2ENTRY(IsTexture)(GLuint texture) {
+ return FNPTR(IsTexture)(texture);
+}
+
+#if ! defined(GL_GENERATE_MIPMAP)
+#define GL_GENERATE_MIPMAP 0x8191
+#endif
+
+void GL_APIENTRY ES2ENTRY(BindTexture)(GLenum target, GLuint texture) {
+ switch (target) {
+ default:
+ ES2INTER(SetError)(GL_INVALID_ENUM);
+ return;
+ case GL_TEXTURE_2D:
+ case GL_TEXTURE_CUBE_MAP:
+ FNPTR(BindTexture)(target, texture);
+ break;
+ }
+}
+
+void GL_APIENTRY ES2ENTRY(PixelStorei)(GLenum pname, GLint param) {
+ switch (pname) {
+ default:
+ ES2INTER(SetError)(GL_INVALID_ENUM);
+ return;
+ case GL_PACK_ALIGNMENT:
+ case GL_UNPACK_ALIGNMENT:
+ break;
+ }
+ if (param != 1 && param != 2 && param != 4 && param != 8) {
+ ES2INTER(SetError)(GL_INVALID_ENUM);
+ return;
+ }
+ FNPTR(PixelStorei)(pname, param);
+}
+
+void GL_APIENTRY ES2ENTRY(ActiveTexture)(GLenum texture) {
+ GLint iMaxCombinedTextureImageUnits;
+ FNPTR(GetIntegerv)(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &iMaxCombinedTextureImageUnits);
+ if (texture < GL_TEXTURE0 || GL_TEXTURE0 + iMaxCombinedTextureImageUnits <= texture) {
+ ES2INTER(SetError)(GL_INVALID_ENUM);
+ return;
+ }
+ FNPTR(ActiveTexture)(texture);
+}
+
+void GL_APIENTRY ES2ENTRY(GenerateMipmap)(GLenum target) {
+ switch (target) {
+ default:
+ ES2INTER(SetError)(GL_INVALID_ENUM);
+ return;
+ case GL_TEXTURE_2D:
+ case GL_TEXTURE_CUBE_MAP:
+ break;
+ }
+ FNPTR(GenerateMipmap)(target);
+}
+
+void GL_APIENTRY ES2ENTRY(TexParameterf)(GLenum target, GLenum pname, GLfloat param) {
+ GLint iParam = (GLint)(param);
+ GLfloat fError = param - iParam;
+ if (fError != 0.0F) {
+ ES2INTER(SetError)(GL_INVALID_ENUM);
+ return;
+ }
+ ES2ENTRY(TexParameteri)(target, pname, iParam);
+}
+
+void GL_APIENTRY ES2ENTRY(TexParameterfv)(GLenum target, GLenum pname, const GLfloat* params) {
+ GLint iParam = (GLint)(*params);
+ GLfloat fError = *params - iParam;
+ if (fError != 0.0F) {
+ ES2INTER(SetError)(GL_INVALID_ENUM);
+ return;
+ }
+ ES2ENTRY(TexParameteri)(target, pname, iParam);
+}
+
+void GL_APIENTRY ES2ENTRY(TexParameteri)(GLenum target, GLenum pname, GLint param) {
+ switch (target) {
+ default:
+ ES2INTER(SetError)(GL_INVALID_ENUM);
+ return;
+ case GL_TEXTURE_2D:
+ case GL_TEXTURE_CUBE_MAP:
+ break;
+ }
+ switch (pname) {
+ default:
+ ES2INTER(SetError)(GL_INVALID_ENUM);
+ return;
+ case GL_TEXTURE_MIN_FILTER:
+ switch (param) {
+ default:
+ ES2INTER(SetError)(GL_INVALID_ENUM);
+ return;
+ case GL_NEAREST:
+ case GL_LINEAR:
+ case GL_NEAREST_MIPMAP_NEAREST:
+ case GL_LINEAR_MIPMAP_NEAREST:
+ case GL_NEAREST_MIPMAP_LINEAR:
+ case GL_LINEAR_MIPMAP_LINEAR:
+ break;
+ }
+ break;
+ case GL_TEXTURE_MAG_FILTER:
+ switch (param) {
+ default:
+ ES2INTER(SetError)(GL_INVALID_ENUM);
+ return;
+ case GL_NEAREST:
+ case GL_LINEAR:
+ break;
+ }
+ break;
+ case GL_TEXTURE_WRAP_S:
+ case GL_TEXTURE_WRAP_T:
+#if defined(PROVIDING_OES_texture_3D)
+ case GL_TEXTURE_WRAP_R_OES:
+#endif
+ switch (param) {
+ default:
+ ES2INTER(SetError)(GL_INVALID_ENUM);
+ return;
+ case GL_CLAMP_TO_EDGE:
+ case GL_MIRRORED_REPEAT:
+ case GL_REPEAT:
+ break;
+ }
+ }
+ FNPTR(TexParameteri)(target, pname, param);
+}
+
+void GL_APIENTRY ES2ENTRY(TexParameteriv)(GLenum target, GLenum pname, const GLint* params) {
+ ES2ENTRY(TexParameteri)(target, pname, *params);
+}
+
+void GL_APIENTRY ES2ENTRY(GetTexParameterfv)(GLenum target, GLenum pname, GLfloat* params) {
+ switch (target) {
+ default:
+ ES2INTER(SetError)(GL_INVALID_ENUM);
+ return;
+ case GL_TEXTURE_2D:
+ case GL_TEXTURE_CUBE_MAP:
+#if defined(PROVIDING_OES_texture_3D)
+ case GL_TEXTURE_3D_OES:
+#endif
+ break;
+ }
+ switch (pname) {
+ default:
+ ES2INTER(SetError)(GL_INVALID_ENUM);
+ return;
+ case GL_TEXTURE_MAG_FILTER:
+ case GL_TEXTURE_MIN_FILTER:
+ case GL_TEXTURE_WRAP_S:
+ case GL_TEXTURE_WRAP_T:
+#if defined(PROVIDING_OES_texture_3D)
+ case GL_TEXTURE_WRAP_R_OES:
+#endif
+ break;
+ }
+ FNPTR(GetTexParameterfv)(target, pname, params);
+}
+
+void GL_APIENTRY ES2ENTRY(GetTexParameteriv)(GLenum target, GLenum pname, GLint* params) {
+ switch (target) {
+ default:
+ ES2INTER(SetError)(GL_INVALID_ENUM);
+ return;
+ case GL_TEXTURE_2D:
+ case GL_TEXTURE_CUBE_MAP:
+#if defined(PROVIDING_OES_texture_3D)
+ case GL_TEXTURE_3D_OES:
+#endif
+ break;
+ }
+ switch (pname) {
+ default:
+ ES2INTER(SetError)(GL_INVALID_ENUM);
+ return;
+ case GL_TEXTURE_MAG_FILTER:
+ case GL_TEXTURE_MIN_FILTER:
+ case GL_TEXTURE_WRAP_S:
+ case GL_TEXTURE_WRAP_T:
+#if defined(PROVIDING_OES_texture_3D)
+ case GL_TEXTURE_WRAP_R_OES:
+#endif
+ break;
+ }
+ FNPTR(GetTexParameteriv)(target, pname, params);
+}