Spleesh said:
These interfaces are not exactly going to be necessarily easy to use though. For instance my logger class uses templates to make some logger::log executions get (mostly) compiled out. So, if you define TOAST_RELEASE the function body is empty for logger::log() calls (but not FATAL and such). I can understand that is annoying syntax for some people, but I like how its both typesafe (unlike macro functions), and allows me to drastically change the program with a single line (i.e. TOAST_RELEASE).
We're doing something similar for logging and profiling our code. I described it ind etail some time ago in this post https://gamedev.net/forums/topic/710402-looking-for-recommendations-on-profiling-tools/5440829/
Spleesh said:
What I'm working on now is essentially wrapping platform specifics in one set of procedures so games don't have to be made explicitly multiplatform (who likes having the #ifdef _WIN32 … all through their code)
We have a couple of compiler/platform specific headers which are used by our wrapper classes. The “System” namespace contains everything platform specific and we can extend that by simply adding more packages to it. This is due to how our build tool manages those packages, paths are added to the project/compilation for each package root directory. Then we have a convention of naming code files, for example maht is placed in a Math package and a Math subdirectory. This leads to unified include paths like
#include <Common/Array.h>
#include <Math/Vector3.h>
...
… eh, ah, so we defined a unified interface to cover common parameter pairs in our system headers and implemented those in the corresponding code files. I did some reasearch and finally got everything to only include that parts of the OS which are really needed, that's why our code looks somehow weird at some places and we have declared our own windows types and alias structs for example. The benefits are that we don't polute our code base with windows header stuff except for what we really need.
Spleesh said:
I did the logger code in a class because OOP allows for easier maintainability etc. but i don't see how the platform code could be efficiently wrapped in a class so I'm using a namespace.
This may be true but we ended up with more static functions which look like classes than really OOP based code. You're free to declare global static functions in C++ which isn't possible in for example C# or Java, that's a benefit ?
namespace Log
{
api void Write(const char*);
}
leads for example to a call like
Log::Write("Hello World");
Spleesh said:
and then I can inherit from it but that's only an intermediate version since inheritance tends to have some unwanted
I don't see a reason to strictly use OOP, add a macro and then have people write their own game loop is absolutely fine. I took this idea from Urho3D
// Define a platform-specific main function, which in turn executes the user-defined function
// MSVC debug mode: use memory leak reporting
#if defined(_MSC_VER) && defined(_DEBUG) && !defined(URHO3D_WIN32_CONSOLE)
#define URHO3D_DEFINE_MAIN(function) \
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE prevInstance, PSTR cmdLine, int showCmd) \
{ \
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); \
Urho3D::ParseArguments(GetCommandLineW()); \
return function; \
}
// MSVC release mode: write minidump on crash
#elif defined(_MSC_VER) && defined(URHO3D_MINIDUMPS) && !defined(URHO3D_WIN32_CONSOLE)
#define URHO3D_DEFINE_MAIN(function) \
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE prevInstance, PSTR cmdLine, int showCmd) \
{ \
Urho3D::ParseArguments(GetCommandLineW()); \
int exitCode; \
__try \
{ \
exitCode = function; \
} \
__except(Urho3D::WriteMiniDump("Urho3D", GetExceptionInformation())) \
{ \
} \
return exitCode; \
}
// Other Win32 or minidumps disabled: just execute the function
#elif defined(_WIN32) && !defined(URHO3D_WIN32_CONSOLE)
#define URHO3D_DEFINE_MAIN(function) \
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE prevInstance, PSTR cmdLine, int showCmd) \
{ \
Urho3D::ParseArguments(GetCommandLineW()); \
return function; \
}
// Android or iOS or tvOS: use SDL_main
#elif defined(__ANDROID__) || defined(IOS) || defined(TVOS)
#define URHO3D_DEFINE_MAIN(function) \
extern "C" __attribute__((visibility("default"))) int SDL_main(int argc, char** argv); \
int SDL_main(int argc, char** argv) \
{ \
Urho3D::ParseArguments(argc, argv); \
return function; \
}
// Linux or OS X: use main
#else
#define URHO3D_DEFINE_MAIN(function) \
int main(int argc, char** argv) \
{ \
Urho3D::ParseArguments(argc, argv); \
return function; \
}
#endif
Spleesh said:
to create an editor that would be a mildly scaled down version of hammer or some other primative editor (using xml or json files to manage level formats).
As you might already know, I prefer C# for the tooling and so for the Editor as well. We're currently working on our own C# graphics API which will drive all our graphical tools. We'll then pass a handle to the C++ Engine code which the engine performs off-screen rendering into. That handle is pointing to C# managed byte[] memory which got pinned to the CLR (so it is never changed and could be exchanged to C++) and then put into a Bitmap object, so the engine renders everything into that array buffer, which is held from a C# Bitmap and finally copied to the screen using GDI+ on Windows and Linux as well.
It has some advantages, first and foremost the memory management is done by .NET except for engine specific stuff and debugging the editor will be easier. On the other hand we could also use the entire environment we already have for plugins and a ton of utility code, for example our Swarm package to achieve network wide cooperative development on a virtual file system.
Spleesh said:
I intend to do some more reading before I make decisions about it - but bullet still looks like a good option. I've been reading through the bullet source code to get a better idea as well.
Physics as well as graphics isn't essential to me so counts to the final things to be implemented at all. I guess we'll use a thirdparty physics solution as well (at least for now)