]> git.sesse.net Git - casparcg/blobdiff - core/mixer/gpu/ogl_device.cpp
Merge pull request #134 from cambell-prince/master_dshow
[casparcg] / core / mixer / gpu / ogl_device.cpp
index 2ea639ce78de52b537254bff147039263a48202a..12f14b3d75f58ecf9bbbfa91366ef6f7d02650f8 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
-* Copyright (c) 2011 Sveriges Television AB <info@casparcg.com>\r
+* Copyright 2013 Sveriges Television AB http://casparcg.com/\r
 *\r
 * This file is part of CasparCG (www.casparcg.com).\r
 *\r
@@ -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
@@ -62,16 +63,10 @@ ogl_device::ogl_device()
                CASPAR_LOG(info) << L"OpenGL " << version();\r
 \r
                if(!GLEW_VERSION_3_0)\r
-                       CASPAR_LOG(warning) << "Missing OpenGL 3.0 support.";\r
+                       BOOST_THROW_EXCEPTION(gl::ogl_exception() << msg_info("Your graphics card does not meet the minimum hardware requirements since it does not support OpenGL 3.0 or higher. CasparCG Server will not be able to continue."));\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