Browse Source

fixed ClipRectActor when render to texture enabled

dmuratshin 10 years ago
parent
commit
1ab7ec47bb

+ 5 - 2
oxygine/src/STDMaterial.cpp

@@ -64,8 +64,11 @@ namespace oxygine
                                    int(clippedRect.size.x + 0.01f),
                                    int(clippedRect.size.y + 0.01f));
 
-                Point vp_size = core::getDisplaySize();
-                gl_rect.pos.y = vp_size.y - gl_rect.getBottom();
+                if (!_renderer->getDriver()->getRenderTarget())
+                {
+                    Point vp_size = core::getDisplaySize();
+                    gl_rect.pos.y = vp_size.y - gl_rect.getBottom();
+                }
 
                 _renderer->getDriver()->setScissorRect(&gl_rect);
             }

+ 7 - 2
oxygine/src/core/VideoDriver.cpp

@@ -35,6 +35,11 @@ namespace oxygine
         return false;
     }
 
+    spNativeTexture VideoDriverNull::getRenderTarget() const
+    {
+        return _rt;
+    }
+
     const VertexDeclaration*    VideoDriverNull::getVertexDeclaration(bvertex_format bf) const
     {
         return IVideoDriver::instance->getVertexDeclaration(bf);
@@ -49,9 +54,9 @@ namespace oxygine
     {
 
     }
-    void VideoDriverNull::setRenderTarget(spNativeTexture)
+    void VideoDriverNull::setRenderTarget(spNativeTexture rt)
     {
-
+        _rt = rt;
     }
     void VideoDriverNull::setShaderProgram(ShaderProgram*)
     {

+ 8 - 3
oxygine/src/core/VideoDriver.h

@@ -71,9 +71,10 @@ namespace oxygine
         virtual void draw(PRIMITIVE_TYPE pt, const VertexDeclaration* decl, const void* verticesData, unsigned int verticesDataSize) = 0;
         virtual void draw(PRIMITIVE_TYPE pt, const VertexDeclaration* decl, const void* verticesData, unsigned int verticesDataSize, const void* indicesData, unsigned int numIndices, bool indicesShortType) = 0;
 
-        virtual void    getStats(Stats& s) const = 0;
-        virtual void    getViewport(Rect& r) const = 0;
-        virtual bool    getScissorRect(Rect&) const = 0;
+        virtual void            getStats(Stats& s) const = 0;
+        virtual void            getViewport(Rect& r) const = 0;
+        virtual bool            getScissorRect(Rect&) const = 0;
+        virtual spNativeTexture getRenderTarget() const = 0;
         virtual const VertexDeclaration* getVertexDeclaration(bvertex_format) const = 0;
 
         virtual void setScissorRect(const Rect*) = 0;
@@ -109,6 +110,8 @@ namespace oxygine
         void getStats(Stats& s) const;
         void getViewport(Rect& r) const;
         bool getScissorRect(Rect&) const;
+        spNativeTexture getRenderTarget() const;
+
         const VertexDeclaration*    getVertexDeclaration(bvertex_format) const;
 
         void draw(PRIMITIVE_TYPE pt, const VertexDeclaration* decl, const void* verticesData, unsigned int verticesDataSize) {}
@@ -135,6 +138,8 @@ namespace oxygine
 
         void reset() {}
         void restore() {}
+
+        spNativeTexture _rt;
     };
 
 }

+ 6 - 0
oxygine/src/core/gl/VideoDriverGL.cpp

@@ -101,6 +101,11 @@ namespace oxygine
         return scrTest ? true : false;
     }
 
+    spNativeTexture VideoDriverGL::getRenderTarget() const
+    {
+        return _rt;
+    }
+
     const VertexDeclarationGL* VideoDriverGL::getVertexDeclaration(bvertex_format fmt) const
     {
         return _vdeclarations.get(fmt);
@@ -130,6 +135,7 @@ namespace oxygine
 
     void VideoDriverGL::setRenderTarget(spNativeTexture rt)
     {
+        _rt = rt;
         if (!rt)
         {
             oxglBindFramebuffer(GL_FRAMEBUFFER, _prevFBO);

+ 2 - 0
oxygine/src/core/gl/VideoDriverGL.h

@@ -18,6 +18,7 @@ namespace oxygine
         void    getStats(Stats& s) const;
         void    getViewport(Rect& r) const;
         bool    getScissorRect(Rect&) const;
+        spNativeTexture getRenderTarget() const;
         const VertexDeclarationGL*  getVertexDeclaration(bvertex_format) const;
 
         void setScissorRect(const Rect*);
@@ -36,6 +37,7 @@ namespace oxygine
 
         void _begin(const Rect& viewport, const Color* clearColor);
         GLint _prevFBO;
+        spNativeTexture _rt;
 
         mutable VertexDeclarations<VertexDeclarationGL> _vdeclarations;
         bool _traceStats;