Esempio n. 1
0
void Graphics::resize(const Size& size)
{
    setViewportSize(size);

    // The projection matrix converts from Painter's coordinate system to GL's coordinate system
    //    * GL's viewport is 2x2, Painter's is width x height
    //    * GL has +y -> -y going from bottom -> top, Painter is the other way round
    //    * GL has [0,0] in the center, Painter has it in the top-left
    //
    // This results in the Projection matrix below.
    //
    //                                    Projection Matrix
    //   Painter Coord     ------------------------------------------------        GL Coord
    //   -------------     | 2.0 / width  |      0.0      |      0.0      |     ---------------
    //   |  x  y  1  |  *  |     0.0      | -2.0 / height |      0.0      |  =  |  x'  y'  1  |
    //   -------------     |    -1.0      |      1.0      |      1.0      |     ---------------
    //                     ------------------------------------------------
    Matrix3 projectionMatrix = { 2.0f/size.width(),  0.0f,                 0.0f,
                                 0.0f,              -2.0f/size.height(),   0.0f,
                                -1.0f,               1.0f,                 1.0f };

#ifdef PAINTER_OGL1
    if(g_painterOGL1)
        g_painterOGL1->setProjectionMatrix(projectionMatrix);
#endif

#ifdef PAINTER_OGL2
    if(g_painterOGL2)
        g_painterOGL2->setProjectionMatrix(projectionMatrix);
#endif
}
Esempio n. 2
0
void Render_SW_SDL::resetViewport()
{
    float w, w1, h, h1;
    int   wi, hi;
    SDL_GetWindowSize(PGE_Window::window, &wi, &hi);
    w=wi; h=hi; w1=w; h1=h;
    scale_x=(float)((float)(w)/(float)window_w);
    scale_y=(float)((float)(h)/(float)window_h);
    viewport_scale_x = scale_x;
    viewport_scale_y = scale_y;
    if(scale_x>scale_y)
    {
        w1=scale_y*window_w;
        viewport_scale_x=w1/window_w;
    }
    else if(scale_x<scale_y)
    {
        h1=scale_x*window_h;
        viewport_scale_y=h1/window_h;
    }

    offset_x=(w-w1)/2;
    offset_y=(h-h1)/2;
    //glViewport(offset_x, offset_y, (GLsizei)w1, (GLsizei)h1); GLERRORCHECK();
    SDL_Rect topLeftViewport;
    topLeftViewport.x = offset_x;
    topLeftViewport.y = offset_y;
    topLeftViewport.w = w1;
    topLeftViewport.h = h1;
    SDL_RenderSetViewport( m_gRenderer, &topLeftViewport );
    setViewportSize(window_w, window_h);
}
Esempio n. 3
0
void Render_OpenGL31::resetViewport()
{
    float w, w1, h, h1;
    int   wi, hi;
    SDL_GetWindowSize(PGE_Window::window, &wi, &hi);
    w = wi;
    h = hi;
    w1 = w;
    h1 = h;
    scale_x = w / window_w;
    scale_y = h / window_h;
    viewport_scale_x = scale_x;
    viewport_scale_y = scale_y;

    if(scale_x > scale_y)
    {
        w1 = scale_y * window_w;
        viewport_scale_x = w1 / window_w;
    }
    else if(scale_x < scale_y)
    {
        h1 = scale_x * window_h;
        viewport_scale_y = h1 / window_h;
    }

    offset_x = (w - w1) / 2.0f;
    offset_y = (h - h1) / 2.0f;
    glViewport(static_cast<GLint>(offset_x),
               static_cast<GLint>(offset_y),
               static_cast<GLsizei>(w1),
               static_cast<GLsizei>(h1));
    GLERRORCHECK();
    setViewportSize(window_w, window_h);
}
 TransparencyManagerOITClosestArray::TransparencyManagerOITClosestArray( dp::math::Vec2ui const & size, unsigned int depth )
   : TransparencyManager( TransparencyMode::ORDER_INDEPENDENT_CLOSEST_ARRAY )
   , m_initializedBuffers( false )
   , m_initializedHandles( false )
 {
   setLayersCount( depth );
   setViewportSize( size );
 }
