Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

9 Create a Complete New Architecture #10

Draft
wants to merge 32 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
19fed98
[Docs] : add github setup and documentation
MasterLaplace Oct 13, 2023
3922adb
[Feat] : add Scripts and github workflows
MasterLaplace Oct 13, 2023
8edf898
feat(root): add Laplace Libraries v1.0.0
MasterLaplace Oct 13, 2023
e599d8d
fix(workflows): fix the cpp_norm_checker error
MasterLaplace Oct 13, 2023
5d96dad
feat(map): add Laplace Map Library v1.0.0
MasterLaplace Oct 14, 2023
4d49893
feat(Launcher): add Laplace Launcher v0.1.0 and Laplace logo
MasterLaplace Oct 16, 2023
8fc9d35
feat(root): add documentation for Laplace Launcher
MasterLaplace Oct 16, 2023
7f530c4
feat(src): add create project page in Launcher
MasterLaplace Oct 17, 2023
1578a02
style(Launcher): add Warning in Launcher README
MasterLaplace Oct 17, 2023
50c93b5
docs(.github): put the correct name of the project
MasterLaplace Oct 17, 2023
c8b4500
Merge pull request #14 from MasterLaplace/11-implement-github-setup
MasterLaplace Oct 17, 2023
6f01aed
refactor(LaplaceLib): improve lib_two_free, lib_two_print and add an …
MasterLaplace Oct 17, 2023
c54b2e2
Merge pull request #15 from MasterLaplace/12-implement-laplace-library
MasterLaplace Oct 17, 2023
e157c6b
style(src): improve style of Laplace Launcher
MasterLaplace Oct 17, 2023
01fccd2
Merge pull request #16 from MasterLaplace/13-implement-laplace-launcher
MasterLaplace Oct 17, 2023
174a8f9
feat(Engine): build core file of the Engine
MasterLaplace Oct 17, 2023
a4b6c45
feat(src): build with the engine version specified in the config file
MasterLaplace Oct 18, 2023
936571d
Merge pull request #18 from MasterLaplace/17-implement-a-version-mana…
MasterLaplace Oct 18, 2023
e005197
feat(Engine): Clock, Window, Config, Math and Engine module implemented
MasterLaplace Oct 18, 2023
b66e267
Merge pull request #20 from MasterLaplace/19-implement-engine-module
MasterLaplace Oct 18, 2023
b4a1296
style(root): fclean when make launcher is executed
MasterLaplace Oct 18, 2023
6e1ea18
style(root): error in the Copyright line of the README
MasterLaplace Oct 18, 2023
8874936
fix(root): fix build error
Martin-Boucault-35 Oct 18, 2023
777ea5e
Merge pull request #22 from MasterLaplace/21-fix-build-error
Martin-Boucault-35 Oct 18, 2023
7b23dda
feat(worflows): implement workflows to increment the current version …
MasterLaplace Oct 20, 2023
3be09a5
feat(docs): add doxygen generator action
MasterLaplace Oct 22, 2023
e3cf589
fix(libs): fix build error
Sigmanificient Oct 22, 2023
f65d500
docs(root): update checkout version of workflows, and fix some review…
MasterLaplace Oct 22, 2023
d65c869
Merge pull request #23 from Sigmanificient/laplace/9-create-a-complet…
MasterLaplace Oct 22, 2023
a863e62
fix(.github): workflow error
MasterLaplace Oct 22, 2023
b5c07cf
feat(Engine): add keyboard handling and render window
MasterLaplace Nov 12, 2023
608dc0d
docs: add `important` note in readme
MasterLaplace Nov 12, 2023
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
Prev Previous commit
Next Next commit
feat(Engine): Clock, Window, Config, Math and Engine module implemented
MasterLaplace committed Oct 18, 2023
commit e005197c2f6085a58734469b463b9a5fcecb3139
60 changes: 60 additions & 0 deletions Engine/Config/GraphicsLibrary/graphics.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
** EPITECH PROJECT, 2023
** Title: Engine-3D
** Author: MasterLaplace
** Created: 2023-10-12
** File description:
** graphics
*/

#ifndef GRAPHICS_H_
#define GRAPHICS_H_

////////////////////////////////////////////////////////////
// Define an enum for the graphics libraries
////////////////////////////////////////////////////////////
enum GraphicsLibrary {
CSFML,
SFML,
SDL,
OPENGL,
VULKAN,
DIRECTX
};

////////////////////////////////////////////////////////////
// Define the default graphics library
////////////////////////////////////////////////////////////
#define GRAPHICS_LIBRARY_DEFALUT CSFML

#ifndef GRAPHICS_LIBRARY
#define GRAPHICS_LIBRARY GRAPHICS_LIBRARY_DEFALUT
#endif

