ShaderBuffer

class ShaderBuffer

Bases: TypedWritableReferenceCount, Namable, GeomEnums

This is a generic buffer object that lives in graphics memory.

New in version 1.10.0.

Inheritance diagram

Inheritance diagram of ShaderBuffer

explicit ShaderBuffer(std::string const &name, uint64_t size, GeomEnums::UsageHint usage_hint)
explicit ShaderBuffer(std::string const &name, vector_uchar initial_data, GeomEnums::UsageHint usage_hint)
ShaderBuffer(ShaderBuffer const&) = default

Creates an uninitialized buffer object with the given size. For now, these parameters cannot be modified, but this may change in the future.

Creates a buffer object initialized with the given data. For now, these parameters cannot be modified, but this may change in the future.

static TypeHandle get_class_type(void)
bool is_prepared(PreparedGraphicsObjects *prepared_objects) const

Returns true if the data has already been prepared or enqueued for preparation on the indicated GSG, false otherwise.

void prepare(PreparedGraphicsObjects *prepared_objects)

Indicates that the data should be enqueued to be prepared in the indicated prepared_objects at the beginning of the next frame. This will ensure the data is already loaded into the GSG if it is expected to be rendered soon.

Use this function instead of prepare_now() to preload datas from a user interface standpoint.

BufferContext *prepare_now(PreparedGraphicsObjects *prepared_objects, GraphicsStateGuardianBase *gsg)

Creates a context for the data on the particular GSG, if it does not already exist. Returns the new (or old) BufferContext. This assumes that the GraphicsStateGuardian is the currently active rendering context and that it is ready to accept new datas. If this is not necessarily the case, you should use prepare() instead.

Normally, this is not called directly except by the GraphicsStateGuardian; a data does not need to be explicitly prepared by the user before it may be rendered.

bool release(PreparedGraphicsObjects *prepared_objects)

Frees the data context only on the indicated object, if it exists there. Returns true if it was released, false if it had not been prepared.

int release_all(void)

Frees the context allocated on all objects for which the data has been declared. Returns the number of contexts which have been freed.