1
0
Fork 0
mirror of https://git.coom.tech/drummyfish/small3dlib.git synced 2024-11-23 20:59:58 +01:00

Add todos

This commit is contained in:
Miloslav Číž 2019-05-26 20:00:28 +02:00
parent 9a24ad5ade
commit 2f6e21e3d8
3 changed files with 49 additions and 21 deletions

View file

@ -185,16 +185,29 @@ typedef uint16_t S3L_Index;
S3L_Z_BUFFER_*. */ S3L_Z_BUFFER_*. */
#endif #endif
#if S3L_Z_BUFFER == S3L_Z_BUFFER_FULL #define S3L_SORT_NONE 0 /**< Don't sort triangles. This is fastest. */
#define S3L_COMPUTE_DEPTH 1 #define S3L_SORT_BACK_TO_FRONT 1 /**< Sort triangles from back to front. This
#define S3L_MAX_DEPTH 2147483647 can in most cases solve visibility
S3L_Unit S3L_zBuffer[S3L_RESOLUTION_X * S3L_RESOLUTION_Y]; without requiring almost any extra
#define S3L_zBufferFormat(depth) (depth) memory compared to z-buffer. */
#elif S3L_Z_BUFFER == S3L_Z_BUFFER_BYTE #define S3L_SORT_FRONT_TO_BACK 2 /**< Sort triangles front to back AND use
#define S3L_COMPUTE_DEPTH 1 a 1bit stencil buffer to not draw over
#define S3L_MAX_DEPTH 255 already drawn triangles. This prevents
uint8_t S3L_zBuffer[S3L_RESOLUTION_X * S3L_RESOLUTION_Y]; overwriting already computed pixels, but
#define S3L_zBufferFormat(depth) (((depth) >> 5) & 0x000000FF) requires a little but extra memory (the
stencil buffer). */
#ifndef S3L_SORT
#define S3L_SORT S3L_SORT_NONE /**< Defines how to sort triangles before
drawing a frame. This can be used to solve
visibility in case z-buffer is not used, to
prevent overwrting already rasterized
pixels, implement transparency etc. Note
that for simplicity and performance a
relatively simple sorting is used which
doesn't work completely correctly, so
mistakes can occur (even the best sorting
wouldn't be able to solve e.g. intersecting
triangles). */
#endif #endif
#ifndef S3L_NEAR #ifndef S3L_NEAR
@ -509,6 +522,18 @@ static inline void S3L_rotate2DPoint(S3L_Unit *x, S3L_Unit *y, S3L_Unit angle);
//============================================================================= //=============================================================================
// privates // privates
#if S3L_Z_BUFFER == S3L_Z_BUFFER_FULL
#define S3L_COMPUTE_DEPTH 1
#define S3L_MAX_DEPTH 2147483647
S3L_Unit S3L_zBuffer[S3L_RESOLUTION_X * S3L_RESOLUTION_Y];
#define S3L_zBufferFormat(depth) (depth)
#elif S3L_Z_BUFFER == S3L_Z_BUFFER_BYTE
#define S3L_COMPUTE_DEPTH 1
#define S3L_MAX_DEPTH 255
uint8_t S3L_zBuffer[S3L_RESOLUTION_X * S3L_RESOLUTION_Y];
#define S3L_zBufferFormat(depth) (((depth) >> 5) & 0x000000FF)
#endif
#define S3L_COMPUTE_LERP_DEPTH\ #define S3L_COMPUTE_LERP_DEPTH\
(S3L_COMPUTE_DEPTH && (S3L_PERSPECTIVE_CORRECTION != 1)) (S3L_COMPUTE_DEPTH && (S3L_PERSPECTIVE_CORRECTION != 1))

View file

@ -7,7 +7,7 @@
#include <stdio.h> #include <stdio.h>
#include <math.h> #include <math.h>
#define S3L_Z_BUFFER S3L_Z_BUFFER_FULL #define S3L_Z_BUFFER 0
#define S3L_PIXEL_FUNCTION drawPixel #define S3L_PIXEL_FUNCTION drawPixel
@ -15,7 +15,7 @@
#define S3L_RESOLUTION_Y 480 #define S3L_RESOLUTION_Y 480
#define S3L_COMPUTE_DEPTH 1 #define S3L_COMPUTE_DEPTH 1
#define S3L_PERSPECTIVE_CORRECTION 1 #define S3L_PERSPECTIVE_CORRECTION 0
#include "small3dlib.h" #include "small3dlib.h"

View file

@ -1,14 +1,17 @@
features: features:
- scene and model rendering strategies: - scene and model rendering strategies, that can be optionally selected and
- random (no visibility checks) will configure other constants (e.g. a "low memory sort strategy" will turn
- sorted: z-buffer off and turn back-to-front sorting on).
- back-to-front (slower, better memory efficiency)
- front-to-back (faster, but needs 1bit stencil buffer) - triangle sorting:
- Z-buffer: - back-to-front (slower, better memory efficiency)
- full DONE - front-to-back (faster, but needs 1bit stencil buffer)
- reduced (resolution and precision) DONE
- more reduced (4-bit) - Z-buffer:
- full DONE
- reduced (resolution and precision) DONE
- more reduced (4-bit)
- perspective correction modes: - perspective correction modes:
- none DONE - none DONE