some texture fixes

This commit is contained in:
aap 2016-08-05 01:13:41 +02:00
parent a980b32e67
commit 2cd032a79e
5 changed files with 15 additions and 13 deletions

View File

@ -33,6 +33,8 @@ Engine::init(void)
engine->currentCamera = nil; engine->currentCamera = nil;
engine->currentWorld = nil; engine->currentWorld = nil;
engine->currentTexDictionary = nil; engine->currentTexDictionary = nil;
engine->loadTextures = 1;
engine->makeDummies = 1;
engine->beginUpdate = null::beginUpdate; engine->beginUpdate = null::beginUpdate;
engine->endUpdate = null::endUpdate; engine->endUpdate = null::endUpdate;

View File

@ -635,8 +635,6 @@ Material::streamRead(Stream *stream)
goto fail; goto fail;
} }
Texture *t = Texture::streamRead(stream); Texture *t = Texture::streamRead(stream);
if(t == nil)
goto fail;
mat->setTexture(t); mat->setTexture(t);
} }

View File

@ -45,6 +45,8 @@ TexDictionary::create(void)
void void
TexDictionary::destroy(void) TexDictionary::destroy(void)
{ {
if(engine->currentTexDictionary == this)
engine->currentTexDictionary = nil;
FORLIST(lnk, this->textures) FORLIST(lnk, this->textures)
Texture::fromDict(lnk)->destroy(); Texture::fromDict(lnk)->destroy();
s_plglist.destruct(this); s_plglist.destruct(this);
@ -54,13 +56,12 @@ TexDictionary::destroy(void)
void void
TexDictionary::add(Texture *t) TexDictionary::add(Texture *t)
{ {
if(engine->currentTexDictionary == this)
engine->currentTexDictionary = nil;
if(t->dict) if(t->dict)
t->inDict.remove(); t->inDict.remove();
t->dict = this; t->dict = this;
this->textures.append(&t->inDict); this->textures.append(&t->inDict);
} }
Texture* Texture*
TexDictionary::find(const char *name) TexDictionary::find(const char *name)
{ {
@ -152,8 +153,6 @@ TexDictionary::getCurrent(void)
// Texture // Texture
// //
bool32 loadTextures;
static Texture *defaultFindCB(const char *name); static Texture *defaultFindCB(const char *name);
static Texture *defaultReadCB(const char *name, const char *mask); static Texture *defaultReadCB(const char *name, const char *mask);
@ -234,12 +233,11 @@ Texture::read(const char *name, const char *mask)
tex->refCount++; tex->refCount++;
return tex; return tex;
} }
if(loadTextures){ if(engine->loadTextures){
tex = Texture::readCB(name, mask); tex = Texture::readCB(name, mask);
if(tex == nil) if(tex == nil)
goto dummytex; goto dummytex;
}else{ }else dummytex: if(engine->makeDummies){
dummytex:
tex = Texture::create(nil); tex = Texture::create(nil);
if(tex == nil) if(tex == nil)
return nil; return nil;
@ -249,7 +247,7 @@ Texture::read(const char *name, const char *mask)
raster = Raster::create(0, 0, 0, Raster::DONTALLOCATE); raster = Raster::create(0, 0, 0, Raster::DONTALLOCATE);
tex->raster = raster; tex->raster = raster;
} }
if(engine->currentTexDictionary){ if(tex && engine->currentTexDictionary){
if(tex->dict) if(tex->dict)
tex->inDict.remove(); tex->inDict.remove();
engine->currentTexDictionary->add(tex); engine->currentTexDictionary->add(tex);

View File

@ -50,7 +50,11 @@ struct Engine
{ {
void *currentCamera; void *currentCamera;
void *currentWorld; void *currentWorld;
TexDictionary *currentTexDictionary; TexDictionary *currentTexDictionary;
bool32 loadTextures; // load textures from files
bool32 makeDummies; // create dummy textures to store just names
// Device // Device
float32 zNear, zFar; float32 zNear, zFar;

View File

@ -159,8 +159,10 @@ struct ObjectWithFrame
if(this->object.parent) if(this->object.parent)
this->inFrame.remove(); this->inFrame.remove();
this->object.parent = f; this->object.parent = f;
if(f) if(f){
f->objectList.add(&this->inFrame); f->objectList.add(&this->inFrame);
f->updateObjects();
}
} }
void sync(void){ this->syncCB(this); } void sync(void){ this->syncCB(this); }
static ObjectWithFrame *fromFrame(LLLink *lnk){ static ObjectWithFrame *fromFrame(LLLink *lnk){
@ -258,8 +260,6 @@ struct Raster : PluginBase<Raster>
}; };
}; };
extern bool32 loadTextures;
#define IGNORERASTERIMP 0 #define IGNORERASTERIMP 0
struct TexDictionary; struct TexDictionary;