Something went wrong. Try again.
"Simulating GPU Rendering workloads on the CPU" Mirrored from exoad's Git Server.
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889#ifndef SCENE_H#define SCENE_H
#include "shared.h"#include "gfx.h"#include "renderer.h"#include "geometry.h"#include "tigr.h"
typedef struct { Vec3 min; Vec3 max;} AABB;
typedef struct { AABB bounds; Int32 left; // child index or triangle start Int32 triCount; // 0 if internal node} BVHNode;
typedef struct { Vec3 min; Vec3 max;} ObjModel;
typedef struct { Vec3 pos; CharSeq text; TPixel color;} DebugLabel;
typedef struct { Camera camera; GeomSphere* spheres; Int32 sphereCount; Int32 sphereCapacity; GeomBox* boxes; Int32 boxCount; Int32 boxCapacity; GeomPlane* planes; Int32 planeCount; Int32 planeCapacity; GeomTriangle* triangles; Int32 triangleCount; Int32 triangleCapacity; Light* lights; Int32 lightCount; Int32 lightCapacity; ObjModel* models; Int32 modelCount; Int32 modelCapacity; DebugLabel* labels; Int32 labelCount; Int32 labelCapacity; BVHNode* bvhNodes; Int32 bvhNodeCount; Int32 bvhNodeCapacity; Int32 bvhRoot; Tigr** textures; Int32 textureCount; Int32 textureCapacity; Vec3 backgroundColor;} Scene;
Void sceneAddModel(Scene* scene, ObjModel model);Void sceneAddDebugLabel(Scene* scene, Vec3 pos, CharSeq text, TPixel color);Void sceneBuildBVH(Scene* scene);Tigr* sceneLoadTexture(Scene* scene, CharSeq path);Tigr* sceneCreateDebugTexture(Scene* scene, Int32 width, Int32 height);
Scene* createScene(Camera camera, Vec3 backgroundColor);Void destroyScene(Scene* scene);Void sceneAddSphere(Scene* scene, GeomSphere sphere);Void sceneAddBox(Scene* scene, GeomBox box);Void sceneAddPlane(Scene* scene, GeomPlane plane);Void sceneAddTriangle(Scene* scene, GeomTriangle triangle);Void sceneAddLight(Scene* scene, Light light);Void sceneRender(Scene* scene, Tigr* buffer);
Void sceneAddSphereSimple(Scene* scene, Vec3 center, Float32 radius, Vec3 color);Void sceneAddBoxSimple(Scene* scene, Vec3 center, Vec3 extents, Vec3 color);Void sceneAddPlaneSimple(Scene* scene, Vec3 normal, Float32 distance, Vec3 color);Void sceneAddLightSimple(Scene* scene, Vec3 pos, Vec3 color, Float32 intensity);Void sceneAddSpotLight(Scene* scene, Vec3 pos, Vec3 dir, Float32 inner, Float32 outer, Vec3 color, Float32 intensity);Void sceneAddAreaLight(Scene* scene, Vec3 pos, Float32 radius, Vec3 color, Float32 intensity);Void sceneAddDefaultLights(Scene* scene);Void sceneAddDefaultGround(Scene* scene);
#endif