From e72b321d293461f698a765c0fbff2c7b8e6dbb3c Mon Sep 17 00:00:00 2001 From: zeromus Date: Sun, 18 Apr 2010 23:10:53 +0000 Subject: [PATCH] rasterizer: fix an occasional crash during loadstate --- desmume/src/rasterize.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/desmume/src/rasterize.cpp b/desmume/src/rasterize.cpp index a874d1a66..8b2211206 100644 --- a/desmume/src/rasterize.cpp +++ b/desmume/src/rasterize.cpp @@ -925,6 +925,7 @@ public: u32 lastTextureFormat = 0, lastTexturePalette = 0; //iterate over polys + bool first=true; for(int i=0;iclippedPolyCounter;i++) { if(!RENDERER) _debug_thisPoly = (i==engine->_debug_drawClippedUserPoly); @@ -935,7 +936,7 @@ public: POLY *poly = clippedPoly.poly; int type = clippedPoly.type; - if(i == 0 || lastPolyAttr != poly->polyAttr) + if(first || lastPolyAttr != poly->polyAttr) { polyAttr.setup(poly->polyAttr); polyAttr.translucent = poly->isTranslucent(); @@ -943,13 +944,15 @@ public: } - if(i == 0 || lastTextureFormat != poly->texParam || lastTexturePalette != poly->texPalette) + if(first || lastTextureFormat != poly->texParam || lastTexturePalette != poly->texPalette) { sampler.setup(poly->texParam); lastTextureFormat = poly->texParam; lastTexturePalette = poly->texPalette; } + first = false; + lastTexKey = engine->polyTexKeys[i]; //hmm... shader gets setup every time because it depends on sampler which may have just changed