1 /******************************************************************************* 2 * Copyright 2011 See AUTHORS file. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 ******************************************************************************/ 16 17 package com.badlogic.gdx.backends.android; 18 19 import java.nio.Buffer; 20 import java.nio.FloatBuffer; 21 import java.nio.IntBuffer; 22 23 import com.badlogic.gdx.graphics.GL20; 24 25 public class AndroidGL20 implements GL20 { 26 static { 27 System.loadLibrary("gdx"); 28 init(); 29 } 30 31 private static native void init (); 32 33 public native void glActiveTexture (int texture); 34 35 public native void glAttachShader (int program, int shader); 36 37 public native void glBindAttribLocation (int program, int index, String name); 38 39 public native void glBindBuffer (int target, int buffer); 40 41 public native void glBindFramebuffer (int target, int framebuffer); 42 43 public native void glBindRenderbuffer (int target, int renderbuffer); 44 45 public native void glBindTexture (int target, int texture); 46 47 public native void glBlendColor (float red, float green, float blue, float alpha); 48 49 public native void glBlendEquation (int mode); 50 51 public native void glBlendEquationSeparate (int modeRGB, int modeAlpha); 52 53 public native void glBlendFunc (int sfactor, int dfactor); 54 55 public native void glBlendFuncSeparate (int srcRGB, int dstRGB, int srcAlpha, int dstAlpha); 56 57 public native void glBufferData (int target, int size, Buffer data, int usage); 58 59 public native void glBufferSubData (int target, int offset, int size, Buffer data); 60 61 public native int glCheckFramebufferStatus (int target); 62 63 public native void glClear (int mask); 64 65 public native void glClearColor (float red, float green, float blue, float alpha); 66 67 public native void glClearDepthf (float depth); 68 69 public native void glClearStencil (int s); 70 71 public native void glColorMask (boolean red, boolean green, boolean blue, boolean alpha); 72 73 public native void glCompileShader (int shader); 74 75 public native void glCompressedTexImage2D (int target, int level, int internalformat, int width, int height, int border, 76 int imageSize, Buffer data); 77 78 public native void glCompressedTexSubImage2D (int target, int level, int xoffset, int yoffset, int width, int height, 79 int format, int imageSize, Buffer data); 80 81 public native void glCopyTexImage2D (int target, int level, int internalformat, int x, int y, int width, int height, int border); 82 83 public native void glCopyTexSubImage2D (int target, int level, int xoffset, int yoffset, int x, int y, int width, int height); 84 85 public native int glCreateProgram (); 86 87 public native int glCreateShader (int type); 88 89 public native void glCullFace (int mode); 90 91 public native void glDeleteBuffers (int n, IntBuffer buffers); 92 93 public native void glDeleteBuffer (int buffer); 94 95 public native void glDeleteFramebuffers (int n, IntBuffer framebuffers); 96 97 public native void glDeleteFramebuffer (int framebuffer); 98 99 public native void glDeleteProgram (int program); 100 101 public native void glDeleteRenderbuffers (int n, IntBuffer renderbuffers); 102 103 public native void glDeleteRenderbuffer (int renderbuffer); 104 105 public native void glDeleteShader (int shader); 106 107 public native void glDeleteTextures (int n, IntBuffer textures); 108 109 public native void glDeleteTexture (int texture); 110 111 public native void glDepthFunc (int func); 112 113 public native void glDepthMask (boolean flag); 114 115 public native void glDepthRangef (float zNear, float zFar); 116 117 public native void glDetachShader (int program, int shader); 118 119 public native void glDisable (int cap); 120 121 public native void glDisableVertexAttribArray (int index); 122 123 public native void glDrawArrays (int mode, int first, int count); 124 125 public native void glDrawElements (int mode, int count, int type, Buffer indices); 126 127 public native void glDrawElements (int mode, int count, int type, int indices); 128 129 public native void glEnable (int cap); 130 131 public native void glEnableVertexAttribArray (int index); 132 133 public native void glFinish (); 134 135 public native void glFlush (); 136 137 public native void glFramebufferRenderbuffer (int target, int attachment, int renderbuffertarget, int renderbuffer); 138 139 public native void glFramebufferTexture2D (int target, int attachment, int textarget, int texture, int level); 140 141 public native void glFrontFace (int mode); 142 143 public native void glGenBuffers (int n, IntBuffer buffers); 144 145 public native int glGenBuffer (); 146 147 public native void glGenerateMipmap (int target); 148 149 public native void glGenFramebuffers (int n, IntBuffer framebuffers); 150 151 public native int glGenFramebuffer (); 152 153 public native void glGenRenderbuffers (int n, IntBuffer renderbuffers); 154 155 public native int glGenRenderbuffer (); 156 157 public native void glGenTextures (int n, IntBuffer textures); 158 159 public native int glGenTexture (); 160 161 public native String glGetActiveAttrib (int program, int index, IntBuffer size, Buffer type); 162 163 public native String glGetActiveUniform (int program, int index, IntBuffer size, Buffer type); 164 165 public native void glGetAttachedShaders (int program, int maxcount, Buffer count, IntBuffer shaders); 166 167 public native int glGetAttribLocation (int program, String name); 168 169 public native void glGetBooleanv (int pname, Buffer params); 170 171 public native void glGetBufferParameteriv (int target, int pname, IntBuffer params); 172 173 public native int glGetError (); 174 175 public native void glGetFloatv (int pname, FloatBuffer params); 176 177 public native void glGetFramebufferAttachmentParameteriv (int target, int attachment, int pname, IntBuffer params); 178 179 public native void glGetIntegerv (int pname, IntBuffer params); 180 181 public native void glGetProgramiv (int program, int pname, IntBuffer params); 182 183 public native String glGetProgramInfoLog (int program); 184 185 public native void glGetRenderbufferParameteriv (int target, int pname, IntBuffer params); 186 187 public native void glGetShaderiv (int shader, int pname, IntBuffer params); 188 189 public native String glGetShaderInfoLog (int shader); 190 191 public native void glGetShaderPrecisionFormat (int shadertype, int precisiontype, IntBuffer range, IntBuffer precision); 192 193 public native void glGetShaderSource (int shader, int bufsize, Buffer length, String source); 194 195 public native String glGetString (int name); 196 197 public native void glGetTexParameterfv (int target, int pname, FloatBuffer params); 198 199 public native void glGetTexParameteriv (int target, int pname, IntBuffer params); 200 201 public native void glGetUniformfv (int program, int location, FloatBuffer params); 202 203 public native void glGetUniformiv (int program, int location, IntBuffer params); 204 205 public native int glGetUniformLocation (int program, String name); 206 207 public native void glGetVertexAttribfv (int index, int pname, FloatBuffer params); 208 209 public native void glGetVertexAttribiv (int index, int pname, IntBuffer params); 210 211 public native void glGetVertexAttribPointerv (int index, int pname, Buffer pointer); 212 213 public native void glHint (int target, int mode); 214 215 public native boolean glIsBuffer (int buffer); 216 217 public native boolean glIsEnabled (int cap); 218 219 public native boolean glIsFramebuffer (int framebuffer); 220 221 public native boolean glIsProgram (int program); 222 223 public native boolean glIsRenderbuffer (int renderbuffer); 224 225 public native boolean glIsShader (int shader); 226 227 public native boolean glIsTexture (int texture); 228 229 public native void glLineWidth (float width); 230 231 public native void glLinkProgram (int program); 232 233 public native void glPixelStorei (int pname, int param); 234 235 public native void glPolygonOffset (float factor, float units); 236 237 public native void glReadPixels (int x, int y, int width, int height, int format, int type, Buffer pixels); 238 239 public native void glReleaseShaderCompiler (); 240 241 public native void glRenderbufferStorage (int target, int internalformat, int width, int height); 242 243 public native void glSampleCoverage (float value, boolean invert); 244 245 public native void glScissor (int x, int y, int width, int height); 246 247 public native void glShaderBinary (int n, IntBuffer shaders, int binaryformat, Buffer binary, int length); 248 249 public native void glShaderSource (int shader, String string); 250 251 public native void glStencilFunc (int func, int ref, int mask); 252 253 public native void glStencilFuncSeparate (int face, int func, int ref, int mask); 254 255 public native void glStencilMask (int mask); 256 257 public native void glStencilMaskSeparate (int face, int mask); 258 259 public native void glStencilOp (int fail, int zfail, int zpass); 260 261 public native void glStencilOpSeparate (int face, int fail, int zfail, int zpass); 262 263 public native void glTexImage2D (int target, int level, int internalformat, int width, int height, int border, int format, 264 int type, Buffer pixels); 265 266 public native void glTexParameterf (int target, int pname, float param); 267 268 public native void glTexParameterfv (int target, int pname, FloatBuffer params); 269 270 public native void glTexParameteri (int target, int pname, int param); 271 272 public native void glTexParameteriv (int target, int pname, IntBuffer params); 273 274 public native void glTexSubImage2D (int target, int level, int xoffset, int yoffset, int width, int height, int format, 275 int type, Buffer pixels); 276 277 public native void glUniform1f (int location, float x); 278 279 public native void glUniform1fv (int location, int count, FloatBuffer v); 280 281 public native void glUniform1fv (int location, int count, float[] v, int offset); 282 283 public native void glUniform1i (int location, int x); 284 285 public native void glUniform1iv (int location, int count, IntBuffer v); 286 287 public native void glUniform1iv (int location, int count, int[] v, int offset); 288 289 public native void glUniform2f (int location, float x, float y); 290 291 public native void glUniform2fv (int location, int count, FloatBuffer v); 292 293 public native void glUniform2fv (int location, int count, float[] v, int offset); 294 295 public native void glUniform2i (int location, int x, int y); 296 297 public native void glUniform2iv (int location, int count, IntBuffer v); 298 299 public native void glUniform2iv (int location, int count, int[] v, int offset); 300 301 public native void glUniform3f (int location, float x, float y, float z); 302 303 public native void glUniform3fv (int location, int count, FloatBuffer v); 304 305 public native void glUniform3fv (int location, int count, float[] v, int offset); 306 307 public native void glUniform3i (int location, int x, int y, int z); 308 309 public native void glUniform3iv (int location, int count, IntBuffer v); 310 311 public native void glUniform3iv (int location, int count, int[] v, int offset); 312 313 public native void glUniform4f (int location, float x, float y, float z, float w); 314 315 public native void glUniform4fv (int location, int count, FloatBuffer v); 316 317 public native void glUniform4fv (int location, int count, float[] v, int offset); 318 319 public native void glUniform4i (int location, int x, int y, int z, int w); 320 321 public native void glUniform4iv (int location, int count, IntBuffer v); 322 323 public native void glUniform4iv (int location, int count, int[] v, int offset); 324 325 public native void glUniformMatrix2fv (int location, int count, boolean transpose, FloatBuffer value); 326 327 public native void glUniformMatrix2fv (int location, int count, boolean transpose, float[] value, int offset); 328 329 public native void glUniformMatrix3fv (int location, int count, boolean transpose, FloatBuffer value); 330 331 public native void glUniformMatrix3fv (int location, int count, boolean transpose, float[] value, int offset); 332 333 public native void glUniformMatrix4fv (int location, int count, boolean transpose, FloatBuffer value); 334 335 public native void glUniformMatrix4fv (int location, int count, boolean transpose, float[] value, int offset); 336 337 public native void glUseProgram (int program); 338 339 public native void glValidateProgram (int program); 340 341 public native void glVertexAttrib1f (int indx, float x); 342 343 public native void glVertexAttrib1fv (int indx, FloatBuffer values); 344 345 public native void glVertexAttrib2f (int indx, float x, float y); 346 347 public native void glVertexAttrib2fv (int indx, FloatBuffer values); 348 349 public native void glVertexAttrib3f (int indx, float x, float y, float z); 350 351 public native void glVertexAttrib3fv (int indx, FloatBuffer values); 352 353 public native void glVertexAttrib4f (int indx, float x, float y, float z, float w); 354 355 public native void glVertexAttrib4fv (int indx, FloatBuffer values); 356 357 public native void glVertexAttribPointer (int indx, int size, int type, boolean normalized, int stride, Buffer ptr); 358 359 public native void glVertexAttribPointer (int indx, int size, int type, boolean normalized, int stride, int ptr); 360 361 public native void glViewport (int x, int y, int width, int height); 362 } 363