diff --git a/world.c b/world.c index e84212a..f64db10 100644 --- a/world.c +++ b/world.c @@ -193,12 +193,6 @@ static void world_drawface_textured(const world_t *world, const ps1bsp_face_t *f } } } - - // Texture window commands needs to be placed *after* the draw commands, because the commands are executed in reverse order - DR_TWIN *twin = (DR_TWIN*)mem_prim(sizeof(DR_TWIN)); - setlen(twin, 1); - twin->code[0] = texture->twin; - addPrim(ot, twin); } static void (*world_drawface)(const world_t*, const ps1bsp_face_t*, u_long *ot) = &world_drawface_fast; @@ -215,6 +209,16 @@ static void world_drawFaces(const world_t *world, const ps1bsp_face_t *firstFace break; world_drawface(world, face, curOT); + + // Texture window commands needs to be placed *after* the draw commands, because the commands are executed in reverse order + if (face->nextFace == NULL || face->textureId != face->nextFace->textureId) + { + const ps1bsp_texture_t *texture = &world->textures[face->textureId]; + DR_TWIN *twin = (DR_TWIN*)mem_prim(sizeof(DR_TWIN)); + setlen(twin, 1); + twin->code[0] = texture->twin; + addPrim(curOT, twin); + } } }