dmuratshin 9 years ago
parent
commit
bf45343172

+ 1 - 1
oxygine/src/MaskedRenderer.cpp

@@ -5,7 +5,7 @@
 
 namespace oxygine
 {
-    MaskedRenderer::MaskedRenderer(spNativeTexture mask, const RectF& srcRect, const RectF& destRect, const Transform& t, bool channelR, IVideoDriver *driver) : STDRenderer(driver), _mask(mask)
+    MaskedRenderer::MaskedRenderer(spNativeTexture mask, const RectF& srcRect, const RectF& destRect, const Transform& t, bool channelR, IVideoDriver* driver) : STDRenderer(driver), _mask(mask)
     {
         _clipUV = ClipUV(
                       t.transform(destRect.getLeftTop()),

+ 1 - 1
oxygine/src/MaskedRenderer.h

@@ -72,7 +72,7 @@ namespace oxygine
     class MaskedRenderer : public STDRenderer
     {
     public:
-        MaskedRenderer(spNativeTexture mask, const RectF& srcRect, const RectF& destRect, const Transform& t, bool channelR, IVideoDriver *);
+        MaskedRenderer(spNativeTexture mask, const RectF& srcRect, const RectF& destRect, const Transform& t, bool channelR, IVideoDriver*);
 
         //void draw(const RState *rs, const RectF &destRect) OVERRIDE;
 

+ 7 - 0
oxygine/src/Stage.cpp

@@ -50,6 +50,13 @@ namespace oxygine
             return _window;
         return core::getWindow();
     }
+
+    Stage* Stage::getStageFromWindow(SDL_Window* wnd)
+    {
+        void* data = SDL_GetWindowData(wnd, "_");
+        return (Stage*)data;
+    }
+
 #endif
 
     Stage::~Stage()

+ 1 - 0
oxygine/src/Stage.h

@@ -51,6 +51,7 @@ namespace oxygine
 #if OXYGINE_SDL
         void associateWithWindow(SDL_Window* wnd);
         SDL_Window* getAssociatedWindow() const;
+        static Stage* getStageFromWindow(SDL_Window* wnd);
 #endif
 
     protected:

+ 1 - 1
oxygine/src/Tween.cpp

@@ -98,7 +98,7 @@ namespace oxygine
         if (_status >= status_done)
             return;
 
-        OX_ASSERT(_client);
+        //OX_ASSERT(_client);
 
 		if (!_client)
 			return;

+ 20 - 12
oxygine/src/core/oxygine.cpp

@@ -606,17 +606,25 @@ namespace oxygine
 #ifdef __S3E__
 #elif OXYGINE_EDITOR
 #else
+        spStage getStageByWindow(Uint32 windowID)
+        {
+            SDL_Window* wnd = SDL_GetWindowFromID(windowID);
+            if (!wnd)
+                return getStage();
+
+            spStage stage = Stage::getStageFromWindow(wnd);
+            if (!stage)
+                return getStage();
+
+            return stage;
+        }
+
         void SDL_handleEvent(SDL_Event& event, bool& done)
         {
             Input* input = &Input::instance;
 
 
-            SDL_Window* wnd = SDL_GetWindowFromID(event.window.windowID);
-            void* data = SDL_GetWindowData(wnd, "_");
-            spStage stage = (Stage*)data;
 
-            if (!stage)
-                stage = getStage();
 
             Event ev(EVENT_SYSTEM);
             ev.userData = &event;
@@ -676,22 +684,22 @@ namespace oxygine
                         break;
                     }
                     case SDL_MOUSEWHEEL:
-                        input->sendPointerWheelEvent(stage, event.wheel.y, &input->_pointerMouse);
+                        input->sendPointerWheelEvent(getStageByWindow(event.window.windowID), event.wheel.y, &input->_pointerMouse);
                         break;
                     case SDL_KEYDOWN:
                     {
                         KeyEvent ev(KeyEvent::KEY_DOWN, &event.key);
-                        stage->dispatchEvent(&ev);
+                        getStageByWindow(event.window.windowID)->dispatchEvent(&ev);
                     } break;
                     case SDL_KEYUP:
                     {
                         KeyEvent ev(KeyEvent::KEY_UP, &event.key);
-                        stage->dispatchEvent(&ev);
+                        getStageByWindow(event.window.windowID)->dispatchEvent(&ev);
                     } break;
 
                     case SDL_MOUSEMOTION:
                         if (!_useTouchAPI)
-                            input->sendPointerMotionEvent(stage, (float)event.motion.x, (float)event.motion.y, 1.0f, &input->_pointerMouse);
+                            input->sendPointerMotionEvent(getStageByWindow(event.window.windowID), (float)event.motion.x, (float)event.motion.y, 1.0f, &input->_pointerMouse);
                         break;
                     case SDL_MOUSEBUTTONDOWN:
                     case SDL_MOUSEBUTTONUP:
@@ -706,7 +714,7 @@ namespace oxygine
                                 case 3: b = MouseButton_Right; break;
                             }
 
-                            input->sendPointerButtonEvent(stage, b, (float)event.button.x, (float)event.button.y, 1.0f,
+                            input->sendPointerButtonEvent(getStageByWindow(event.window.windowID), b, (float)event.button.x, (float)event.button.y, 1.0f,
                                                           event.type == SDL_MOUSEBUTTONDOWN ? TouchEvent::TOUCH_DOWN : TouchEvent::TOUCH_UP, &input->_pointerMouse);
                         }
                     }
@@ -719,7 +727,7 @@ namespace oxygine
                             Vector2 pos = convertTouch(event);
                             PointerState* ps = input->getTouchByID((int64_t)event.tfinger.fingerId);
                             if (ps)
-                                input->sendPointerMotionEvent(stage,
+                                input->sendPointerMotionEvent(getStageByWindow(event.window.windowID),
                                                               pos.x, pos.y, event.tfinger.pressure, ps);
                         }
                     }
