void PlaneViewer::draw(TRasterP ras, double dpiX, double dpiY, TPalette *pal) { TPointD rasCenter(ras->getCenterD()); TRaster32P aux(rasterBuffer()); aux->lock(); ras->lock(); glGetDoublev(GL_MODELVIEW_MATRIX, m_matrix); TAffine viewAff(m_matrix[0], m_matrix[4], m_matrix[12], m_matrix[1], m_matrix[5], m_matrix[13]); viewAff = viewAff * TScale(Stage::inch / dpiX, Stage::inch / dpiY) * TTranslation(-rasCenter); pushGLWinCoordinates(); aux->clear(); if (pal) TRop::quickPut(aux, (TRasterCM32P)ras, pal, viewAff); else TRop::quickPut(aux, ras, viewAff); flushRasterBuffer(); popGLCoordinates(); }
void paintGL() override { pushGLWorldCoordinates(); drawBackground(); if (m_ras) { glEnable(GL_BLEND); glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); //Note GL_ONE instead of GL_SRC_ALPHA: it's needed since the input //image is supposedly premultiplied - and it works because the //viewer's background is opaque. //See tpixelutils.h's overPixT function for comparison. draw(m_ras); glDisable(GL_BLEND); } popGLCoordinates(); }
void paintGL() override { drawBackground(); // Draw original if (m_img) { pushGLWorldCoordinates(); glEnable(GL_BLEND); glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); // Note GL_ONE instead of GL_SRC_ALPHA: it's needed since the input // image is supposedly premultiplied - and it works because the // viewer's background is opaque. // See tpixelutils.h's overPixT function for comparison. draw(m_img); glDisable(GL_BLEND); popGLCoordinates(); } else if (m_xsh) { // Build reference change affines // EXPLANATION: RasterPainter receives an affine specifiying the reference change // from world coordinates to the OpenGL viewport, where (0,0) corresponds to the // viewport center. const TAffine &cameraAff = m_xsh->getPlacement(m_xsh->getStageObjectTree()->getCurrentCameraId(), m_row); TTranslation centeredWidgetToWidgetAff(0.5 * width(), 0.5 * height()); const TAffine &worldToCenteredWigetAff = centeredWidgetToWidgetAff.inv() * viewAff() * cameraAff.inv(); glPushMatrix(); tglMultMatrix(centeredWidgetToWidgetAff); assert(m_row >= 0); ImagePainter::VisualSettings vs; TDimension viewerSize(width(), height()); Stage::RasterPainter painter(viewerSize, worldToCenteredWigetAff, TRect(viewerSize), vs, false); ToonzScene *scene = TApp::instance()->getCurrentScene()->getScene(); Stage::visit(painter, scene, m_xsh.getPointer(), m_row); painter.flushRasterImages(); glFlush(); glPopMatrix(); } // Draw mesh preview if (m_meshImg) { glEnable(GL_BLEND); glEnable(GL_LINE_SMOOTH); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Retrieve mesh dpi TPointD meshDpi; m_meshImg->getDpi(meshDpi.x, meshDpi.y); // Push mesh-to-world coordinates change pushGLWorldCoordinates(); glScaled(Stage::inch / meshDpi.x, Stage::inch / meshDpi.y, 1.0); glColor4f(0.0, 1.0, 0.0, 0.7); // Translucent green tglDrawEdges(*m_meshImg); popGLCoordinates(); glDisable(GL_LINE_SMOOTH); glDisable(GL_BLEND); } }