More work on reloading textures for the Win32 port. Mostly works, although some models don't seem to get their textures back, and some get the wrong ones. Most issues sort themselves out after the player's next witchspace jump. Stars, nebulae, planet, particle, and subentity issues fixes though.
git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@456 127b21dd-08f5-0310-b4b7-95ae10353056
This commit is contained in:
parent
03d71df977
commit
c86eb2ed3b
@ -781,11 +781,14 @@ static Universe *data_store_universe;
|
||||
#ifdef WIN32
|
||||
int fi;
|
||||
|
||||
//NSLog(@"Entity::reloadTextures called on [%@]", [self description]);
|
||||
|
||||
// Force the entity to reload the textures for each face by clearing the face's texture name.
|
||||
for (fi = 0; fi < n_faces; fi++)
|
||||
faces[fi].texName = 0;
|
||||
|
||||
[self initialiseTextures];
|
||||
[self generateDisplayList];
|
||||
// Force the display list to be regenerated next time a frame is drawn.
|
||||
[self regenerateDisplayList];
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -795,19 +798,16 @@ static Universe *data_store_universe;
|
||||
// roll out each face and texture in turn
|
||||
//
|
||||
int fi,ti ;
|
||||
//
|
||||
|
||||
for (fi = 0; fi < n_faces; fi++)
|
||||
{
|
||||
// texture
|
||||
NSString* texture = [NSString stringWithUTF8String:(char*)faces[fi].textureFileStr255];
|
||||
// if ((faces[fi].texName == 0)&&(faces[fi].textureFile))
|
||||
if ((faces[fi].texName == 0)&&(texture))
|
||||
{
|
||||
// load texture into Universe texturestore
|
||||
// NSLog(@"Off to load %@",faces[fi].textureFile);
|
||||
//NSLog(@"Off to load %@", texture);
|
||||
if (universe)
|
||||
{
|
||||
// faces[fi].texName = [[universe textureStore] getTextureNameFor:faces[fi].textureFile];
|
||||
faces[fi].texName = [[universe textureStore] getTextureNameFor: texture];
|
||||
}
|
||||
}
|
||||
@ -817,7 +817,6 @@ static Universe *data_store_universe;
|
||||
{
|
||||
if (!texture_name[ti])
|
||||
{
|
||||
// texture_name[ti] = [[universe textureStore] getTextureNameFor: texture_file[ti]];
|
||||
texture_name[ti] = [[universe textureStore] getTextureNameFor: [NSString stringWithUTF8String: (char*)texture_file[ti]]];
|
||||
// NSLog(@"DEBUG (initialiseTextures) Processed textureFile : %@ to texName : %d", entityData[ti].textureFile, entityData[ti].texName);
|
||||
}
|
||||
|
@ -1930,4 +1930,21 @@ void drawQuadForView(int viewdir, GLfloat x, GLfloat y, GLfloat z, GLfloat xx, G
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
// No over-ride of Entity's version of the method is required for non-Win32 platforms.
|
||||
- (void) reloadTextures
|
||||
{
|
||||
//NSLog(@"ParticleEntity::reloadTextures called, calling super and resetTextureNames");
|
||||
|
||||
// Force the sky textures to be reloaded next time a frame is drawn.
|
||||
texName = 0;
|
||||
faces[0].texName = 0;
|
||||
faces[1].texName = 0;
|
||||
|
||||
// Reset the entity display list.
|
||||
[super reloadTextures];
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@end
|
||||
|
@ -1959,5 +1959,25 @@ double longitudeFromVector(Vector v)
|
||||
velocity.z = 10000;
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
// No over-ride of Entity's version of the method is required for non-Win32 platforms.
|
||||
- (void) reloadTextures
|
||||
{
|
||||
//NSLog(@"PlanetEntity::reloadTextures called, clearing planet draw lists and calling super");
|
||||
|
||||
int i;
|
||||
// Clear out the planet's various detail level display lists.
|
||||
for (i = 0; i < MAX_SUBDIVIDE; i++)
|
||||
{
|
||||
glDeleteLists(displayListNames[i], 1);
|
||||
displayListNames[i] = 0;
|
||||
}
|
||||
|
||||
// Don't know if this will help for planets, but it shouldn't hurt.
|
||||
[super reloadTextures];
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@end
|
||||
|
@ -7294,4 +7294,23 @@ inline BOOL pairOK(NSString* my_role, NSString* their_role)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
// No over-ride of Entity's version of the method is required for non-Win32 platforms.
|
||||
- (void) reloadTextures
|
||||
{
|
||||
//NSLog(@"ShipEntity::reloadTextures called, resetting subentities and calling super");
|
||||
int i;
|
||||
for (i = 0; i < [sub_entities count]; i++)
|
||||
{
|
||||
Entity *e = (Entity *)[sub_entities objectAtIndex:i];
|
||||
//NSLog(@"ShipEntity::reloadTextures calling reloadTextures on: %@", [e description]);
|
||||
[e reloadTextures];
|
||||
}
|
||||
|
||||
// Reset the entity display list.
|
||||
[super reloadTextures];
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@end
|
||||
|
@ -648,8 +648,20 @@ Your fair use and other rights are in no way affected by the above.
|
||||
checkGLErrors([NSString stringWithFormat:@"SkyEntity after drawing %@", self]);
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
// No over-ride of Entity's version of the method is required for non-Win32 platforms.
|
||||
- (void) reloadTextures
|
||||
{
|
||||
//NSLog(@"SkyEntity::reloadTextures called, calling super and resetTextureNames");
|
||||
|
||||
// Force the sky textures to be reloaded next time a frame is drawn.
|
||||
star_textureName = 0;
|
||||
blob_textureName = 0;
|
||||
|
||||
// Reset the entity display list.
|
||||
[super reloadTextures];
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@end
|
||||
|
@ -299,6 +299,20 @@ Your fair use and other rights are in no way affected by the above.
|
||||
|
||||
- (void) reloadTextures
|
||||
{
|
||||
#ifdef WIN32
|
||||
int i;
|
||||
|
||||
// Free up the texture image data from video memory. I assume this is a reasonable thing
|
||||
// to do for any platform, but just in case... stick it in a WIN32 only condition.
|
||||
NSArray *keys = [textureDictionary allKeys];
|
||||
for (i = 0; i < [keys count]; i++)
|
||||
{
|
||||
GLuint texName = (GLuint)[(NSNumber *)[[textureDictionary objectForKey:[keys objectAtIndex:i]] objectForKey:@"texName"] intValue];
|
||||
NSLog(@"deleting texture #%d (%@)", texName, (NSString *)[keys objectAtIndex:i]);
|
||||
glDeleteTextures(1, &texName);
|
||||
}
|
||||
#endif
|
||||
|
||||
[textureDictionary removeAllObjects];
|
||||
return;
|
||||
}
|
||||
|
@ -443,13 +443,16 @@ Your fair use and other rights are in no way affected by the above.
|
||||
Universe *universe = [gameController universe];
|
||||
if (universe)
|
||||
{
|
||||
NSLog(@"WIN32: clearing texture store cache");
|
||||
[[universe textureStore] reloadTextures]; // clears the cached references
|
||||
PlayerEntity *player = (PlayerEntity *)[universe entityZero];
|
||||
if (player)
|
||||
{
|
||||
NSLog(@"WIN32: resetting text texture");
|
||||
[[player hud] setPlayer:player]; // resets the reference to the asciitext texture
|
||||
}
|
||||
|
||||
NSLog(@"WIN32: resetting entity textures");
|
||||
int i;
|
||||
Entity **elist = universe->sortedEntities;
|
||||
for (i = 0; i < universe->n_entities; i++)
|
||||
|
Loading…
x
Reference in New Issue
Block a user