Archived

This topic is now archived and is closed to further replies.

Dr Pain

Deleting and replacing textures

Recommended Posts

Dr Pain    122
There sure seems to be a lot of terrain questions lately. Here''s mine. I use an array of patches for my terrain, and move them around as the user walks. I need to be able to replace the texture on these patches when they move. I''m currently doing this (simplified for readability):
   PR_DeleteTextureByIndex(terrainTexture);
   terrainTexture = PR_LoadTexture(textureName);
   PR_Globals.PR_Materials[terrainMaterial].texture_number[0] = terrainTexture;
 
However, after a short while, it crashes in the render routine, in PR_DrawSegmentBuffer. If I remove this texture-replacing code, it runs happily all day. Is this the correct way to replace a texture, or is there perhaps a way to directly replace the bitmap of a texture without deleting it first? Does anyone know why this would crash?

Share this post


Link to post
Share on other sites
Dr Pain    122
More info:

I removed the PR_DeleteTextureByIndex call so it just keeps loading in more textures, and eventually my camera object gets trashed (overwritten). I''ve got a total of 48Meg of terrain textures at the moment, so I could be running out of RAM, but I would expect PR_LoadTexture to fail gracefully if this were the case, and even more likely to be hitting the swap file and therefore keep running, but at a much slower rate.

Chris, any ideas?

Share this post


Link to post
Share on other sites