-
Notifications
You must be signed in to change notification settings - Fork 0
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
Extension and Capabilities Querying System #17
Comments
As you have already implemented this in TS, could you Clone && make the changes in engine.js && push? After all, GitHub allows for multiple people changing code 😄 |
A big reason I don't push here that often is that I can't check that my changes actually work in jsdoc. I can't run Node.js on my dev machine since its V8 conflicts with TS's. I'll write it up, though. Or at least attempt to :) |
Oh no biggie. Not all of my code works well either. So just edit it, and I'll fix it up later :) |
I'm not sure I like the underscores in the extension names. In minisphere I implemented
And so forth. Using dashes makes names easier to type and less error prone as you don't have to reach for the shift key while typing out extensions. |
I suggested underscores for two reasons:
|
Is there any benefit to allowing them to be used as identifier names, though? In JavaScript you have the index syntax |
I originally planned on implementing any extension in JS within an object of that name. Another way to check for an extension would be
I personally don't have too strong a preference, but I don't really think using a dash is less error prone. I do find underscores a bit easier to read, though. ...cool bikeshed, btw :) |
Bikeshed...? Huh? Ugh, extensions as global objects... I'm glad you didn't implement that idea. :P It's so much nicer to just call var extensions = typeof GetExtensions !== 'undefined' ? GetExtensions() : [ 'sphere-legacy-api' ];
var q = Link(extensions);
var isSupportedEngine = GetVersion() >= 1.5
&& q.contains('sphere-legacy-api')
&& q.contains('sphere-obj-constructors')
&& q.contains('sphere-obj-props')
&& q.contains('sphere-galileo')
&& q.contains('sphere-new-sockets')
&& q.contains('set-script-function');
if (!isSupportedEngine) {
Abort("This engine is not supported.\n");
} I could indeed refactor that to use the |
The extensions as global objects would solely have been for the implementation. However, this is not really useful anymore since all functionality has proper namespaces anyway.
Dashes or underscores is such a tiny detail. It's a bikeshed problem (what color do we paint the bikeshed?). |
Bikeshed problem or not, we're trying to design a unified standard here, so we do have to end up coming to an agreement one way or the other. 😅 |
Getting away from splitting hairs: I propose we standardize See, because here's what I'm thinking: We can standardize the API all we want, but realistically there are always going to be discrepancies due to bugs, subtle behavior differences not covered by the spec, etc. So this way, a game can simply query |
I think that is fine, but using arrays seems error prone, as the order of extensions is not predefined. If there is a, b and c, c is [2]. If b is missing, c becomes [1]. Why not use an object with keys being the ext names? Then a ['myext'] does the job. For namespacing the low level functions: do it. You should minimize the number of global functions. The module system provides a context for every file (bot sure how far i got with the module system), and it will need to provide every global object you need in a file. This will only be like 4 or 5 standard items, one being 'sphere'.
|
I know that. I'd expect most people would use either I don't see that the order of the rest of the extensions being variable is an issue; anyone checking for a specific extension at, say, As for the namespacing, I still have an issue with it. I despise it for the same reason I despise C++ putting the entire standard library in the |
As I experiment with the CommonJS module system more, I'm beginning to feel like a global extension registry is unnecessary and maybe even counterproductive. If you try to In the end the engine should merely be a facilitator, not an |
The point of the extension system was mainly to explicitly state certain features of the environment, not to force plugins or modules to register. It was more intended to allow different implementations some leeway in how they implemented certain features, and to allow features to easily be optional on other platforms, but defining the bare minimum as the standard and optional features as extensions. For instance, one implementation might support loading an Image straight from a filename, while another might require a Surface intermediate. Or it would allow you to query which version of GLSL, HLSL, or some other shader language was available. |
Okay, that makes more sense then. Some optional functionality can only be provided by the implementation, or may not even have an API attached to it (like the |
What Martin says is correct, that is indeed how we designed the extension system, purely for the implementation of the game system. The module system is for libraries such as Bluebird or Link. (Speaking ofbluebird, is everything asynchronous yet? We should use promises!!!!)
|
Ugh, no. minisphere includes promises - see the miniRT/pacts module. But there are no asynchronous APIs other than the Async() function to dispatch scripts to run in the next cycle. I'm not a big fan of async-everywhere systems. The one time I tried to write something using node.js I ended up wanting to kill someone. Granted a lot of that has to do with JS syntax - if JS had something like C# async/await and events I think I might enjoy it more. That said, async code can be a nightmare to debug, and I don't think it buys us anything in a game engine regardless. |
I just want to try it out. Just make some code and see what happens. I am mostly concerned about file reads and write. Things that really block. The rest of the stuff should be near-real time, because it is a game engine. IF we do Async for stuff like files, I would suggest it uses Promises. |
This feature is implemented in minisphere 4.0 as // writing save file
if (system.extensions.sphere_stateful_rng) {
// save RNG state in save file
} I went with a somewhat simpler naming convention than described above of |
minisphere 4.1 advertises the following extensions:
|
Question: Do we want all core features to have their own extension, e.g.:
Or would it be better to define a core set of functionality and then only optional features get an extension string? |
I suggest a system be put in place that allows scripts to query the capabilities and extensions available from the engine they are running under.
This would be exposed as a function, for instance
sphere.getExtensions()
, that returns and array of strings which describe the capabilities of the engine. I propose the following structure for the capabilities strings:sphere_[authority]_[description]
The
authority
part of the string is similar to ARB/EXT/NV/ATI/AMD in OpenGL capabilities strings, and represents what level of support this capability has. It would be omitted in full engine support (for instance, it's not engine-dependant per se to support MIDI files, but not all engines may do so), while engine-dependant functionality will have the engine's prefix as the authority (for instance, TurboSphere supports true-type fonts, while it is unlikely this will ever be a full API requirement,and so it would be under
ts
authority).Legacy function from the older engine could also be specified with this, perhaps with the authority
legacy
.For example:
sphere_midi_sound_object
sphere_array_buffers
sphere_legacy_complex_primitive
sphere_legacy_direct_surface_blit
sphere_ts_ttf_font_object
sphere_ts_external_soundfont
sphere_amd_bonjour_networking
This would put codified names to abilities that are optional to an engine, as well as allow non-standard extensions to be easily tested for.
If we are going to have more than a single, unified engine, having the ability to ask about the engine (beyond just what its version number is) is important. It also helps quite a bit for plugin-based engines, where even knowing all the intricacies of the engine's version tells you very little about what is available.
The core, required engine capabilities can still be queried with the equivalent of GetVersion(), which really should be (at this point) returning the API version rather than a true engine version number.
The text was updated successfully, but these errors were encountered: