浏览代码

update_texture()

David Rose 17 年之前
父节点
当前提交
d6eef63f61
共有 2 个文件被更改,包括 16 次插入14 次删除
  1. 15 13
      panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx
  2. 1 1
      panda/src/tinydisplay/tinyGraphicsStateGuardian.h

+ 15 - 13
panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx

@@ -1497,7 +1497,7 @@ update_texture(TextureContext *tc, bool force) {
 
 
   if (gtc->was_image_modified() || gltex->num_levels == 0) {
   if (gtc->was_image_modified() || gltex->num_levels == 0) {
     // If the texture image was modified, reload the texture.
     // If the texture image was modified, reload the texture.
-    bool okflag = upload_texture(gtc);
+    bool okflag = upload_texture(gtc, force);
     if (!okflag) {
     if (!okflag) {
       tinydisplay_cat.error()
       tinydisplay_cat.error()
         << "Could not load " << *gtc->get_texture() << "\n";
         << "Could not load " << *gtc->get_texture() << "\n";
@@ -2076,21 +2076,23 @@ apply_texture(TextureContext *tc) {
 //               the texture has no image.
 //               the texture has no image.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 bool TinyGraphicsStateGuardian::
 bool TinyGraphicsStateGuardian::
-upload_texture(TinyTextureContext *gtc) {
+upload_texture(TinyTextureContext *gtc, bool force) {
   Texture *tex = gtc->get_texture();
   Texture *tex = gtc->get_texture();
 
 
-  if (_incomplete_render && 
-      !tex->has_uncompressed_ram_image() && tex->might_have_ram_image() &&
-      tex->has_simple_ram_image() &&
-      !_loader.is_null()) {
-    // If we don't have the texture data right now, go get it, but in
-    // the meantime load a temporary simple image in its place.
-    async_reload_texture(gtc);
-    if (!tex->has_ram_image()) {
-      if (gtc->was_simple_image_modified()) {
-        return upload_simple_texture(gtc);
+  if (_incomplete_render && !force) {
+    bool has_image = _supports_compressed_texture ? tex->has_ram_image() : tex->has_uncompressed_ram_image();
+    if (!has_image && tex->might_have_ram_image() &&
+        tex->has_simple_ram_image() &&
+        !_loader.is_null()) {
+      // If we don't have the texture data right now, go get it, but in
+      // the meantime load a temporary simple image in its place.
+      async_reload_texture(gtc);
+      if (!tex->has_ram_image()) {
+        if (gtc->was_simple_image_modified()) {
+          return upload_simple_texture(gtc);
+        }
+        return true;
       }
       }
-      return true;
     }
     }
   }
   }
 
 

+ 1 - 1
panda/src/tinydisplay/tinyGraphicsStateGuardian.h

@@ -108,7 +108,7 @@ private:
   void set_scissor(float left, float right, float bottom, float top);
   void set_scissor(float left, float right, float bottom, float top);
 
 
   bool apply_texture(TextureContext *tc);
   bool apply_texture(TextureContext *tc);
-  bool upload_texture(TinyTextureContext *gtc);
+  bool upload_texture(TinyTextureContext *gtc, bool force);
   bool upload_simple_texture(TinyTextureContext *gtc);
   bool upload_simple_texture(TinyTextureContext *gtc);
   bool setup_gltex(GLTexture *gltex, int x_size, int y_size, int num_levels);
   bool setup_gltex(GLTexture *gltex, int x_size, int y_size, int num_levels);
   int get_tex_shift(int orig_size);
   int get_tex_shift(int orig_size);