浏览代码

Fix errors in OpenGL renderer due to type size mismatches

rdb 10 年之前
父节点
当前提交
a5f340c587

+ 4 - 4
panda/src/glstuff/glShaderContext_src.cxx

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

+ 1 - 1
panda/src/gobj/geomPrimitive.cxx

@@ -1304,7 +1304,7 @@ set_vertices(const GeomVertexArrayData *vertices, int num_vertices) {
   // Validate the format and make sure to copy its numeric type.
   const GeomVertexArrayFormat *format = vertices->get_array_format();
   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->_got_minmax = false;

+ 5 - 5
panda/src/gobj/geomVertexArrayFormat.I

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

+ 2 - 2
panda/src/gobj/geomVertexArrayFormat.h

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

+ 1 - 1
panda/src/gobj/geomVertexData.cxx

@@ -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);
 
     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
       // common case.
       CPT(GeomVertexArrayDataHandle) blend_array_handle = cdata->_arrays[blend_array_index].get_read_pointer()->get_handle(current_thread);