| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "jni/android_extension.h" |
| 6 |
| 5 #include <android/log.h> | 7 #include <android/log.h> |
| 6 #include <EGL/egl.h> | 8 #include <EGL/egl.h> |
| 7 #include <GLES2/gl2.h> | 9 #include <GLES2/gl2.h> |
| 8 #include <GLES2/gl2ext.h> | 10 #include <GLES2/gl2ext.h> |
| 9 #include <jni.h> | 11 #include <jni.h> |
| 10 #include <stdio.h> | 12 #include <stdio.h> |
| 11 #include <stdlib.h> | 13 #include <stdlib.h> |
| 12 #include <string.h> | 14 #include <string.h> |
| 13 | 15 |
| 14 #include "bin/log.h" | |
| 15 #include "include/dart_api.h" | 16 #include "include/dart_api.h" |
| 16 #include "jni/android_extension.h" | 17 #include "jni/log.h" |
| 17 | |
| 18 Dart_NativeFunction ResolveName(Dart_Handle name, int argc); | |
| 19 | |
| 20 DART_EXPORT Dart_Handle android_extension_Init(Dart_Handle parent_library) { | |
| 21 if (Dart_IsError(parent_library)) { return parent_library; } | |
| 22 | |
| 23 Dart_Handle result_code = Dart_SetNativeResolver(parent_library, ResolveName); | |
| 24 if (Dart_IsError(result_code)) return result_code; | |
| 25 | |
| 26 return Dart_Null(); | |
| 27 } | |
| 28 | 18 |
| 29 Dart_Handle HandleError(Dart_Handle handle) { | 19 Dart_Handle HandleError(Dart_Handle handle) { |
| 30 if (Dart_IsError(handle)) Dart_PropagateError(handle); | 20 if (Dart_IsError(handle)) Dart_PropagateError(handle); |
| 31 return handle; | 21 return handle; |
| 32 } | 22 } |
| 33 | 23 |
| 34 void CheckGLError(const char *function) { | 24 void CheckGLError(const char *function) { |
| 35 int error = glGetError(); | 25 int error = glGetError(); |
| 36 if (error != GL_NO_ERROR) { | 26 if (error != GL_NO_ERROR) { |
| 37 Log::PrintErr("ERROR!: %s returns %d", function, error); | 27 LOGE("ERROR!: %s returns %d", function, error); |
| 38 } | 28 } |
| 39 } | 29 } |
| 40 | 30 |
| 41 const char* GetStringArg(Dart_NativeArguments arguments, int idx) { | 31 const char* GetStringArg(Dart_NativeArguments arguments, int idx) { |
| 42 Dart_Handle whatHandle = HandleError(Dart_GetNativeArgument(arguments, idx)); | 32 Dart_Handle whatHandle = HandleError(Dart_GetNativeArgument(arguments, idx)); |
| 43 uint8_t* str; | 33 uint8_t* str; |
| 44 intptr_t length; | 34 intptr_t length; |
| 45 HandleError(Dart_StringLength(whatHandle, &length)); | 35 HandleError(Dart_StringLength(whatHandle, &length)); |
| 46 HandleError(Dart_StringToUTF8(whatHandle, &str, length)); | 36 HandleError(Dart_StringToUTF8(whatHandle, &str, &length)); |
| 47 str[length] = 0; | 37 str[length] = 0; |
| 48 return const_cast<const char*>(reinterpret_cast<char*>(str)); | 38 return const_cast<const char*>(reinterpret_cast<char*>(str)); |
| 49 } | 39 } |
| 50 | 40 |
| 51 void Log(Dart_NativeArguments arguments) { | 41 void Log(Dart_NativeArguments arguments) { |
| 52 Dart_EnterScope(); | 42 Dart_EnterScope(); |
| 53 Log::Print(GetStringArg(arguments, 0)); | 43 LOGI(GetStringArg(arguments, 0)); |
| 54 Dart_ExitScope(); | 44 Dart_ExitScope(); |
| 55 } | 45 } |
| 56 | 46 |
| 57 void SystemRand(Dart_NativeArguments arguments) { | 47 void SystemRand(Dart_NativeArguments arguments) { |
| 58 Dart_EnterScope(); | 48 Dart_EnterScope(); |
| 59 Dart_Handle result = HandleError(Dart_NewInteger(rand())); | 49 Dart_Handle result = HandleError(Dart_NewInteger(rand())); |
| 60 Dart_SetReturnValue(arguments, result); | 50 Dart_SetReturnValue(arguments, result); |
| 61 Dart_ExitScope(); | 51 Dart_ExitScope(); |
| 62 } | 52 } |
| 63 | 53 |
| 64 void SystemSrand(Dart_NativeArguments arguments) { | 54 void SystemSrand(Dart_NativeArguments arguments) { |
| 65 Dart_EnterScope(); | 55 Dart_EnterScope(); |
| 66 bool success = false; | 56 bool success = false; |
| 67 Dart_Handle seed_object = HandleError(Dart_GetNativeArgument(arguments, 0)); | 57 Dart_Handle seed_object = HandleError(Dart_GetNativeArgument(arguments, 0)); |
| 68 if (Dart_IsInteger(seed_object)) { | 58 if (Dart_IsInteger(seed_object)) { |
| 69 bool fits; | 59 bool fits; |
| 70 HandleError(Dart_IntegerFitsIntoInt64(seed_object, &fits)); | 60 HandleError(Dart_IntegerFitsIntoInt64(seed_object, &fits)); |
| 71 if (fits) { | 61 if (fits) { |
| 72 int64_t seed; | 62 int64_t seed; |
| 73 HandleError(Dart_IntegerToInt64(seed_object, &seed)); | 63 HandleError(Dart_IntegerToInt64(seed_object, &seed)); |
| 74 srand(static_cast<unsigned>(seed)); | 64 srand(static_cast<unsigned>(seed)); |
| 75 success = true; | 65 success = true; |
| 76 } | 66 } |
| 77 } | 67 } |
| 78 Dart_SetReturnValue(arguments, HandleError(Dart_NewBoolean(success))); | 68 Dart_SetReturnValue(arguments, HandleError(Dart_NewBoolean(success))); |
| 79 Dart_ExitScope(); | 69 Dart_ExitScope(); |
| 80 } | 70 } |
| 81 | 71 |
| 82 void EGLSwapBuffers(Dart_NativeArguments arguments) { | 72 void EGLSwapBuffers(Dart_NativeArguments arguments) { |
| 83 Log::Print("GLSwapBuffers"); | 73 LOGI("GLSwapBuffers"); |
| 84 Dart_EnterScope(); | 74 Dart_EnterScope(); |
| 85 | 75 |
| 86 EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY); | 76 EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY); |
| 87 EGLSurface surface = eglGetCurrentSurface(EGL_DRAW); | 77 EGLSurface surface = eglGetCurrentSurface(EGL_DRAW); |
| 88 eglSwapBuffers(display, surface); | 78 eglSwapBuffers(display, surface); |
| 89 | 79 |
| 90 CheckGLError("eglSwapBuffers"); | 80 CheckGLError("eglSwapBuffers"); |
| 91 Dart_ExitScope(); | 81 Dart_ExitScope(); |
| 92 } | 82 } |
| 93 | 83 |
| 94 void GLAttachShader(Dart_NativeArguments arguments) { | 84 void GLAttachShader(Dart_NativeArguments arguments) { |
| 95 Log::Print("GLAttachShader"); | 85 LOGI("GLAttachShader"); |
| 96 Dart_EnterScope(); | 86 Dart_EnterScope(); |
| 97 | 87 |
| 98 Dart_Handle programHandle = HandleError(Dart_GetNativeArgument(arguments, 0)); | 88 Dart_Handle programHandle = HandleError(Dart_GetNativeArgument(arguments, 0)); |
| 99 int64_t program; | 89 int64_t program; |
| 100 HandleError(Dart_IntegerToInt64(programHandle, &program)); | 90 HandleError(Dart_IntegerToInt64(programHandle, &program)); |
| 101 | 91 |
| 102 Dart_Handle shaderHandle = HandleError(Dart_GetNativeArgument(arguments, 1)); | 92 Dart_Handle shaderHandle = HandleError(Dart_GetNativeArgument(arguments, 1)); |
| 103 int64_t shader; | 93 int64_t shader; |
| 104 HandleError(Dart_IntegerToInt64(shaderHandle, &shader)); | 94 HandleError(Dart_IntegerToInt64(shaderHandle, &shader)); |
| 105 | 95 |
| 106 glAttachShader(program, shader); | 96 glAttachShader(program, shader); |
| 107 CheckGLError("glAttachShader"); | 97 CheckGLError("glAttachShader"); |
| 108 Dart_ExitScope(); | 98 Dart_ExitScope(); |
| 109 } | 99 } |
| 110 | 100 |
| 111 void GLBindBuffer(Dart_NativeArguments arguments) { | 101 void GLBindBuffer(Dart_NativeArguments arguments) { |
| 112 Log::Print("GLBindBuffer"); | 102 LOGI("GLBindBuffer"); |
| 113 Dart_EnterScope(); | 103 Dart_EnterScope(); |
| 114 | 104 |
| 115 Dart_Handle targetHandle = HandleError(Dart_GetNativeArgument(arguments, 0)); | 105 Dart_Handle targetHandle = HandleError(Dart_GetNativeArgument(arguments, 0)); |
| 116 int64_t target; | 106 int64_t target; |
| 117 HandleError(Dart_IntegerToInt64(targetHandle, &target)); | 107 HandleError(Dart_IntegerToInt64(targetHandle, &target)); |
| 118 | 108 |
| 119 Dart_Handle bufferHandle = HandleError(Dart_GetNativeArgument(arguments, 1)); | 109 Dart_Handle bufferHandle = HandleError(Dart_GetNativeArgument(arguments, 1)); |
| 120 int64_t buffer; | 110 int64_t buffer; |
| 121 HandleError(Dart_IntegerToInt64(bufferHandle, &buffer)); | 111 HandleError(Dart_IntegerToInt64(bufferHandle, &buffer)); |
| 122 | 112 |
| 123 glBindBuffer(target, buffer); | 113 glBindBuffer(target, buffer); |
| 124 CheckGLError("glBindBuffer"); | 114 CheckGLError("glBindBuffer"); |
| 125 Dart_ExitScope(); | 115 Dart_ExitScope(); |
| 126 } | 116 } |
| 127 | 117 |
| 128 void GLBufferData(Dart_NativeArguments arguments) { | 118 void GLBufferData(Dart_NativeArguments arguments) { |
| 129 Log::Print("GLBufferData"); | 119 LOGI("GLBufferData"); |
| 130 Dart_EnterScope(); | 120 Dart_EnterScope(); |
| 131 | 121 |
| 132 Dart_Handle targetHandle = HandleError(Dart_GetNativeArgument(arguments, 0)); | 122 Dart_Handle targetHandle = HandleError(Dart_GetNativeArgument(arguments, 0)); |
| 133 int64_t target; | 123 int64_t target; |
| 134 HandleError(Dart_IntegerToInt64(targetHandle, &target)); | 124 HandleError(Dart_IntegerToInt64(targetHandle, &target)); |
| 135 | 125 |
| 136 Dart_Handle dataHandle = HandleError(Dart_GetNativeArgument(arguments, 1)); | 126 Dart_Handle dataHandle = HandleError(Dart_GetNativeArgument(arguments, 1)); |
| 137 intptr_t size; | 127 intptr_t size; |
| 138 HandleError(Dart_ListLength(dataHandle, &size)); | 128 HandleError(Dart_ListLength(dataHandle, &size)); |
| 139 | 129 |
| 140 Log::Print("Size: %d", size); | 130 LOGI("Size: %d", size); |
| 141 | 131 |
| 142 // TODO(vsm): No guarantee that this is a float! | 132 // TODO(vsm): No guarantee that this is a float! |
| 143 float* data = reinterpret_cast<float*>(malloc(size * sizeof(float))); | 133 float* data = reinterpret_cast<float*>(malloc(size * sizeof(float))); |
| 144 for (int i = 0; i < size; i++) { | 134 for (int i = 0; i < size; i++) { |
| 145 Dart_Handle elemHandle = HandleError(Dart_ListGetAt(dataHandle, i)); | 135 Dart_Handle elemHandle = HandleError(Dart_ListGetAt(dataHandle, i)); |
| 146 double value; | 136 double value; |
| 147 Dart_DoubleValue(elemHandle, &value); | 137 Dart_DoubleValue(elemHandle, &value); |
| 148 data[i] = static_cast<float>(value); | 138 data[i] = static_cast<float>(value); |
| 149 Log::Print("Value[%d]: %f", i, data[i]); | 139 LOGI("Value[%d]: %f", i, data[i]); |
| 150 } | 140 } |
| 151 | 141 |
| 152 Dart_Handle usageHandle = HandleError(Dart_GetNativeArgument(arguments, 2)); | 142 Dart_Handle usageHandle = HandleError(Dart_GetNativeArgument(arguments, 2)); |
| 153 int64_t usage; | 143 int64_t usage; |
| 154 HandleError(Dart_IntegerToInt64(usageHandle, &usage)); | 144 HandleError(Dart_IntegerToInt64(usageHandle, &usage)); |
| 155 | 145 |
| 156 glBufferData(target, size * sizeof(float), data, usage); | 146 glBufferData(target, size * sizeof(float), data, usage); |
| 157 CheckGLError("glBufferData"); | 147 CheckGLError("glBufferData"); |
| 158 free(data); | 148 free(data); |
| 159 Dart_ExitScope(); | 149 Dart_ExitScope(); |
| 160 } | 150 } |
| 161 | 151 |
| 162 void GLCompileShader(Dart_NativeArguments arguments) { | 152 void GLCompileShader(Dart_NativeArguments arguments) { |
| 163 Dart_EnterScope(); | 153 Dart_EnterScope(); |
| 164 | 154 |
| 165 Dart_Handle shaderHandle = HandleError(Dart_GetNativeArgument(arguments, 0)); | 155 Dart_Handle shaderHandle = HandleError(Dart_GetNativeArgument(arguments, 0)); |
| 166 int64_t shader; | 156 int64_t shader; |
| 167 HandleError(Dart_IntegerToInt64(shaderHandle, &shader)); | 157 HandleError(Dart_IntegerToInt64(shaderHandle, &shader)); |
| 168 | 158 |
| 169 Log::Print("GLCompileShader"); | 159 LOGI("GLCompileShader"); |
| 170 glCompileShader(shader); | 160 glCompileShader(shader); |
| 171 CheckGLError("glCompileShader"); | 161 CheckGLError("glCompileShader"); |
| 172 Dart_ExitScope(); | 162 Dart_ExitScope(); |
| 173 } | 163 } |
| 174 | 164 |
| 175 void GLCreateBuffer(Dart_NativeArguments arguments) { | 165 void GLCreateBuffer(Dart_NativeArguments arguments) { |
| 176 Log::Print("GLCreateBuffer"); | 166 LOGI("GLCreateBuffer"); |
| 177 Dart_EnterScope(); | 167 Dart_EnterScope(); |
| 178 GLuint buffer; | 168 GLuint buffer; |
| 179 | 169 |
| 180 glGenBuffers(1, &buffer); | 170 glGenBuffers(1, &buffer); |
| 181 CheckGLError("glGenBuffers"); | 171 CheckGLError("glGenBuffers"); |
| 182 Dart_Handle result = HandleError(Dart_NewInteger(buffer)); | 172 Dart_Handle result = HandleError(Dart_NewInteger(buffer)); |
| 183 Dart_SetReturnValue(arguments, result); | 173 Dart_SetReturnValue(arguments, result); |
| 184 Dart_ExitScope(); | 174 Dart_ExitScope(); |
| 185 } | 175 } |
| 186 | 176 |
| 187 void GLCreateProgram(Dart_NativeArguments arguments) { | 177 void GLCreateProgram(Dart_NativeArguments arguments) { |
| 188 Log::Print("GLCreateProgram"); | 178 LOGI("GLCreateProgram"); |
| 189 Dart_EnterScope(); | 179 Dart_EnterScope(); |
| 190 | 180 |
| 191 int64_t program = glCreateProgram(); | 181 int64_t program = glCreateProgram(); |
| 192 CheckGLError("glCreateProgram"); | 182 CheckGLError("glCreateProgram"); |
| 193 Dart_Handle result = HandleError(Dart_NewInteger(program)); | 183 Dart_Handle result = HandleError(Dart_NewInteger(program)); |
| 194 Dart_SetReturnValue(arguments, result); | 184 Dart_SetReturnValue(arguments, result); |
| 195 Dart_ExitScope(); | 185 Dart_ExitScope(); |
| 196 } | 186 } |
| 197 | 187 |
| 198 void GLCreateShader(Dart_NativeArguments arguments) { | 188 void GLCreateShader(Dart_NativeArguments arguments) { |
| 199 Dart_EnterScope(); | 189 Dart_EnterScope(); |
| 200 | 190 |
| 201 Dart_Handle typeHandle = HandleError(Dart_GetNativeArgument(arguments, 0)); | 191 Dart_Handle typeHandle = HandleError(Dart_GetNativeArgument(arguments, 0)); |
| 202 int64_t type; | 192 int64_t type; |
| 203 HandleError(Dart_IntegerToInt64(typeHandle, &type)); | 193 HandleError(Dart_IntegerToInt64(typeHandle, &type)); |
| 204 | 194 |
| 205 int64_t shader = glCreateShader((GLenum)type); | 195 int64_t shader = glCreateShader((GLenum)type); |
| 206 Log::Print("GLCreateShader"); | 196 LOGI("GLCreateShader"); |
| 207 CheckGLError("glCreateShader"); | 197 CheckGLError("glCreateShader"); |
| 208 Dart_Handle result = HandleError(Dart_NewInteger(shader)); | 198 Dart_Handle result = HandleError(Dart_NewInteger(shader)); |
| 209 Dart_SetReturnValue(arguments, result); | 199 Dart_SetReturnValue(arguments, result); |
| 210 Dart_ExitScope(); | 200 Dart_ExitScope(); |
| 211 } | 201 } |
| 212 | 202 |
| 213 void GLDrawArrays(Dart_NativeArguments arguments) { | 203 void GLDrawArrays(Dart_NativeArguments arguments) { |
| 214 Log::Print("GLDrawArrays"); | 204 LOGI("GLDrawArrays"); |
| 215 Dart_EnterScope(); | 205 Dart_EnterScope(); |
| 216 | 206 |
| 217 Dart_Handle modeHandle = HandleError(Dart_GetNativeArgument(arguments, 0)); | 207 Dart_Handle modeHandle = HandleError(Dart_GetNativeArgument(arguments, 0)); |
| 218 int64_t mode; | 208 int64_t mode; |
| 219 HandleError(Dart_IntegerToInt64(modeHandle, &mode)); | 209 HandleError(Dart_IntegerToInt64(modeHandle, &mode)); |
| 220 | 210 |
| 221 Dart_Handle firstHandle = HandleError(Dart_GetNativeArgument(arguments, 1)); | 211 Dart_Handle firstHandle = HandleError(Dart_GetNativeArgument(arguments, 1)); |
| 222 int64_t first; | 212 int64_t first; |
| 223 HandleError(Dart_IntegerToInt64(firstHandle, &first)); | 213 HandleError(Dart_IntegerToInt64(firstHandle, &first)); |
| 224 | 214 |
| 225 Dart_Handle countHandle = HandleError(Dart_GetNativeArgument(arguments, 2)); | 215 Dart_Handle countHandle = HandleError(Dart_GetNativeArgument(arguments, 2)); |
| 226 int64_t count; | 216 int64_t count; |
| 227 HandleError(Dart_IntegerToInt64(countHandle, &count)); | 217 HandleError(Dart_IntegerToInt64(countHandle, &count)); |
| 228 | 218 |
| 229 glDrawArrays(mode, first, count); | 219 glDrawArrays(mode, first, count); |
| 230 CheckGLError("glDrawArrays"); | 220 CheckGLError("glDrawArrays"); |
| 231 Dart_ExitScope(); | 221 Dart_ExitScope(); |
| 232 } | 222 } |
| 233 | 223 |
| 234 void GLEnableVertexAttribArray(Dart_NativeArguments arguments) { | 224 void GLEnableVertexAttribArray(Dart_NativeArguments arguments) { |
| 235 Log::Print("GLEnableVertexAttribArray"); | 225 LOGI("GLEnableVertexAttribArray"); |
| 236 Dart_EnterScope(); | 226 Dart_EnterScope(); |
| 237 | 227 |
| 238 Dart_Handle locationHandle = | 228 Dart_Handle locationHandle = |
| 239 HandleError(Dart_GetNativeArgument(arguments, 0)); | 229 HandleError(Dart_GetNativeArgument(arguments, 0)); |
| 240 int64_t location; | 230 int64_t location; |
| 241 HandleError(Dart_IntegerToInt64(locationHandle, &location)); | 231 HandleError(Dart_IntegerToInt64(locationHandle, &location)); |
| 242 | 232 |
| 243 glEnableVertexAttribArray(location); | 233 glEnableVertexAttribArray(location); |
| 244 CheckGLError("glEnableVertexAttribArray"); | 234 CheckGLError("glEnableVertexAttribArray"); |
| 245 Dart_ExitScope(); | 235 Dart_ExitScope(); |
| 246 } | 236 } |
| 247 | 237 |
| 248 void GLGetAttribLocation(Dart_NativeArguments arguments) { | 238 void GLGetAttribLocation(Dart_NativeArguments arguments) { |
| 249 Log::Print("GLGetAttribLocation"); | 239 LOGI("GLGetAttribLocation"); |
| 250 Dart_EnterScope(); | 240 Dart_EnterScope(); |
| 251 | 241 |
| 252 Dart_Handle programHandle = HandleError(Dart_GetNativeArgument(arguments, 0)); | 242 Dart_Handle programHandle = HandleError(Dart_GetNativeArgument(arguments, 0)); |
| 253 int64_t program; | 243 int64_t program; |
| 254 HandleError(Dart_IntegerToInt64(programHandle, &program)); | 244 HandleError(Dart_IntegerToInt64(programHandle, &program)); |
| 255 | 245 |
| 256 Dart_Handle nameHandle = HandleError(Dart_GetNativeArgument(arguments, 1)); | 246 Dart_Handle nameHandle = HandleError(Dart_GetNativeArgument(arguments, 1)); |
| 257 intptr_t length; | 247 intptr_t length; |
| 258 HandleError(Dart_StringLength(nameHandle, &length)); | 248 HandleError(Dart_StringLength(nameHandle, &length)); |
| 259 uint8_t* str; | 249 uint8_t* str; |
| 260 HandleError(Dart_StringToUTF8(nameHandle, &str, &length)); | 250 HandleError(Dart_StringToUTF8(nameHandle, &str, &length)); |
| 261 str[length] = 0; | 251 str[length] = 0; |
| 262 | 252 |
| 263 int64_t location = glGetAttribLocation(program, | 253 int64_t location = glGetAttribLocation(program, |
| 264 const_cast<const GLchar*>(reinterpret_cast<GLchar*>(str))); | 254 const_cast<const GLchar*>(reinterpret_cast<GLchar*>(str))); |
| 265 CheckGLError("glGetAttribLocation"); | 255 CheckGLError("glGetAttribLocation"); |
| 266 Dart_Handle result = HandleError(Dart_NewInteger(location)); | 256 Dart_Handle result = HandleError(Dart_NewInteger(location)); |
| 267 Dart_SetReturnValue(arguments, result); | 257 Dart_SetReturnValue(arguments, result); |
| 268 Dart_ExitScope(); | 258 Dart_ExitScope(); |
| 269 } | 259 } |
| 270 | 260 |
| 271 void GLGetError(Dart_NativeArguments arguments) { | 261 void GLGetError(Dart_NativeArguments arguments) { |
| 272 Log::Print("GLGetError"); | 262 LOGI("GLGetError"); |
| 273 Dart_EnterScope(); | 263 Dart_EnterScope(); |
| 274 | 264 |
| 275 int64_t error = glGetError(); | 265 int64_t error = glGetError(); |
| 276 Dart_Handle result = HandleError(Dart_NewInteger(error)); | 266 Dart_Handle result = HandleError(Dart_NewInteger(error)); |
| 277 Dart_SetReturnValue(arguments, result); | 267 Dart_SetReturnValue(arguments, result); |
| 278 Dart_ExitScope(); | 268 Dart_ExitScope(); |
| 279 } | 269 } |
| 280 | 270 |
| 281 void GLGetProgramParameter(Dart_NativeArguments arguments) { | 271 void GLGetProgramParameter(Dart_NativeArguments arguments) { |
| 282 Log::Print("GLGetProgramParameter"); | 272 LOGI("GLGetProgramParameter"); |
| 283 Dart_EnterScope(); | 273 Dart_EnterScope(); |
| 284 | 274 |
| 285 Dart_Handle programHandle = HandleError(Dart_GetNativeArgument(arguments, 0)); | 275 Dart_Handle programHandle = HandleError(Dart_GetNativeArgument(arguments, 0)); |
| 286 int64_t program; | 276 int64_t program; |
| 287 HandleError(Dart_IntegerToInt64(programHandle, &program)); | 277 HandleError(Dart_IntegerToInt64(programHandle, &program)); |
| 288 | 278 |
| 289 Dart_Handle paramHandle = HandleError(Dart_GetNativeArgument(arguments, 1)); | 279 Dart_Handle paramHandle = HandleError(Dart_GetNativeArgument(arguments, 1)); |
| 290 int64_t param; | 280 int64_t param; |
| 291 HandleError(Dart_IntegerToInt64(paramHandle, ¶m)); | 281 HandleError(Dart_IntegerToInt64(paramHandle, ¶m)); |
| 292 | 282 |
| 293 GLint value = -1; | 283 GLint value = -1; |
| 294 glGetProgramiv(program, param, &value); | 284 glGetProgramiv(program, param, &value); |
| 295 CheckGLError("glGetProgramiv"); | 285 CheckGLError("glGetProgramiv"); |
| 296 | 286 |
| 297 Dart_Handle result = HandleError(Dart_NewInteger(value)); | 287 Dart_Handle result = HandleError(Dart_NewInteger(value)); |
| 298 Dart_SetReturnValue(arguments, result); | 288 Dart_SetReturnValue(arguments, result); |
| 299 Dart_ExitScope(); | 289 Dart_ExitScope(); |
| 300 } | 290 } |
| 301 | 291 |
| 302 void GLGetShaderParameter(Dart_NativeArguments arguments) { | 292 void GLGetShaderParameter(Dart_NativeArguments arguments) { |
| 303 Log::Print("GLGetShaderParameter"); | 293 LOGI("GLGetShaderParameter"); |
| 304 Dart_EnterScope(); | 294 Dart_EnterScope(); |
| 305 | 295 |
| 306 Dart_Handle shaderHandle = HandleError(Dart_GetNativeArgument(arguments, 0)); | 296 Dart_Handle shaderHandle = HandleError(Dart_GetNativeArgument(arguments, 0)); |
| 307 int64_t shader; | 297 int64_t shader; |
| 308 HandleError(Dart_IntegerToInt64(shaderHandle, &shader)); | 298 HandleError(Dart_IntegerToInt64(shaderHandle, &shader)); |
| 309 | 299 |
| 310 Dart_Handle paramHandle = HandleError(Dart_GetNativeArgument(arguments, 1)); | 300 Dart_Handle paramHandle = HandleError(Dart_GetNativeArgument(arguments, 1)); |
| 311 int64_t param; | 301 int64_t param; |
| 312 HandleError(Dart_IntegerToInt64(paramHandle, ¶m)); | 302 HandleError(Dart_IntegerToInt64(paramHandle, ¶m)); |
| 313 | 303 |
| 314 GLint value = -1; | 304 GLint value = -1; |
| 315 glGetShaderiv((GLuint)shader, (GLenum)param, &value); | 305 glGetShaderiv((GLuint)shader, (GLenum)param, &value); |
| 316 CheckGLError("glGetShaderiv"); | 306 CheckGLError("glGetShaderiv"); |
| 317 | 307 |
| 318 Dart_Handle result = HandleError(Dart_NewInteger(value)); | 308 Dart_Handle result = HandleError(Dart_NewInteger(value)); |
| 319 Dart_SetReturnValue(arguments, result); | 309 Dart_SetReturnValue(arguments, result); |
| 320 Dart_ExitScope(); | 310 Dart_ExitScope(); |
| 321 } | 311 } |
| 322 | 312 |
| 323 void GLGetShaderInfoLog(Dart_NativeArguments arguments) { | 313 void GLGetShaderInfoLog(Dart_NativeArguments arguments) { |
| 324 Log::Print("GLGetShaderInfoLog"); | 314 LOGI("GLGetShaderInfoLog"); |
| 325 Dart_EnterScope(); | 315 Dart_EnterScope(); |
| 326 | 316 |
| 327 Dart_Handle shaderHandle = HandleError(Dart_GetNativeArgument(arguments, 0)); | 317 Dart_Handle shaderHandle = HandleError(Dart_GetNativeArgument(arguments, 0)); |
| 328 int64_t shader; | 318 int64_t shader; |
| 329 HandleError(Dart_IntegerToInt64(shaderHandle, &shader)); | 319 HandleError(Dart_IntegerToInt64(shaderHandle, &shader)); |
| 330 | 320 |
| 331 GLint infoLogLength = 0; | 321 GLint infoLogLength = 0; |
| 332 glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &infoLogLength); | 322 glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &infoLogLength); |
| 333 | 323 |
| 334 GLchar* strInfoLog = new GLchar[infoLogLength + 1]; | 324 GLchar* strInfoLog = new GLchar[infoLogLength + 1]; |
| 335 glGetShaderInfoLog(shader, infoLogLength, NULL, strInfoLog); | 325 glGetShaderInfoLog(shader, infoLogLength, NULL, strInfoLog); |
| 336 strInfoLog[infoLogLength] = 0; | 326 strInfoLog[infoLogLength] = 0; |
| 337 | 327 |
| 338 Dart_Handle result = HandleError(Dart_NewStringFromCString(strInfoLog)); | 328 Dart_Handle result = HandleError(Dart_NewStringFromCString(strInfoLog)); |
| 339 Dart_SetReturnValue(arguments, result); | 329 Dart_SetReturnValue(arguments, result); |
| 340 Dart_ExitScope(); | 330 Dart_ExitScope(); |
| 341 delete[] strInfoLog; | 331 delete[] strInfoLog; |
| 342 } | 332 } |
| 343 | 333 |
| 344 void GLGetProgramInfoLog(Dart_NativeArguments arguments) { | 334 void GLGetProgramInfoLog(Dart_NativeArguments arguments) { |
| 345 Log::Print("GLGetProgramInfoLog"); | 335 LOGI("GLGetProgramInfoLog"); |
| 346 Dart_EnterScope(); | 336 Dart_EnterScope(); |
| 347 | 337 |
| 348 Dart_Handle programHandle = HandleError(Dart_GetNativeArgument(arguments, 0)); | 338 Dart_Handle programHandle = HandleError(Dart_GetNativeArgument(arguments, 0)); |
| 349 int64_t program; | 339 int64_t program; |
| 350 HandleError(Dart_IntegerToInt64(programHandle, &program)); | 340 HandleError(Dart_IntegerToInt64(programHandle, &program)); |
| 351 | 341 |
| 352 GLint infoLogLength; | 342 GLint infoLogLength; |
| 353 glGetProgramiv(program, GL_INFO_LOG_LENGTH, &infoLogLength); | 343 glGetProgramiv(program, GL_INFO_LOG_LENGTH, &infoLogLength); |
| 354 | 344 |
| 355 GLchar* strInfoLog = new GLchar[infoLogLength + 1]; | 345 GLchar* strInfoLog = new GLchar[infoLogLength + 1]; |
| 356 glGetProgramInfoLog(program, infoLogLength, NULL, strInfoLog); | 346 glGetProgramInfoLog(program, infoLogLength, NULL, strInfoLog); |
| 357 strInfoLog[infoLogLength] = 0; | 347 strInfoLog[infoLogLength] = 0; |
| 358 | 348 |
| 359 Dart_Handle result = HandleError(Dart_NewStringFromCString(strInfoLog)); | 349 Dart_Handle result = HandleError(Dart_NewStringFromCString(strInfoLog)); |
| 360 Dart_SetReturnValue(arguments, result); | 350 Dart_SetReturnValue(arguments, result); |
| 361 Dart_ExitScope(); | 351 Dart_ExitScope(); |
| 362 delete[] strInfoLog; | 352 delete[] strInfoLog; |
| 363 } | 353 } |
| 364 | 354 |
| 365 void GLGetUniformLocation(Dart_NativeArguments arguments) { | 355 void GLGetUniformLocation(Dart_NativeArguments arguments) { |
| 366 Log::Print("GLGetUniformLocation"); | 356 LOGI("GLGetUniformLocation"); |
| 367 Dart_EnterScope(); | 357 Dart_EnterScope(); |
| 368 | 358 |
| 369 Dart_Handle programHandle = HandleError(Dart_GetNativeArgument(arguments, 0)); | 359 Dart_Handle programHandle = HandleError(Dart_GetNativeArgument(arguments, 0)); |
| 370 int64_t program; | 360 int64_t program; |
| 371 HandleError(Dart_IntegerToInt64(programHandle, &program)); | 361 HandleError(Dart_IntegerToInt64(programHandle, &program)); |
| 372 | 362 |
| 373 Dart_Handle nameHandle = HandleError(Dart_GetNativeArgument(arguments, 1)); | 363 Dart_Handle nameHandle = HandleError(Dart_GetNativeArgument(arguments, 1)); |
| 374 intptr_t length; | 364 intptr_t length; |
| 375 HandleError(Dart_StringLength(nameHandle, &length)); | 365 HandleError(Dart_StringLength(nameHandle, &length)); |
| 376 uint8_t* str; | 366 uint8_t* str; |
| 377 HandleError(Dart_StringToUTF8(nameHandle, &str, &length)); | 367 HandleError(Dart_StringToUTF8(nameHandle, &str, &length)); |
| 378 str[length] = 0; | 368 str[length] = 0; |
| 379 | 369 |
| 380 int64_t location = glGetUniformLocation(program, | 370 int64_t location = glGetUniformLocation(program, |
| 381 const_cast<const GLchar*>(reinterpret_cast<GLchar*>(str))); | 371 const_cast<const GLchar*>(reinterpret_cast<GLchar*>(str))); |
| 382 CheckGLError("glGetUniformLocation"); | 372 CheckGLError("glGetUniformLocation"); |
| 383 Dart_Handle result = HandleError(Dart_NewInteger(location)); | 373 Dart_Handle result = HandleError(Dart_NewInteger(location)); |
| 384 Dart_SetReturnValue(arguments, result); | 374 Dart_SetReturnValue(arguments, result); |
| 385 Dart_ExitScope(); | 375 Dart_ExitScope(); |
| 386 } | 376 } |
| 387 | 377 |
| 388 void GLLinkProgram(Dart_NativeArguments arguments) { | 378 void GLLinkProgram(Dart_NativeArguments arguments) { |
| 389 Log::Print("GLLinkProgram"); | 379 LOGI("GLLinkProgram"); |
| 390 Dart_EnterScope(); | 380 Dart_EnterScope(); |
| 391 | 381 |
| 392 Dart_Handle programHandle = HandleError(Dart_GetNativeArgument(arguments, 0)); | 382 Dart_Handle programHandle = HandleError(Dart_GetNativeArgument(arguments, 0)); |
| 393 int64_t program; | 383 int64_t program; |
| 394 HandleError(Dart_IntegerToInt64(programHandle, &program)); | 384 HandleError(Dart_IntegerToInt64(programHandle, &program)); |
| 395 | 385 |
| 396 glLinkProgram(program); | 386 glLinkProgram(program); |
| 397 CheckGLError("glLinkProgram"); | 387 CheckGLError("glLinkProgram"); |
| 398 Dart_ExitScope(); | 388 Dart_ExitScope(); |
| 399 } | 389 } |
| 400 | 390 |
| 401 void GLShaderSource(Dart_NativeArguments arguments) { | 391 void GLShaderSource(Dart_NativeArguments arguments) { |
| 402 Log::Print("GLShaderSource"); | 392 LOGI("GLShaderSource"); |
| 403 Dart_EnterScope(); | 393 Dart_EnterScope(); |
| 404 | 394 |
| 405 Dart_Handle shaderHandle = HandleError(Dart_GetNativeArgument(arguments, 0)); | 395 Dart_Handle shaderHandle = HandleError(Dart_GetNativeArgument(arguments, 0)); |
| 406 int64_t shader; | 396 int64_t shader; |
| 407 HandleError(Dart_IntegerToInt64(shaderHandle, &shader)); | 397 HandleError(Dart_IntegerToInt64(shaderHandle, &shader)); |
| 408 | 398 |
| 409 Dart_Handle sourceHandle = HandleError(Dart_GetNativeArgument(arguments, 1)); | 399 Dart_Handle sourceHandle = HandleError(Dart_GetNativeArgument(arguments, 1)); |
| 410 intptr_t length[1]; | 400 intptr_t length[1]; |
| 411 HandleError(Dart_StringLength(sourceHandle, length)); | 401 HandleError(Dart_StringLength(sourceHandle, length)); |
| 412 Log::Print("Source length is %d", length[0]); | 402 LOGI("Source length is %d", length[0]); |
| 413 uint8_t* str[1]; | 403 uint8_t* str[1]; |
| 414 HandleError(Dart_StringToUTF8(sourceHandle, &str[0], length)); | 404 HandleError(Dart_StringToUTF8(sourceHandle, &str[0], length)); |
| 415 Log::Print("Converted length is %d", length[0]); | 405 LOGI("Converted length is %d", length[0]); |
| 416 str[0][*length] = 0; | 406 str[0][*length] = 0; |
| 417 | 407 |
| 418 const GLchar* source = | 408 const GLchar* source = |
| 419 const_cast<const GLchar*>(reinterpret_cast<GLchar*>(str[0])); | 409 const_cast<const GLchar*>(reinterpret_cast<GLchar*>(str[0])); |
| 420 Log::Print("Source: %s", source); | 410 LOGI("Source: %s", source); |
| 421 glShaderSource(shader, 1, | 411 glShaderSource(shader, 1, |
| 422 const_cast<const GLchar**>(reinterpret_cast<GLchar**>(str)), NULL); | 412 const_cast<const GLchar**>(reinterpret_cast<GLchar**>(str)), NULL); |
| 423 CheckGLError("glShaderSource"); | 413 CheckGLError("glShaderSource"); |
| 424 Dart_ExitScope(); | 414 Dart_ExitScope(); |
| 425 } | 415 } |
| 426 | 416 |
| 427 void GLUseProgram(Dart_NativeArguments arguments) { | 417 void GLUseProgram(Dart_NativeArguments arguments) { |
| 428 Log::Print("GLUseProgram"); | 418 LOGI("GLUseProgram"); |
| 429 Dart_EnterScope(); | 419 Dart_EnterScope(); |
| 430 | 420 |
| 431 Dart_Handle programHandle = HandleError(Dart_GetNativeArgument(arguments, 0)); | 421 Dart_Handle programHandle = HandleError(Dart_GetNativeArgument(arguments, 0)); |
| 432 int64_t program; | 422 int64_t program; |
| 433 HandleError(Dart_IntegerToInt64(programHandle, &program)); | 423 HandleError(Dart_IntegerToInt64(programHandle, &program)); |
| 434 | 424 |
| 435 glUseProgram(program); | 425 glUseProgram(program); |
| 436 CheckGLError("glUseProgram"); | 426 CheckGLError("glUseProgram"); |
| 437 Dart_ExitScope(); | 427 Dart_ExitScope(); |
| 438 } | 428 } |
| 439 | 429 |
| 440 void GLUniform1i(Dart_NativeArguments arguments) { | 430 void GLUniform1i(Dart_NativeArguments arguments) { |
| 441 Log::Print("GLUniform1i"); | 431 LOGI("GLUniform1i"); |
| 442 Dart_EnterScope(); | 432 Dart_EnterScope(); |
| 443 | 433 |
| 444 Dart_Handle locationHandle = | 434 Dart_Handle locationHandle = |
| 445 HandleError(Dart_GetNativeArgument(arguments, 0)); | 435 HandleError(Dart_GetNativeArgument(arguments, 0)); |
| 446 int64_t location; | 436 int64_t location; |
| 447 HandleError(Dart_IntegerToInt64(locationHandle, &location)); | 437 HandleError(Dart_IntegerToInt64(locationHandle, &location)); |
| 448 | 438 |
| 449 Dart_Handle v0Handle = HandleError(Dart_GetNativeArgument(arguments, 1)); | 439 Dart_Handle v0Handle = HandleError(Dart_GetNativeArgument(arguments, 1)); |
| 450 int64_t v0; | 440 int64_t v0; |
| 451 HandleError(Dart_IntegerToInt64(v0Handle, &v0)); | 441 HandleError(Dart_IntegerToInt64(v0Handle, &v0)); |
| 452 | 442 |
| 453 glUniform1i(location, v0); | 443 glUniform1i(location, v0); |
| 454 CheckGLError("glUniform1i"); | 444 CheckGLError("glUniform1i"); |
| 455 Dart_ExitScope(); | 445 Dart_ExitScope(); |
| 456 } | 446 } |
| 457 | 447 |
| 458 void GLUniform2i(Dart_NativeArguments arguments) { | 448 void GLUniform2i(Dart_NativeArguments arguments) { |
| 459 Log::Print("GLUniform2i"); | 449 LOGI("GLUniform2i"); |
| 460 Dart_EnterScope(); | 450 Dart_EnterScope(); |
| 461 | 451 |
| 462 Dart_Handle locationHandle = | 452 Dart_Handle locationHandle = |
| 463 HandleError(Dart_GetNativeArgument(arguments, 0)); | 453 HandleError(Dart_GetNativeArgument(arguments, 0)); |
| 464 int64_t location; | 454 int64_t location; |
| 465 HandleError(Dart_IntegerToInt64(locationHandle, &location)); | 455 HandleError(Dart_IntegerToInt64(locationHandle, &location)); |
| 466 | 456 |
| 467 Dart_Handle v0Handle = HandleError(Dart_GetNativeArgument(arguments, 1)); | 457 Dart_Handle v0Handle = HandleError(Dart_GetNativeArgument(arguments, 1)); |
| 468 int64_t v0; | 458 int64_t v0; |
| 469 HandleError(Dart_IntegerToInt64(v0Handle, &v0)); | 459 HandleError(Dart_IntegerToInt64(v0Handle, &v0)); |
| 470 | 460 |
| 471 Dart_Handle v1Handle = HandleError(Dart_GetNativeArgument(arguments, 2)); | 461 Dart_Handle v1Handle = HandleError(Dart_GetNativeArgument(arguments, 2)); |
| 472 int64_t v1; | 462 int64_t v1; |
| 473 HandleError(Dart_IntegerToInt64(v1Handle, &v1)); | 463 HandleError(Dart_IntegerToInt64(v1Handle, &v1)); |
| 474 | 464 |
| 475 glUniform2i(location, v0, v1); | 465 glUniform2i(location, v0, v1); |
| 476 CheckGLError("glUniform2i"); | 466 CheckGLError("glUniform2i"); |
| 477 Dart_ExitScope(); | 467 Dart_ExitScope(); |
| 478 } | 468 } |
| 479 | 469 |
| 480 void GLUniform3i(Dart_NativeArguments arguments) { | 470 void GLUniform3i(Dart_NativeArguments arguments) { |
| 481 Log::Print("GLUniform3i"); | 471 LOGI("GLUniform3i"); |
| 482 Dart_EnterScope(); | 472 Dart_EnterScope(); |
| 483 | 473 |
| 484 Dart_Handle locationHandle = | 474 Dart_Handle locationHandle = |
| 485 HandleError(Dart_GetNativeArgument(arguments, 0)); | 475 HandleError(Dart_GetNativeArgument(arguments, 0)); |
| 486 int64_t location; | 476 int64_t location; |
| 487 HandleError(Dart_IntegerToInt64(locationHandle, &location)); | 477 HandleError(Dart_IntegerToInt64(locationHandle, &location)); |
| 488 | 478 |
| 489 Dart_Handle v0Handle = HandleError(Dart_GetNativeArgument(arguments, 1)); | 479 Dart_Handle v0Handle = HandleError(Dart_GetNativeArgument(arguments, 1)); |
| 490 int64_t v0; | 480 int64_t v0; |
| 491 HandleError(Dart_IntegerToInt64(v0Handle, &v0)); | 481 HandleError(Dart_IntegerToInt64(v0Handle, &v0)); |
| 492 | 482 |
| 493 Dart_Handle v1Handle = HandleError(Dart_GetNativeArgument(arguments, 2)); | 483 Dart_Handle v1Handle = HandleError(Dart_GetNativeArgument(arguments, 2)); |
| 494 int64_t v1; | 484 int64_t v1; |
| 495 HandleError(Dart_IntegerToInt64(v1Handle, &v1)); | 485 HandleError(Dart_IntegerToInt64(v1Handle, &v1)); |
| 496 | 486 |
| 497 Dart_Handle v2Handle = HandleError(Dart_GetNativeArgument(arguments, 3)); | 487 Dart_Handle v2Handle = HandleError(Dart_GetNativeArgument(arguments, 3)); |
| 498 int64_t v2; | 488 int64_t v2; |
| 499 HandleError(Dart_IntegerToInt64(v2Handle, &v2)); | 489 HandleError(Dart_IntegerToInt64(v2Handle, &v2)); |
| 500 | 490 |
| 501 glUniform3i(location, v0, v1, v2); | 491 glUniform3i(location, v0, v1, v2); |
| 502 CheckGLError("glUniform3i"); | 492 CheckGLError("glUniform3i"); |
| 503 Dart_ExitScope(); | 493 Dart_ExitScope(); |
| 504 } | 494 } |
| 505 | 495 |
| 506 void GLUniform4i(Dart_NativeArguments arguments) { | 496 void GLUniform4i(Dart_NativeArguments arguments) { |
| 507 Log::Print("GLUniform4i"); | 497 LOGI("GLUniform4i"); |
| 508 Dart_EnterScope(); | 498 Dart_EnterScope(); |
| 509 | 499 |
| 510 Dart_Handle locationHandle = | 500 Dart_Handle locationHandle = |
| 511 HandleError(Dart_GetNativeArgument(arguments, 0)); | 501 HandleError(Dart_GetNativeArgument(arguments, 0)); |
| 512 int64_t location; | 502 int64_t location; |
| 513 HandleError(Dart_IntegerToInt64(locationHandle, &location)); | 503 HandleError(Dart_IntegerToInt64(locationHandle, &location)); |
| 514 | 504 |
| 515 Dart_Handle v0Handle = HandleError(Dart_GetNativeArgument(arguments, 1)); | 505 Dart_Handle v0Handle = HandleError(Dart_GetNativeArgument(arguments, 1)); |
| 516 int64_t v0; | 506 int64_t v0; |
| 517 HandleError(Dart_IntegerToInt64(v0Handle, &v0)); | 507 HandleError(Dart_IntegerToInt64(v0Handle, &v0)); |
| 518 | 508 |
| 519 Dart_Handle v1Handle = HandleError(Dart_GetNativeArgument(arguments, 2)); | 509 Dart_Handle v1Handle = HandleError(Dart_GetNativeArgument(arguments, 2)); |
| 520 int64_t v1; | 510 int64_t v1; |
| 521 HandleError(Dart_IntegerToInt64(v1Handle, &v1)); | 511 HandleError(Dart_IntegerToInt64(v1Handle, &v1)); |
| 522 | 512 |
| 523 Dart_Handle v2Handle = HandleError(Dart_GetNativeArgument(arguments, 3)); | 513 Dart_Handle v2Handle = HandleError(Dart_GetNativeArgument(arguments, 3)); |
| 524 int64_t v2; | 514 int64_t v2; |
| 525 HandleError(Dart_IntegerToInt64(v2Handle, &v2)); | 515 HandleError(Dart_IntegerToInt64(v2Handle, &v2)); |
| 526 | 516 |
| 527 Dart_Handle v3Handle = HandleError(Dart_GetNativeArgument(arguments, 4)); | 517 Dart_Handle v3Handle = HandleError(Dart_GetNativeArgument(arguments, 4)); |
| 528 int64_t v3; | 518 int64_t v3; |
| 529 HandleError(Dart_IntegerToInt64(v3Handle, &v3)); | 519 HandleError(Dart_IntegerToInt64(v3Handle, &v3)); |
| 530 | 520 |
| 531 glUniform4i(location, v0, v1, v2, v3); | 521 glUniform4i(location, v0, v1, v2, v3); |
| 532 CheckGLError("glUniform4i"); | 522 CheckGLError("glUniform4i"); |
| 533 Dart_ExitScope(); | 523 Dart_ExitScope(); |
| 534 } | 524 } |
| 535 | 525 |
| 536 void GLUniform1f(Dart_NativeArguments arguments) { | 526 void GLUniform1f(Dart_NativeArguments arguments) { |
| 537 Log::Print("GLUniform1f"); | 527 LOGI("GLUniform1f"); |
| 538 Dart_EnterScope(); | 528 Dart_EnterScope(); |
| 539 | 529 |
| 540 Dart_Handle locationHandle = | 530 Dart_Handle locationHandle = |
| 541 HandleError(Dart_GetNativeArgument(arguments, 0)); | 531 HandleError(Dart_GetNativeArgument(arguments, 0)); |
| 542 int64_t location; | 532 int64_t location; |
| 543 HandleError(Dart_IntegerToInt64(locationHandle, &location)); | 533 HandleError(Dart_IntegerToInt64(locationHandle, &location)); |
| 544 | 534 |
| 545 Dart_Handle v0Handle = HandleError(Dart_GetNativeArgument(arguments, 1)); | 535 Dart_Handle v0Handle = HandleError(Dart_GetNativeArgument(arguments, 1)); |
| 546 double v0; | 536 double v0; |
| 547 HandleError(Dart_DoubleValue(v0Handle, &v0)); | 537 HandleError(Dart_DoubleValue(v0Handle, &v0)); |
| 548 | 538 |
| 549 glUniform1f(location, v0); | 539 glUniform1f(location, v0); |
| 550 CheckGLError("glUniform1f"); | 540 CheckGLError("glUniform1f"); |
| 551 Dart_ExitScope(); | 541 Dart_ExitScope(); |
| 552 } | 542 } |
| 553 | 543 |
| 554 void GLUniform2f(Dart_NativeArguments arguments) { | 544 void GLUniform2f(Dart_NativeArguments arguments) { |
| 555 Log::Print("GLUniform2f"); | 545 LOGI("GLUniform2f"); |
| 556 Dart_EnterScope(); | 546 Dart_EnterScope(); |
| 557 | 547 |
| 558 Dart_Handle locationHandle = | 548 Dart_Handle locationHandle = |
| 559 HandleError(Dart_GetNativeArgument(arguments, 0)); | 549 HandleError(Dart_GetNativeArgument(arguments, 0)); |
| 560 int64_t location; | 550 int64_t location; |
| 561 HandleError(Dart_IntegerToInt64(locationHandle, &location)); | 551 HandleError(Dart_IntegerToInt64(locationHandle, &location)); |
| 562 | 552 |
| 563 Dart_Handle v0Handle = HandleError(Dart_GetNativeArgument(arguments, 1)); | 553 Dart_Handle v0Handle = HandleError(Dart_GetNativeArgument(arguments, 1)); |
| 564 double v0; | 554 double v0; |
| 565 HandleError(Dart_DoubleValue(v0Handle, &v0)); | 555 HandleError(Dart_DoubleValue(v0Handle, &v0)); |
| 566 | 556 |
| 567 Dart_Handle v1Handle = HandleError(Dart_GetNativeArgument(arguments, 2)); | 557 Dart_Handle v1Handle = HandleError(Dart_GetNativeArgument(arguments, 2)); |
| 568 double v1; | 558 double v1; |
| 569 HandleError(Dart_DoubleValue(v1Handle, &v1)); | 559 HandleError(Dart_DoubleValue(v1Handle, &v1)); |
| 570 | 560 |
| 571 glUniform2f(location, v0, v1); | 561 glUniform2f(location, v0, v1); |
| 572 CheckGLError("glUniform2f"); | 562 CheckGLError("glUniform2f"); |
| 573 Dart_ExitScope(); | 563 Dart_ExitScope(); |
| 574 } | 564 } |
| 575 | 565 |
| 576 void GLUniform3f(Dart_NativeArguments arguments) { | 566 void GLUniform3f(Dart_NativeArguments arguments) { |
| 577 Log::Print("GLUniform3f"); | 567 LOGI("GLUniform3f"); |
| 578 Dart_EnterScope(); | 568 Dart_EnterScope(); |
| 579 | 569 |
| 580 Dart_Handle locationHandle = | 570 Dart_Handle locationHandle = |
| 581 HandleError(Dart_GetNativeArgument(arguments, 0)); | 571 HandleError(Dart_GetNativeArgument(arguments, 0)); |
| 582 int64_t location; | 572 int64_t location; |
| 583 HandleError(Dart_IntegerToInt64(locationHandle, &location)); | 573 HandleError(Dart_IntegerToInt64(locationHandle, &location)); |
| 584 | 574 |
| 585 Dart_Handle v0Handle = HandleError(Dart_GetNativeArgument(arguments, 1)); | 575 Dart_Handle v0Handle = HandleError(Dart_GetNativeArgument(arguments, 1)); |
| 586 double v0; | 576 double v0; |
| 587 HandleError(Dart_DoubleValue(v0Handle, &v0)); | 577 HandleError(Dart_DoubleValue(v0Handle, &v0)); |
| 588 | 578 |
| 589 Dart_Handle v1Handle = HandleError(Dart_GetNativeArgument(arguments, 2)); | 579 Dart_Handle v1Handle = HandleError(Dart_GetNativeArgument(arguments, 2)); |
| 590 double v1; | 580 double v1; |
| 591 HandleError(Dart_DoubleValue(v1Handle, &v1)); | 581 HandleError(Dart_DoubleValue(v1Handle, &v1)); |
| 592 | 582 |
| 593 Dart_Handle v2Handle = HandleError(Dart_GetNativeArgument(arguments, 3)); | 583 Dart_Handle v2Handle = HandleError(Dart_GetNativeArgument(arguments, 3)); |
| 594 double v2; | 584 double v2; |
| 595 HandleError(Dart_DoubleValue(v2Handle, &v2)); | 585 HandleError(Dart_DoubleValue(v2Handle, &v2)); |
| 596 | 586 |
| 597 glUniform3f(location, v0, v1, v2); | 587 glUniform3f(location, v0, v1, v2); |
| 598 CheckGLError("glUniform3f"); | 588 CheckGLError("glUniform3f"); |
| 599 Dart_ExitScope(); | 589 Dart_ExitScope(); |
| 600 } | 590 } |
| 601 | 591 |
| 602 void GLUniform4f(Dart_NativeArguments arguments) { | 592 void GLUniform4f(Dart_NativeArguments arguments) { |
| 603 Log::Print("GLUniform4f"); | 593 LOGI("GLUniform4f"); |
| 604 Dart_EnterScope(); | 594 Dart_EnterScope(); |
| 605 | 595 |
| 606 Dart_Handle locationHandle = | 596 Dart_Handle locationHandle = |
| 607 HandleError(Dart_GetNativeArgument(arguments, 0)); | 597 HandleError(Dart_GetNativeArgument(arguments, 0)); |
| 608 int64_t location; | 598 int64_t location; |
| 609 HandleError(Dart_IntegerToInt64(locationHandle, &location)); | 599 HandleError(Dart_IntegerToInt64(locationHandle, &location)); |
| 610 | 600 |
| 611 Dart_Handle v0Handle = HandleError(Dart_GetNativeArgument(arguments, 1)); | 601 Dart_Handle v0Handle = HandleError(Dart_GetNativeArgument(arguments, 1)); |
| 612 double v0; | 602 double v0; |
| 613 HandleError(Dart_DoubleValue(v0Handle, &v0)); | 603 HandleError(Dart_DoubleValue(v0Handle, &v0)); |
| 614 | 604 |
| 615 Dart_Handle v1Handle = HandleError(Dart_GetNativeArgument(arguments, 2)); | 605 Dart_Handle v1Handle = HandleError(Dart_GetNativeArgument(arguments, 2)); |
| 616 double v1; | 606 double v1; |
| 617 HandleError(Dart_DoubleValue(v1Handle, &v1)); | 607 HandleError(Dart_DoubleValue(v1Handle, &v1)); |
| 618 | 608 |
| 619 Dart_Handle v2Handle = HandleError(Dart_GetNativeArgument(arguments, 3)); | 609 Dart_Handle v2Handle = HandleError(Dart_GetNativeArgument(arguments, 3)); |
| 620 double v2; | 610 double v2; |
| 621 HandleError(Dart_DoubleValue(v2Handle, &v2)); | 611 HandleError(Dart_DoubleValue(v2Handle, &v2)); |
| 622 | 612 |
| 623 Dart_Handle v3Handle = HandleError(Dart_GetNativeArgument(arguments, 4)); | 613 Dart_Handle v3Handle = HandleError(Dart_GetNativeArgument(arguments, 4)); |
| 624 double v3; | 614 double v3; |
| 625 HandleError(Dart_DoubleValue(v3Handle, &v3)); | 615 HandleError(Dart_DoubleValue(v3Handle, &v3)); |
| 626 | 616 |
| 627 glUniform4f(location, v0, v1, v2, v3); | 617 glUniform4f(location, v0, v1, v2, v3); |
| 628 CheckGLError("glUniform4f"); | 618 CheckGLError("glUniform4f"); |
| 629 Dart_ExitScope(); | 619 Dart_ExitScope(); |
| 630 } | 620 } |
| 631 | 621 |
| 632 void GLUniform1iv(Dart_NativeArguments arguments) { | 622 void GLUniform1iv(Dart_NativeArguments arguments) { |
| 633 Log::Print("GLUniform1iv"); | 623 LOGI("GLUniform1iv"); |
| 634 Dart_EnterScope(); | 624 Dart_EnterScope(); |
| 635 | 625 |
| 636 Dart_Handle locationHandle = | 626 Dart_Handle locationHandle = |
| 637 HandleError(Dart_GetNativeArgument(arguments, 0)); | 627 HandleError(Dart_GetNativeArgument(arguments, 0)); |
| 638 int64_t location; | 628 int64_t location; |
| 639 HandleError(Dart_IntegerToInt64(locationHandle, &location)); | 629 HandleError(Dart_IntegerToInt64(locationHandle, &location)); |
| 640 | 630 |
| 641 Dart_Handle argHandle = HandleError(Dart_GetNativeArgument(arguments, 1)); | 631 Dart_Handle argHandle = HandleError(Dart_GetNativeArgument(arguments, 1)); |
| 642 | 632 |
| 643 if (Dart_IsList(argHandle)) { | 633 if (Dart_IsList(argHandle)) { |
| 644 int len; | 634 int len; |
| 645 HandleError(Dart_ListLength(argHandle, &len)); | 635 HandleError(Dart_ListLength(argHandle, &len)); |
| 646 GLint* list = new GLint[len]; | 636 GLint* list = new GLint[len]; |
| 647 for (int i = 0; i < len; i++) { | 637 for (int i = 0; i < len; i++) { |
| 648 Dart_Handle vHandle = Dart_ListGetAt(argHandle, i); | 638 Dart_Handle vHandle = Dart_ListGetAt(argHandle, i); |
| 649 int64_t v; | 639 int64_t v; |
| 650 HandleError(Dart_IntegerToInt64(vHandle, &v)); | 640 HandleError(Dart_IntegerToInt64(vHandle, &v)); |
| 651 list[i] = v; | 641 list[i] = v; |
| 652 } | 642 } |
| 653 glUniform1iv(location, len, list); | 643 glUniform1iv(location, len, list); |
| 654 delete [] list; | 644 delete [] list; |
| 655 CheckGLError("glUniform1iv"); | 645 CheckGLError("glUniform1iv"); |
| 656 } | 646 } |
| 657 Dart_ExitScope(); | 647 Dart_ExitScope(); |
| 658 } | 648 } |
| 659 | 649 |
| 660 void GLUniform2iv(Dart_NativeArguments arguments) { | 650 void GLUniform2iv(Dart_NativeArguments arguments) { |
| 661 Log::Print("GLUniform2iv"); | 651 LOGI("GLUniform2iv"); |
| 662 Dart_EnterScope(); | 652 Dart_EnterScope(); |
| 663 | 653 |
| 664 Dart_Handle locationHandle = | 654 Dart_Handle locationHandle = |
| 665 HandleError(Dart_GetNativeArgument(arguments, 0)); | 655 HandleError(Dart_GetNativeArgument(arguments, 0)); |
| 666 int64_t location; | 656 int64_t location; |
| 667 HandleError(Dart_IntegerToInt64(locationHandle, &location)); | 657 HandleError(Dart_IntegerToInt64(locationHandle, &location)); |
| 668 | 658 |
| 669 Dart_Handle argHandle = HandleError(Dart_GetNativeArgument(arguments, 1)); | 659 Dart_Handle argHandle = HandleError(Dart_GetNativeArgument(arguments, 1)); |
| 670 | 660 |
| 671 if (Dart_IsList(argHandle)) { | 661 if (Dart_IsList(argHandle)) { |
| 672 int len; | 662 int len; |
| 673 HandleError(Dart_ListLength(argHandle, &len)); | 663 HandleError(Dart_ListLength(argHandle, &len)); |
| 674 GLint* list = new GLint[len]; | 664 GLint* list = new GLint[len]; |
| 675 for (int i = 0; i < len; i++) { | 665 for (int i = 0; i < len; i++) { |
| 676 Dart_Handle vHandle = Dart_ListGetAt(argHandle, i); | 666 Dart_Handle vHandle = Dart_ListGetAt(argHandle, i); |
| 677 int64_t v; | 667 int64_t v; |
| 678 HandleError(Dart_IntegerToInt64(vHandle, &v)); | 668 HandleError(Dart_IntegerToInt64(vHandle, &v)); |
| 679 list[i] = v; | 669 list[i] = v; |
| 680 } | 670 } |
| 681 glUniform2iv(location, len / 2, list); | 671 glUniform2iv(location, len / 2, list); |
| 682 delete [] list; | 672 delete [] list; |
| 683 CheckGLError("glUniform2iv"); | 673 CheckGLError("glUniform2iv"); |
| 684 } | 674 } |
| 685 Dart_ExitScope(); | 675 Dart_ExitScope(); |
| 686 } | 676 } |
| 687 | 677 |
| 688 void GLUniform3iv(Dart_NativeArguments arguments) { | 678 void GLUniform3iv(Dart_NativeArguments arguments) { |
| 689 Log::Print("GLUniform3iv"); | 679 LOGI("GLUniform3iv"); |
| 690 Dart_EnterScope(); | 680 Dart_EnterScope(); |
| 691 | 681 |
| 692 Dart_Handle locationHandle = | 682 Dart_Handle locationHandle = |
| 693 HandleError(Dart_GetNativeArgument(arguments, 0)); | 683 HandleError(Dart_GetNativeArgument(arguments, 0)); |
| 694 int64_t location; | 684 int64_t location; |
| 695 HandleError(Dart_IntegerToInt64(locationHandle, &location)); | 685 HandleError(Dart_IntegerToInt64(locationHandle, &location)); |
| 696 | 686 |
| 697 Dart_Handle argHandle = HandleError(Dart_GetNativeArgument(arguments, 1)); | 687 Dart_Handle argHandle = HandleError(Dart_GetNativeArgument(arguments, 1)); |
| 698 | 688 |
| 699 if (Dart_IsList(argHandle)) { | 689 if (Dart_IsList(argHandle)) { |
| 700 int len; | 690 int len; |
| 701 HandleError(Dart_ListLength(argHandle, &len)); | 691 HandleError(Dart_ListLength(argHandle, &len)); |
| 702 GLint* list = new GLint[len]; | 692 GLint* list = new GLint[len]; |
| 703 for (int i = 0; i < len; i++) { | 693 for (int i = 0; i < len; i++) { |
| 704 Dart_Handle vHandle = Dart_ListGetAt(argHandle, i); | 694 Dart_Handle vHandle = Dart_ListGetAt(argHandle, i); |
| 705 int64_t v; | 695 int64_t v; |
| 706 HandleError(Dart_IntegerToInt64(vHandle, &v)); | 696 HandleError(Dart_IntegerToInt64(vHandle, &v)); |
| 707 list[i] = v; | 697 list[i] = v; |
| 708 } | 698 } |
| 709 glUniform3iv(location, len / 3, list); | 699 glUniform3iv(location, len / 3, list); |
| 710 delete [] list; | 700 delete [] list; |
| 711 CheckGLError("glUniform3iv"); | 701 CheckGLError("glUniform3iv"); |
| 712 } | 702 } |
| 713 Dart_ExitScope(); | 703 Dart_ExitScope(); |
| 714 } | 704 } |
| 715 | 705 |
| 716 void GLUniform4iv(Dart_NativeArguments arguments) { | 706 void GLUniform4iv(Dart_NativeArguments arguments) { |
| 717 Log::Print("GLUniform4iv"); | 707 LOGI("GLUniform4iv"); |
| 718 Dart_EnterScope(); | 708 Dart_EnterScope(); |
| 719 | 709 |
| 720 Dart_Handle locationHandle = | 710 Dart_Handle locationHandle = |
| 721 HandleError(Dart_GetNativeArgument(arguments, 0)); | 711 HandleError(Dart_GetNativeArgument(arguments, 0)); |
| 722 int64_t location; | 712 int64_t location; |
| 723 HandleError(Dart_IntegerToInt64(locationHandle, &location)); | 713 HandleError(Dart_IntegerToInt64(locationHandle, &location)); |
| 724 | 714 |
| 725 Dart_Handle argHandle = HandleError(Dart_GetNativeArgument(arguments, 1)); | 715 Dart_Handle argHandle = HandleError(Dart_GetNativeArgument(arguments, 1)); |
| 726 | 716 |
| 727 if (Dart_IsList(argHandle)) { | 717 if (Dart_IsList(argHandle)) { |
| 728 int len; | 718 int len; |
| 729 HandleError(Dart_ListLength(argHandle, &len)); | 719 HandleError(Dart_ListLength(argHandle, &len)); |
| 730 GLint* list = new GLint[len]; | 720 GLint* list = new GLint[len]; |
| 731 for (int i = 0; i < len; i++) { | 721 for (int i = 0; i < len; i++) { |
| 732 Dart_Handle vHandle = Dart_ListGetAt(argHandle, i); | 722 Dart_Handle vHandle = Dart_ListGetAt(argHandle, i); |
| 733 int64_t v; | 723 int64_t v; |
| 734 HandleError(Dart_IntegerToInt64(vHandle, &v)); | 724 HandleError(Dart_IntegerToInt64(vHandle, &v)); |
| 735 list[i] = v; | 725 list[i] = v; |
| 736 } | 726 } |
| 737 glUniform1iv(location, len / 4, list); | 727 glUniform1iv(location, len / 4, list); |
| 738 delete [] list; | 728 delete [] list; |
| 739 CheckGLError("glUniform4iv"); | 729 CheckGLError("glUniform4iv"); |
| 740 } | 730 } |
| 741 Dart_ExitScope(); | 731 Dart_ExitScope(); |
| 742 } | 732 } |
| 743 | 733 |
| 744 void GLUniform1fv(Dart_NativeArguments arguments) { | 734 void GLUniform1fv(Dart_NativeArguments arguments) { |
| 745 Log::Print("GLUniform1fv"); | 735 LOGI("GLUniform1fv"); |
| 746 Dart_EnterScope(); | 736 Dart_EnterScope(); |
| 747 | 737 |
| 748 Dart_Handle locationHandle = | 738 Dart_Handle locationHandle = |
| 749 HandleError(Dart_GetNativeArgument(arguments, 0)); | 739 HandleError(Dart_GetNativeArgument(arguments, 0)); |
| 750 int64_t location; | 740 int64_t location; |
| 751 HandleError(Dart_IntegerToInt64(locationHandle, &location)); | 741 HandleError(Dart_IntegerToInt64(locationHandle, &location)); |
| 752 | 742 |
| 753 Dart_Handle argHandle = HandleError(Dart_GetNativeArgument(arguments, 1)); | 743 Dart_Handle argHandle = HandleError(Dart_GetNativeArgument(arguments, 1)); |
| 754 | 744 |
| 755 if (Dart_IsList(argHandle)) { | 745 if (Dart_IsList(argHandle)) { |
| 756 int len; | 746 int len; |
| 757 HandleError(Dart_ListLength(argHandle, &len)); | 747 HandleError(Dart_ListLength(argHandle, &len)); |
| 758 GLfloat* list = new GLfloat[len]; | 748 GLfloat* list = new GLfloat[len]; |
| 759 for (int i = 0; i < len; i++) { | 749 for (int i = 0; i < len; i++) { |
| 760 Dart_Handle vHandle = Dart_ListGetAt(argHandle, i); | 750 Dart_Handle vHandle = Dart_ListGetAt(argHandle, i); |
| 761 double v; | 751 double v; |
| 762 HandleError(Dart_DoubleValue(vHandle, &v)); | 752 HandleError(Dart_DoubleValue(vHandle, &v)); |
| 763 list[i] = v; | 753 list[i] = v; |
| 764 } | 754 } |
| 765 glUniform1fv(location, len, list); | 755 glUniform1fv(location, len, list); |
| 766 delete [] list; | 756 delete [] list; |
| 767 CheckGLError("glUniform1fv"); | 757 CheckGLError("glUniform1fv"); |
| 768 } | 758 } |
| 769 Dart_ExitScope(); | 759 Dart_ExitScope(); |
| 770 } | 760 } |
| 771 | 761 |
| 772 void GLUniform2fv(Dart_NativeArguments arguments) { | 762 void GLUniform2fv(Dart_NativeArguments arguments) { |
| 773 Log::Print("GLUniform2fv"); | 763 LOGI("GLUniform2fv"); |
| 774 Dart_EnterScope(); | 764 Dart_EnterScope(); |
| 775 | 765 |
| 776 Dart_Handle locationHandle = | 766 Dart_Handle locationHandle = |
| 777 HandleError(Dart_GetNativeArgument(arguments, 0)); | 767 HandleError(Dart_GetNativeArgument(arguments, 0)); |
| 778 int64_t location; | 768 int64_t location; |
| 779 HandleError(Dart_IntegerToInt64(locationHandle, &location)); | 769 HandleError(Dart_IntegerToInt64(locationHandle, &location)); |
| 780 | 770 |
| 781 Dart_Handle argHandle = HandleError(Dart_GetNativeArgument(arguments, 1)); | 771 Dart_Handle argHandle = HandleError(Dart_GetNativeArgument(arguments, 1)); |
| 782 | 772 |
| 783 if (Dart_IsList(argHandle)) { | 773 if (Dart_IsList(argHandle)) { |
| 784 int len; | 774 int len; |
| 785 HandleError(Dart_ListLength(argHandle, &len)); | 775 HandleError(Dart_ListLength(argHandle, &len)); |
| 786 GLfloat* list = new GLfloat[len]; | 776 GLfloat* list = new GLfloat[len]; |
| 787 for (int i = 0; i < len; i++) { | 777 for (int i = 0; i < len; i++) { |
| 788 Dart_Handle vHandle = Dart_ListGetAt(argHandle, i); | 778 Dart_Handle vHandle = Dart_ListGetAt(argHandle, i); |
| 789 double v; | 779 double v; |
| 790 HandleError(Dart_DoubleValue(vHandle, &v)); | 780 HandleError(Dart_DoubleValue(vHandle, &v)); |
| 791 list[i] = v; | 781 list[i] = v; |
| 792 } | 782 } |
| 793 glUniform2fv(location, len / 2, list); | 783 glUniform2fv(location, len / 2, list); |
| 794 delete [] list; | 784 delete [] list; |
| 795 CheckGLError("glUniform2fv"); | 785 CheckGLError("glUniform2fv"); |
| 796 } | 786 } |
| 797 Dart_ExitScope(); | 787 Dart_ExitScope(); |
| 798 } | 788 } |
| 799 | 789 |
| 800 void GLUniform3fv(Dart_NativeArguments arguments) { | 790 void GLUniform3fv(Dart_NativeArguments arguments) { |
| 801 Log::Print("GLUniform3fv"); | 791 LOGI("GLUniform3fv"); |
| 802 Dart_EnterScope(); | 792 Dart_EnterScope(); |
| 803 | 793 |
| 804 Dart_Handle locationHandle = | 794 Dart_Handle locationHandle = |
| 805 HandleError(Dart_GetNativeArgument(arguments, 0)); | 795 HandleError(Dart_GetNativeArgument(arguments, 0)); |
| 806 int64_t location; | 796 int64_t location; |
| 807 HandleError(Dart_IntegerToInt64(locationHandle, &location)); | 797 HandleError(Dart_IntegerToInt64(locationHandle, &location)); |
| 808 | 798 |
| 809 Dart_Handle argHandle = HandleError(Dart_GetNativeArgument(arguments, 1)); | 799 Dart_Handle argHandle = HandleError(Dart_GetNativeArgument(arguments, 1)); |
| 810 | 800 |
| 811 if (Dart_IsList(argHandle)) { | 801 if (Dart_IsList(argHandle)) { |
| 812 int len; | 802 int len; |
| 813 HandleError(Dart_ListLength(argHandle, &len)); | 803 HandleError(Dart_ListLength(argHandle, &len)); |
| 814 GLfloat* list = new GLfloat[len]; | 804 GLfloat* list = new GLfloat[len]; |
| 815 for (int i = 0; i < len; i++) { | 805 for (int i = 0; i < len; i++) { |
| 816 Dart_Handle vHandle = Dart_ListGetAt(argHandle, i); | 806 Dart_Handle vHandle = Dart_ListGetAt(argHandle, i); |
| 817 double v; | 807 double v; |
| 818 HandleError(Dart_DoubleValue(vHandle, &v)); | 808 HandleError(Dart_DoubleValue(vHandle, &v)); |
| 819 list[i] = v; | 809 list[i] = v; |
| 820 } | 810 } |
| 821 glUniform3fv(location, len / 3, list); | 811 glUniform3fv(location, len / 3, list); |
| 822 delete [] list; | 812 delete [] list; |
| 823 CheckGLError("glUniform3fv"); | 813 CheckGLError("glUniform3fv"); |
| 824 } | 814 } |
| 825 Dart_ExitScope(); | 815 Dart_ExitScope(); |
| 826 } | 816 } |
| 827 | 817 |
| 828 void GLUniform4fv(Dart_NativeArguments arguments) { | 818 void GLUniform4fv(Dart_NativeArguments arguments) { |
| 829 Log::Print("In GLUniform4fv"); | 819 LOGI("In GLUniform4fv"); |
| 830 Dart_EnterScope(); | 820 Dart_EnterScope(); |
| 831 | 821 |
| 832 Dart_Handle locationHandle = | 822 Dart_Handle locationHandle = |
| 833 HandleError(Dart_GetNativeArgument(arguments, 0)); | 823 HandleError(Dart_GetNativeArgument(arguments, 0)); |
| 834 int64_t location; | 824 int64_t location; |
| 835 HandleError(Dart_IntegerToInt64(locationHandle, &location)); | 825 HandleError(Dart_IntegerToInt64(locationHandle, &location)); |
| 836 | 826 |
| 837 Dart_Handle argHandle = HandleError(Dart_GetNativeArgument(arguments, 1)); | 827 Dart_Handle argHandle = HandleError(Dart_GetNativeArgument(arguments, 1)); |
| 838 | 828 |
| 839 if (Dart_IsList(argHandle)) { | 829 if (Dart_IsList(argHandle)) { |
| 840 int len; | 830 int len; |
| 841 HandleError(Dart_ListLength(argHandle, &len)); | 831 HandleError(Dart_ListLength(argHandle, &len)); |
| 842 GLfloat* list = new GLfloat[len]; | 832 GLfloat* list = new GLfloat[len]; |
| 843 for (int i = 0; i < len; i++) { | 833 for (int i = 0; i < len; i++) { |
| 844 Dart_Handle vHandle = Dart_ListGetAt(argHandle, i); | 834 Dart_Handle vHandle = Dart_ListGetAt(argHandle, i); |
| 845 double v; | 835 double v; |
| 846 HandleError(Dart_DoubleValue(vHandle, &v)); | 836 HandleError(Dart_DoubleValue(vHandle, &v)); |
| 847 list[i] = v; | 837 list[i] = v; |
| 848 } | 838 } |
| 849 glUniform4fv(location, len / 4, list); | 839 glUniform4fv(location, len / 4, list); |
| 850 delete [] list; | 840 delete [] list; |
| 851 CheckGLError("glUniform4fv"); | 841 CheckGLError("glUniform4fv"); |
| 852 } | 842 } |
| 853 Dart_ExitScope(); | 843 Dart_ExitScope(); |
| 854 } | 844 } |
| 855 | 845 |
| 856 void GLViewport(Dart_NativeArguments arguments) { | 846 void GLViewport(Dart_NativeArguments arguments) { |
| 857 Log::Print("GLViewport"); | 847 LOGI("GLViewport"); |
| 858 Dart_EnterScope(); | 848 Dart_EnterScope(); |
| 859 | 849 |
| 860 Dart_Handle xHandle = HandleError(Dart_GetNativeArgument(arguments, 0)); | 850 Dart_Handle xHandle = HandleError(Dart_GetNativeArgument(arguments, 0)); |
| 861 int64_t x; | 851 int64_t x; |
| 862 HandleError(Dart_IntegerToInt64(xHandle, &x)); | 852 HandleError(Dart_IntegerToInt64(xHandle, &x)); |
| 863 | 853 |
| 864 Dart_Handle yHandle = HandleError(Dart_GetNativeArgument(arguments, 1)); | 854 Dart_Handle yHandle = HandleError(Dart_GetNativeArgument(arguments, 1)); |
| 865 int64_t y; | 855 int64_t y; |
| 866 HandleError(Dart_IntegerToInt64(yHandle, &y)); | 856 HandleError(Dart_IntegerToInt64(yHandle, &y)); |
| 867 | 857 |
| 868 Dart_Handle widthHandle = HandleError(Dart_GetNativeArgument(arguments, 2)); | 858 Dart_Handle widthHandle = HandleError(Dart_GetNativeArgument(arguments, 2)); |
| 869 int64_t width; | 859 int64_t width; |
| 870 HandleError(Dart_IntegerToInt64(widthHandle, &width)); | 860 HandleError(Dart_IntegerToInt64(widthHandle, &width)); |
| 871 | 861 |
| 872 Dart_Handle heightHandle = HandleError(Dart_GetNativeArgument(arguments, 3)); | 862 Dart_Handle heightHandle = HandleError(Dart_GetNativeArgument(arguments, 3)); |
| 873 int64_t height; | 863 int64_t height; |
| 874 HandleError(Dart_IntegerToInt64(heightHandle, &height)); | 864 HandleError(Dart_IntegerToInt64(heightHandle, &height)); |
| 875 | 865 |
| 876 Log::Print("Dimensions: [%ld, %ld, %ld, %ld]", x, y, width, height); | 866 LOGI("Dimensions: [%ld, %ld, %ld, %ld]", x, y, width, height); |
| 877 | 867 |
| 878 glViewport(x, y, width, height); | 868 glViewport(x, y, width, height); |
| 879 CheckGLError("glViewPort"); | 869 CheckGLError("glViewPort"); |
| 880 Dart_ExitScope(); | 870 Dart_ExitScope(); |
| 881 } | 871 } |
| 882 | 872 |
| 883 void GLVertexAttribPointer(Dart_NativeArguments arguments) { | 873 void GLVertexAttribPointer(Dart_NativeArguments arguments) { |
| 884 Log::Print("GLVertexAttribPointer"); | 874 LOGI("GLVertexAttribPointer"); |
| 885 Dart_EnterScope(); | 875 Dart_EnterScope(); |
| 886 | 876 |
| 887 Dart_Handle indexHandle = HandleError(Dart_GetNativeArgument(arguments, 0)); | 877 Dart_Handle indexHandle = HandleError(Dart_GetNativeArgument(arguments, 0)); |
| 888 int64_t index; | 878 int64_t index; |
| 889 HandleError(Dart_IntegerToInt64(indexHandle, &index)); | 879 HandleError(Dart_IntegerToInt64(indexHandle, &index)); |
| 890 | 880 |
| 891 Dart_Handle sizeHandle = HandleError(Dart_GetNativeArgument(arguments, 1)); | 881 Dart_Handle sizeHandle = HandleError(Dart_GetNativeArgument(arguments, 1)); |
| 892 int64_t size; | 882 int64_t size; |
| 893 HandleError(Dart_IntegerToInt64(sizeHandle, &size)); | 883 HandleError(Dart_IntegerToInt64(sizeHandle, &size)); |
| 894 | 884 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 910 HandleError(Dart_IntegerToInt64(pointerHandle, &pointerValue)); | 900 HandleError(Dart_IntegerToInt64(pointerHandle, &pointerValue)); |
| 911 const void* pointer; | 901 const void* pointer; |
| 912 pointer = const_cast<const void*>(reinterpret_cast<void*>(pointerValue)); | 902 pointer = const_cast<const void*>(reinterpret_cast<void*>(pointerValue)); |
| 913 | 903 |
| 914 glVertexAttribPointer(index, size, type, normalized, stride, pointer); | 904 glVertexAttribPointer(index, size, type, normalized, stride, pointer); |
| 915 CheckGLError("glVertexAttribPointer"); | 905 CheckGLError("glVertexAttribPointer"); |
| 916 Dart_ExitScope(); | 906 Dart_ExitScope(); |
| 917 } | 907 } |
| 918 | 908 |
| 919 void GLClearColor(Dart_NativeArguments arguments) { | 909 void GLClearColor(Dart_NativeArguments arguments) { |
| 920 Log::Print("GLClearColor"); | 910 LOGI("GLClearColor"); |
| 921 Dart_EnterScope(); | 911 Dart_EnterScope(); |
| 922 | 912 |
| 923 Dart_Handle redHandle = HandleError(Dart_GetNativeArgument(arguments, 0)); | 913 Dart_Handle redHandle = HandleError(Dart_GetNativeArgument(arguments, 0)); |
| 924 double red; | 914 double red; |
| 925 HandleError(Dart_DoubleValue(redHandle, &red)); | 915 HandleError(Dart_DoubleValue(redHandle, &red)); |
| 926 | 916 |
| 927 Dart_Handle greenHandle = HandleError(Dart_GetNativeArgument(arguments, 1)); | 917 Dart_Handle greenHandle = HandleError(Dart_GetNativeArgument(arguments, 1)); |
| 928 double green; | 918 double green; |
| 929 HandleError(Dart_DoubleValue(greenHandle, &green)); | 919 HandleError(Dart_DoubleValue(greenHandle, &green)); |
| 930 | 920 |
| 931 Dart_Handle blueHandle = HandleError(Dart_GetNativeArgument(arguments, 2)); | 921 Dart_Handle blueHandle = HandleError(Dart_GetNativeArgument(arguments, 2)); |
| 932 double blue; | 922 double blue; |
| 933 HandleError(Dart_DoubleValue(blueHandle, &blue)); | 923 HandleError(Dart_DoubleValue(blueHandle, &blue)); |
| 934 | 924 |
| 935 Dart_Handle alphaHandle = HandleError(Dart_GetNativeArgument(arguments, 3)); | 925 Dart_Handle alphaHandle = HandleError(Dart_GetNativeArgument(arguments, 3)); |
| 936 double alpha; | 926 double alpha; |
| 937 HandleError(Dart_DoubleValue(alphaHandle, &alpha)); | 927 HandleError(Dart_DoubleValue(alphaHandle, &alpha)); |
| 938 | 928 |
| 939 glClearColor(red, green, blue, alpha); | 929 glClearColor(red, green, blue, alpha); |
| 940 CheckGLError("glClearColor"); | 930 CheckGLError("glClearColor"); |
| 941 Dart_ExitScope(); | 931 Dart_ExitScope(); |
| 942 } | 932 } |
| 943 | 933 |
| 944 void GLClearDepth(Dart_NativeArguments arguments) { | 934 void GLClearDepth(Dart_NativeArguments arguments) { |
| 945 Log::Print("GLClearDepth"); | 935 LOGI("GLClearDepth"); |
| 946 Dart_EnterScope(); | 936 Dart_EnterScope(); |
| 947 | 937 |
| 948 Dart_Handle depthHandle = HandleError(Dart_GetNativeArgument(arguments, 0)); | 938 Dart_Handle depthHandle = HandleError(Dart_GetNativeArgument(arguments, 0)); |
| 949 double depth; | 939 double depth; |
| 950 HandleError(Dart_DoubleValue(depthHandle, &depth)); | 940 HandleError(Dart_DoubleValue(depthHandle, &depth)); |
| 951 | 941 |
| 952 glClearDepthf(depth); | 942 glClearDepthf(depth); |
| 953 CheckGLError("glClearDepthf"); | 943 CheckGLError("glClearDepthf"); |
| 954 Dart_ExitScope(); | 944 Dart_ExitScope(); |
| 955 } | 945 } |
| 956 | 946 |
| 957 void GLClear(Dart_NativeArguments arguments) { | 947 void GLClear(Dart_NativeArguments arguments) { |
| 958 Log::Print("GLClear"); | 948 LOGI("GLClear"); |
| 959 Dart_EnterScope(); | 949 Dart_EnterScope(); |
| 960 Dart_Handle maskHandle = HandleError(Dart_GetNativeArgument(arguments, 0)); | 950 Dart_Handle maskHandle = HandleError(Dart_GetNativeArgument(arguments, 0)); |
| 961 int64_t mask; | 951 int64_t mask; |
| 962 HandleError(Dart_IntegerToInt64(maskHandle, &mask)); | 952 HandleError(Dart_IntegerToInt64(maskHandle, &mask)); |
| 963 glClear(mask); | 953 glClear(mask); |
| 964 CheckGLError("glClear"); | 954 CheckGLError("glClear"); |
| 965 Dart_ExitScope(); | 955 Dart_ExitScope(); |
| 966 } | 956 } |
| 967 | 957 |
| 968 void GLArrayBuffer(Dart_NativeArguments arguments) { | 958 void GLArrayBuffer(Dart_NativeArguments arguments) { |
| 969 Log::Print("GLArrayBuffer"); | 959 LOGI("GLArrayBuffer"); |
| 970 Dart_EnterScope(); | 960 Dart_EnterScope(); |
| 971 Dart_Handle result = HandleError(Dart_NewInteger(GL_ARRAY_BUFFER)); | 961 Dart_Handle result = HandleError(Dart_NewInteger(GL_ARRAY_BUFFER)); |
| 972 Dart_SetReturnValue(arguments, result); | 962 Dart_SetReturnValue(arguments, result); |
| 973 Dart_ExitScope(); | 963 Dart_ExitScope(); |
| 974 } | 964 } |
| 975 | 965 |
| 976 void GLColorBufferBit(Dart_NativeArguments arguments) { | 966 void GLColorBufferBit(Dart_NativeArguments arguments) { |
| 977 Log::Print("GLColorBuffer"); | 967 LOGI("GLColorBuffer"); |
| 978 Dart_EnterScope(); | 968 Dart_EnterScope(); |
| 979 Dart_Handle result = HandleError(Dart_NewInteger(GL_COLOR_BUFFER_BIT)); | 969 Dart_Handle result = HandleError(Dart_NewInteger(GL_COLOR_BUFFER_BIT)); |
| 980 Dart_SetReturnValue(arguments, result); | 970 Dart_SetReturnValue(arguments, result); |
| 981 Dart_ExitScope(); | 971 Dart_ExitScope(); |
| 982 } | 972 } |
| 983 | 973 |
| 984 void GLCompileStatus(Dart_NativeArguments arguments) { | 974 void GLCompileStatus(Dart_NativeArguments arguments) { |
| 985 Log::Print("GLCompileStatus"); | 975 LOGI("GLCompileStatus"); |
| 986 Dart_EnterScope(); | 976 Dart_EnterScope(); |
| 987 Dart_Handle result = HandleError(Dart_NewInteger(GL_COMPILE_STATUS)); | 977 Dart_Handle result = HandleError(Dart_NewInteger(GL_COMPILE_STATUS)); |
| 988 Dart_SetReturnValue(arguments, result); | 978 Dart_SetReturnValue(arguments, result); |
| 989 Dart_ExitScope(); | 979 Dart_ExitScope(); |
| 990 } | 980 } |
| 991 | 981 |
| 992 void GLDepthBufferBit(Dart_NativeArguments arguments) { | 982 void GLDepthBufferBit(Dart_NativeArguments arguments) { |
| 993 Log::Print("GLDepthBufferBit"); | 983 LOGI("GLDepthBufferBit"); |
| 994 Dart_EnterScope(); | 984 Dart_EnterScope(); |
| 995 Dart_Handle result = HandleError(Dart_NewInteger(GL_DEPTH_BUFFER_BIT)); | 985 Dart_Handle result = HandleError(Dart_NewInteger(GL_DEPTH_BUFFER_BIT)); |
| 996 Dart_SetReturnValue(arguments, result); | 986 Dart_SetReturnValue(arguments, result); |
| 997 Dart_ExitScope(); | 987 Dart_ExitScope(); |
| 998 } | 988 } |
| 999 | 989 |
| 1000 void GLFloat(Dart_NativeArguments arguments) { | 990 void GLFloat(Dart_NativeArguments arguments) { |
| 1001 Dart_EnterScope(); | 991 Dart_EnterScope(); |
| 1002 Dart_Handle result = HandleError(Dart_NewInteger(GL_FLOAT)); | 992 Dart_Handle result = HandleError(Dart_NewInteger(GL_FLOAT)); |
| 1003 Dart_SetReturnValue(arguments, result); | 993 Dart_SetReturnValue(arguments, result); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1103 Dart_Port service_port = | 1093 Dart_Port service_port = |
| 1104 Dart_NewNativePort("RandomArrayService", WrappedRandomArray, true); | 1094 Dart_NewNativePort("RandomArrayService", WrappedRandomArray, true); |
| 1105 if (service_port != ((Dart_Port)0)) { | 1095 if (service_port != ((Dart_Port)0)) { |
| 1106 Dart_Handle send_port = HandleError(Dart_NewSendPort(service_port)); | 1096 Dart_Handle send_port = HandleError(Dart_NewSendPort(service_port)); |
| 1107 Dart_SetReturnValue(arguments, send_port); | 1097 Dart_SetReturnValue(arguments, send_port); |
| 1108 } | 1098 } |
| 1109 Dart_ExitScope(); | 1099 Dart_ExitScope(); |
| 1110 } | 1100 } |
| 1111 | 1101 |
| 1112 void PlayBackground(Dart_NativeArguments arguments) { | 1102 void PlayBackground(Dart_NativeArguments arguments) { |
| 1113 Log::Print("PlayBackground"); | 1103 LOGI("PlayBackground"); |
| 1114 Dart_EnterScope(); | 1104 Dart_EnterScope(); |
| 1115 const char* what = GetStringArg(arguments, 0); | 1105 const char* what = GetStringArg(arguments, 0); |
| 1116 int rtn = PlayBackground(what); | 1106 PlayBackground(what); |
| 1117 Dart_Handle result = HandleError(Dart_NewInteger(rtn)); | |
| 1118 Dart_SetReturnValue(arguments, result); | |
| 1119 Dart_ExitScope(); | 1107 Dart_ExitScope(); |
| 1120 } | 1108 } |
| 1121 | 1109 |
| 1122 void StopBackground(Dart_NativeArguments arguments) { | 1110 void StopBackground(Dart_NativeArguments arguments) { |
| 1123 Log::Print("StopBackground"); | 1111 LOGI("StopBackground"); |
| 1124 Dart_EnterScope(); | 1112 Dart_EnterScope(); |
| 1125 StopBackground(); | 1113 StopBackground(); |
| 1126 Dart_ExitScope(); | 1114 Dart_ExitScope(); |
| 1127 } | 1115 } |
| 1128 | 1116 |
| 1129 struct FunctionLookup { | 1117 struct FunctionLookup { |
| 1130 const char* name; | 1118 const char* name; |
| 1131 Dart_NativeFunction function; | 1119 Dart_NativeFunction function; |
| 1132 }; | 1120 }; |
| 1133 | 1121 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1204 HandleError(Dart_StringToCString(name, &cname)); | 1192 HandleError(Dart_StringToCString(name, &cname)); |
| 1205 for (int i = 0; function_list[i].name != NULL; ++i) { | 1193 for (int i = 0; function_list[i].name != NULL; ++i) { |
| 1206 if (strcmp(function_list[i].name, cname) == 0) { | 1194 if (strcmp(function_list[i].name, cname) == 0) { |
| 1207 result = function_list[i].function; | 1195 result = function_list[i].function; |
| 1208 break; | 1196 break; |
| 1209 } | 1197 } |
| 1210 } | 1198 } |
| 1211 Dart_ExitScope(); | 1199 Dart_ExitScope(); |
| 1212 return result; | 1200 return result; |
| 1213 } | 1201 } |
| 1214 | |
| OLD | NEW |