mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 02:15:43 -04:00
vertex buffer fixes
This commit is contained in:
parent
85b019feda
commit
aeeca93186
@ -2348,7 +2348,10 @@ release_geom(GeomContext *gc) {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
DataContext *CLP(GraphicsStateGuardian)::
|
||||
prepare_data(qpGeomVertexArrayData *data) {
|
||||
cerr << "prepare_data\n";
|
||||
if (GLCAT.is_debug()) {
|
||||
GLCAT.debug()
|
||||
<< "prepare_data(" << (void *)data << ")\n";
|
||||
}
|
||||
|
||||
if (_supports_buffers) {
|
||||
CLP(DataContext) *gdc = new CLP(DataContext)(data);
|
||||
@ -2375,7 +2378,10 @@ prepare_data(qpGeomVertexArrayData *data) {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void CLP(GraphicsStateGuardian)::
|
||||
apply_data(DataContext *dc) {
|
||||
cerr << "apply_data\n";
|
||||
if (GLCAT.is_debug()) {
|
||||
GLCAT.debug()
|
||||
<< "apply_data(" << (void *)dc->_data << ")\n";
|
||||
}
|
||||
|
||||
nassertv(_supports_buffers);
|
||||
|
||||
@ -2404,7 +2410,10 @@ apply_data(DataContext *dc) {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void CLP(GraphicsStateGuardian)::
|
||||
release_data(DataContext *dc) {
|
||||
cerr << "release_data\n";
|
||||
if (GLCAT.is_debug()) {
|
||||
GLCAT.debug()
|
||||
<< "release_data(" << (void *)dc->_data << ")\n";
|
||||
}
|
||||
|
||||
nassertv(_supports_buffers);
|
||||
|
||||
|
@ -28,6 +28,23 @@ get_format() const {
|
||||
return _format;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpGeomVertexData::get_usage_hint
|
||||
// Access: Published
|
||||
// Description: Returns the usage hint that was passed to the
|
||||
// constructor, and which will be passed to each array
|
||||
// data object created initially. However, each
|
||||
// individual array may be replaced with a different
|
||||
// array object with an independent usage hint
|
||||
// specified.
|
||||
//
|
||||
// See GeomVertexArrayData::get_usage_hint().
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE qpGeomVertexArrayData::UsageHint qpGeomVertexData::
|
||||
get_usage_hint() const {
|
||||
return _usage_hint;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpGeomVertexData::set_num_vertices
|
||||
// Access: Published
|
||||
|
@ -45,7 +45,8 @@ qpGeomVertexData() {
|
||||
qpGeomVertexData::
|
||||
qpGeomVertexData(const qpGeomVertexFormat *format,
|
||||
qpGeomVertexArrayData::UsageHint usage_hint) :
|
||||
_format(format)
|
||||
_format(format),
|
||||
_usage_hint(usage_hint)
|
||||
{
|
||||
nassertv(_format->is_registered());
|
||||
|
||||
@ -263,7 +264,7 @@ convert_to(const qpGeomVertexFormat *new_format) const {
|
||||
PStatTimer timer(_munge_data_pcollector);
|
||||
|
||||
PT(qpGeomVertexData) new_data =
|
||||
new qpGeomVertexData(new_format, qpGeomVertexArrayData::UH_client);
|
||||
new qpGeomVertexData(new_format, get_usage_hint());
|
||||
|
||||
pset<int> done_arrays;
|
||||
|
||||
@ -299,7 +300,7 @@ convert_to(const qpGeomVertexFormat *new_format) const {
|
||||
|
||||
// Now go back through and copy any data that's left over.
|
||||
for (i = 0; i < num_arrays; ++i) {
|
||||
CPTA_uchar data = get_array(i)->get_data();
|
||||
CPTA_uchar array_data = get_array(i)->get_data();
|
||||
const qpGeomVertexArrayFormat *array_format = _format->get_array(i);
|
||||
int num_data_types = array_format->get_num_data_types();
|
||||
for (int di = 0; di < num_data_types; ++di) {
|
||||
@ -308,10 +309,8 @@ convert_to(const qpGeomVertexFormat *new_format) const {
|
||||
int new_i = new_format->get_array_with(data_type->get_name());
|
||||
if (new_i >= 0 && done_arrays.count(new_i) == 0) {
|
||||
// The data type exists in the new format; we have to copy it.
|
||||
PT(qpGeomVertexArrayData) new_array_data = new
|
||||
qpGeomVertexArrayData(*get_array(i));
|
||||
new_data->set_array(new_i, new_array_data);
|
||||
PTA_uchar new_data = new_array_data->modify_data();
|
||||
PTA_uchar new_array_data =
|
||||
new_data->modify_array(new_i)->modify_data();
|
||||
|
||||
const qpGeomVertexArrayFormat *new_array_format =
|
||||
new_format->get_array(new_i);
|
||||
@ -319,9 +318,9 @@ convert_to(const qpGeomVertexFormat *new_format) const {
|
||||
new_array_format->get_data_type(data_type->get_name());
|
||||
|
||||
new_data_type->copy_records
|
||||
(new_data + new_data_type->get_start(),
|
||||
(new_array_data + new_data_type->get_start(),
|
||||
new_array_format->get_stride(),
|
||||
data + data_type->get_start(), array_format->get_stride(),
|
||||
array_data + data_type->get_start(), array_format->get_stride(),
|
||||
data_type, num_vertices);
|
||||
}
|
||||
}
|
||||
|
@ -69,6 +69,7 @@ PUBLISHED:
|
||||
virtual ~qpGeomVertexData();
|
||||
|
||||
INLINE const qpGeomVertexFormat *get_format() const;
|
||||
INLINE qpGeomVertexArrayData::UsageHint get_usage_hint() const;
|
||||
|
||||
int get_num_vertices() const;
|
||||
INLINE bool set_num_vertices(int n);
|
||||
@ -112,6 +113,7 @@ private:
|
||||
|
||||
private:
|
||||
CPT(qpGeomVertexFormat) _format;
|
||||
qpGeomVertexArrayData::UsageHint _usage_hint;
|
||||
|
||||
typedef pvector< PT(qpGeomVertexArrayData) > Arrays;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user