1. Do not walk behind me, for I may not lead. Do not walk ahead of me, for I may not follow. Do not walk beside me, either. Just pretty much leave me the hell alone.
2. The journey of a thousand miles begins with a broken fan belt and a leaky tire.
3. It's always darkest before dawn. So if you're going to steal your neighbor's newspaper, that's the time to do it.
4. Don't be irreplaceable. If you can't be replaced, you can't be promoted.
5. No one is listening until you fart.
6. Always remember that you're unique. Just like everyone else.
7. Never test the depth of the water with both feet.
8. If you think nobody cares if you're alive, try missing a couple of car payments.
9. Before you criticize someone, you should walk a mile in their shoes.That way, when you criticize them, you're a mile away and you have their shoes.
10. If at first you don't succeed, skydiving is not for you.
11. Give a man a fish and he will eat for a day. Teach him how to fish, and he will sit in a boat and drink beer all day.
12. If you lend someone $20 and never see that person again, it was probably worth it.
13. If you tell the truth, you don't have to remember anything.
14. Sex is like air. It's not important unless you aren't getting any.
15. Don't squat with your spurs on.
16. Some days you're the bug; some days you're the windshield.
17. Don't worry; it only seems kinky the first time.
18. Good judgment comes from bad experience, and a lot of that comes from bad judgment.
19. The quickest way to double your money is to fold it in half and put it back in your pocket.
20. A closed mouth gathers no foot.
21. Duct tape is like the Force. It has a light side and a dark side, and it holds the universe together.
22. There are two theories to arguing with women. Neither one works.
23. Generally speaking, you aren't learning much when your lips are moving.
24. Experience is something you don't get until just after you need it.
25. Never miss a good chance to shut up.
26. We are born naked, wet and hungry, and get slapped on our behind. Then things get worse.
27. Never, under any circumstances, take a sleeping pill and a laxative on the same night.
28. There is a fine line between "hobby" and "mental illness."
29. No matter what happens, somebody will find a way to take it too seriously.
30. There comes a time when you should stop expecting other people to make a big deal about your birthday...around age 12.
31. Everyone seems normal until you get to know them

The way it is meant to work is that as RenderPolyScene draws the solid part of a scene from the player's viewpoint, it collects a list of portals seen (PolyDrawSectorPortal and PolyDrawLinePortal). Mirrors is a variation of the line portal, where the destination is the same line with the camera rotated (mirrored) in that line.

Once it collected the list of portals, it renders the solid part of each of them. It does this by calling PolyDrawLinePortal::Render, which then changes the ViewPos, ViewAngle, camera, and other nasty globals to convince the renderer that we are now standing in a new location. After that, it asks RenderPolyScene to draw the scene again where the output is restricted to just the pixels covered by the portal. If mirror rendering crashes it, the reason is probably something missing in PolyDrawLinePortal::SaveGlobals or RestoreGlobals.

The main thing making the portal stuff so incomplete is that it doesn't properly restrict what is viewable by a portal. A side effect of that is it often tries to draw half the world, plummeting the frame rate. It also doesn't properly track if a portal has already been seen, often causing it to recursively draw them over and over again until reaching the recursion limit.

Anyhow, to answer your question about the triangle drawer, the way to do it is to apply the mirror to the WorldToClip matrix. The rotation code already seems to be there in SaveGlobals (untested, looted from zdoom), but there might be a TriMatrix::scale(-1,0,0) missing for the matrix in PolyDrawLinePortal::Render. Note that mirroring like that changes all clockwise to counterclockwise, which means all the args.ccw values have to be negated. It is probably easiest to do that in PolyTriangleDrawer::draw_arrays PolyTriangleDrawer::draw, as that's what all those other places end up calling.

Hope this wasn't to complex or that I skipped over too many details. Portal/mirror rendering is probably the most advanced part of the rendering process.

Do you want the pointer checks merged? They're really just safety checks but it doesn't seem like they can hurt.

Spoiler: Zen Sarcasm

