nGL icon indicating copy to clipboard operation
nGL copied to clipboard

Update gl.cpp

Open ricosolana opened this issue 3 years ago • 6 comments

Support for SDL2, and fixed some divide by 0 errors with Fix<>, changed some other things for simplicity.

Some questions:

  • why use this to create the depth buffer instead of new: z_buffer = new std::remove_reference<decltype(*z_buffer)>::type[SCREEN_WIDTH*SCREEN_HEIGHT];

  • why use <signal.h>?

  • why were all the beginning variables static?

  • lastly, the #define cluster around line 477, why so much/complicated?:

//I hate code duplication more than macros and includes
#ifdef TEXTURE_SUPPORT
    #define TRANSPARENCY
    #include "triangle.inc.h"
    #undef TRANSPARENCY
    #undef TEXTURE_SUPPORT
    #define FORCE_COLOR
    #include "triangle.inc.h"
    #define TEXTURE_SUPPORT
    #undef FORCE_COLOR
#endif
#include "triangle.inc.h"

A lot of the code will appear as changed because MSVC beautified it. I spent a lot of time wondering why I couldn't get a triangle to draw, so I went ahead to learn about matrices and stuff to try and backtrack the problem. I thought of enabling wireframe, so it would draw a 3d line which was pretty basic, then I got the div by 0 errors... Well it's fixed now, I hope my changes can be used.

ricosolana avatar Feb 09 '21 18:02 ricosolana