浏览代码

Update shaders_deferred_render.c

Ray 1 年之前
父节点
当前提交
df0f7ba61e
共有 1 个文件被更改,包括 6 次插入4 次删除
  1. 6 4
      examples/shaders/shaders_deferred_render.c

+ 6 - 4
examples/shaders/shaders_deferred_render.c

@@ -31,6 +31,8 @@
 
 
 #include <stdlib.h>         // Required for: NULL
 #include <stdlib.h>         // Required for: NULL
 
 
+#define MAX_CUBES   30
+
 typedef struct GBuffer {
 typedef struct GBuffer {
     unsigned int framebuffer;
     unsigned int framebuffer;
 
 
@@ -144,18 +146,18 @@ int main(void)
     lights[2] = CreateLight(LIGHT_POINT, (Vector3){ -2, 1, 2 }, Vector3Zero(), GREEN, deferredShader);
     lights[2] = CreateLight(LIGHT_POINT, (Vector3){ -2, 1, 2 }, Vector3Zero(), GREEN, deferredShader);
     lights[3] = CreateLight(LIGHT_POINT, (Vector3){ 2, 1, -2 }, Vector3Zero(), BLUE, deferredShader);
     lights[3] = CreateLight(LIGHT_POINT, (Vector3){ 2, 1, -2 }, Vector3Zero(), BLUE, deferredShader);
 
 
-    const int MAX_CUBES = 30;
     const float CUBE_SCALE = 0.25;
     const float CUBE_SCALE = 0.25;
-    Vector3 cubePositions[MAX_CUBES];
-    float cubeRotations[MAX_CUBES];
+    Vector3 cubePositions[MAX_CUBES] = { 0 };
+    float cubeRotations[MAX_CUBES] = { 0 };
     
     
-    for(int i = 0; i < MAX_CUBES; i++)
+    for (int i = 0; i < MAX_CUBES; i++)
     {
     {
         cubePositions[i] = (Vector3){
         cubePositions[i] = (Vector3){
             .x = (float)(rand()%10) - 5,
             .x = (float)(rand()%10) - 5,
             .y = (float)(rand()%5),
             .y = (float)(rand()%5),
             .z = (float)(rand()%10) - 5,
             .z = (float)(rand()%10) - 5,
         };
         };
+        
         cubeRotations[i] = (float)(rand()%360);
         cubeRotations[i] = (float)(rand()%360);
     }
     }