Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ endif()

add_subdirectory(third_party/tracy)
add_subdirectory(lib lib)
add_subdirectory(mym mym)
add_subdirectory(mygl mygl)
add_subdirectory(linalg linalg)
add_subdirectory(gl_render gl_render)

# imgui
set(IMGUI_PATH "${CMAKE_SOURCE_DIR}/third_party/imgui")
Expand All @@ -34,8 +34,8 @@ target_link_libraries(ImGui PRIVATE SDL3::SDL3)
add_executable(native index.cpp events.cpp)

target_link_libraries(native PRIVATE
mym
mygl
linalg
gl_render
lib
SDL3::SDL3
${OPENGL_LIBRARIES}
Expand Down Expand Up @@ -70,7 +70,7 @@ add_executable(tests
)

target_link_libraries(tests PRIVATE
mym
linalg
lib
)

Expand Down
2 changes: 1 addition & 1 deletion events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

#include "backends/imgui_impl_sdl3.h"

using namespace mym;
using namespace linalg;

void processEvents(WindowState& window, Camera& camera, InputState& input, Scene& scene, Arena& frame_arena)
{
Expand Down
8 changes: 4 additions & 4 deletions mygl/CMakeLists.txt → gl_render/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
include_guard(GLOBAL)
cmake_minimum_required(VERSION 3.24)
project(MyGl)
project(GlRenderer)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

find_package(OpenGL REQUIRED)
add_subdirectory(../lib lib)

add_library(mygl SHARED
add_library(gl_render SHARED
basic_color_render_program.cpp
gl_renderer.cpp
render_program.cpp
texture_render_program.cpp
)

target_include_directories(mygl PUBLIC include)
target_link_libraries(mygl PUBLIC lib)
target_include_directories(gl_render PUBLIC include)
target_link_libraries(gl_render PUBLIC lib)

2 changes: 1 addition & 1 deletion mygl/gl_renderer.cpp → gl_render/gl_renderer.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "gl_renderer.h"

using namespace mym;
using namespace linalg;

WindowState initWindow(const char* title)
{
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion include/events.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ struct Entity {

typedef struct InputState {
bool pointer_down;
mym::Vec2 pointer_position;
linalg::Vec2 pointer_position;
std::optional<Entity> selected_entity;
} InputState;

Expand Down
2 changes: 1 addition & 1 deletion index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include <mutex>
#include <thread>

using namespace mym;
using namespace linalg;
#define UPDATE_INTERVAL 10

float dt = 1.0f/UPDATE_INTERVAL;
Expand Down
4 changes: 2 additions & 2 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ set(ASSIMP_BUILD_ALL_EXPORTERS_BY_DEFAULT OFF)
set(ASSIMP_BUILD_GLTF_IMPORTER ON)
add_subdirectory(../third_party/assimp assimp)

add_subdirectory(../mym mym)
add_subdirectory(../linalg linalg)

# lib (include is for templates)
add_library(lib SHARED
Expand All @@ -33,7 +33,7 @@ add_library(lib SHARED
target_include_directories(lib PUBLIC include)

target_link_libraries(lib
mym
linalg
SDL3::SDL3
assimp::assimp
${OPENGL_LIBRARIES})
Expand Down
2 changes: 1 addition & 1 deletion lib/camera.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "camera.h"

using namespace mym;
using namespace linalg;

Mat4 getProjectionMatrix(Camera camera) {
return perspective(camera.field_of_view_radians, camera.aspect, camera.near, camera.far);
Expand Down
2 changes: 1 addition & 1 deletion lib/include/camera.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "vec.h"
#include "mat4.h"

using namespace mym;
using namespace linalg;

typedef struct Orbit {
float azimuth;
Expand Down
2 changes: 1 addition & 1 deletion lib/include/light.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include "vec.h"

using namespace mym;
using namespace linalg;

typedef struct PointLight {
Vec3 color;
Expand Down
4 changes: 2 additions & 2 deletions lib/include/material.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ struct TextureData {
};

struct BasicColorMaterial {
mym::Vec3 color;
mym::Vec3 specular_color;
linalg::Vec3 color;
linalg::Vec3 specular_color;
float shininess;
};

Expand Down
6 changes: 3 additions & 3 deletions mym/CMakeLists.txt → linalg/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
include_guard(GLOBAL)
cmake_minimum_required(VERSION 3.24)
project(MyMaths)
project(Linalg)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)


add_library(mym SHARED
add_library(linalg SHARED
vec.cpp
mat4.cpp
math_utils.cpp
)

target_include_directories(mym PUBLIC include)
target_include_directories(linalg PUBLIC include)


3 changes: 1 addition & 2 deletions mym/include/mat4.h → linalg/include/mat4.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#ifndef MAT_4_H
#define MAT_4_H

#include "math_utils.h"
#include "vec.h"

namespace mym {
namespace linalg {

typedef union Mat4 {
struct {
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion mym/include/vec.h → linalg/include/vec.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <math.h>
#include <stdbool.h>

namespace mym {
namespace linalg {

typedef union Vec2 {
struct {
Expand Down
3 changes: 2 additions & 1 deletion mym/mat4.cpp → linalg/mat4.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#include "vec.h"
#include "mat4.h"
#include "math_utils.h"

namespace mym {
namespace linalg {

Mat4 lookAt(const Vec3 camera_position, const Vec3 target, const Vec3 up) {
const Vec3 z_axis = normalize(
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion mym/vec.cpp → linalg/vec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "math_utils.h"
#include <algorithm>

namespace mym {
namespace linalg {
Vec3 scaleVector(const Vec3 vec, const float scalar) {

return (Vec3){
Expand Down
2 changes: 1 addition & 1 deletion tests/include/test_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ struct TestResult {
};

bool floatsAreClose(float a, float b);
bool vec3sAreEqual(mym::Vec3 a, mym::Vec3 b);
bool vec3sAreEqual(linalg::Vec3 a, linalg::Vec3 b);

std::vector<TestResult> runTriangleTests();
std::vector<TestResult> runVerticesTests();
Expand Down
3 changes: 2 additions & 1 deletion tests/raycast_scene_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
#include "scene.h"
#include "test_helpers.h"
#include "raycast.h"
#include "math_utils.h"

using namespace mym;
using namespace linalg;

Vertices setupVertices() {

Expand Down
2 changes: 1 addition & 1 deletion tests/test_helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ bool floatsAreClose(float a, float b) {
return fabs(a - b) < 0.00001f;
}

bool vec3sAreEqual(mym::Vec3 a, mym::Vec3 b) {
bool vec3sAreEqual(linalg::Vec3 a, linalg::Vec3 b) {
return (floatsAreClose(a.x, b.x) &&
floatsAreClose(a.y, b.y) &&
floatsAreClose(a.z, b.z));
Expand Down
Loading