• ### Announcements

#### Archived

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

# Deleting and replacing textures

## Recommended Posts

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);
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?