Skip to content

Commit

Permalink
update_buffer_object: return nil rather than builtin error
Browse files Browse the repository at this point in the history
  • Loading branch information
aardappel committed May 21, 2024
1 parent 1f095fb commit 72fe2da
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
7 changes: 3 additions & 4 deletions dev/src/graphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,7 @@ Value UpdateBufferObjectResource(VM &vm, Value buf, const void *data, size_t len
ptrdiff_t offset, bool ssbo, bool dyn) {
auto bo = buf.True() ? &GetBufferObject(buf) : nullptr;
bo = UpdateBufferObject(bo, data, len, offset, ssbo, dyn);
if (!bo) vm.BuiltinError("bufferobject creation failed");
return buf.True() ? buf : Value(vm.NewResource(&buffer_object_type, bo));
return buf.True() ? buf : (bo ? Value(vm.NewResource(&buffer_object_type, bo)) : NilVal());
}

void BindBufferObjectResource(VM &vm, Value buf, string_view_nt name) {
Expand Down Expand Up @@ -1100,10 +1099,10 @@ nfr("set_uniform_matrix", "name,value,morerows", "SF]B?", "B",
return Value(ok);
});

nfr("update_buffer_object", "value,ssbo,offset,existing,dyn", "SIIRk:bufferobject?B", "R:bufferobject",
nfr("update_buffer_object", "value,ssbo,offset,existing,dyn", "SIIRk:bufferobject?B", "R:bufferobject?",
"creates a uniform buffer object"
" ssbo indicates if you want a shader storage block instead."
" returns buffer id or 0 on error.",
" returns buffer resource or nil on error.",
[](StackPtr &, VM &vm, Value &vec, Value &ssbo, Value &offset, Value &buf, Value &dyn) {
TestGL(vm);
return UpdateBufferObjectResource(vm, buf, vec.sval()->strv().data(),
Expand Down
2 changes: 1 addition & 1 deletion modules/gl.lobster
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,6 @@ def scissor(topleft, size, body):

// For backwards compatibility, don't use.
def update_bind_buffer_object(name, buf, ssbo, res = nil):
res = update_buffer_object(buf, ssbo, -1, nil, false)
res = assert update_buffer_object(buf, ssbo, -1, nil, false)
assert bind_buffer_object(name, res)
return res

0 comments on commit 72fe2da

Please sign in to comment.