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

SDL build #346

Draft
wants to merge 39 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
1e0a2e0
Replace extern with static
bobsayshilol Aug 13, 2022
a2ba10e
Use / for path separators
bobsayshilol Aug 13, 2022
6f04f0a
Add a user defined constructor for Mix
bobsayshilol Aug 13, 2022
5f7a1f1
Remove unused method
bobsayshilol Aug 13, 2022
69394f7
Explicitly delete unimplemented LookupChannelType() calls
bobsayshilol Aug 13, 2022
9004a75
Add missing stdlib headers
bobsayshilol Aug 13, 2022
b9d04b0
Use the correct member in ring_buffer.h
bobsayshilol Aug 13, 2022
fb1c529
Remove unnecessary f's from stdlib cmath functions
bobsayshilol Aug 13, 2022
644b63b
GCC fixes
bobsayshilol Aug 13, 2022
5eb6d9b
Move divisions that could be 1/0 to where that can't happen
bobsayshilol Aug 15, 2022
ebc5b8f
Add missing overrides that clang wants
bobsayshilol Aug 15, 2022
a3cd6d0
Add a main() and common app running code
bobsayshilol Aug 15, 2022
c585136
Replace forceinline with inline for now
bobsayshilol Aug 15, 2022
0ff772d
Only enable discord on Win32
bobsayshilol Aug 15, 2022
07be9f0
More renaming for GCC
bobsayshilol Aug 21, 2022
185253c
Use the x-platform WAV reader
bobsayshilol Aug 21, 2022
9ebe02b
Fix linker issue by linking engine-sim last
bobsayshilol Sep 6, 2022
1cfb102
Default to Release when using single-configuration generators
bobsayshilol Sep 11, 2022
b89ce11
Clarify fpclassify() for libstdc++
bobsayshilol Sep 30, 2022
da2a0b9
Grab data locations during initialisation
bobsayshilol Oct 2, 2022
951a682
Pass the error log into the compiler as a stream
bobsayshilol Oct 2, 2022
c585157
Search the user folders for scripts first, then fallback on the one i…
bobsayshilol Oct 2, 2022
d0ff823
Add support for custom search paths to the compiler
bobsayshilol Oct 2, 2022
e2e8320
Rename DATA_ROOT to something better
bobsayshilol Oct 3, 2022
127026b
Allow the root data path to be provided via cmake defines
bobsayshilol Oct 3, 2022
a3b164e
Pull the version string out of cmake
bobsayshilol Oct 3, 2022
14c97c7
Add an underscore to be consistent with the macro
bobsayshilol Oct 3, 2022
e9c26bd
Destroy m_dynoTorqueSamples in destroy()
bobsayshilol Oct 12, 2022
643d10a
Destroy and delete objects causing leaks when reloading
bobsayshilol Oct 12, 2022
521a955
Replace prebuilt discord-rpc with submodule
bobsayshilol Oct 13, 2022
d1200f2
Add an error handler so that we can debug issues people might have
bobsayshilol Oct 14, 2022
319460a
Use DX11 on Windows
bobsayshilol Oct 14, 2022
02f3d28
Add more missing overrides
bobsayshilol Oct 18, 2022
fe3d724
Use floating point for min/max of gauges
bobsayshilol Oct 18, 2022
fbe369d
Fix off-by-one error
bobsayshilol Oct 18, 2022
6a11c1a
Remove assignment that can index out of bounds
bobsayshilol Oct 18, 2022
99ab9d2
Don't divide by 0
bobsayshilol Oct 18, 2022
6614d6a
Use correct engine object
bobsayshilol Oct 18, 2022
e14ed3c
Temporary update of submodules
bobsayshilol Sep 6, 2022
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
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@
[submodule "dependencies/submodules/piranha"]
path = dependencies/submodules/piranha
url = https://github.com/ange-yaghi/piranha.git
[submodule "dependencies/discord"]
path = dependencies/discord
url = https://github.com/discord/discord-rpc.git
63 changes: 39 additions & 24 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
cmake_minimum_required(VERSION 3.10)

include(CMakeDependentOption)

option(DTV "Enable video output" OFF)
option(PIRANHA_ENABLED "Enable scripting input" ON)
option(DISCORD_ENABLED "Enable Discord Rich Presence" ON)