1. Do not walk behind me, for I may not lead. Do not walk ahead of me, for I may not follow. Do not walk beside me, either. Just pretty much leave me the hell alone.
2. The journey of a thousand miles begins with a broken fan belt and a leaky tire.
3. It's always darkest before dawn. So if you're going to steal your neighbor's newspaper, that's the time to do it.
4. Don't be irreplaceable. If you can't be replaced, you can't be promoted.
5. No one is listening until you fart.
6. Always remember that you're unique. Just like everyone else.
7. Never test the depth of the water with both feet.
8. If you think nobody cares if you're alive, try missing a couple of car payments.
9. Before you criticize someone, you should walk a mile in their shoes.That way, when you criticize them, you're a mile away and you have their shoes.
10. If at first you don't succeed, skydiving is not for you.
11. Give a man a fish and he will eat for a day. Teach him how to fish, and he will sit in a boat and drink beer all day.
12. If you lend someone $20 and never see that person again, it was probably worth it.
13. If you tell the truth, you don't have to remember anything.
14. Sex is like air. It's not important unless you aren't getting any.
15. Don't squat with your spurs on.
16. Some days you're the bug; some days you're the windshield.
17. Don't worry; it only seems kinky the first time.
18. Good judgment comes from bad experience, and a lot of that comes from bad judgment.
19. The quickest way to double your money is to fold it in half and put it back in your pocket.
20. A closed mouth gathers no foot.
21. Duct tape is like the Force. It has a light side and a dark side, and it holds the universe together.
22. There are two theories to arguing with women. Neither one works.
23. Generally speaking, you aren't learning much when your lips are moving.
24. Experience is something you don't get until just after you need it.
25. Never miss a good chance to shut up.
26. We are born naked, wet and hungry, and get slapped on our behind. Then things get worse.
27. Never, under any circumstances, take a sleeping pill and a laxative on the same night.
28. There is a fine line between "hobby" and "mental illness."
29. No matter what happens, somebody will find a way to take it too seriously.
30. There comes a time when you should stop expecting other people to make a big deal about your birthday...around age 12.
31. Everyone seems normal until you get to know them

Sleep tight. The last check should be there, but I'm less sure about the second one, and the first is most likely wrong. I belong to the school that believes null checks should only be done if that pointer is allowed to be null. Otherwise it sends the incorrect message to the next developer reading the code that this value can be null. I'm not so sure camera is allowed to be null in the first two situations.

