summaryrefslogtreecommitdiff
path: root/scene/main
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2017-12-04 15:55:20 -0300
committerJuan Linietsky <reduzio@gmail.com>2017-12-04 15:56:17 -0300
commitd438ac0aeda8509e5961296a5950c2755ba8a966 (patch)
tree51c3276112e016f544cc2822d99049bd82f02a24 /scene/main
parentfaaa012b843466805a41f90edf69442c69a3aeea (diff)
-Implemented Proxy Textures (needed to solve the problem with ViewportTexture)
-Properly use hierarchy to initialize resources local to scene (solves problem of GUI in 3D)
Diffstat (limited to 'scene/main')
-rw-r--r--scene/main/viewport.cpp10
-rw-r--r--scene/main/viewport.h2
2 files changed, 10 insertions, 2 deletions
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp
index 1fc2d4b16e..d864b0f763 100644
--- a/scene/main/viewport.cpp
+++ b/scene/main/viewport.cpp
@@ -69,6 +69,8 @@ void ViewportTexture::setup_local_to_scene() {
ERR_FAIL_COND(!vp);
vp->viewport_textures.insert(this);
+
+ VS::get_singleton()->texture_set_proxy(proxy, vp->texture_rid);
}
void ViewportTexture::set_viewport_path_in_scene(const NodePath &p_path) {
@@ -105,8 +107,8 @@ Size2 ViewportTexture::get_size() const {
}
RID ViewportTexture::get_rid() const {
- ERR_FAIL_COND_V(!vp, RID());
- return vp->texture_rid;
+ //ERR_FAIL_COND_V(!vp, RID());
+ return proxy;
}
bool ViewportTexture::has_alpha() const {
@@ -147,6 +149,7 @@ ViewportTexture::ViewportTexture() {
vp = NULL;
set_local_to_scene(true);
+ proxy = VS::get_singleton()->texture_create();
}
ViewportTexture::~ViewportTexture() {
@@ -154,6 +157,8 @@ ViewportTexture::~ViewportTexture() {
if (vp) {
vp->viewport_textures.erase(this);
}
+
+ VS::get_singleton()->free(proxy);
}
/////////////////////////////////////
@@ -2813,6 +2818,7 @@ Viewport::Viewport() {
default_texture.instance();
default_texture->vp = const_cast<Viewport *>(this);
viewport_textures.insert(default_texture.ptr());
+ VS::get_singleton()->texture_set_proxy(default_texture->proxy, texture_rid);
//internal_listener = SpatialSoundServer::get_singleton()->listener_create();
audio_listener = false;
diff --git a/scene/main/viewport.h b/scene/main/viewport.h
index 6bbd4b26b5..0835e3f69a 100644
--- a/scene/main/viewport.h
+++ b/scene/main/viewport.h
@@ -59,6 +59,8 @@ class ViewportTexture : public Texture {
friend class Viewport;
Viewport *vp;
+ RID proxy;
+
protected:
static void _bind_methods();