Esempio n. 5
0
void Render_OpenGL31::setViewport(int x, int y, int w, int h)
{
    glViewport(static_cast<GLint>(offset_x + x * viewport_scale_x),
               static_cast<GLint>(offset_y + (window_h - (y + h))*viewport_scale_y),
               static_cast<GLsizei>(w * viewport_scale_x),
               static_cast<GLsizei>(h * viewport_scale_y));
    GLERRORCHECK();
    viewport_x = x;
    viewport_y = y;
    setViewportSize(w, h);
}
Esempio n. 6
0
WebPuppeteerTab::WebPuppeteerTab(WebPuppeteer *_parent): QWebPage(_parent) {
	parent = _parent;

	// define standard values
	setViewportSize(QSize(1024,768));
	setForwardUnsupportedContent(true);

	setNetworkAccessManager(new WebPuppeteerTabNetSpy(this));

	connect(this, SIGNAL(unsupportedContent(QNetworkReply*)), this, SLOT(downloadFile(QNetworkReply*)));
	connect(networkAccessManager(), SIGNAL(sslErrors(QNetworkReply*,const QList<QSslError>&)), this, SLOT(handleSslErrors(QNetworkReply*,const QList<QSslError>&)));
}
Esempio n. 7
0
void Render_SW_SDL::setViewport(int x, int y, int w, int h)
{
    SDL_Rect topLeftViewport;
    topLeftViewport.x = offset_x + (int)ceil((float)x*viewport_scale_x);
    topLeftViewport.y = offset_y + (int)ceil((float)y*viewport_scale_y);
    topLeftViewport.w = (int)round((float)w*viewport_scale_x);
    topLeftViewport.h = (int)round((float)h*viewport_scale_y);
    SDL_RenderSetViewport( m_gRenderer, &topLeftViewport );
    viewport_x=(float)x;
    viewport_y=(float)y;
    setViewportSize(w, h);
}
Esempio n. 8
0
void WebPage::saveScreenshot(const QString& fileName, const QSize& vpSize)
{
  QSize originalVpSize = viewportSize();
  QWebFrame* frame = mainFrame();

  if (!vpSize.isNull()) {
    setViewportSize(vpSize);
  }

  QImage image(frame->contentsSize(), QImage::Format_ARGB32_Premultiplied);
  image.fill(Qt::transparent);

  QPainter painter(&image);
  painter.setRenderHint(QPainter::Antialiasing, true);
  painter.setRenderHint(QPainter::TextAntialiasing, true);
  painter.setRenderHint(QPainter::SmoothPixmapTransform, true);
  frame->documentElement().render(&painter);
  painter.end();

  image.save(fileName);

  setViewportSize(originalVpSize);
}
Esempio n. 9
0
void PageRunner::reallyFinished() {
    int latency = time.restart();
    // err << latency << " " << changed << " " << nam->hasOutstandingRequests() << endl;
    if (changed || latency >= 152 || nam->hasOutstandingRequests()) {
        QTimer::singleShot(150, this, SLOT(reallyFinished()));
        changed = false;
        return;
    }
    if (!exportpdf.isEmpty() || !exportpng.isEmpty()) {
        setViewportSize(mainFrame()->contentsSize());
    }
    if (!exportpng.isEmpty()) {
        renderToFile(exportpng);
    }
    if (!exportpdf.isEmpty()) {
        printToFile(exportpdf);
    }
    qApp->exit(sawJSError);
}
Esempio n. 10
0
void Graphics::resize(const Size& size)
{
    setViewportSize(size);

    // The projection matrix converts from Painter's coordinate system to GL's coordinate system
    //    * GL's viewport is 2x2, Painter's is width x height
    //    * GL has +y -> -y going from bottom -> top, Painter is the other way round
    //    * GL has [0,0] in the center, Painter has it in the top-left
    //
    // This results in the Projection matrix below.
    //
    //                Projection Matrix                   Painter Coord   GL Coord
    // ------------------------------------------------     ---------     ---------
    // | 2.0 / width  |      0.0      |     -1.0      |     |   x   |     |   x'  |
    // |     0.0      | -2.0 / height |      1.0      |  *  |   y   |  =  |   y'  |
    // |     0.0      |      0.0      |      0.0      |     |   1   |     |   0   |
    // ------------------------------------------------     ---------     ---------
    Matrix3 projectionMatrix = { 2.0f/size.width(),  0.0f,                -1.0f,
                                 0.0f,              -2.0f/size.height(),   1.0f,
                                 0.0f,               0.0f,                 0.0f
                               };
    projectionMatrix.transpose();
    g_painter.setProjectionMatrix(projectionMatrix);
}
Esempio n. 11
0
void WebPage::resize(int width, int height) {
  QSize size(width, height);
  setViewportSize(size);
}
Esempio n. 12
0
void WebPage::createWindow() {
  QSize size(1680, 1050);
  setViewportSize(size);
}
Esempio n. 13
0
void Render_OpenGL31::setViewportSize(int w, int h)
{
    setViewportSize(static_cast<float>(w), static_cast<float>(h));
}