@@ -734,7 +742,7 @@ namespace oxygine
                             Vector2 pos = convertTouch(event);
                             PointerState* ps = input->getTouchByID((int64_t)event.tfinger.fingerId);
                             if (ps)
-                                input->sendPointerButtonEvent(stage,
+                                input->sendPointerButtonEvent(getStageByWindow(event.window.windowID),
                                                               MouseButton_Touch,
                                                               pos.x, pos.y, event.tfinger.pressure,
                                                               event.type == SDL_FINGERDOWN ? TouchEvent::TOUCH_DOWN : TouchEvent::TOUCH_UP,

+ 5 - 3
oxygine/src/dev_tools/TreeInspectorLine.cpp

@@ -32,7 +32,7 @@ namespace oxygine
         addChild(_item);
 
         _itemTree = new TreeInspectorPreview();
-        _itemTree->init(item, getStage()->getSize()/2, true);
+        _itemTree->init(item, getStage()->getSize() / 2, true);
 
 
         spTextField tb = new TextField();
@@ -68,13 +68,15 @@ namespace oxygine
         Vector2 sz = TreeInspector::calcBounds(this).size;
         setSize(sz);
 
-        addTouchDownListener([=](Event*) {
+        addTouchDownListener([ = ](Event*)
+        {
             _itemTree->setPriority(_stage->getLastChild()->getPriority());
             _itemTree->setPosition(getStage()->getSize() / 4);
             _stage->addChild(_itemTree);
         });
 
-        addTouchUpListener([=](Event*) {
+        addTouchUpListener([ = ](Event*)
+        {
             _itemTree->detach();
         });
     }

+ 28 - 28
oxygine/src/dev_tools/TreeInspectorPreview.cpp

@@ -11,7 +11,7 @@
 
 namespace oxygine
 {
-    
+
 
     Vector2 fitSize(const Vector2& destSize, const Vector2& src)
     {
@@ -64,7 +64,7 @@ namespace oxygine
 
         _render2cache = true;
 
-        VideoDriverCache &cache = _videoCache;
+        VideoDriverCache& cache = _videoCache;
 
         STDRenderer renderer(&cache);
         renderer.setViewProjTransform(STDRenderer::instance->getViewProjection());
@@ -77,7 +77,7 @@ namespace oxygine
         renderer.begin(0);
         if (child)
         {
-            STDMaterial *originalMat = STDMaterial::instance;
+            STDMaterial* originalMat = STDMaterial::instance;
 
             STDMaterial::instance = &mat;
 
@@ -230,12 +230,12 @@ namespace oxygine
         current().states[state] = value;
     }
 
-    void VideoDriverCache::addUni(const char *id, cached_batch::uni::type tp, const void* ptr, int sz)
+    void VideoDriverCache::addUni(const char* id, cached_batch::uni::type tp, const void* ptr, int sz)
     {
         cached_batch::uni uni;
         uni.id = id;
         uni.tp = tp;
-        const unsigned char *data = (const unsigned char*)ptr;
+        const unsigned char* data = (const unsigned char*)ptr;
         uni.data.assign(data, data + sz);
         current().uniforms.push_back(uni);
     }
@@ -299,7 +299,7 @@ namespace oxygine
         vertexPCT2* v = (vertexPCT2*)(&current().vertices.front());
 
         size_t num = current().vertices.size() / current().vdecl->size;
-        
+
 
         for (size_t i = 0; i != num; ++i)
         {
@@ -316,7 +316,7 @@ namespace oxygine
 
 
         _batches.push_back(cached_batch());
-        cached_batch &b = _batches.back();
+        cached_batch& b = _batches.back();
         b = _batches[_batches.size() - 2];
         b.indices.clear();
         b.vertices.clear();
@@ -389,28 +389,28 @@ namespace oxygine
             //if(0)
             for (size_t i = 0; i < b.uniforms.size(); ++i)
             {
-                const cached_batch::uni &uni = b.uniforms[i];
+                const cached_batch::uni& uni = b.uniforms[i];
                 switch (uni.tp)
                 {
-                case cached_batch::uni::uni_float:
-                    instance->setUniform(uni.id.c_str(), *((const float*)&uni.data[0])); break;
-                case cached_batch::uni::uni_int:
-                    instance->setUniformInt(uni.id.c_str(), *((const int*)&uni.data[0])); break;
-                case cached_batch::uni::uni_matrix:
-                {
-                    Matrix m = STDRenderer::instance->getViewProjection();
-                    //instance->setUniform(uni.id.c_str(), ((const Matrix*)&uni.data[0])); 
-                    instance->setUniform(uni.id.c_str(), &m);
-                    break;
-                }
-                case cached_batch::uni::uni_vec2:
-                    instance->setUniform(uni.id.c_str(), ((const Vector2*)&uni.data[0]), uni.data.size() / sizeof(Vector2)); break;
-                case cached_batch::uni::uni_vec3:
-                    instance->setUniform(uni.id.c_str(), ((const Vector3*)&uni.data[0]), uni.data.size() / sizeof(Vector3)); break;
-                case cached_batch::uni::uni_vec4:
-                    instance->setUniform(uni.id.c_str(), ((const Vector4*)&uni.data[0]), uni.data.size() / sizeof(Vector4)); break;
-                default:
-                    break;
+                    case cached_batch::uni::uni_float:
+                        instance->setUniform(uni.id.c_str(), *((const float*)&uni.data[0])); break;
+                    case cached_batch::uni::uni_int:
+                        instance->setUniformInt(uni.id.c_str(), *((const int*)&uni.data[0])); break;
+                    case cached_batch::uni::uni_matrix:
+                    {
+                        Matrix m = STDRenderer::instance->getViewProjection();
+                        //instance->setUniform(uni.id.c_str(), ((const Matrix*)&uni.data[0]));
+                        instance->setUniform(uni.id.c_str(), &m);
+                        break;
+                    }
+                    case cached_batch::uni::uni_vec2:
+                        instance->setUniform(uni.id.c_str(), ((const Vector2*)&uni.data[0]), uni.data.size() / sizeof(Vector2)); break;
+                    case cached_batch::uni::uni_vec3:
+                        instance->setUniform(uni.id.c_str(), ((const Vector3*)&uni.data[0]), uni.data.size() / sizeof(Vector3)); break;
+                    case cached_batch::uni::uni_vec4:
+                        instance->setUniform(uni.id.c_str(), ((const Vector4*)&uni.data[0]), uni.data.size() / sizeof(Vector4)); break;
+                    default:
+                        break;
                 }
             }
 
@@ -439,7 +439,7 @@ namespace oxygine
 
             size_t num = b.vertices.size() / b.vdecl->size;
 
-            std::vector<char> &modified = b.vertices;
+            std::vector<char>& modified = b.vertices;
             //if (0)
             for (size_t i = 0; i != num; ++i)
             {

+ 2 - 2
oxygine/src/dev_tools/TreeInspectorPreview.h

@@ -37,7 +37,7 @@ namespace oxygine
             PRIMITIVE_TYPE pt;
             std::vector<char> vertices;
             std::vector<unsigned short> indices;
-            
+
             struct uni
             {
                 std::string id;
@@ -87,7 +87,7 @@ namespace oxygine
 
         void setState(STATE state, unsigned int value);
 
-        void addUni(const char *id, cached_batch::uni::type tp, const void* ptr, int sz);
+        void addUni(const char* id, cached_batch::uni::type tp, const void* ptr, int sz);
 
         void setUniformInt(const char* id, int v);
 

+ 8 - 8
oxygine/src/math/Rect.h

@@ -20,19 +20,19 @@ namespace oxygine
         static const RectT invalidated()
         {
             return RectT(
-                std::numeric_limits<T>::max() / 2,
-                std::numeric_limits<T>::max() / 2,
-                -std::numeric_limits<T>::max(),
-                -std::numeric_limits<T>::max());
+                       std::numeric_limits<T>::max() / 2,
+                       std::numeric_limits<T>::max() / 2,
+                       -std::numeric_limits<T>::max(),
+                       -std::numeric_limits<T>::max());
         }
 
         static const RectT huge()
         {
             return RectT(
-                -std::numeric_limits<T>::max() / 2,
-                -std::numeric_limits<T>::max() / 2,
-                std::numeric_limits<T>::max(),
-                std::numeric_limits<T>::max());
+                       -std::numeric_limits<T>::max() / 2,
+                       -std::numeric_limits<T>::max() / 2,
+                       std::numeric_limits<T>::max(),
+                       std::numeric_limits<T>::max());
         }
 
         bool operator == (const RectT& r) const