summaryrefslogtreecommitdiff
path: root/main.cpp
diff options
context:
space:
mode:
authortalha <talha@talhaamir.xyz>2024-03-12 04:47:19 +0500
committertalha <talha@talhaamir.xyz>2024-03-12 04:47:19 +0500
commitb8b64ac409f78f3b7a1798aa645a44554f99868f (patch)
tree085aee04220a2b7d7e192bd10784502c1edefa5f /main.cpp
parent7cc462063081f613c50bfd872188a50b8300d151 (diff)
Updated project, fixed implicit type conversion issues
Diffstat (limited to 'main.cpp')
-rw-r--r--main.cpp15
1 files changed, 6 insertions, 9 deletions
diff --git a/main.cpp b/main.cpp
index 957e765..8c931c2 100644
--- a/main.cpp
+++ b/main.cpp
@@ -5,9 +5,6 @@
#define STB_IMAGE_IMPLEMENTATION
#include "stb_image.h"
-#pragma comment(lib, "SDL2.lib")
-#pragma comment(lib, "SDL2main.lib")
-
/* @lookup:
* - The normal matrix calculation in the fragment shader for the object affected by light has been mainly copied.
* I have tried to understand the formula, and whilst it made some sense, it is not fully clear to me, and I cannot picture it yet.
@@ -88,7 +85,7 @@ unsigned int create_shader_program(unsigned int vertex_shader, unsigned int frag
}
// =========================================================== MATH ==================================================
-#define PI 3.14159265358979323846264338327950288
+#define PI 3.14159265358979323846264338327950288f
#define Square(x) ((x)*(x))
#define To_Radian(x) ((x) * PI / 180.0f)
#define To_Degree(x) ((x) * 180.0f / PI)
@@ -864,8 +861,8 @@ int main(int argc, char* argv[])
Vec3 preset_up_dir = Vec3{ 0.0, 1.0, 0.0 };
float angle_yaw, angle_pitch, angle_roll;
- angle_pitch = To_Radian(0.0);
- angle_yaw = -To_Radian(90.0);
+ angle_pitch = (float)To_Radian(0.0f);
+ angle_yaw = (float)-To_Radian(90.0f);
Vec3 camera_look = camera_look_around(angle_pitch, angle_yaw);
@@ -878,7 +875,7 @@ int main(int argc, char* argv[])
uint32_t view_loc = glGetUniformLocation(shader_program, "View");
glUniformMatrix4fv(view_loc, 1, GL_TRUE, view.buffer);
- Mat4 proj = perspective4m(To_Radian(90.0), (float)width / (float)height, 0.1, 100.0);
+ Mat4 proj = perspective4m((float)To_Radian(90.0), (float)width / (float)height, 0.1f, 100.0f);
uint32_t proj_loc = glGetUniformLocation(shader_program, "Projection");
glUniformMatrix4fv(proj_loc, 1, GL_TRUE, proj.buffer);
@@ -980,8 +977,8 @@ int main(int argc, char* argv[])
case (SDL_MOUSEMOTION):
{
SDL_MouseMotionEvent mouse_event = ev.motion;
- float x_motion = mouse_event.xrel;
- float y_motion = mouse_event.yrel;
+ float x_motion = (float)mouse_event.xrel;
+ float y_motion = (float)mouse_event.yrel;
if (x_motion != 0.0 || y_motion != 0.0)
{
angle_yaw = angle_yaw + To_Radian(x_motion * 0.1f);