-
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
third nene refactor (v0.3.0) #17
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The main changes are the usage of the newer module system, no more globals, and the usage of `Nene.instance()` instead of passing nene by argument. The math library also got split in different modules, but a Math wrapper is still provided. The core module is just `nene.init.nelua` file, not `nene.core.nelua` anymore, this means that `local Nene = require 'nene'` doesn't require all modules at once anymore, just the core. To require all nene at once, you should use `require 'nene.all'` module, however this isn't implemented for now. Another change is that checking or asserting ok status is now a requirement, this means that instead of `local tex = Texture.load'something.png'`, where the ok status is the second returned value, now you must do `local ok, tex = Texture.load'something.png'`. Please check the examples to see how nene should be used.
Note: however, it uses 'solid' instead of 'blended' by default
methods added: * get_glyph_metrics, from TTF_GlyphMetrics * get_height, from TTF_FontHeight * get_ascent, from TTF_FontAscent * get_descent, from TTF_FontDescent * get_line_skip, from TTF_FontLineSkip * get_text_dimensions, from TTF_SizeUTF8 * is_monospaced, from TTF_FontFaceIsFixedWidth Proper testing it's still to be added
Now both Rect and Vec2 are generics that accepts any arithmetic type, for example, now you can make a 2D vector using bytes like this: ```lua local Vec2n = require 'nene.math.vec2n' local Vec2i8 = Vec2n(int8) ``` For both `integer` and `number`, two aliases modules are provided for both rects and 2D vectors: * `nene.math.rect` for `RectN(integer)` * `nene.math.rectf` for `RectN(number)` * `nene.math.vec2` for `Vec2n(number)` * `nene.math.vec2i` for `Vec2n(integer)` So you can require them like that: ```lua local Vec2 = require 'nene.math.vec2' ``` If you prefer the Math module, you can still use it, since it's not removed and there is not much reason to remove it: ```lua local Math = require 'nene.math' local function x(v: Math.Vec2): Math.Rect -- ... impl ... end ```
The Audio module still exists though, now it's a init that wrap both modules
Seems that everything is setup and ready 👍 |
This was referenced Feb 19, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The main changes are the usage of the newer module system, no more
globals, and the usage of
Nene.instance()
instead of passing nene byargument.
The math library also got split in different modules, but a Math wrapper
is still provided.
The core module is just
nene.init.nelua
file, notnene.core.nelua
anymore, this means that
local Nene = require 'nene'
doesn't requireall modules at once anymore, just the core.
To require all nene at once, you should use
require 'nene.all'
module,however this isn't implemented for now.
Another change is that checking or asserting ok status is now a
requirement, this means that instead of
local tex = Texture.load'something.png'
, where the ok status is the second returnedvalue, now you must do
local ok, tex = Texture.load'something.png'
, note that the ok status is now the first returned value; This is true for other modules, not only Texture.Finally, any SDL data is considered a "raw data", which should always be got using the
get_raw()
method, this method checks if the value isn'tnilptr
.Please check the examples to see how nene should be used.
This is WIP, and still need to be reviewed.