Fix errors in OpenGL renderer due to type size mismatches

This commit is contained in:
rdb 2015-10-07 19:29:39 +02:00
parent 7738294657
commit a5f340c587
5 changed files with 13 additions and 13 deletions

View File

@ -1852,9 +1852,9 @@ void CLP(ShaderContext)::
update_transform_table(const TransformTable *table) { update_transform_table(const TransformTable *table) {
LMatrix4f *matrices = (LMatrix4f *)alloca(_transform_table_size * 64); LMatrix4f *matrices = (LMatrix4f *)alloca(_transform_table_size * 64);
int i = 0; size_t i = 0;
if (table != NULL) { if (table != NULL) {
int num_transforms = min(_transform_table_size, table->get_num_transforms()); size_t num_transforms = min((size_t)_transform_table_size, table->get_num_transforms());
for (; i < num_transforms; ++i) { for (; i < num_transforms; ++i) {
#ifdef STDFLOAT_DOUBLE #ifdef STDFLOAT_DOUBLE
LMatrix4 matrix; LMatrix4 matrix;
@ -1885,8 +1885,8 @@ update_slider_table(const SliderTable *table) {
memset(sliders, 0, _slider_table_size * 4); memset(sliders, 0, _slider_table_size * 4);
if (table != NULL) { if (table != NULL) {
int num_sliders = min(_slider_table_size, table->get_num_sliders()); size_t num_sliders = min((size_t)_slider_table_size, table->get_num_sliders());
for (int i = 0; i < num_sliders; ++i) { for (size_t i = 0; i < num_sliders; ++i) {
sliders[i] = table->get_slider(i)->get_slider(); sliders[i] = table->get_slider(i)->get_slider();
} }
} }

View File

@ -1304,7 +1304,7 @@ set_vertices(const GeomVertexArrayData *vertices, int num_vertices) {
// Validate the format and make sure to copy its numeric type. // Validate the format and make sure to copy its numeric type.
const GeomVertexArrayFormat *format = vertices->get_array_format(); const GeomVertexArrayFormat *format = vertices->get_array_format();
nassertv(format->get_num_columns() == 1); nassertv(format->get_num_columns() == 1);
cdata->_index_type = format->get_column((size_t)0)->get_numeric_type(); cdata->_index_type = format->get_column(0)->get_numeric_type();
cdata->_modified = Geom::get_next_modified(); cdata->_modified = Geom::get_next_modified();
cdata->_got_minmax = false; cdata->_got_minmax = false;

View File

@ -151,9 +151,9 @@ get_total_bytes() const {
// Description: Returns the number of different columns in the // Description: Returns the number of different columns in the
// array. // array.
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
INLINE size_t GeomVertexArrayFormat:: INLINE int GeomVertexArrayFormat::
get_num_columns() const { get_num_columns() const {
return _columns.size(); return (int)_columns.size();
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
@ -162,10 +162,10 @@ get_num_columns() const {
// Description: Returns the ith column of the array. // Description: Returns the ith column of the array.
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
INLINE const GeomVertexColumn *GeomVertexArrayFormat:: INLINE const GeomVertexColumn *GeomVertexArrayFormat::
get_column(size_t i) const { get_column(int i) const {
nassertr(i < _columns.size(), NULL); nassertr(i >= 0 && i < (int)_columns.size(), NULL);
consider_sort_columns(); consider_sort_columns();
return _columns[i]; return _columns[(size_t)i];
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////

View File

@ -102,8 +102,8 @@ PUBLISHED:
void pack_columns(); void pack_columns();
void align_columns_for_animation(); void align_columns_for_animation();
INLINE size_t get_num_columns() const; INLINE int get_num_columns() const;
INLINE const GeomVertexColumn *get_column(size_t i) const; INLINE const GeomVertexColumn *get_column(int i) const;
MAKE_SEQ(get_columns, get_num_columns, get_column); MAKE_SEQ(get_columns, get_num_columns, get_column);
const GeomVertexColumn *get_column(const InternalName *name) const; const GeomVertexColumn *get_column(const InternalName *name) const;

View File

@ -1675,7 +1675,7 @@ update_animated_vertices(GeomVertexData::CData *cdata, Thread *current_thread) {
CPT(GeomVertexArrayFormat) blend_array_format = orig_format->get_array(blend_array_index); CPT(GeomVertexArrayFormat) blend_array_format = orig_format->get_array(blend_array_index);
if (blend_array_format->get_stride() == 2 && if (blend_array_format->get_stride() == 2 &&
blend_array_format->get_column((size_t)0)->get_component_bytes() == 2) { blend_array_format->get_column(0)->get_component_bytes() == 2) {
// The blend indices are a table of ushorts. Optimize this // The blend indices are a table of ushorts. Optimize this
// common case. // common case.
CPT(GeomVertexArrayDataHandle) blend_array_handle = cdata->_arrays[blend_array_index].get_read_pointer()->get_handle(current_thread); CPT(GeomVertexArrayDataHandle) blend_array_handle = cdata->_arrays[blend_array_index].get_read_pointer()->get_handle(current_thread);