All 3 of those checks are needed, unfortunately, to stop the crashing. I could put in asserts to discourage future developers from trying to pass nulls into there, since nulls clearly do not belong (and are what's causing the problem in the first place).

I think for now I am going to hands-off on the mirror drawing, as there were other projects I was wanting to do with the ZDoom code base. This one seems a bit out of my league at the moment, even though I do want to help out. >_<

Spoiler: Zen Sarcasm

1. Do not walk behind me, for I may not lead. Do not walk ahead of me, for I may not follow. Do not walk beside me, either. Just pretty much leave me the hell alone.
2. The journey of a thousand miles begins with a broken fan belt and a leaky tire.
3. It's always darkest before dawn. So if you're going to steal your neighbor's newspaper, that's the time to do it.
4. Don't be irreplaceable. If you can't be replaced, you can't be promoted.
5. No one is listening until you fart.
6. Always remember that you're unique. Just like everyone else.
7. Never test the depth of the water with both feet.
8. If you think nobody cares if you're alive, try missing a couple of car payments.
9. Before you criticize someone, you should walk a mile in their shoes.That way, when you criticize them, you're a mile away and you have their shoes.
10. If at first you don't succeed, skydiving is not for you.
11. Give a man a fish and he will eat for a day. Teach him how to fish, and he will sit in a boat and drink beer all day.
12. If you lend someone $20 and never see that person again, it was probably worth it.
13. If you tell the truth, you don't have to remember anything.
14. Sex is like air. It's not important unless you aren't getting any.
15. Don't squat with your spurs on.
16. Some days you're the bug; some days you're the windshield.
17. Don't worry; it only seems kinky the first time.
18. Good judgment comes from bad experience, and a lot of that comes from bad judgment.
19. The quickest way to double your money is to fold it in half and put it back in your pocket.
20. A closed mouth gathers no foot.
21. Duct tape is like the Force. It has a light side and a dark side, and it holds the universe together.
22. There are two theories to arguing with women. Neither one works.
23. Generally speaking, you aren't learning much when your lips are moving.
24. Experience is something you don't get until just after you need it.
25. Never miss a good chance to shut up.
26. We are born naked, wet and hungry, and get slapped on our behind. Then things get worse.
27. Never, under any circumstances, take a sleeping pill and a laxative on the same night.
28. There is a fine line between "hobby" and "mental illness."
29. No matter what happens, somebody will find a way to take it too seriously.
30. There comes a time when you should stop expecting other people to make a big deal about your birthday...around age 12.
31. Everyone seems normal until you get to know them

What I meant is that the actual bug might be where camera is assigned a null value rather than where it is being used. In such a situation the check only further cloak the origin of the error and while it stopped it from crashing it might still not be correct.

Especially the check in the general code also used by the other renderers is suspecious. The critical question to ask there is why it only crashes for the softpoly renderer, and my hunch is that this is because camera is not meant to be null.

I would probably leave the mirror thing alone until normal line portals are working flawlessly. That entire section of code was left half-finished by me and that makes the task so much greater for you as you don't know what I finished and what I didn't.

1. Do not walk behind me, for I may not lead. Do not walk ahead of me, for I may not follow. Do not walk beside me, either. Just pretty much leave me the hell alone.
2. The journey of a thousand miles begins with a broken fan belt and a leaky tire.
3. It's always darkest before dawn. So if you're going to steal your neighbor's newspaper, that's the time to do it.
4. Don't be irreplaceable. If you can't be replaced, you can't be promoted.
5. No one is listening until you fart.
6. Always remember that you're unique. Just like everyone else.
7. Never test the depth of the water with both feet.
8. If you think nobody cares if you're alive, try missing a couple of car payments.
9. Before you criticize someone, you should walk a mile in their shoes.That way, when you criticize them, you're a mile away and you have their shoes.
10. If at first you don't succeed, skydiving is not for you.
11. Give a man a fish and he will eat for a day. Teach him how to fish, and he will sit in a boat and drink beer all day.
12. If you lend someone $20 and never see that person again, it was probably worth it.
13. If you tell the truth, you don't have to remember anything.
14. Sex is like air. It's not important unless you aren't getting any.
15. Don't squat with your spurs on.
16. Some days you're the bug; some days you're the windshield.
17. Don't worry; it only seems kinky the first time.
18. Good judgment comes from bad experience, and a lot of that comes from bad judgment.
19. The quickest way to double your money is to fold it in half and put it back in your pocket.
20. A closed mouth gathers no foot.
21. Duct tape is like the Force. It has a light side and a dark side, and it holds the universe together.
22. There are two theories to arguing with women. Neither one works.
23. Generally speaking, you aren't learning much when your lips are moving.
24. Experience is something you don't get until just after you need it.
25. Never miss a good chance to shut up.
26. We are born naked, wet and hungry, and get slapped on our behind. Then things get worse.
27. Never, under any circumstances, take a sleeping pill and a laxative on the same night.
28. There is a fine line between "hobby" and "mental illness."
29. No matter what happens, somebody will find a way to take it too seriously.
30. There comes a time when you should stop expecting other people to make a big deal about your birthday...around age 12.
31. Everyone seems normal until you get to know them

1. Do not walk behind me, for I may not lead. Do not walk ahead of me, for I may not follow. Do not walk beside me, either. Just pretty much leave me the hell alone.
2. The journey of a thousand miles begins with a broken fan belt and a leaky tire.
3. It's always darkest before dawn. So if you're going to steal your neighbor's newspaper, that's the time to do it.
4. Don't be irreplaceable. If you can't be replaced, you can't be promoted.
5. No one is listening until you fart.
6. Always remember that you're unique. Just like everyone else.
7. Never test the depth of the water with both feet.
8. If you think nobody cares if you're alive, try missing a couple of car payments.
9. Before you criticize someone, you should walk a mile in their shoes.That way, when you criticize them, you're a mile away and you have their shoes.
10. If at first you don't succeed, skydiving is not for you.
11. Give a man a fish and he will eat for a day. Teach him how to fish, and he will sit in a boat and drink beer all day.
12. If you lend someone $20 and never see that person again, it was probably worth it.
13. If you tell the truth, you don't have to remember anything.
14. Sex is like air. It's not important unless you aren't getting any.
15. Don't squat with your spurs on.
16. Some days you're the bug; some days you're the windshield.
17. Don't worry; it only seems kinky the first time.
18. Good judgment comes from bad experience, and a lot of that comes from bad judgment.
19. The quickest way to double your money is to fold it in half and put it back in your pocket.
20. A closed mouth gathers no foot.
21. Duct tape is like the Force. It has a light side and a dark side, and it holds the universe together.
22. There are two theories to arguing with women. Neither one works.
23. Generally speaking, you aren't learning much when your lips are moving.
24. Experience is something you don't get until just after you need it.
25. Never miss a good chance to shut up.
26. We are born naked, wet and hungry, and get slapped on our behind. Then things get worse.
27. Never, under any circumstances, take a sleeping pill and a laxative on the same night.
28. There is a fine line between "hobby" and "mental illness."
29. No matter what happens, somebody will find a way to take it too seriously.
30. There comes a time when you should stop expecting other people to make a big deal about your birthday...around age 12.
31. Everyone seems normal until you get to know them