void MaterialServer::completeDraw( Tempest::Device & device, const Scene &scene, GBuffer &g, Tempest::Texture2d* screen, Tempest::Texture2d* depth, ShaderMaterial::UniformsContext& context, ShaderMaterial::UniformsContext& econtext ) { Mat *waterM = mat[water].get(); Tempest::Texture2d buf, *rTaget = screen; if( screen && settings.api==GraphicsSettingsWidget::Settings::directX ){ buf = localTex.create( screen->size(), screen->format() ); rTaget = &buf; } size_t countSS = 0; for( size_t i=0; i<sspass.size(); ++i ) countSS += sspass[i]->obj.size(); if( sswater ) countSS += waterM->obj.size(); if( countSS ){ completeDrawMMat( device, scene, context, econtext, g.color[0], g.depth ); execEfect(blt_to_tex, device, rTaget, econtext, g.color[0]); } else { if( screen ) completeDrawMMat( device, scene, context, econtext, *rTaget, *depth ); else completeDrawMMat( device, scene, context, econtext ); } if( countSS ){ Tempest::Texture2d r = localTex.create( g.color[0].size(), g.color[0].format() ); execEfect(blt, device, &r, econtext, g.color[0]); context.texture[ ShaderSource::tsScreenData ][0] = g.color[0]; for( size_t i=0; i<sspass.size(); ++i ){ Mat &m = *sspass[i]; drawTo(m, device, false, context, r, g.depth ); } if( sswater ){ context.texture[1][0] = hWater[0]; context.texture[1][1] = hWater[1]; drawTo( *waterM, device, false, context, r, g.depth ); } if( screen ) execEfect(blt_to_tex, device, rTaget, econtext, r); else execEfect(blt, device, screen, econtext, r); } if( screen && rTaget!=screen ){ execEfect(mirron_blt, device, screen, econtext, *rTaget); } for( size_t i=0; i<mat.size(); ++i ) mat[i]->obj.clear(); }
void DrawArea::mouseReleaseEvent(QMouseEvent *event) { if (event->button() == Qt::LeftButton && mScribbling ) { drawTo(event->pos(), true); mScribbling = false; } }
void SkCanvasWidget::mouseMoveEvent(QMouseEvent* event) { SkIPoint eventPoint = SkIPoint::Make(event->globalX(), event->globalY()); fUserOffset += eventPoint - fPreviousPoint; fPreviousPoint = eventPoint; fDebugger->setUserOffset(fUserOffset); drawTo(fDebugger->index()); }
void SkCanvasWidget::mouseMoveEvent(QMouseEvent* event) { SkIPoint eventPoint = SkIPoint::Make(event->globalX(), event->globalY()); SkIPoint eventOffset = eventPoint - fPreviousPoint; fPreviousPoint = eventPoint; fUserMatrix.postTranslate(eventOffset.fX, eventOffset.fY); fDebugger->setUserMatrix(fUserMatrix); drawTo(fDebugger->index()); }
void DrawArea::mouseMoveEvent(QMouseEvent *event) { if((event->buttons() & Qt::LeftButton) && mScribbling ) { //clearOverlayImage(); drawTo(event->pos(), false); } }
void SkCanvasWidget::resetWidgetTransform() { fUserOffset.set(0,0); fUserScaleFactor = 1.0; fDebugger->setUserOffset(fUserOffset); fDebugger->setUserScale(fUserScaleFactor); emit scaleFactorChanged(fUserScaleFactor); drawTo(fDebugger->index()); }
void SkCanvasWidget::snapWidgetTransform() { double x, y; modf(fUserMatrix.getTranslateX(), &x); modf(fUserMatrix.getTranslateY(), &y); fUserMatrix[SkMatrix::kMTransX] = x; fUserMatrix[SkMatrix::kMTransY] = y; fDebugger->setUserMatrix(fUserMatrix); drawTo(fDebugger->index()); }
void Renderer::drawAll() { if (mDrawablesBuffer.size() == 0) { return; } #if 0 std::sort(mDrawablesBuffer.begin(), mDrawablesBuffer.end(), [](const std::shared_ptr<Drawable>& a, const std::shared_ptr<Drawable>& b) { return *a < *b; }); #endif State rendererState(mCamera, mAmbientLightColor, mLights); for (const Light& light: mLights) { if (light.makesShadows) { sbAssert(light.type == Light::Type::Parallel, "TODO: shadows for point lights"); Camera camera = Camera::orthographic(-100.0, 100.0, -100.0, 100.0, -1000.0, 1000.0); camera.lookAt(-light.pos, Vec3(0.0, 0.0, 0.0)); IntRect savedViewport = mViewport; Vec2i shadowFbSize = light.shadowFramebuffer->getSize(); setViewport(0, 0, shadowFbSize.x, shadowFbSize.y); drawTo(*light.shadowFramebuffer, camera); setViewport(savedViewport); rendererState.shadows.push_back({ light.shadowFramebuffer->getTexture(), math::matrixShadowBias() * camera.getViewProjectionMatrix() }); } } GL_CHECK(glClearColor(mClearColor.r, mClearColor.g, mClearColor.b, mClearColor.a)); clear(); for (const std::shared_ptr<Drawable>& d: mDrawablesBuffer) { if (d->mProjectionType == ProjectionType::Perspective) { rendererState.camera = &mCamera; } else { rendererState.camera = &mSpriteCamera; } d->draw(rendererState); } mAmbientLightColor = Color::White; mLights.clear(); mDrawablesBuffer.clear(); }
void SkCanvasWidget::wheelEvent(QWheelEvent* event) { Qt::KeyboardModifiers modifiers = event->modifiers(); if (modifiers.testFlag(Qt::ControlModifier)) { zoom(event->delta() > 0 ? ZOOM_FACTOR : (1.0f / ZOOM_FACTOR), event->x(), event->y()); } else { if (Qt::Horizontal == event->orientation()) { fUserMatrix.postTranslate(event->delta(), 0.0f); } else { fUserMatrix.postTranslate(0.0f, event->delta()); } fDebugger->setUserMatrix(fUserMatrix); drawTo(fDebugger->index()); } }
void MaterialServer::completeDrawMMat(Tempest::Device &device, const Scene &/*scene*/, ShaderMaterial::UniformsContext &context, ShaderMaterial::UniformsContext &/*econtext*/, Args&... g ){ Mat *waterM = mat[water].get(); for( size_t i=0; i<gbufPass.size(); ++i ){ Mat &m = *gbufPass[i]; drawTo(m, device, i==0, context, g... ); } for( size_t i=0; i<blpass.size(); ++i ){ Mat &m = *blpass[i]; drawTo(m, device, i==0 && gbufPass.size()==0, context, g... ); } if( !sswater ){ context.texture[1][0] = hWater[0]; context.texture[1][1] = hWater[1]; drawTo( *waterM, device, false, context ); } }
void SkCanvasWidget::zoom(float zoomIncrement) { fUserScaleFactor += zoomIncrement; /* The range of the fUserScaleFactor crosses over the range -1,0,1 frequently. * Based on the code below, -1 and 1 both scale the image to it's original * size we do the following to never have a registered wheel scroll * not effect the fUserScaleFactor. */ if (fUserScaleFactor == 0) { fUserScaleFactor = 2 * zoomIncrement; } emit scaleFactorChanged(fUserScaleFactor); fDebugger->setUserScale(fUserScaleFactor); drawTo(fDebugger->index()); }
void MaterialServer::completeDraw( Tempest::Device &device, const Scene &, ShadowBuffer &g, ShaderMaterial::UniformsContext &context, ShaderMaterial::UniformsContext & ){ { Mat &m = *mat[ shadow_main[2] ]; { Tempest::Render render(device, g.z, g.depth, m.m.vs, m.m.fs); render.clear( Tempest::Color(1,1,1,0), 1 ); } for( size_t i=0; i<gbufPass.size(); ++i ){ Mat &m1 = *gbufPass[i]; drawTo( m1, device, false, context, g.z, g.depth ); //draw( m1, m1, render, context ); } for( size_t i=0; i<mat.size(); ++i ) mat[i]->obj.clear(); } //execEfect(device, econtext, g.z); }
void SkCanvasWidget::zoom(float scale, int px, int py) { fUserMatrix.postScale(scale, scale, px, py); emit scaleFactorChanged(fUserMatrix.getScaleX()); fDebugger->setUserMatrix(fUserMatrix); drawTo(fDebugger->index()); }
void SkCanvasWidget::resetWidgetTransform() { fUserMatrix.reset(); fDebugger->setUserMatrix(fUserMatrix); emit scaleFactorChanged(fUserMatrix.getScaleX()); drawTo(fDebugger->index()); }
void WinImageRGB::drawTo(HDC hdc, slen_t dstX, slen_t dstY) const { drawTo(hdc, dstX, dstY, header.biWidth, -header.biHeight, 0, 0); }
inline void drawTo(HDC hdc, slen_t dstX, slen_t dstY) const { drawTo(hdc, dstX, dstY, wd, ht, 0, 0); }