14.5 C
New York
Friday, May 2, 2025

C – How do I make my 3D software program rendering slowly so long as the display decision modified in the course of the execution time?


I’m writing a 3D rendering of software program in C many months after I wrote it initially in Python. It’s made with SDL2. At present, my engine has depth shaded, appropriate texture in perspective and actually nice efficiency (330 fps in 1920×1080 in my Ryzen 5 5500, or a framework of roughly 3 ms). Nevertheless, I made a decision so as to add a configuration operate to my engine that may enable the consumer to vary the decision with out having to recompile this system. This is able to finish that I needed to attempt to discover an necessary mistake that resulted in an enormous failure, an error that solely occurred each time the decision of the display of a matrix in the course of the execution time was configured.

I’ve finished my finest to unravel the issue and I’ve not been profitable. Nevertheless, I’ve seen that if the variables are identified in the course of the compilation, my efficiency doesn’t endure, even when I name the operate for it in execution time. If the values ​​are unknown and alter them in the course of the execution time, my efficiency is lowered by virtually half.

I’ve requested in some locations earlier than and I’ve not been profitable with the strategies they gave me. I don’t need to use a profiler as a result of there’s nothing that profiles, I do know the place the issue is, however I have no idea learn how to clear up that drawback, one thing {that a} profiler is not going to immediately inform me the reply. I at present suspect that the compiler is upset with the truth that my variables should not fixed, even when they’re modified as soon as and apply applicable optimizations. I’ve tried to jot down a few of my plot features in ASM, however that has failed.

My raster works. I apologize if any of that’s careless.

static inline void draw_wall(float sx0, float sx1, 
    float sy0, float sy1, float sy2, float sy3, Uint16 * prohibit pixels, 
    portalCull portalBounds, int * prohibit ceilingLut, int * prohibit floorLut, int flat, uint16_t * prohibit w_pixels, float t0, float t1, float wy0, float wy1, float size, float top) {

    float dx = (sx1 > sx0) ? (sx1 - sx0) : 1.0f;
    int startX = clamp((int)sx0, portalBounds.x0, portalBounds.x1);
    int endX   = clamp((int)sx1, portalBounds.x0, portalBounds.x1);

    float invDx = 1.0f / dx;
    float invCullDx = 1.0f / portalBounds.dxCull;
    
    float z0 = 1/wy0;
    float z1 = 1/wy1;
    
    float sf = size/4;
    float tLeft = (1-t0) * 0 + t0*sf;
    float tRight = (1-t1) * 0 + t1*sf;
    float tLZ0 = tLeft/z0;
    float tRZ1 = tRight/z1;
    
    float wz0 = wy0/z0;
    float wz1 = wy1/z1;

    float wh = top/4;

    float TEXTURE_DETAIL = ((1 > 11) & 0x1F) >> shade);
            uint8_t g = (((baseColour >> 5)  & 0x3F) >> shade);
            uint8_t b = ((baseColour & 0x1F) >> shade);
            
            pixels(row) = (r > 11) & 0x1F) >> shade);
                    register uint8_t g = (((baseColour >> 5)  & 0x3F) >> shade);
                    register uint8_t b = ((baseColour & 0x1F) >> shade);
                    
                    pixels(row) = (r > 11) & 0x1F) >> shade);
                register uint8_t g = (((baseColour >> 5)  & 0x3F) >> shade);
                register uint8_t b = ((baseColour & 0x1F) >> shade);
                
                pixels(row) = (r 

GitHub repository: https://github.com/goosymcgoosington/scotch-engine-c

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles