From 6ff62a8995b393d4259b6203b5566cca7e10ca7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20=C4=8C=C3=AD=C5=BE?= Date: Tue, 21 May 2019 14:13:07 +0200 Subject: [PATCH] Add depth to pixelinfo --- s3l.h | 53 ++++++++++++++++++++++++++++++----------------------- testSDL.c | 2 +- 2 files changed, 31 insertions(+), 24 deletions(-) diff --git a/s3l.h b/s3l.h index f3ed75c..3b4e6d8 100644 --- a/s3l.h +++ b/s3l.h @@ -112,26 +112,32 @@ #include #ifndef S3L_RESOLUTION_X - #define S3L_RESOLUTION_X 640 //< Redefine to your screen x resolution. +#define S3L_RESOLUTION_X 640 ///< Redefine to your screen x resolution. #endif #ifndef S3L_RESOLUTION_Y - #define S3L_RESOLUTION_Y 480 //< Redefine to your screen y resolution. +#define S3L_RESOLUTION_Y 480 ///< Redefine to your screen y resolution. +#endif + +#ifndef S3L_COMPUTE_DEPTH +#define S3L_COMPUTE_DEPTH 0 /**< Whether to compute depth for each pixel + (fragment). Some other options may turn this + on. */ #endif #ifndef S3L_PERSPECTIVE_CORRECTION - #define S3L_PERSPECTIVE_CORRECTION 0 /**< Specifies what type of perspective - correction (PC) to use. Remember - this is an expensive operation! - Possible values: +#define S3L_PERSPECTIVE_CORRECTION 0 /**< Specifies what type of perspective + correction (PC) to use. Remember + this is an expensive operation! + Possible values: - 0: no PC, fastest but ugliest - 1: full (per-pixel) PC, nicest but - extremely expensive! - 2: triangle subdivided PC, a - compromise between quality and - speed (TODO, not implemented) - */ + 0: no PC, fastest but ugliest + 1: full (per-pixel) PC, nicest but + extremely expensive! + 2: triangle subdivided PC, a + compromise between quality and + speed (TODO, not implemented) + */ #endif typedef int32_t S3L_Unit; /**< Units of measurement in 3D space. There is @@ -151,19 +157,19 @@ typedef int16_t S3L_ScreenCoord; typedef uint16_t S3L_Index; #ifndef S3L_NEAR - #define S3L_NEAR (S3L_FRACTIONS_PER_UNIT) /**< Distance of the near clipping - plane. */ +#define S3L_NEAR (S3L_FRACTIONS_PER_UNIT / 4) /**< Distance of the near + clipping plane. */ #endif #ifndef S3L_FAST_LERP_QUALITY - #define S3L_FAST_LERP_QUALITY 8 /**< Quality (scaling) of SOME linear - interpolations. 0 will most likely be - faster, but artifacts can occur for - bigger tris, while higher values can fix - this -- in theory all higher values will - have the same speed (it is a shift - value), but it mustn't be too high to - prevent overflow. */ +#define S3L_FAST_LERP_QUALITY 8 /**< Quality (scaling) of SOME linear + interpolations. 0 will most likely be + faster, but artifacts can occur for + bigger tris, while higher values can fix + this -- in theory all higher values will + have the same speed (it is a shift + value), but it mustn't be too high to + prevent overflow. */ #endif #define S3L_HALF_RESOLUTION_X (S3L_RESOLUTION_X >> 1) @@ -346,6 +352,7 @@ typedef struct S3L_Unit barycentric1; ///< Baryc. coord 1 (corresponds to 2nd vertex). S3L_Unit barycentric2; ///< Baryc. coord 2 (corresponds to 3rd vertex). S3L_Index triangleID; + S3L_Unit depth; ///< Depth (only if depth is turned on). } S3L_PixelInfo; /**< Used to pass the info about a rasterized pixel (fragment) to the user-defined drawing func. */ diff --git a/testSDL.c b/testSDL.c index 939eddc..c558441 100644 --- a/testSDL.c +++ b/testSDL.c @@ -12,7 +12,7 @@ #define S3L_RESOLUTION_X 640 #define S3L_RESOLUTION_Y 480 -#define S3L_PERSPECTIVE_CORRECTION 1 +#define S3L_PERSPECTIVE_CORRECTION 0 #include "s3l.h"