Browse Source

Lesson 3.10

Godzil 3 years ago
parent
commit
30de591d4a
1 changed files with 18 additions and 1 deletions
  1. 18 1
      source/main.c

+ 18 - 1
source/main.c

@@ -143,6 +143,21 @@ void clearFrameBuffer(uint32_t colour)
     }
 }
 
+void drawGrid(int spacing, uint32_t colour)
+{
+    int x, y;
+    for(y = 0; y < windowHeight; y++)
+    {
+        for(x = 0; x < windowWidth; x++)
+        {
+            if (((x % spacing) == 0) || ((y % spacing) == 0))
+            {
+                frameBuffer[x + (y * windowWidth)] = colour;
+            }
+        }
+    }
+}
+
 void renderFrameBuffer()
 {
     SDL_UpdateTexture(frameBufferTexture, NULL, frameBuffer, windowWidth * sizeof(uint32_t));
@@ -154,8 +169,10 @@ void render()
     SDL_SetRenderDrawColor(renderer, 255, 64, 13, 255);
     SDL_RenderClear(renderer);
 
+    drawGrid(100, 0xFF003353);
+
     renderFrameBuffer();
-    clearFrameBuffer(0xFFFFFF00);
+    clearFrameBuffer(0xFF000000);
 
 
     SDL_RenderPresent(renderer);