Skip to content

Commit b590958

Browse files
authored
Add upload() and wrap methods (#2326)
1 parent d03dfcd commit b590958

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

korge-core/src/korlibs/graphics/AGObjects.kt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,24 @@ class AGBuffer : AGObject() {
6666
fun upload(data: Buffer): AGBuffer =
6767
upload(data, needClone = true)
6868

69+
/**
70+
* Marks this buffer as dirty, so it will be uploaded to the GPU later.
71+
*/
72+
fun upload(): AGBuffer {
73+
markAsDirty()
74+
return this
75+
}
76+
77+
/**
78+
* Wraps the given buffer, so it will be used as is.
79+
* This buffer can be modified later, and the changes will be reflected in the GPU after call to [upload] without arguments.
80+
*/
81+
fun wrap(data: Buffer): AGBuffer {
82+
mem = data
83+
markAsDirty()
84+
return this
85+
}
86+
6987
private fun upload(data: Buffer, needClone: Boolean): AGBuffer {
7088
if (mem?.sizeInBytes == data.sizeInBytes) {
7189
// Do not mark as dirty if the data is the same

0 commit comments

Comments
 (0)