| 672 | } |
| 673 | |
| 674 | void krom_create_vertexbuffer(const FunctionCallbackInfo<Value> &args) { |
| 675 | HandleScope scope(args.GetIsolate()); |
| 676 | Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); |
| 677 | templ->SetInternalFieldCount(1); |
| 678 | Local<Object> obj = templ->NewInstance(isolate->GetCurrentContext()).ToLocalChecked(); |
| 679 | Local<Object> jsstructure = args[1]->ToObject(isolate->GetCurrentContext()).ToLocalChecked(); |
| 680 | int32_t length = jsstructure->Get(isolate->GetCurrentContext(), String::NewFromUtf8(isolate, "length").ToLocalChecked()).ToLocalChecked()->ToInt32(isolate->GetCurrentContext()).ToLocalChecked()->Value(); |
| 681 | kinc_g4_vertex_structure_t structure; |
| 682 | kinc_g4_vertex_structure_init(&structure); |
| 683 | for (int32_t i = 0; i < length; ++i) { |
| 684 | Local<Object> element = jsstructure->Get(isolate->GetCurrentContext(), i).ToLocalChecked()->ToObject(isolate->GetCurrentContext()).ToLocalChecked(); |
| 685 | Local<Value> str = element->Get(isolate->GetCurrentContext(), String::NewFromUtf8(isolate, "name").ToLocalChecked()).ToLocalChecked(); |
| 686 | String::Utf8Value utf8_value(isolate, str); |
| 687 | int32_t data = element->Get(isolate->GetCurrentContext(), String::NewFromUtf8(isolate, "data").ToLocalChecked()).ToLocalChecked()->ToInt32(isolate->GetCurrentContext()).ToLocalChecked()->Value(); |
| 688 | strcpy(temp_string_vstruct[0][i], *utf8_value); |
| 689 | kinc_g4_vertex_structure_add(&structure, temp_string_vstruct[0][i], convert_vertex_data(data)); |
| 690 | } |
| 691 | kinc_g4_vertex_buffer_t *buffer = (kinc_g4_vertex_buffer_t *)malloc(sizeof(kinc_g4_vertex_buffer_t)); |
| 692 | kinc_g4_vertex_buffer_init(buffer, args[0]->Int32Value(isolate->GetCurrentContext()).FromJust(), &structure, (kinc_g4_usage_t)args[2]->Int32Value(isolate->GetCurrentContext()).FromJust(), args[3]->Int32Value(isolate->GetCurrentContext()).FromJust()); |
| 693 | obj->SetInternalField(0, External::New(isolate, buffer)); |
| 694 | args.GetReturnValue().Set(obj); |
| 695 | } |
| 696 | |
| 697 | void krom_delete_vertexbuffer(const FunctionCallbackInfo<Value> &args) { |
| 698 | HandleScope scope(args.GetIsolate()); |
nothing calls this directly
no test coverage detected