Esempio n. 1
0
void QgsPointMarkerItem::updateSize()
{
  QgsRenderContext rc = renderContext( nullptr );
  mMarkerSymbol->startRender( rc, mFeature.fields() );
  QRectF bounds =  mMarkerSymbol->bounds( mLocation, rc, mFeature );
  mMarkerSymbol->stopRender( rc );
  QgsRectangle r( mMapCanvas->mapSettings().mapToPixel().toMapCoordinates( bounds.x(), bounds.y() ),
                  mMapCanvas->mapSettings().mapToPixel().toMapCoordinates( bounds.x() + bounds.width() * 2, bounds.y() + bounds.height() * 2 ) );
  setRect( r );
}
Esempio n. 2
0
 bool Template::TryRender(HashFragment* data,
                          RenderError& error,
                          std::string& result)
 {
     // Initialize a render context
     RenderContext renderContext(data,
                                 this->_strainer,
                                 error);
     
     // Try to render the root node
     if (!this->_root.TryRender(renderContext))
         return false;
     
     // Assign the result to the output
     result = renderContext.Result.str();
     return true;
 }
Esempio n. 3
0
SchedulerCPU::ProducedCommands SchedulerCPU::ExecuteNode(GraphicsTask& task, std::optional<ProducedCommands>& inherited, const FrameContextEx& context) {
	// Inherit command list, if available.
	std::unique_ptr<BasicCommandList> inheritedCommandList;
	std::unique_ptr<VolatileViewHeap> inheritedVheap;
	if (inherited) {
		inheritedCommandList = std::move(inherited->list);
		inheritedVheap = std::move(inherited->vheap);
		inherited.reset();
	}

	// Execute given node.
	auto vheap = std::make_unique<VolatileViewHeap>(context.gxApi);
	RenderContext renderContext(context.memoryManager,
								context.textureSpace,
								context.shaderManager,
								context.gxApi,
								context.commandListPool,
								context.commandAllocatorPool,
								context.scratchSpacePool,
								std::move(inheritedCommandList),
								std::move(inheritedVheap));
	renderContext.SetCommandListName(typeid(task).name());
	task.Execute(renderContext);

	// Get inherited and current list, if any.
	std::unique_ptr<BasicCommandList> currentCommandList;
	std::unique_ptr<VolatileViewHeap> currentVheap;
	renderContext.Decompose(inheritedCommandList, currentCommandList, currentVheap);

	if (inheritedCommandList) {
		inherited = ProducedCommands{ std::move(inheritedCommandList), nullptr };
	}
	else {
		inherited.reset();
	}

	return { std::move(currentCommandList), std::move(currentVheap) };
}
Esempio n. 4
0
int gameloop(GLFWwindow* window)
{
  GLFWControlContext controlContext(window);
  GlhckGLFWRenderContext renderContext(window);
  GLFWTimeContext timeContext;
  ew::Engine engine(&controlContext, &renderContext, &timeContext);

  glfwSetWindowUserPointer(window, &engine);
  glfwSetWindowSizeCallback(window, windowResizeCallback);

  GameState::init();
  GameState game(&engine);
  engine.addState(0, &game);
  engine.setState(0);

  glhckMemoryGraph();

  engine.run();

  GameState::term();

  return EXIT_SUCCESS;
}
Esempio n. 5
0
static std::tuple<std::unique_ptr<BasicCommandList>, std::unique_ptr<VolatileViewHeap>> ExecuteUploadTask(const FrameContext& context) {
	UploadTask uploadTask(context.uploadRequests);
	SetupContext setupContext(context.memoryManager,
		context.textureSpace,
		context.rtvHeap,
		context.dsvHeap,
		context.shaderManager,
		context.gxApi);
	RenderContext renderContext(context.memoryManager,
		context.textureSpace,
		context.shaderManager,
		context.gxApi,
		context.commandListPool,
		context.commandAllocatorPool,
		context.scratchSpacePool,
		nullptr);
	uploadTask.Setup(setupContext);
	uploadTask.Execute(renderContext);
	std::unique_ptr<BasicCommandList> uploadInherit, uploadList;
	std::unique_ptr<VolatileViewHeap> uploadVheap;
	renderContext.Decompose(uploadInherit, uploadList, uploadVheap);
	return { std::move(uploadList), std::move(uploadVheap) };
}
Esempio n. 6
0
int main() {
    try {
        std::string mediaPath = UTILS::GetMediaFolder();
        std::string fontPath = mediaPath + "Fonts/courier.ttf";

        RenderContextSetup setup;
        setup.Width = 640;
        setup.Height = 480;
        RenderContext renderContext(setup);
        //LayoutManager layout(&renderContext);

        // Sprite setup
        Sprite sprite0(&renderContext);
        Sprite sprite1(&renderContext);
        Sprite sprite2(&renderContext);
        Sprite sprite3(&renderContext);
        
        sprite0.SetSize(SPRITE_SIZE, SPRITE_SIZE);
        sprite1.SetSize(SPRITE_SIZE, SPRITE_SIZE);
        sprite2.SetSize(SPRITE_SIZE, SPRITE_SIZE);
        sprite3.SetSize(SPRITE_SIZE, SPRITE_SIZE);
        
        sprite0.SetPosition(0, 0);
        sprite1.SetPosition(renderContext.GetWindowWidth() - SPRITE_SIZE, 0);
        sprite2.SetPosition(0, renderContext.GetWindowHeight() - SPRITE_SIZE);
        sprite3.SetPosition(renderContext.GetWindowWidth() - SPRITE_SIZE, renderContext.GetWindowHeight() - SPRITE_SIZE);

        sprite0.SetTexture(mediaPath + "Textures/Smile.png");
        sprite1.SetTexture(mediaPath + "Textures/Smile.png");
        sprite2.SetTexture(mediaPath + "Textures/Smile.png");
        sprite3.SetTexture(mediaPath + "Textures/Smile.png");
        //Console console(&renderContext);
        // Text setup
        Text text(&renderContext, fontPath);
        text << Text::set_size(32) << "Font rendering is guano!";
        float opacity = 1.0f;
        bool direction = true;
        while (renderContext.ProcessMessage()) {
            renderContext.Clear();
            if (direction) {
                opacity -= 0.01f;
                sprite0.SetPosition(sprite0.GetX() + 1, sprite0.GetY() + 1);
                sprite3.SetPosition(sprite3.GetX() - 1, sprite3.GetY() - 1);
                if (opacity <= 0.0f) {
                    direction = false;
                }
            }
            else {
                opacity += 0.01f;
                sprite0.SetPosition(sprite0.GetX() - 1, sprite0.GetY() - 1);
                sprite3.SetPosition(sprite3.GetX() + 1, sprite3.GetY() + 1);
                if (opacity >= 1.0f) {
                    direction = true;
                }
            }
            sprite0.SetOpacity(opacity);
            sprite3.SetOpacity(opacity);

            sprite0.Render();
            sprite1.Render();
            sprite2.Render();
            sprite3.Render();
            
            //console.Render();
            text.Render();
            renderContext.Present();
        }
        return 0;
    }
    catch (std::exception& ex) {
        ::MessageBoxA(NULL, ex.what(), NULL, NULL); 
    }
}
Esempio n. 7
0
void QgsDxfExport::writeEntitiesSymbolLevels( QgsVectorLayer* layer )
{
  if ( !layer )
  {
    return;
  }

  QgsFeatureRendererV2* renderer = layer->rendererV2();
  if ( !renderer )
  {
    //return error
  }
  QHash< QgsSymbolV2*, QList<QgsFeature> > features;

  QgsRenderContext ctx = renderContext();
  QgsSymbolV2RenderContext sctx( ctx, QgsSymbolV2::MM , 1.0, false, 0, 0 );
  renderer->startRender( ctx, layer->pendingFields() );

  //get iterator
  QgsFeatureRequest req;
  if ( layer->wkbType() == QGis::WKBNoGeometry )
  {
    req.setFlags( QgsFeatureRequest::NoGeometry );
  }
  req.setSubsetOfAttributes( QStringList( renderer->usedAttributes() ), layer->pendingFields() );
  if ( !mExtent.isEmpty() )
  {
    req.setFilterRect( mExtent );
  }
  QgsFeatureIterator fit = layer->getFeatures( req );

  //fetch features
  QgsFeature fet;
  QgsSymbolV2* featureSymbol = 0;
  while ( fit.nextFeature( fet ) )
  {
    featureSymbol = renderer->symbolForFeature( fet );
    if ( !featureSymbol )
    {
      continue;
    }

    QHash< QgsSymbolV2*, QList<QgsFeature> >::iterator it = features.find( featureSymbol );
    if ( it == features.end() )
    {
      it = features.insert( featureSymbol, QList<QgsFeature>() );
    }
    it.value().append( fet );
  }

  //find out order
  QgsSymbolV2LevelOrder levels;
  QgsSymbolV2List symbols = renderer->symbols();
  for ( int i = 0; i < symbols.count(); i++ )
  {
    QgsSymbolV2* sym = symbols[i];
    for ( int j = 0; j < sym->symbolLayerCount(); j++ )
    {
      int level = sym->symbolLayer( j )->renderingPass();
      if ( level < 0 || level >= 1000 ) // ignore invalid levels
        continue;
      QgsSymbolV2LevelItem item( sym, j );
      while ( level >= levels.count() ) // append new empty levels
        levels.append( QgsSymbolV2Level() );
      levels[level].append( item );
    }
  }

  //export symbol layers and symbology
  for ( int l = 0; l < levels.count(); l++ )
  {
    QgsSymbolV2Level& level = levels[l];
    for ( int i = 0; i < level.count(); i++ )
    {
      QgsSymbolV2LevelItem& item = level[i];
      QHash< QgsSymbolV2*, QList<QgsFeature> >::iterator levelIt = features.find( item.symbol() );

      int llayer = item.layer();
      QList<QgsFeature>& featureList = levelIt.value();
      QList<QgsFeature>::iterator featureIt = featureList.begin();
      for ( ; featureIt != featureList.end(); ++featureIt )
      {
        addFeature( sctx, layer->name(), levelIt.key()->symbolLayer( llayer ), levelIt.key() );
      }
    }
  }
  renderer->stopRender( ctx );
}