////////////////////////////////////////////////////////////
// Include the appropriate header based on the enum value
////////////////////////////////////////////////////////////
#ifdef GRAPHICS_LIBRARY
#if GRAPHICS_LIBRARY == CSFML
#include <SFML/Graphics.h>
#elif GRAPHICS_LIBRARY == SFML
#include <SFML/Graphics.hpp>
#elif GRAPHICS_LIBRARY == SDL
#include <SDL2/SDL.h>
#elif GRAPHICS_LIBRARY == OPENGL
#include <GL/glew.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <GLFW/glfw3.h>
#elif GRAPHICS_LIBRARY == VULKAN
#include <vulkan/vulkan.h>
#include <GL/glew.h>
#include <GLFW/glfw3.h>
#elif GRAPHICS_LIBRARY == DIRECTX
#include <d3d11.h>
#else
#error "[Config@GraphicsLibrary]: No graphics library or invalid graphics library."
#endif
#endif

#endif /* !GRAPHICS_H_ */
126 changes: 126 additions & 0 deletions Engine/Config/OperatingSystem/distribution.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
/*
** EPITECH PROJECT, 2023
** Title: Engine-3D
** Author: MasterLaplace
** Created: 2023-10-12
** File description:
** distribution
*/

#ifndef DISTRIBUTION_H_
#define DISTRIBUTION_H_

////////////////////////////////////////////////////////////
// Check if we need to mark functions as extern "C"
////////////////////////////////////////////////////////////
#ifdef __cplusplus
#define ENGINE_EXTERN_C extern "C"
#else
#define ENGINE_EXTERN_C extern
#endif


////////////////////////////////////////////////////////////
// Identify the operating system
////////////////////////////////////////////////////////////
#if defined(_WIN32) || defined(__WIN32__)

// Windows
#define ENGINE_SYSTEM_WINDOWS

#elif defined(linux) || defined(__linux)

// Linux
#define ENGINE_SYSTEM_LINUX

#elif defined(__APPLE__) || defined(MACOSX) || defined(macintosh) || defined(Macintosh)

// MacOS
#define ENGINE_SYSTEM_MACOS

#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)

// FreeBSD
#define ENGINE_SYSTEM_FREEBSD

#else

// Unsupported system
#error [Config@Distribution]: This operating system is not supported by ENGINE library.

#endif


////////////////////////////////////////////////////////////
// Define helpers to create portable import / export macros for each module
////////////////////////////////////////////////////////////
#if defined(ENGINE_SYSTEM_WINDOWS)

// Windows compilers need specific (and different) keywords for export and import
#define ENGINE_API_EXPORT extern "C" __declspec(dllexport)
#define ENGINE_API_IMPORT ENGINE_EXTERN_C __declspec(dllimport)

// For Visual C++ compilers, we also need to turn off this annoying C4251 warning
#ifdef _MSC_VER

#pragma warning(disable : 4251)

#endif

#else // Linux, FreeBSD, Mac OS X

#if __GNUC__ >= 4

// GCC 4 has special keywords for showing/hidding symbols,
// the same keyword is used for both importing and exporting
#define ENGINE_API_EXPORT extern "C" __attribute__ ((__visibility__ ("default")))
#define ENGINE_API_IMPORT ENGINE_EXTERN_C __attribute__ ((__visibility__ ("default")))

#else

// GCC < 4 has no mechanism to explicitely hide symbols, everything's exported
#define ENGINE_API_EXPORT extern "C"
#define ENGINE_API_IMPORT ENGINE_EXTERN_C

#endif

#endif

////////////////////////////////////////////////////////////
// Cross-platform warning for deprecated functions and classes
//
// @example:
// struct ENGINE_DEPRECATED MyStruct
// {
// ...
// };
//
// ENGINE_DEPRECATED void global_func();
////////////////////////////////////////////////////////////
#if defined(ENGINE_NO_DEPRECATED_WARNINGS)

// User explicitly requests to disable deprecation warnings
#define ENGINE_DEPRECATED

#elif defined(_MSC_VER)

// Microsoft C++ compiler
// Note: On newer MSVC versions, using deprecated functions causes a compiler error. In order to
// trigger a warning instead of an error, the compiler flag /sdl- (instead of /sdl) must be specified.
#define ENGINE_DEPRECATED __declspec(deprecated)

#elif defined(__GNUC__)

// g++ and Clang
#define ENGINE_DEPRECATED __attribute__ ((deprecated))

#else

// Other compilers are not supported, leave class or function as-is.
// With a bit of luck, the #pragma directive works, otherwise users get a warning (no error!) for unrecognized #pragma.
#pragma message("ENGINE_DEPRECATED is not supported for your compiler, please contact the ENGINE team")
#define ENGINE_DEPRECATED

#endif

#endif /* !DISTRIBUTION_H_ */
46 changes: 46 additions & 0 deletions Engine/Config/Version/version.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
** EPITECH PROJECT, 2023
** Title: Engine-3D
** Author: MasterLaplace
** Created: 2023-10-12
** File description:
** version
*/

#ifndef VERSION_H_
#define VERSION_H_

////////////////////////////////////////////////////////////
// Define the ENGINE version
////////////////////////////////////////////////////////////
#ifdef FLAG_VERSION_MAJOR
#define ENGINE_VERSION_MAJOR FLAG_VERSION_MAJOR
#else
#define ENGINE_VERSION_MAJOR 0
#endif

#ifdef FLAG_VERSION_MINOR
#define ENGINE_VERSION_MINOR FLAG_VERSION_MINOR
#else
#define ENGINE_VERSION_MINOR 1
#endif

