Clean up main engine loop

This commit is contained in:
austin committed 2020-07-01 17:42:57 -07:00
1 parent d26e4cb5dc
commit 0f73e2cd91
8 files changed
+200 -170

No files matched your search

+19 -17
View File
@@ -1,5 +1,6 @@
#ifndef CAMERA_H
#include "engine.h"
#include "point.h"
#include "util.h"
#include <cmath>
@@ -14,27 +15,28 @@ struct Camera
position.y = 0.0f;
position.z = 0.0f;
rotation[0] = 0.0f;
rotation[1] = 0.0f;
rotation[2] = 0.0f;
rotation.x = 0.0f;
rotation.y = 0.0f;
rotation.z = 0.0f;
nearClip = 5.0f;
farClip = 600.0f;
zClipBias0 =
(CAMERA_FAR_CLIP + CAMERA_NEAR_CLIP)
/ (CAMERA_FAR_CLIP - CAMERA_NEAR_CLIP);
zClipBias1 =
(-2.0f * CAMERA_FAR_CLIP * CAMERA_NEAR_CLIP)
/ (CAMERA_FAR_CLIP - CAMERA_NEAR_CLIP);
xZoom = 1.0f / tanf(DEG_TO_RAD(CAMERA_FOV/2.0f));
yZoom = (xZoom * WINDOW_WIDTH) / WINDOW_HEIGHT;
xScale = (0.5f * WINDOW_WIDTH) - 0.5f;
yScale = (0.5f * WINDOW_HEIGHT) - 0.5f;
}
inline void SetFOV(float fov, int winWidth, int winHeight)
{
xZoom = 1.0f / tanf(DEG_TO_RAD(fov/2.0f));
yZoom = (xZoom * winWidth) / winHeight;
xScale = (0.5f * winWidth) - 0.5f;
yScale = (0.5f * winHeight) - 0.5f;
}
Point position;
float rotation[3];
float nearClip, farClip;
Point rotation;
float zClipBias0, zClipBias1;
float xZoom, yZoom;
float xScale, yScale;
};
+13 -2
View File
@@ -3,11 +3,22 @@
#include <cstdint>
// CONSTANTS
// WINDOW CONFIGURATION
#define WINDOW_WIDTH (1920)
#define WINDOW_HEIGHT (1080)
#define WINDOW_FPS (30)
// CAMERA CONFIGURATION
#define CAMERA_FOV (90.0f)
#define CAMERA_NEAR_CLIP (5.0f)
#define CAMERA_FAR_CLIP (600.0f)
// GEOMETRY CONFIGURATION
#define FACE_LIMIT (30000)
#define MATERIAL_LIMIT (10)
#define TEXTURE_SIZE_LIMIT (1024)
#define VERTEX_LIMIT (20000)
// ENUMS
enum Engine_Input
@@ -40,7 +51,7 @@ struct Engine_Buffer
// FUNCTIONS
int Engine_Init(Engine_Buffer &buffer, char *objFilename, char *mtlFilename);
int Engine_Init(char *objFilename, char *mtlFilename);
void Engine_Render(Engine_Buffer &buffer, uint32_t input);
void Engine_Shutdown(void);
+1 -21
View File
@@ -6,13 +6,6 @@
#include <cstdint>
// CONSTANTS
#define VERTEX_LIMIT (20000)
#define FACE_LIMIT (30000)
#define MATERIAL_LIMIT (10)
#define TEXTURE_SIZE_LIMIT (1024)
// STRUCTURES
struct Texture
{
@@ -82,21 +75,8 @@ struct FaceList
struct Mesh
{
inline Mesh(void)
{
position.x = 0.0f;
position.y = 0.0f;
position.z = 0.0f;
rotation[0] = 0.0f;
rotation[1] = 0.0f;
rotation[2] = 0.0f;
scale = 1.0f;
}
Point position;
float rotation[3];
Point rotation;
float scale;
};
+7 -7
View File
@@ -1,15 +1,15 @@
#ifndef TRANSFORM_H
#include "camera.h"
#include "matrix.h"
Matrix Transform_Translate(float x, float y, float z);
Matrix Transform_Rotate(float x, float y, float z);
Matrix Transform_Scale(float s);
Matrix Transform_View(Point &position, float rotation[]);
Matrix Transform_Perspective(float zoomX, float zoomY, float nearClip, float farClip);
Matrix Transform_Screen(float xScale, float yScale);
Matrix Transform_Translate(Point &translation);
Matrix Transform_Rotate(Point &rotation);
Matrix Transform_Scale(float scale);
Matrix Transform_View(Camera &camera);
Matrix Transform_Perspective(Camera &camera);
Matrix Transform_Screen(Camera &camera);
#define TRANSFORM_H