From 3e4fbbeca13d301a4cb2a3be5b9f7ea8477a5176 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20=C4=8C=C3=AD=C5=BE?= Date: Mon, 1 Jul 2019 01:42:26 +0200 Subject: [PATCH] Remove some warnings --- programs/city.c | 7 +++---- programs/hqOffline.c | 11 ++++------- programs/level.c | 4 +--- small3dlib.h | 3 +++ 4 files changed, 11 insertions(+), 14 deletions(-) diff --git a/programs/city.c b/programs/city.c index 0366688..b47f21f 100644 --- a/programs/city.c +++ b/programs/city.c @@ -114,8 +114,8 @@ void drawPixel(S3L_PixelInfo *p) { if (p->triangleID != previousTriangle) { - S3L_Index *uvIndices; - S3L_Unit *uvs; + const S3L_Index *uvIndices; + const S3L_Unit *uvs; if (p->modelIndex == 0) { @@ -245,7 +245,7 @@ int main() if (event.type == SDL_QUIT) running = 0; - uint8_t *state = SDL_GetKeyboardState(NULL); + const uint8_t *state = SDL_GetKeyboardState(NULL); int16_t step = (velocity * frameDiffMs) / 1000; int16_t stepFriction = (FRICTION * frameDiffMs) / 1000; @@ -277,7 +277,6 @@ int main() S3L_rotationToDirections(models[1].transform.rotation,S3L_FRACTIONS_PER_UNIT,&carDirection,0,0); S3L_Vec4 previousCarPos = models[1].transform.translation; - S3L_Vec4 previousCamPos = scene.camera.transform.translation; int16_t friction = 0; diff --git a/programs/hqOffline.c b/programs/hqOffline.c index d1b3790..7f025d2 100644 --- a/programs/hqOffline.c +++ b/programs/hqOffline.c @@ -21,6 +21,7 @@ #include "../small3dlib.h" #include +#include #include #include "grassTexture.h" @@ -84,7 +85,7 @@ S3L_Unit treeNormals[TREE_VERTEX_COUNT * 3]; S3L_Model3D models[MODELS_TOTAL]; S3L_Scene scene; -int previousTriangle = -1; +uint32_t previousTriangle = 1000; S3L_Vec4 toLightDirection; @@ -92,7 +93,7 @@ S3L_Vec4 n0, n1, n2, v0, v1, v2; S3L_Vec4 uv0, uv1, uv2; -void sampleTexture(uint8_t *texture, int w, int h, float x, float y, uint8_t color[3]) +void sampleTexture(const uint8_t *texture, int w, int h, float x, float y, uint8_t color[3]) { // we do linear interpolation of the samples @@ -220,7 +221,7 @@ void drawPixel(S3L_PixelInfo *p) specularIntensity = 0.8; specularPower = 40.0; - float dist, dx, dy; + float dist; // create wavy normal map for water @@ -453,14 +454,10 @@ int main() char fileName[] = "test00.ppm"; S3L_Transform3D transform0, transform1; - S3L_Vec4 target0, target1; S3L_initTransoform3D(&transform0); S3L_initTransoform3D(&transform1); - target0 = scene.models[0].transform.translation; - target1 = scene.models[2].transform.translation; - transform0.translation.x = -2 * S3L_FRACTIONS_PER_UNIT; transform0.translation.y = 5 * S3L_FRACTIONS_PER_UNIT; transform0.translation.z = -14 * S3L_FRACTIONS_PER_UNIT; diff --git a/programs/level.c b/programs/level.c index 2bfaea0..21c9383 100644 --- a/programs/level.c +++ b/programs/level.c @@ -190,8 +190,6 @@ void draw() clearScreen(); - uint32_t f = frame; - S3L_drawScene(scene); S3L_Vec4 screenPoint; @@ -255,7 +253,7 @@ int main() S3L_rotationToDirections(scene.camera.transform.rotation,20,&camF,&camR,0); - uint8_t *state = SDL_GetKeyboardState(NULL); + const uint8_t *state = SDL_GetKeyboardState(NULL); if (state[SDL_SCANCODE_A]) scene.camera.transform.rotation.y += 1; diff --git a/small3dlib.h b/small3dlib.h index 959341d..e38c9a1 100644 --- a/small3dlib.h +++ b/small3dlib.h @@ -2130,7 +2130,9 @@ void S3L_drawTriangle( int8_t rowCount = S3L_PC_APPROX_LENGTH; #endif +#if S3L_Z_BUFFER S3L_Index zBufferIndex = p.y * S3L_RESOLUTION_X + lXClipped; +#endif // draw the row -- inner loop: @@ -2230,6 +2232,7 @@ void S3L_drawTriangle( #if S3L_Z_BUFFER p.previousZ = S3L_zBuffer[zBufferIndex]; + zBufferIndex++; if (!S3L_zTest(p.x,p.y,p.depth))