#ifdef FLAG_VERSION_PATCH
#define ENGINE_VERSION_PATCH FLAG_VERSION_PATCH
#else
#define ENGINE_VERSION_PATCH 0
#endif

////////////////////////////////////////////////////////////
// Define the ENGINE version string
////////////////////////////////////////////////////////////
// Helper macro to convert a macro to a string
#define STRINGIFY(x) STRINGIFY_(x)
#define STRINGIFY_(x) #x

#define ENGINE_VERSION_STRING \
STRINGIFY(ENGINE_VERSION_MAJOR) "." \
STRINGIFY(ENGINE_VERSION_MINOR) "." \
STRINGIFY(ENGINE_VERSION_PATCH)

#endif /* !VERSION_H_ */
23 changes: 23 additions & 0 deletions Engine/Config/config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
** EPITECH PROJECT, 2023
** Title: Engine-3D
** Author: MasterLaplace
** Created: 2023-10-12
** File description:
** config
*/

#ifndef CONFIG_H_
#define CONFIG_H_

////////////////////////////////////////////////////////////
// Include the appropriate header based on the platform used:
// - the GraphicsLibrary used by the user (OpenGL, Vulkan, DirectX, etc.)
// - the OperatingSystem used by the user (Windows, Linux, MacOS, etc.)
// - the Version of the Engine used by the user (0.0.1, 0.1.0, 1.0.0, etc.)
////////////////////////////////////////////////////////////
#include "GraphicsLibrary/graphics.h"
#include "OperatingSystem/distribution.h"
#include "Version/version.h"

#endif /* !CONFIG_H_ */
85 changes: 85 additions & 0 deletions Engine/Engine/Clock/clock.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/*
** EPITECH PROJECT, 2023
** Title: Engine-3D
** Author: MasterLaplace
** Created: 2023-10-12
** File description:
** clock
*/

#include "engine_clock.h"

engine_clock_t *clock_create(void)
{
engine_clock_t *clock = (engine_clock_t*)malloc(sizeof(engine_clock_t));
#if GRAPHICS_LIBRARY == CSFML
clock->clock = sfClock_create();
#elif GRAPHICS_LIBRARY == SFML
clock->clock = new sf::Clock();
#elif GRAPHICS_LIBRARY == SDL
clock->clock = SDL_CreateClock();
#elif GRAPHICS_LIBRARY == OPENGL
clock->clock = GL_CreateClock();
#elif GRAPHICS_LIBRARY == VULKAN
clock->clock = VK_CreateClock();
#endif
return clock;
}

void clock_destroy(engine_clock_t *clock)
{
#if GRAPHICS_LIBRARY == CSFML
sfClock_destroy(clock->clock);
#elif GRAPHICS_LIBRARY == SFML
delete clock->clock;
#elif GRAPHICS_LIBRARY == SDL
SDL_DestroyClock(clock->clock);
#elif GRAPHICS_LIBRARY == OPENGL //using glwf for opengl and vulkan
GL_DestroyClock(clock->clock);
#elif GRAPHICS_LIBRARY == VULKAN
VK_DestroyClock(clock->clock);
#elif GRAPHICS_LIBRARY == DIRECTX
DX_DestroyClock(clock->clock);
#endif
free(clock);
}

void clock_restart(engine_clock_t *clock)
{
#if GRAPHICS_LIBRARY == CSFML
sfClock_restart(clock->clock);
#elif GRAPHICS_LIBRARY == SFML
clock->clock->restart();
#elif GRAPHICS_LIBRARY == SDL
SDL_RestartClock(clock->clock);
#elif GRAPHICS_LIBRARY == OPENGL
GL_RestartClock(clock->clock);
#elif GRAPHICS_LIBRARY == VULKAN
VK_RestartClock(clock->clock);
#elif GRAPHICS_LIBRARY == DIRECTX
DX_RestartClock(clock->clock);
#endif
}

float clock_get_f_delta_time(engine_clock_t *clock)
{
#if GRAPHICS_LIBRARY == CSFML
float delta_time = sfTime_asSeconds(sfClock_getElapsedTime(clock->clock));
return sfClock_restart(clock->clock), delta_time;
#elif GRAPHICS_LIBRARY == SFML
float delta_time = clock->clock->getElapsedTime().asSeconds();
return clock->clock->restart().asSeconds(), delta_time;
#elif GRAPHICS_LIBRARY == SDL
float delta_time = SDL_GetElapsedTime(clock->clock);
return SDL_RestartClock(clock->clock), delta_time;
#elif GRAPHICS_LIBRARY == OPENGL
float delta_time = GL_GetElapsedTime(clock->clock);
return GL_RestartClock(clock->clock), delta_time;
#elif GRAPHICS_LIBRARY == VULKAN
float delta_time = VK_GetElapsedTime(clock->clock);
return VK_RestartClock(clock->clock), delta_time;
#elif GRAPHICS_LIBRARY == DIRECTX
float delta_time = DX_GetElapsedTime(clock->clock);
return DX_RestartClock(clock->clock), delta_time;
#endif
}
Loading