summaryrefslogtreecommitdiff
path: root/external/libgltf/patches/init_scene_set_handle.patch
blob: 88ad05325cf336c17344ac4f86c524a064dddbb7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
diff -ur libgltf.org/src/LoadScene.cpp libgltf/src/LoadScene.cpp
--- libgltf.org/src/LoadScene.cpp	2014-06-23 14:55:58.099723870 +0200
+++ libgltf/src/LoadScene.cpp	2014-06-23 14:56:04.399723599 +0200
@@ -149,10 +149,14 @@
     return true;
 }
 
-int Parser::parseScene(Scene* pscene)
+void Parser::setScene(Scene* pscene)
+{
+    pScene = pscene;
+}
+
+int Parser::parseScene()
 {
     int status;
-    this->pScene = pscene;
 
     status = this->readBuffers();
     if (status < 0)
diff -ur libgltf.org/src/LoadScene.h libgltf/src/LoadScene.h
--- libgltf.org/src/LoadScene.h	2014-06-23 14:55:58.079723871 +0200
+++ libgltf/src/LoadScene.h	2014-06-23 14:56:37.303722182 +0200
@@ -21,7 +21,8 @@
 public:
     glTFHandle* getFileNameInJson(const std::string& jsonFile);
     bool releaseFileName();
-    int parseScene(Scene* pscene);
+    void setScene(Scene* pscene);
+    int parseScene();
     bool parseJsonFile();
     void setJsonInfo(const std::string& sbuffer);
     void setJsonInfo(const std::string& direct, const std::string& fileName);
diff -ur libgltf.org/src/RenderScene.cpp libgltf/src/RenderScene.cpp
--- libgltf.org/src/RenderScene.cpp	2014-06-23 14:55:58.099723870 +0200
+++ libgltf/src/RenderScene.cpp	2014-06-23 14:56:07.239723477 +0200
@@ -657,16 +657,15 @@
     {
         return LIBGLTF_PARSE_JSON_ERROR;
     }
-    int iStatus = mLoadJson.parseScene(&scene);
+    int iStatus = mLoadJson.parseScene();
     return iStatus;
 }
 
 int RenderScene::loadScene(Scene& scene, glTFHandle* handle)
 {
-    scene.setGltfHandle(handle);
     try
     {
-        int iStatus = mLoadJson.parseScene(&scene);
+        int iStatus = mLoadJson.parseScene();
         return iStatus;
     }
     catch (boost::property_tree::ptree_error& e)
@@ -694,7 +693,11 @@
         return 0;
     }
     string tmpFileName(jsonfile->filename);
-    return mLoadJson.getFileNameInJson(tmpFileName);
+    glTFHandle* handle = mLoadJson.getFileNameInJson(tmpFileName);
+    pScene = new Scene();
+    pScene->setGltfHandle(handle);
+    mLoadJson.setScene(pScene);
+    return handle;
 }
 
 unsigned int RenderScene::bindAttribute(const Attribute* pAttr)
@@ -969,11 +972,6 @@
 {
     initOpengl();
 
-    pScene = new Scene();
-    if (0 == pScene)
-    {
-        return LIBGLTF_MEMORY_ERROR;
-    }
     int iResult = loadScene(*pScene, handle);
     if (iResult != LIBGLTF_SUCCESS)
     {