Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions korge-core/src/korlibs/graphics/AGObjects.kt
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,24 @@ class AGBuffer : AGObject() {
fun upload(data: Buffer): AGBuffer =
upload(data, needClone = true)

/**
* Marks this buffer as dirty, so it will be uploaded to the GPU later.
*/
fun upload(): AGBuffer {
markAsDirty()
return this
}

/**
* Wraps the given buffer, so it will be used as is.
* This buffer can be modified later, and the changes will be reflected in the GPU after call to [upload] without arguments.
*/
fun wrap(data: Buffer): AGBuffer {
mem = data
markAsDirty()
return this
}

private fun upload(data: Buffer, needClone: Boolean): AGBuffer {
if (mem?.sizeInBytes == data.sizeInBytes) {
// Do not mark as dirty if the data is the same
Expand Down
Loading