jboolean Java_android_filterfw_core_ShaderProgram_setShaderAttributeVertexFrame( JNIEnv* env, jobject thiz, jstring attr_name, jobject vertex_frame, jint type, jint component_count, jint stride, jint offset, jboolean normalize) { ShaderProgram* program = ConvertFromJava<ShaderProgram>(env, thiz); if (program) { // Get the vertex frame VertexFrame* v_frame = ConvertFromJava<VertexFrame>(env, vertex_frame); // Get the program variable to set const std::string attr_string = ToCppString(env, attr_name); ProgramVar program_var = program->GetAttribute(attr_string); // Set the variable if (v_frame && ShaderProgram::IsVarValid(program_var)) { const bool success = program->SetAttributeValues(program_var, v_frame, type, component_count, stride, offset, ToCppBool(normalize)); return ToJBool(success); } } return JNI_FALSE; }
jboolean Java_android_filterfw_core_ShaderProgram_setShaderAttributeValues( JNIEnv* env, jobject thiz, jstring attr_name, jfloatArray values, jint component_count) { ShaderProgram* program = ConvertFromJava<ShaderProgram>(env, thiz); if (program) { // Get the floats to set jfloat* float_ptr = env->GetFloatArrayElements(values, NULL); const int length = env->GetArrayLength(values); // Get the program variable to set const std::string attr_string = ToCppString(env, attr_name); ProgramVar program_var = program->GetAttribute(attr_string); // Set the variable if (float_ptr && ShaderProgram::IsVarValid(program_var)) { const bool success = program->SetAttributeValues(program_var, reinterpret_cast<float*>(float_ptr), length, component_count); env->ReleaseFloatArrayElements(values, float_ptr, JNI_ABORT); return ToJBool(success); } } return JNI_FALSE; }