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

Add hex-encoded version number to Engine singleton for easy comparisons #25971

Merged
merged 1 commit into from
Feb 18, 2019

Conversation

akien-mga
Copy link
Member

@akien-mga akien-mga commented Feb 17, 2019

This makes it easier to do engine versions comparison from code, e.g.:

# The API used below is only available starting with Godot 3.1
var version = Engine.get_version_info()
if version.major > 3 || (version.major == 3 && version.minor >= 1):
    # GLES2 renders a black screen if WorldEnvironment background mode is "Canvas"
    if OS.get_current_video_driver() == OS.VIDEO_DRIVER_GLES2:
        $WorldEnvironment.environment.background_mode = Environment.BG_CLEAR_COLOR

becomes:

if Engine.get_version_info().hex >= 0x030100:
    # GLES2 renders a black screen if WorldEnvironment background mode is "Canvas"
    if OS.get_current_video_driver() == OS.VIDEO_DRIVER_GLES2:
        $WorldEnvironment.environment.background_mode = Environment.BG_CLEAR_COLOR

The above example is not really useful right now since this hex key is not available in 3.0, but we need to introduce it at some point to be usable for comparison between future releases :)

From experience in Godot's codebase (e.g. checking GCC versions), the non-hex variant above is very error prone and hard to read, so the hex-based version number is quite convenient and something I've seen in various libraries (e.g. OGRE).

@akien-mga akien-mga added this to the 3.1 milestone Feb 17, 2019
@akien-mga akien-mga requested review from reduz and a team as code owners February 17, 2019 12:43
@aaronfranke
Copy link
Member

Ideally, this information should be included in projects as well. See also: #25497 and #25899

@akien-mga
Copy link
Member Author

Ideally, this information should be included in projects as well. See also: #25497 and #25899

That's the plan eventually (though it will be the version string, not the hex one).

@akien-mga akien-mga merged commit 7c8fbd8 into godotengine:master Feb 18, 2019
@akien-mga akien-mga deleted the version-hex branch February 18, 2019 12:51
@akien-mga
Copy link
Member Author

Now that Godot 3.1 has been released, we don't plan to cherry-pick new features and enhancements to the 3.0 branch, unless there is very strong support in favor of it. Removing cherrypick label for 3.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants