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
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
: 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
\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
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
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
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
\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
{\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