void Render::draw(Camera *camera, Container& container) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glUseProgram(shader->getProgramID()); glEnableVertexAttribArray(0); glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer); glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, (void*)0); //glEnableVertexAttribArray(1); //glBindBuffer(GL_ARRAY_BUFFER, colorbuffer); //glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, (void*)0); glEnableVertexAttribArray(2); glBindBuffer(GL_ARRAY_BUFFER, normalbuffer); glVertexAttribPointer(2, 3, GL_FLOAT, GL_FALSE, 0, (void*)0); glUniformMatrix4fv(camera->get_projection_location(), 1, GL_FALSE, camera->get_projection_matrix()); glUniformMatrix4fv(camera->get_view_location(), 1, GL_FALSE, camera->get_view_matrix()); glUniformMatrix4fv(camera->get_model_location(), 1, GL_FALSE, camera->get_model_matrix()); drawGrid(); drawContainer(container, camera); drawLayers(container.getLayers(), camera); glDisableVertexAttribArray(0); glDisableVertexAttribArray(1); glDisableVertexAttribArray(2); }
void PivDisplay::displayCurrent() { // Drawing either A or B image as defined in the DataContainer object: filedata if (filedata->isCurrentA()) currentFileName = filedata->currentData().imageA(); else currentFileName = filedata->currentData().imageB(); drawLayers(); }
void PivDisplay::vectorsToggled(bool isTrue) { if (isTrue) vectorsActive = true; else { vectorsActive = false; if (vectorsDrawn) itemPaint->removeVectors(); } drawLayers(); }
void FindCanvas::drawLayers(LayerAndroid* layer) { #if USE(ACCELERATED_COMPOSITING) SkPicture* picture = layer->picture(); if (picture) { setLayerId(layer->uniqueId()); drawPicture(*picture); } for (int i = 0; i < layer->countChildren(); i++) drawLayers(layer->getChild(i)); #endif }
void GraphicEngine::draw() { (*_layerRefresh)[_cord->get("layer.w")] = false; (*_layerRefresh)[_cord->get("layer.w") - 1] = false; for (_layerPos.x = 0; _layerPos.x < _layerPos.h; _layerPos.x++) { if ((*_layerRefresh)[_layerPos.x] == false) { _cord->set("layer", _layerPos.x); (*_layers)[_layerPos.x]->clear(sf::Color(0, 0, 0, 0)); renderLayers(); (*_layerRefresh)[_layerPos.x] = true; } } _renderEnv->draw(); drawLayers(); _renderInter->draw(); _stp++; }
// アニメ再生中 void AnimeGLWidget::drawLayers_Anime() { ObjectModel *pModel = m_pEditData->getObjectModel(); ObjectItem *pItem = pModel->getObject(m_pEditData->getSelIndex()); if (!pItem) { return; } if (m_pSetting->getUseZSort()) { m_drawList.clear(); } drawLayers(pItem); if (m_pSetting->getUseZSort()) { sortDrawList(); drawList(); } }
void PivDisplay::vectorsChanged() { drawLayers(); }
void PivDisplay::maskToggled(bool isTrue) { if (isTrue) maskActive = true; else maskActive = false; drawLayers(); }
// called from View::Draw int Model::draw (vector<Gtk::TreeModel::Path> &iter) { vector<Shape*> sel_shapes; vector<Matrix4d> transforms; objtree.get_selected_shapes(iter, sel_shapes, transforms); gint index = 1; // pick/select index. matches computation in update_model() Vector3d printOffset = settings.Hardware.PrintMargin; if(settings.RaftEnable) printOffset += Vector3d(settings.Raft.Size, settings.Raft.Size, 0); Vector3d translation = objtree.transform3D.getTranslation(); Vector3d offset = printOffset + translation; // Add the print offset to the drawing location of the STL objects. glTranslatef(offset.x(),offset.y(),offset.z()); glPushMatrix(); glMultMatrixd (&objtree.transform3D.transform.array[0]); // draw preview shapes and nothing else if (settings.Display.PreviewLoad) if (preview_shapes.size() > 0) { offset = GetViewCenter(); glTranslatef( offset.x(), offset.y(), offset.z()); for (uint i = 0; i < preview_shapes.size(); i++) { glPushMatrix(); glMultMatrixd (&preview_shapes[i]->transform3D.transform.array[0]); offset = -preview_shapes[i]->Center; glTranslatef(offset.x(), offset.y(), -offset.z()); preview_shapes[i]->draw (settings, false, 20000); glPopMatrix(); } glPopMatrix(); glPopMatrix(); return 0; } for (uint i = 0; i < objtree.Objects.size(); i++) { TreeObject *object = objtree.Objects[i]; index++; glPushMatrix(); glMultMatrixd (&object->transform3D.transform.array[0]); for (uint j = 0; j < object->shapes.size(); j++) { Shape *shape = object->shapes[j]; glLoadName(index); // Load select/pick index index++; glPushMatrix(); glMultMatrixd (&shape->transform3D.transform.array[0]); bool is_selected = false; for (uint s = 0; s < sel_shapes.size(); s++) if (sel_shapes[s] == shape) is_selected = true; // this is slow for big shapes if (is_selected) { if (!shape->slow_drawing && shape->dimensions()>2) { // Enable stencil buffer when we draw the selected object. glEnable(GL_STENCIL_TEST); glStencilFunc(GL_ALWAYS, 1, 1); glStencilOp(GL_KEEP, GL_REPLACE, GL_REPLACE); shape->draw (settings); if (!settings.Display.DisplayPolygons) { // If not drawing polygons, need to draw the geometry // manually, but invisible, to set up the stencil buffer glEnable(GL_CULL_FACE); glEnable(GL_DEPTH_TEST); glEnable(GL_BLEND); // Set to not draw anything, and not update depth buffer glDepthMask(GL_FALSE); glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); shape->draw_geometry(); glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); glDepthMask(GL_TRUE); } // draw highlight around selected object glColor4f( 1.0f, 1.0f, 1.0f, 1.0f ); glLineWidth(3.0); glEnable (GL_POLYGON_OFFSET_LINE); glDisable (GL_CULL_FACE); glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); glStencilFunc(GL_NOTEQUAL, 1, 1); glEnable(GL_DEPTH_TEST); shape->draw_geometry(); glEnable (GL_CULL_FACE); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); glDisable(GL_STENCIL_TEST); glDisable(GL_POLYGON_OFFSET_LINE); } else shape->draw (settings, true); } else { shape->draw (settings, false); } // draw support triangles if (settings.Slicing.Support) { glColor4f(0.8f,0.f,0.f,0.5f); vector<Triangle> suppTr = shape->trianglesSteeperThan(settings.Slicing.SupportAngle*M_PI/180.); for (uint i=0; i < suppTr.size(); i++) suppTr[i].draw(GL_TRIANGLES); } glPopMatrix(); if(settings.Display.DisplayBBox) shape->drawBBox(); } glPopMatrix(); } glPopMatrix(); glLoadName(0); // Clear selection name to avoid selecting last object with later rendering. // draw total bounding box if(settings.Display.DisplayBBox) { // Draw bbox glDisable(GL_DEPTH_TEST); glLineWidth(1); glColor3f(1,0,0); glBegin(GL_LINE_LOOP); glVertex3f(Min.x(), Min.y(), Min.z()); glVertex3f(Min.x(), Max.y(), Min.z()); glVertex3f(Max.x(), Max.y(), Min.z()); glVertex3f(Max.x(), Min.y(), Min.z()); glEnd(); glBegin(GL_LINE_LOOP); glVertex3f(Min.x(), Min.y(), Max.z()); glVertex3f(Min.x(), Max.y(), Max.z()); glVertex3f(Max.x(), Max.y(), Max.z()); glVertex3f(Max.x(), Min.y(), Max.z()); glEnd(); glBegin(GL_LINES); glVertex3f(Min.x(), Min.y(), Min.z()); glVertex3f(Min.x(), Min.y(), Max.z()); glVertex3f(Min.x(), Max.y(), Min.z()); glVertex3f(Min.x(), Max.y(), Max.z()); glVertex3f(Max.x(), Max.y(), Min.z()); glVertex3f(Max.x(), Max.y(), Max.z()); glVertex3f(Max.x(), Min.y(), Min.z()); glVertex3f(Max.x(), Min.y(), Max.z()); glEnd(); glColor3f(1,0.6,0.6); ostringstream val; val.precision(1); Vector3d pos; val << fixed << (Max.x()-Min.x()); pos = Vector3d((Max.x()+Min.x())/2.,Min.y(),Max.z()); drawString(pos,val.str()); val.str(""); val << fixed << (Max.y()-Min.y()); pos = Vector3d(Min.x(),(Max.y()+Min.y())/2.,Max.z()); drawString(pos,val.str()); val.str(""); val << fixed << (Max.z()-Min.z()); pos = Vector3d(Min.x(),Min.y(),(Max.z()+Min.z())/2.); drawString(pos,val.str()); } int drawnlayer = -1; if(settings.Display.DisplayLayer) { drawnlayer = drawLayers(settings.Display.LayerValue, offset, false); } if(settings.Display.DisplayGCode && gcode.size() == 0) { // preview gcode if not calculated yet if ( m_previewGCode.size() != 0 || ( layers.size() == 0 && gcode.commands.size() == 0 ) ) { Vector3d start(0,0,0); const double thickness = settings.Hardware.LayerThickness; const double z = settings.Display.GCodeDrawStart + thickness/2; const int LayerCount = (int)ceil(Max.z()/thickness)-1; const uint LayerNo = (uint)ceil(settings.Display.GCodeDrawStart*(LayerCount-1)); if (z != m_previewGCode_z) { Layer * previewGCodeLayer = calcSingleLayer(z, LayerNo, thickness, true, true); if (previewGCodeLayer) { vector<Command> commands; previewGCodeLayer->MakeGcode(start, commands, 0, settings); GCodeState state(m_previewGCode); m_previewGCode.clear(); state.AppendCommands(commands, settings.Slicing.RelativeEcode); m_previewGCode_z = z; } } glDisable(GL_DEPTH_TEST); m_previewGCode.drawCommands(settings, 1, m_previewGCode.commands.size(), true, 2, settings.Display.DisplayGCodeArrows, settings.Display.DisplayGCodeBorders); } } return drawnlayer; }
void LayerRendererChromium::updateAndDrawLayers() { // FIXME: use the frame begin time from the overall compositor scheduler. // This value is currently inaccessible because it is up in Chromium's // RenderWidget. m_headsUpDisplay->onFrameBegin(currentTime()); ASSERT(m_hardwareCompositing); if (!m_rootLayer) return; updateRootLayerContents(); // Recheck that we still have a root layer. This may become null if // compositing gets turned off during a paint operation. if (!m_rootLayer) return; { TRACE_EVENT("LayerRendererChromium::synchronizeTrees", this, 0); m_rootCCLayerImpl = TreeSynchronizer::synchronizeTrees(m_rootLayer.get(), m_rootCCLayerImpl.get()); } LayerList renderSurfaceLayerList; updateLayers(renderSurfaceLayerList); // Before drawLayers: if (hardwareCompositing() && m_contextSupportsLatch) { // FIXME: The multithreaded compositor case will not work as long as // copyTexImage2D resolves to the parent texture, because the main // thread can execute WebGL calls on the child context at any time, // potentially clobbering the parent texture that is being renderered // by the compositor thread. if (m_childContextsWereCopied) { Extensions3DChromium* parentExt = static_cast<Extensions3DChromium*>(m_context->getExtensions()); // For each child context: // glWaitLatch(Offscreen->Compositor); ChildContextMap::iterator i = m_childContexts.begin(); for (; i != m_childContexts.end(); ++i) { Extensions3DChromium* childExt = static_cast<Extensions3DChromium*>(i->first->getExtensions()); GC3Duint latchId; childExt->getChildToParentLatchCHROMIUM(&latchId); parentExt->waitLatchCHROMIUM(latchId); } } // Reset to false to indicate that we have consumed the dirty child // contexts' parent textures. (This is only useful when the compositor // is multithreaded.) m_childContextsWereCopied = false; } drawLayers(renderSurfaceLayerList); m_textureManager->unprotectAllTextures(); // After drawLayers: if (hardwareCompositing() && m_contextSupportsLatch) { Extensions3DChromium* parentExt = static_cast<Extensions3DChromium*>(m_context->getExtensions()); // For each child context: // glSetLatch(Compositor->Offscreen); ChildContextMap::iterator i = m_childContexts.begin(); for (; i != m_childContexts.end(); ++i) { Extensions3DChromium* childExt = static_cast<Extensions3DChromium*>(i->first->getExtensions()); GC3Duint latchId; childExt->getParentToChildLatchCHROMIUM(&latchId); parentExt->setLatchCHROMIUM(latchId); } } if (isCompositingOffscreen()) copyOffscreenTextureToDisplay(); }
void AnimeGLWidget::drawLayers(ObjectItem *pLayerItem) { int selFrame = m_pEditData->getSelectFrame(); int flag = pLayerItem->data(Qt::CheckStateRole).toInt(); if (m_pEditData->getObjectModel()->isLayer(pLayerItem->getIndex()) && (flag & ObjectItem::kState_Disp)) { FrameData d; bool valid; d = pLayerItem->getDisplayFrameData(selFrame, &valid); if (valid) { QMatrix4x4 mat = pLayerItem->getDisplayMatrix(selFrame); if (m_pSetting->getUseZSort()) { DRAW_FRAMEDATA draw; draw.mat = mat; draw.data = d; if (m_pSetting->getDrawFrame() && !m_pEditData->isExportPNG()) { ObjectItem *p = m_pEditData->getObjectModel()->getItemFromIndex(m_pEditData->getSelIndex()); if (pLayerItem == p) { if (m_bPressCtrl) { draw.frameCol = QColor(0, 255, 0, 255); } else { draw.frameCol = QColor(255, 0, 0, 255); } } else { draw.frameCol = QColor(64, 64, 64, 255); } } else { draw.frameCol = QColor(0, 0, 0, 0); } m_drawList.append(draw); } else { drawFrameData(d, mat); if (m_pSetting->getDrawFrame() && !m_pEditData->isExportPNG()) { QColor col; ObjectItem *p = m_pEditData->getObjectModel()->getItemFromIndex(m_pEditData->getSelIndex()); if (pLayerItem == p) { if (m_bPressCtrl) { col = QColor(0, 255, 0, 255); } else { col = QColor(255, 0, 0, 255); } } else { col = QColor(64, 64, 64, 255); } drawFrame(d, mat, col); } } } } QList<ObjectItem *> children; for (int i = 0; i < pLayerItem->childCount(); i++) { ObjectItem *pChild = pLayerItem->child(i); bool valid; QMatrix4x4 m = pChild->getDisplayMatrix(selFrame, &valid); if (!valid) { children.append(pChild); continue; } int j; for (j = 0; j < children.size(); j++) { QMatrix4x4 m1 = children[j]->getDisplayMatrix(selFrame, &valid); if (!valid) { continue; } if (m.column(3).z() < m1.column(3).z()) { children.insert(j, pChild); break; } } if (j == children.size()) { children.append(pChild); } } foreach (ObjectItem *p, children) { drawLayers(p); }
void AnimeGLWidget::paintGL() { QColor col = m_pSetting->getAnimeBGColor(); if (m_pEditData->isExportPNG()) { col.setAlphaF(0); } glClearColor(col.redF(), col.greenF(), col.blueF(), col.alphaF()); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); m_matProj.setToIdentity(); m_matProj.ortho(-m_DrawWidth / 2, m_DrawWidth / 2, m_DrawHeight / 2, -m_DrawHeight / 2, -10000, 10000); m_lineShaderProgram.bind(); m_lineShaderProgram.setUniformValue("mvp_matrix", m_matProj); if (m_pSetting->getUseDepthTest()) { glEnable(GL_DEPTH_TEST); } else { glDisable(GL_DEPTH_TEST); } // 背景画像描画 if (m_backImageTex) { RectF rect; RectF uvF; QColor col = QColor(255, 255, 255, 255); m_textureShaderProgram.bind(); QOpenGLTexture *pTex = m_pTextureCacheManager->get(m_backImageTex); if (pTex) { pTex->bind(); } m_textureShaderProgram.setUniformValue("mvp_matrix", m_matProj); rect.setRect(-m_backImageW / 2, m_backImageH / 2, m_backImageW, -m_backImageH); uvF.setRect(0.0, (float)(m_BackImage.height() - m_backImageH) / m_BackImage.height(), (float)m_backImageW / m_BackImage.width(), (float)m_backImageH / m_BackImage.height()); drawRect(rect, uvF, -9999.9, col); } if (m_pEditData) { drawLayers(); } bool bDepth = glIsEnabled(GL_DEPTH_TEST); glDisable(GL_DEPTH_TEST); if (m_bDrawGrid) { if (!m_pEditData->isExportPNG()) { drawGrid(); } } // センター if (m_pSetting->getDrawCenter()) { if (!m_pEditData->isExportPNG()) { drawCenter(); } } // PNG吐き出しモード if (m_pEditData->getEditMode() == EditData::kEditMode_ExportPNG && !m_pEditData->isExportPNG()) { int rect[4]; QColor col = QColor(255, 0, 0, 255); m_pEditData->getExportPNGRect(rect); drawLine(QPoint(rect[0], rect[1]), QPoint(rect[2], rect[1]), col, 1.0); drawLine(QPoint(rect[2], rect[1]), QPoint(rect[2], rect[3]), col, 1.0); drawLine(QPoint(rect[2], rect[3]), QPoint(rect[0], rect[3]), col, 1.0); drawLine(QPoint(rect[0], rect[3]), QPoint(rect[0], rect[1]), col, 1.0); } if (bDepth) { glEnable(GL_DEPTH_TEST); } }