Permalink
Browse files

Added versioning info and checks for Godot 3.1

  • Loading branch information...
BastiaanOlij committed May 30, 2018
1 parent a789cce commit 7dc0c03fdd979121bf042f768261c9e89d9d71d2
View
@@ -5,6 +5,9 @@ This is a GDNative based plugin that adds OpenVR support to Godot.
The leading version of this repository now lives at:
https://github.com/GodotVR/godot_openvr
**note** The master on this repository is now kept in sync with the Godot master.
To build versions for official releases of Godot please check the branches that are named in sync with the Godot release.
Submodules
----------
This project references two submodules. If you do not already have these repositories downloaded somewhere you can execute:
@@ -14,8 +17,9 @@ git submodule update
```
To download the required versions.
Godot_headers is a git repository that keeps a copy of the headers needed for compiling GDNative modules. It ususally contains a copy of the latest official release of Godot and may be outdated.
You can use the switch headers to the location of more recent files which will be inside of your Godot source after compiling in the folder modules/gdnative/include.
Godot_headers is a git repository that keeps a copy of the headers needed for compiling GDNative modules. We try to keep the version of the files in sync with the version of Godot this branch relates.
If it is outdated you can use the switch headers to the location of more recent files which will be inside of your Godot source after compiling in the folder modules/gdnative/include.
OpenVR is a git repository maintained by Valve that contains the OpenVR SDK used to interact with the OpenVR/SteamVR platform.
Alternatively you can use the switch openvr or set the environment variable OPENVR_PATH to the location where you have downloaded a copy of this SDK.
@@ -72,6 +76,16 @@ I am not 100% sure this is a requirement as it automatically installs this when
For Windows you need to supply a copy of openvr_api.dll along with your executable which can be found in openvr/bin/win64
HDR support
-----------
OpenVR does not accept Godots HDR color buffer for rendering.
HDR support for the headset is currently being evaluated through PR:
https://github.com/godotengine/godot/pull/19724
This PR allows Godot to use full HDR rendering but has the last step in post processing do a conversion to RGBA8 which Godot does support.
If you are building Godot without this PR, you will have to turn HDR on your viewport off!
Using the main viewport
-----------------------
The ARVR server module requires a viewport to be configured as the ARVR viewport. If you chose to use the main viewport an aspect ratio corrected copy of the left eye will be rendered to the viewport automatically.
@@ -82,14 +96,14 @@ You will need to add the following code to a script on your root node:
var interface = ARVRServer.find_interface("OpenVR")
if interface and interface.initialize():
get_viewport().arvr = true
get_viewport().hdr = false
get_viewport().rgba8_out = true
```
Using a separate viewport
-------------------------
If you want control over the output on screen so you can show something independent on the desktop you can add a viewport to your scene.
Make sure that you turn the arvr property of this viewport to true and the HDR property to false. Also make sure that both the clear mode and update mode are set to always.
Make sure that you turn the arvr property of this viewport to true and the rgba8_out property to true. Also make sure that both the clear mode and update mode are set to always.
You can add a normal camera to your scene to render a spectator view or turn the main viewport into a 2D viewport and save some rendering overhead.
@@ -101,10 +115,6 @@ if interface:
interface.initialize()
```
HDR support
-----------
HDR support for the headset is currently not available. OpenVR does not accept Godots HDR color buffer for rendering. A solution is currently under review for Godot 3.1
License
-------
Note that the source in this repository is licensed by the MIT license model. This covers only the source code in this repository.
View
@@ -6,8 +6,11 @@ func _ready():
if arvr_interface and arvr_interface.initialize():
get_viewport().arvr = true
# workaround in OpenVR because OpenVR does not like our HDR buffers, so turn it off for now...
get_viewport().hdr = false
# If https://github.com/godotengine/godot/pull/19724 isn't applied:
# get_viewport().hdr = false
# If https://github.com/godotengine/godot/pull/19724 is applied:
get_viewport().rgba8_out = true
# just for testing, list what models are available
var ovr_model = preload("res://addons/godot-openvr/OpenVRRenderModel.gdns").new()
View
Binary file not shown.
View
@@ -470,6 +470,7 @@ void godot_arvr_destructor(void *p_data) {
};
const godot_arvr_interface_gdnative interface_struct = {
GODOTVR_API_MAJOR, GODOTVR_API_MINOR,
godot_arvr_constructor,
godot_arvr_destructor,
godot_arvr_get_name,
View
@@ -10,18 +10,4 @@
extern const godot_arvr_interface_gdnative interface_struct;
// declare our public functions for our ARVR Interface
#ifdef __cplusplus
extern "C" {
#endif
void GDN_EXPORT godot_openvr_gdnative_init(godot_gdnative_init_options *p_options);
void GDN_EXPORT godot_openvr_gdnative_terminate(godot_gdnative_terminate_options *p_options);
void GDN_EXPORT godot_openvr_gdnative_singleton();
void GDN_EXPORT godot_openvr_nativescript_init(void *p_handle);
#ifdef __cplusplus
}
#endif
#endif /* !OVR_ARVR_INTERFACE_H */
View
@@ -12,6 +12,39 @@ const godot_gdnative_core_api_struct *api = NULL;
const godot_gdnative_ext_arvr_api_struct *arvr_api = NULL;
const godot_gdnative_ext_nativescript_api_struct *nativescript_api = NULL;
void GDN_EXPORT godot_openvr_gdnative_init(godot_gdnative_init_options *p_options) {
// get our main API struct
api = p_options->api_struct;
// now find our arvr extension
for (int i = 0; i < api->num_extensions; i++) {
// todo: add version checks
switch (api->extensions[i]->type) {
case GDNATIVE_EXT_ARVR: {
if (api->extensions[i]->version.major > 1 || (api->extensions[i]->version.major == 1 && api->extensions[i]->version.minor >= 1)) {
arvr_api = (godot_gdnative_ext_arvr_api_struct *)api->extensions[i];
} else {
printf("ARVR API version %i.%i isn't supported, need version 1.1 or higher\n", api->extensions[i]->version.major, api->extensions[i]->version.minor);
}
}; break;
case GDNATIVE_EXT_NATIVESCRIPT: {
if (api->extensions[i]->version.major > 1 || (api->extensions[i]->version.major == 1 && api->extensions[i]->version.minor >= 0)) {
nativescript_api = (godot_gdnative_ext_nativescript_api_struct *)api->extensions[i];
} else {
printf("Native script API version %i.%i isn't supported, need version 1.1 or higher\n", api->extensions[i]->version.major, api->extensions[i]->version.minor);
}
}; break;
default: break;
};
};
}
void GDN_EXPORT godot_openvr_gdnative_terminate(godot_gdnative_terminate_options *p_options) {
api = NULL;
nativescript_api = NULL;
arvr_api = NULL;
}
int64_t ___godot_icall_int(godot_method_bind *mb, godot_object *inst) {
int64_t ret;
const void *args[1] = {
View
@@ -66,6 +66,9 @@ extern const godot_gdnative_ext_nativescript_api_struct *nativescript_api;
extern "C" {
#endif
void GDN_EXPORT godot_openvr_gdnative_init(godot_gdnative_init_options *p_options);
void GDN_EXPORT godot_openvr_gdnative_terminate(godot_gdnative_terminate_options *p_options);
int64_t ___godot_icall_int(godot_method_bind *mb, godot_object *inst);
void ___godot_icall_void_int(godot_method_bind *mb, godot_object *inst, const int arg0);
void ___godot_icall_void_int_Array_Array_int(godot_method_bind *mb, godot_object *inst, const int arg0, const godot_array& arg1, const godot_array& arg2, const int arg3);
View
@@ -10,37 +10,17 @@
#include "godot_openvr.h"
////////////////////////////////////////////////////////////////////////
// gdnative init
void GDN_EXPORT godot_openvr_gdnative_init(godot_gdnative_init_options *p_options) {
// get our main API struct
api = p_options->api_struct;
// now find our arvr extension
for (int i = 0; i < api->num_extensions; i++) {
// todo: add version checks
switch (api->extensions[i]->type) {
case GDNATIVE_EXT_ARVR: {
arvr_api = (godot_gdnative_ext_arvr_api_struct *)api->extensions[i];
}; break;
case GDNATIVE_EXT_NATIVESCRIPT: {
nativescript_api = (godot_gdnative_ext_nativescript_api_struct *)api->extensions[i];
}; break;
default: break;
};
};
}
void GDN_EXPORT godot_openvr_gdnative_terminate(godot_gdnative_terminate_options *p_options) {
api = NULL;
}
void GDN_EXPORT godot_openvr_gdnative_singleton() {
arvr_api->godot_arvr_register_interface(&interface_struct);
if (arvr_api != NULL) {
arvr_api->godot_arvr_register_interface(&interface_struct);
}
}
void GDN_EXPORT godot_openvr_nativescript_init(void *p_handle) {
if (nativescript_api == NULL) {
return;
}
{
godot_instance_create_func create = { NULL, NULL, NULL };
create.create_func = &openvr_render_model_constructor;
View
@@ -13,4 +13,15 @@
#include "ARVRInterface.h"
#include "OVRRenderModel.h"
#ifdef __cplusplus
extern "C" {
#endif
void GDN_EXPORT godot_openvr_gdnative_singleton();
void GDN_EXPORT godot_openvr_nativescript_init(void *p_handle);
#ifdef __cplusplus
}
#endif
#endif /* !GODOT_OPENVR_H */

0 comments on commit 7dc0c03

Please sign in to comment.