# Default to compiling as Release in single-configuration generators
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build type" FORCE)
endif()

if (DTV)
add_compile_definitions(ATG_ENGINE_SIM_VIDEO_CAPTURE)
endif (DTV)
Expand All @@ -20,7 +27,7 @@ endif (DISCORD_ENABLED)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "cmake")

project(engine-sim)
project(engine-sim VERSION 0.1.12)

set(CMAKE_CXX_STANDARD 17)

Expand Down Expand Up @@ -191,18 +198,6 @@ if (PIRANHA_ENABLED)
piranha)
endif (PIRANHA_ENABLED)

if (DISCORD_ENABLED)
add_library(discord STATIC
# Source files
dependencies/discord/Discord.cpp

# Include files
dependencies/discord/Discord.h
dependencies/discord/discord_register.h
dependencies/discord/discord_rpc.h
)
endif (DISCORD_ENABLED)

add_executable(engine-sim-app WIN32
# Source files
src/main.cpp
Expand Down Expand Up @@ -274,10 +269,6 @@ add_executable(engine-sim-app WIN32
include/info_cluster.h
)

target_link_libraries(engine-sim-app
engine-sim
)

if (DTV)
target_link_libraries(engine-sim-app
direct-to-video)
Expand All @@ -288,19 +279,43 @@ if (PIRANHA_ENABLED)
engine-sim-script-interpreter)
endif (PIRANHA_ENABLED)

target_include_directories(engine-sim-app
PUBLIC dependencies/submodules)

add_subdirectory(dependencies)

if (DISCORD_ENABLED)
add_library(discord-rpc STATIC IMPORTED)
set_property(TARGET discord-rpc PROPERTY IMPORTED_LOCATION ${PROJECT_SOURCE_DIR}/dependencies/discord/lib/discord-rpc.lib)
target_sources(engine-sim-app PUBLIC
src/discord.cpp
include/discord.h
)
target_include_directories(engine-sim-app PUBLIC
dependencies/discord/include
)
target_link_libraries(engine-sim-app
discord
discord-rpc)
discord-rpc
)
endif (DISCORD_ENABLED)

target_include_directories(engine-sim-app
PUBLIC dependencies/submodules)
target_link_libraries(engine-sim-app
engine-sim
)

add_subdirectory(dependencies)
# ========================================================
# Generated build info

# Fallback to '..' if not provided
if (NOT DEFINED ENGINE_SIM_DATA_ROOT)
set(ENGINE_SIM_DATA_ROOT ".." CACHE STRING "Where to look for data")
endif()
message(STATUS "Data root set to '${ENGINE_SIM_DATA_ROOT}'")

configure_file(include/build_info.h.in
generated/build_info.h @ONLY)
target_include_directories(engine-sim-app
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/generated)

# ========================================================
# GTEST

enable_testing()
Expand Down
1 change: 1 addition & 0 deletions dependencies/discord
Submodule discord added at 963aa9
1 change: 0 additions & 1 deletion dependencies/discord/CMakeLists.txt

This file was deleted.

19 changes: 0 additions & 19 deletions dependencies/discord/LICENSE

This file was deleted.

26 changes: 0 additions & 26 deletions dependencies/discord/discord_register.h

This file was deleted.

86 changes: 0 additions & 86 deletions dependencies/discord/discord_rpc.h

This file was deleted.

Binary file removed dependencies/discord/lib/discord-rpc.lib
Binary file not shown.
2 changes: 1 addition & 1 deletion dependencies/submodules/delta-studio
Submodule delta-studio updated 124 files
9 changes: 9 additions & 0 deletions include/build_info.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#ifndef ATG_ENGINE_SIM_BUILD_OPTIONS_H
#define ATG_ENGINE_SIM_BUILD_OPTIONS_H

/* Grab info from CMake */
#define ENGINE_SIM_PROJECT_VERSION "@PROJECT_VERSION@"
#define ENGINE_SIM_SYSTEM_NAME "@CMAKE_SYSTEM_NAME@"
#define ENGINE_SIM_DATA_ROOT "@ENGINE_SIM_DATA_ROOT@"

