]> git.sesse.net Git - casparcg/commitdiff
Delayed BindFrameBuffer call to avoid hangs during initialization.
authorronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Thu, 19 Jan 2012 17:16:49 +0000 (17:16 +0000)
committerronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Thu, 19 Jan 2012 17:16:49 +0000 (17:16 +0000)
git-svn-id: https://casparcg.svn.sourceforge.net/svnroot/casparcg/server/trunk@2132 362d55ac-95cf-4e76-9f9a-cbaa9c17b72d

core/mixer/gpu/ogl_device.cpp
core/mixer/gpu/ogl_device.h

index 2ea639ce78de52b537254bff147039263a48202a..dd5616f0cd63bc313ec8ddbe40617abbffd045af 100644 (file)
@@ -41,6 +41,7 @@ ogl_device::ogl_device()
        : executor_(L"ogl_device")\r
        , pattern_(nullptr)\r
        , attached_texture_(0)\r
+       , attached_fbo_(0)\r
        , active_shader_(0)\r
        , read_buffer_(0)\r
 {\r
@@ -64,14 +65,8 @@ ogl_device::ogl_device()
                if(!GLEW_VERSION_3_0)\r
                        CASPAR_LOG(warning) << "Missing OpenGL 3.0 support.";\r
        \r
-               CASPAR_LOG(info) << L"Successfully initialized GLEW.";\r
-\r
                glGenFramebuffers(1, &fbo_);    \r
-\r
-               CASPAR_LOG(debug) << "Created framebuffer.";\r
-\r
-               glBindFramebuffer(GL_FRAMEBUFFER, fbo_);\r
-\r
+               \r
                CASPAR_LOG(info) << L"Successfully initialized OpenGL Device.";\r
        });\r
 }\r
@@ -339,6 +334,12 @@ void ogl_device::attach(device_buffer& texture)
 {      \r
        if(attached_texture_ != texture.id())\r
        {\r
+               if(attached_fbo_ != fbo_)\r
+               {\r
+                       glBindFramebuffer(GL_FRAMEBUFFER, fbo_);\r
+                       attached_fbo_ = fbo_;\r
+               }\r
+\r
                GL(glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + 0, GL_TEXTURE_2D, texture.id(), 0));\r
                attached_texture_ = texture.id();\r
        }\r
index 0522617abfa004a9efc41a6f6ff9da4b649c2156..d05c373a4fce6443a58d1498de045311ed4775e0 100644 (file)
@@ -65,6 +65,7 @@ class ogl_device : public std::enable_shared_from_this<ogl_device>, boost::nonco
        std::array<size_t, 4>                    scissor_;\r
        const GLubyte*                                   pattern_;\r
        GLint                                                    attached_texture_;\r
+       GLuint                                                   attached_fbo_;\r
        GLint                                                    active_shader_;\r
        std::array<GLint, 16>                    binded_textures_;\r
        std::array<GLint, 4>                     blend_func_;\r
@@ -75,7 +76,7 @@ class ogl_device : public std::enable_shared_from_this<ogl_device>, boost::nonco
        std::array<tbb::concurrent_unordered_map<size_t, safe_ptr<buffer_pool<device_buffer>>>, 4> device_pools_;\r
        std::array<tbb::concurrent_unordered_map<size_t, safe_ptr<buffer_pool<host_buffer>>>, 2> host_pools_;\r
        \r
-       unsigned int fbo_;\r
+       GLuint fbo_;\r
 \r
        executor executor_;\r
                                \r