Template templates mostly. Value templates. They're pretty underdeveloped tbh.
Most of the things that make templates really powerful
You must be doing something really wrong if templates are what you're missing in C#, btw there's T4 templates if you REALLY need to generate code at compile time.
I hard switched to C# after 6 years of C++. 5 years of C# now. Templates is not something I miss. My opinion is probably biased, but holy shit does over engineering templates make your code untouchable by junior programmers.
If people want to actually produce video games then C++ template black magic is something that they should't do. Usually it's just for the sake of programming or over engineering a solution. Or creating game engines. In which you wouldn't use C# anyways.
If you're making an engine then you've made the right choice.
Why not?
Performance and full control over memory allocation and cleanup mostly. It can be micro optimized for specific purposes in contrast to C# where you trust it to do what you want it to do.
It really depends on what your task is. If it is to create an optimized engine for other people to use, then you'd want to write that part in C++ and rather expose functionality through managed C# dlls. Like Unity does.
If you're making a game in C# and what you are making is the "engine" part of your game, then C# is good enough. But if you're fighting the language and looking for deep low level features then maybe it's not the game you want to make.
One other pitfall of templates is probably compile times, especially if you're using them extensively. Debugging can become a nightmare too. C# templates are pretty simple, yes but for the most part get the job done. I'm not sure how useful value template parameters are in a language like C#.
I think you are underestimating the power and speed of modern C#. There's Xenko and it's written entirely in C#.
My view is mostly biased and based on old opinions so you're right. Modern C# is very fast.
I'd be lying if I said that templates didn't affect compile times, but ever since I began using precompiled headers it's not been enough of an issue for me to care about, even on my laptop.
I've put a preference querying system in my engine that uses the observer pattern to register listener/callback functions that get notified when a specific engine variable changes.
This really helped clean up and shorten a lot of my code, but it required writing the ugliest method I've ever written:
/** Attaches a callback method to be triggered when the supplied preference updates.
* @param targetKey the preference-ID to which this callback will be attached
* @param pointerID the pointer to the object owning the function. Used for sorting and removing the callback.
* @param observer the method to be triggered
* @param <Observer> the (auto-deduced) signature of the method */
template <typename Observer>
float const addPrefCallback(const Preference & targetKey, void * pointerID, Observer&& observer) {
m_callbacks.insert(pair<Preference, map<void*, function<void(float)>>>(targetKey, map<void*, function<void(float)>>()));
m_callbacks[targetKey].insert(std::pair<void*, function<void(float)>>(pointerID, function<void(float)>()));
m_callbacks[targetKey][pointerID] = std::forward<Observer>(observer);
}
// Private members
map<Preference, map<void*, function<void(float)>>> m_callbacks;
// Example usage
addPrefCallback(PreferenceState::C_SHADOW_QUALITY, this, [&](const float &f) {setShadowUpdateQuality(f); });
I don't really have anything to show for it, but I implemented flat buffers as an intermediary cache format to store preprocessed mesh and material data so mesh data can just be zooped into memory in one go with 0 safety checks of any kind once they've been loaded once (well, once for the current timestamp), resulting in load times being quartered.
I learned to create unit tests in Xunit and I feel like I've gained a superpower.
In other news, I have a conspiracy theory that Microsoft has crappy Azure API docs because they charge for support
I tried making a web API in Rust, with no knowledge of Rust whatsoever beforehand.
It took a lot of crying on different IRCs, asking people, a million compiles and a shitton of cursing.
It took me 42 hours. I made it with Rocket and Diesel
Another requirement was using S3, I used Overview · Rusoto
Almost finished with creating a pythonic abstraction of the LPD8 midi device:
https://www.youtube.com/watch?v=JIRJqUM2_1o
The main feature is that you can just attach callback functions to each pad and knob and don't have to worry about all the midi crap inbetween. With the 4 progams you get 4 sets of different knob mappings plus 4*3 mapping for the pads, as the pads can operate in three different modes (note, contro change, program change).
What kind of buffers are those, do you mean using vertex array objects coupled with vertex buffer objects?
He's probably referring to the usage of Google's flatbuffers library, which is an extremely memory-efficient way of storing data - and it can be loaded really quickly, too: https://github.com/google/flatbuffers
I don't completely understand why it works, but it effictively circumvent needing to abuse polymorphism and have a base observer class, using std::forward coupled with templates. And instead of using std::bind I just use lambda functions.
std::function is just an example of type erasure, under the hood it's still an indirection like a vtable but doesn't need inheritance (it's still polymorphism).
yeah I just dropped the std namespace in that example
I mean https://google.github.io/flatbuffers/
in which I'm storing all of the data that is then getting associated with VAOs (including values that were previously computed at load time, like tangents).
So, yes, I just wanted to make sure that it was clear what I was saying.
https://files.facepunch.com/forum/upload/133270/6fbe06e3-e54b-42db-b14a-039ffa2c9950/image.png
Lights! Camera! Action! Well, vertex lit action anyway. Also I'm not sure if those bottom 1/3rd triangles have incorrect normals or if that's just some other weird artifact.
Your normals are most likely off. I don't even bother with supplying them at all and straight up calculate them in the fragment shader. https://github.com/glslify/glsl-face-normal
Out of curiosity, why did you decide to do it this way?
I don't have to calculate normals or tangents on the CPU side at all, cuts off loading times. Especially if i have dynamic geometry like voxels or physical deformations. Another example is simple water deformation noise in the vertex shader. I don't have to bother with the normals at all.
https://files.facepunch.com/forum/upload/133270/78e33c8d-1c0c-4f4e-85ff-6ad5002e8a8d/image.png
Anti-spotlight. Exactly what I wanted.
Make sure that values that are supposed to be clamped between 0 and 1 are saturated properly
i added some slopes to my game
https://www.youtube.com/watch?v=jxp-XjgE_ak
and when you find a bug with their server-side, it's never fixed because they charge for support
Otherwise they just tell you to report it on their feedback page, with the 4000+ other items being tracked
Sorry, you need to Log In to post a reply to this thread.