#endif /* ATG_ENGINE_SIM_BUILD_OPTIONS_H */
4 changes: 2 additions & 2 deletions include/combustion_chamber.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ class Engine;
class CombustionChamber : public atg_scs::ForceGenerator {
public:
struct Parameters {
Piston *Piston;
Piston *piston;
CylinderHead *Head;
Fuel *Fuel;
Fuel *fuel;
Function *MeanPistonSpeedToTurbulence;

double StartingPressure;
Expand Down
8 changes: 4 additions & 4 deletions include/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

namespace constants {

extern constexpr double pi = 3.14159265359;
extern constexpr double R = 8.31446261815324;
extern constexpr double root_2 = 1.41421356237309504880168872420969807856967187537694807317667973799;
extern constexpr double e = 2.71828182845904523536028747135266249775724709369995;
static constexpr double pi = 3.14159265359;
static constexpr double R = 8.31446261815324;
static constexpr double root_2 = 1.41421356237309504880168872420969807856967187537694807317667973799;
static constexpr double e = 2.71828182845904523536028747135266249775724709369995;

} /* namespace Constants */

Expand Down
2 changes: 1 addition & 1 deletion include/convolution_filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class ConvolutionFilter : public Filter {

void initialize(int samples);
virtual float f(float sample) override;
virtual void destroy();
virtual void destroy() override;

int getSampleCount() const { return m_sampleCount; }
float *getImpulseResponse() { return m_impulseResponse; }
Expand Down
2 changes: 1 addition & 1 deletion include/cylinder_head.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class CylinderHead : public Part {
Function *ExhaustPortFlow;
Function *IntakePortFlow;

Valvetrain *Valvetrain;
Valvetrain *valvetrain;

double CombustionChamberVolume;

Expand Down
3 changes: 1 addition & 2 deletions dependencies/discord/Discord.h → include/discord.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

#include <string>
#include "discord_rpc.h"
#pragma comment(lib, "discord-rpc.lib")

class CDiscord
{
Expand Down Expand Up @@ -79,4 +78,4 @@ static CDiscord* GetDiscordManager()
};


#endif
#endif
6 changes: 6 additions & 0 deletions include/engine_sim_application.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ class EngineSimApplication {
dbasic::DeltaEngine m_engine;
dbasic::AssetManager m_assetManager;

dbasic::Path m_dataRoot;
dbasic::Path m_userData;
dbasic::Path m_outputPath;

std::string m_assetPath;

ysRenderTarget *m_mainRenderTarget;
Expand Down Expand Up @@ -184,6 +188,8 @@ class EngineSimApplication {
int m_oscillatorSampleOffset;
int m_screen;

struct LoggingErrorHandler *m_error_handler;

#ifdef ATG_ENGINE_SIM_VIDEO_CAPTURE
atg_dtv::Encoder m_encoder;
#endif /* ATG_ENGINE_SIM_VIDEO_CAPTURE */
Expand Down
2 changes: 1 addition & 1 deletion include/feedback_comb_filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class FeedbackCombFilter : public Filter {

void initialize(int M);
virtual float f(float sample) override;
virtual void destroy();
virtual void destroy() override;

float a_M;

Expand Down
1 change: 1 addition & 0 deletions include/gas_system.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
class GasSystem {
public:
struct Mix {
Mix() {} // Ctor must exist and can't be =default if used as an aggregate (= {})
double p_fuel = 0.0;
double p_inert = 1.0;
double p_o2 = 0.0;
Expand Down
4 changes: 2 additions & 2 deletions include/gauge.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ class Gauge : public UiElement {
float m_thetaMin;
float m_thetaMax;

int m_min;
int m_max;
float m_min;
float m_max;
int m_maxMinorTick;
float m_gamma;

Expand Down
5 changes: 5 additions & 0 deletions include/low_pass_filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@

#include "constants.h"

#ifndef _MSC_VER
// Trust in the compiler
#define __forceinline inline
#endif

class LowPassFilter : public Filter {
public:
LowPassFilter();
Expand Down
2 changes: 1 addition & 1 deletion include/ring_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class RingBuffer {
}

inline void overwrite(T_Data data, size_t index) {
if (start + index < m_capacity) {
if (m_start + index < m_capacity) {
m_buffer[m_start + index] = data;
}
else {
Expand Down
Loading