]> git.sesse.net Git - casparcg/commitdiff
git-svn-id: https://casparcg.svn.sourceforge.net/svnroot/casparcg/server/branches...
authorronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Thu, 10 Mar 2011 23:09:52 +0000 (23:09 +0000)
committerronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Thu, 10 Mar 2011 23:09:52 +0000 (23:09 +0000)
modules/ogl/consumer/ogl_consumer.cpp
shell/caspar.config

index 9d237d3c1d4894b1c072e7fabbbcb48aa6d11cbf..47b73f83c2d20c00ef6b27949cebb97b1bf1b212 100644 (file)
@@ -47,12 +47,9 @@ struct ogl_consumer::implementation : boost::noncopyable
        timer clock_;\r
        printer parent_printer_;\r
        boost::unique_future<void> active_;\r
-\r
-       float wratio_;\r
-       float hratio_;\r
-       \r
-       float wSize_;\r
-       float hSize_;\r
+               \r
+       float width_;\r
+       float height_;\r
 \r
        GLuint                            texture_;\r
        std::array<GLuint, 2> pbos_;\r
@@ -60,8 +57,6 @@ struct ogl_consumer::implementation : boost::noncopyable
        const bool windowed_;\r
        unsigned int screen_width_;\r
        unsigned int screen_height_;\r
-       unsigned int screen_x_;\r
-       unsigned int screen_y_;\r
        const unsigned int screen_index_;\r
                                \r
        const stretch stretch_;\r
@@ -78,8 +73,6 @@ public:
                : stretch_(stretch)\r
                , windowed_(windowed)\r
                , texture_(0)\r
-               , screen_x_(0)\r
-               , screen_y_(0)\r
                , screen_index_(screen_index)\r
                , graph_(diagnostics::create_graph(narrow(print())))\r
                , executor_(print())\r
@@ -127,8 +120,6 @@ public:
                \r
                screen_width_ = windowed_ ? format_desc_.width : devmode.dmPelsWidth;\r
                screen_height_ = windowed_ ? format_desc_.height : devmode.dmPelsHeight;\r
-               screen_x_ = devmode.dmPosition.x;\r
-               screen_y_ = devmode.dmPosition.y;\r
 #else\r
                if(!windowed)\r
                        BOOST_THROW_EXCEPTION(not_supported() << msg_info(narrow(print() + " doesn't support non-Win32 fullscreen"));\r
@@ -139,9 +130,9 @@ public:
                executor_.start();\r
                executor_.invoke([=]\r
                {\r
-                       window_.Create(sf::VideoMode(screen_width_, screen_height_, 32), narrow(print()), windowed_ ? sf::Style::Titlebar : sf::Style::Fullscreen);\r
+                       window_.Create(sf::VideoMode(screen_width_, screen_height_, 32), narrow(print()), windowed_ ? sf::Style::Resize : sf::Style::Fullscreen);\r
                        window_.ShowMouseCursor(false);\r
-                       window_.SetPosition(screen_x_, screen_y_);\r
+                       window_.SetPosition(devmode.dmPosition.x, devmode.dmPosition.y);\r
                        window_.SetSize(screen_width_, screen_height_);\r
                        window_.SetActive();\r
                        GL(glEnable(GL_TEXTURE_2D));\r
@@ -150,19 +141,7 @@ public:
                        GL(glViewport(0, 0, format_desc_.width, format_desc_.height));\r
                        glLoadIdentity();\r
                                \r
-                       wratio_ = static_cast<float>(format_desc_.width)/static_cast<float>(format_desc_.width);\r
-                       hratio_ = static_cast<float>(format_desc_.height)/static_cast<float>(format_desc_.height);\r
-\r
-                       std::pair<float, float> target_ratio = None();\r
-                       if(stretch_ == fill)\r
-                               target_ratio = Fill();\r
-                       else if(stretch_ == uniform)\r
-                               target_ratio = Uniform();\r
-                       else if(stretch_ == uniform_to_fill)\r
-                               target_ratio = UniformToFill();\r
-\r
-                       wSize_ = target_ratio.first;\r
-                       hSize_ = target_ratio.second;\r
+                       calculate_aspect();\r
                        \r
                        glGenTextures(1, &texture_);\r
                        glBindTexture(GL_TEXTURE_2D, texture_);\r
@@ -184,6 +163,28 @@ public:
                active_ = executor_.begin_invoke([]{});\r
                CASPAR_LOG(info) << print() << " Sucessfully initialized.";\r
        }\r
+\r
+       void calculate_aspect()\r
+       {\r
+               if(windowed_)\r
+               {\r
+                       screen_height_ = window_.GetHeight();\r
+                       screen_width_ = window_.GetWidth();\r
+               }\r
+               \r
+               GL(glViewport(0, 0, screen_width_, screen_height_));\r
+\r
+               std::pair<float, float> target_ratio = None();\r
+               if(stretch_ == fill)\r
+                       target_ratio = Fill();\r
+               else if(stretch_ == uniform)\r
+                       target_ratio = Uniform();\r
+               else if(stretch_ == uniform_to_fill)\r
+                       target_ratio = UniformToFill();\r
+\r
+               width_ = target_ratio.first;\r
+               height_ = target_ratio.second;\r
+       }\r
                \r
        std::pair<float, float> None()\r
        {\r
@@ -241,10 +242,10 @@ public:
                                \r
                GL(glClear(GL_COLOR_BUFFER_BIT));                       \r
                glBegin(GL_QUADS);\r
-                               glTexCoord2f(0.0f,        hratio_);     glVertex2f(-wSize_, -hSize_);\r
-                               glTexCoord2f(wratio_, hratio_); glVertex2f( wSize_, -hSize_);\r
-                               glTexCoord2f(wratio_, 0.0f);    glVertex2f( wSize_,  hSize_);\r
-                               glTexCoord2f(0.0f,        0.0f);        glVertex2f(-wSize_,  hSize_);\r
+                               glTexCoord2f(0.0f,        1.0f);        glVertex2f(-width_, -height_);\r
+                               glTexCoord2f(1.0f,        1.0f);        glVertex2f( width_, -height_);\r
+                               glTexCoord2f(1.0f,        0.0f);        glVertex2f( width_,  height_);\r
+                               glTexCoord2f(0.0f,        0.0f);        glVertex2f(-width_,  height_);\r
                glEnd();\r
                \r
                glBindTexture(GL_TEXTURE_2D, 0);\r
@@ -261,7 +262,11 @@ public:
                {\r
                        perf_timer_.reset();\r
                        sf::Event e;\r
-                       while(window_.GetEvent(e)){}\r
+                       while(window_.GetEvent(e))\r
+                       {\r
+                               if(e.Type == sf::Event::Resized)\r
+                                        calculate_aspect();\r
+                       }\r
                        render(frame);\r
                        window_.Display();\r
                        graph_->update_value("frame-time", static_cast<float>(perf_timer_.elapsed()/format_desc_.interval*0.5));\r
index c5616dce5300470abfb176f3f6c2e0421671dcdf..60316945402a68778cabe77d8d8c0e87fea4e454 100644 (file)
           <windowed>true</windowed>\r
         </ogl>\r
         <audio/>\r
-        <decklink>\r
+        <!--decklink>\r
           <device>1</device>\r
           <embedded-audio>true</embedded-audio>\r
           <internal-key>false</internal-key>\r
-        </decklink>\r
+        </decklink-->\r
         <!--<bluefish>\r
           <device>1</device>\r
           <embedded-audio>true</embedded-audio>\r