void launch_renderTile (int numTiles, int* pixels, const int width, const int height, const float time, const Vec3fa& vx, const Vec3fa& vy, const Vec3fa& vz, const Vec3fa& p, const int numTilesX, const int numTilesY) { #if 0 atomic_t tileID = 0; parallel_for(size_t(0),size_t(getNumberOfLogicalThreads()),[&] (const range<size_t>& r) { for (size_t tid=r.begin(); tid<r.end(); tid++) { while (true) { size_t i = atomic_add(&tileID,1); if (i >= numTiles) break; renderTile(i,pixels,width,height,time,vx,vy,vz,p,numTilesX,numTilesY); } } }); #else parallel_for(size_t(0),size_t(numTiles),[&] (const range<size_t>& r) { //if (inrender) PING; //inrender = true; for (size_t i=r.begin(); i<r.end(); i++) renderTile(i,pixels,width,height,time,vx,vy,vz,p,numTilesX,numTilesY); //inrender = false; }); #endif }
void editor::updateTile(int x, int y) { renderTile(x, y); renderTile(x-1, y); renderTile(x+1, y); renderTile(x, y-1); renderTile(x, y+1); update(); }
/** * \brief renders and compares the givent tile with a reference rendering * \param name basename of the file (e.g. 'test' for 'test.png') * \param id the tile to render and compare */ void checkTile(const char* name, shared_ptr<TileIdentifier> id) { string p = (getRenderedDirectory() / string(name)).native() + string(".png"); renderTile(p.c_str(), id); compareTile(name); }
void QwtPolarSpectrogram::renderTile( const QwtScaleMap &azimuthMap, const QwtScaleMap &radialMap, const QPointF &pole, TileInfo *tileInfo ) const { renderTile( azimuthMap, radialMap, pole, tileInfo->imagePos, tileInfo->rect, tileInfo->image ); }
void GBTileView::render() { int tiles = 0x0000; if(charBase) tiles = 0x0800; u8 *charBase = (gbVram != NULL) ? (bank ? &gbVram[0x2000+tiles] : &gbVram[tiles]) : &gbMemory[0x8000+tiles]; int tile = 0; for(int y = 0; y < 16; y++) { for(int x = 0; x < 16; x++) { renderTile(tile, x, y, charBase); tile++; } } tileView.setSize(16*8, 16*8); w = 16*8; h = 16*8; SIZE s; s.cx = s.cy = 16*8; if(tileView.getStretch()) { s.cx = s.cy = 1; } tileView.SetScrollSizes(MM_TEXT, s); }
void GlutClass::drawTiles(){ /* draws the map - only draws the tiles that are within the draw range of the character */ char text; //calculate the min and max draw range and only show those tile within those bounds int draw_range = DEFAULT_DRAW_RANGE; int min_range_y = player_y - draw_range; if (min_range_y < 0){ min_range_y = 0; } int max_range_y = player_y + draw_range; if (max_range_y > map->getSizeY()-1){ max_range_y = map->getSizeY(); } int min_range_x = player_x - draw_range; if (min_range_x < 0){ min_range_x = 0; } int max_range_x = player_x + draw_range; if (max_range_x > map->getSizeX() - 1){ max_range_x = map->getSizeX(); } for (int y = min_range_y; y < max_range_y; y++){ for (int x = min_range_x; x < max_range_x; x++){ Coordinate *pos = new Coordinate(x, y); Tile *tile = map->getTileAtPos(pos); text = tile->current_character; renderTile(tile, text, x, y); delete pos; } } }
void editor::render() { pixmap->fill(transparent); for (int i = -xCorner/tilesize; i <= -(xCorner-width())/tilesize; i++) for (int j = -(height()-yCorner/tilesize); j <= level.h+(yCorner/tilesize); j++) renderTile(i, j); update(); }
/* task that renders a single screen tile */ void renderTileTask (int taskIndex, int threadIndex, int* pixels, const unsigned int width, const unsigned int height, const float time, const ISPCCamera& camera, const int numTilesX, const int numTilesY) { renderTile(taskIndex,threadIndex,pixels,width,height,time,camera,numTilesX,numTilesY); }
/* render and display the current model */ static void renderFrame (struct state *st) { int n; /* This assumes black is zero. */ memset (st->workImage->data, 0, st->workImage->bytes_per_line * st->workImage->height); sortTiles (st); for (n = 0; n < st->tileCount; n++) { renderTile (st, st->sortedTiles[n]); } put_xshm_image (st->dpy, st->window, st->backgroundGC, st->workImage, 0, 0, 0, 0, st->windowWidth, st->windowHeight, &st->shmInfo); }
void GlutClass::InitializeTiles(){ char text; for (int y = 0; y < map->getSizeY(); y++){ for (int x = 0; x < map->getSizeX(); x++){ Coordinate *pos = new Coordinate(x, y); Tile *tile = map->getTileAtPos(pos); /* if (tile->getType().compare("GRASS") == 0){ text = ','; } else if (tile->getType().compare("WALL") == 0){ text = '#'; } */ text = tile->current_character; tile->VISIBLE = false; renderTile(tile, text, x, y); delete pos; } } }
void Raytracer::trace() { osg::Vec3f eye,center,up; _camera->getViewMatrixAsLookAt(eye,center,up); osg::Matrix projToWorld = osg::Matrix::inverse(_camera->getViewMatrix() *_camera->getProjectionMatrix()); const int numTilesX = (_width +TILE_SIZE_X-1)/TILE_SIZE_X; const int numTilesY = (_height+TILE_SIZE_Y-1)/TILE_SIZE_Y; for (int i =0; i < numTilesX*numTilesY;++i) { int tileY = i / numTilesX; int tileX= i - tileY*numTilesX; int x0 = tileX * TILE_SIZE_X; int x1 = std::min(x0+TILE_SIZE_X,_width); int y0 = tileY * TILE_SIZE_Y; int y1 = std::min(y0+TILE_SIZE_Y,_height); renderTile(x0,x1,y0,y1,eye,projToWorld); } osgDB::writeImageFile(*_framebuffer,"result.bmp"); }
/** * Render the tiles for a frame. * @param xOffset the leftmost X coordinate * @param yOffset the topmost Y coordinate * @todo This can be simplified and improved significantly by just rendering a * pre-created vertex array of the entire tilemap on each frame. It will * reduce overhead and actually be faster. */ void GLTileEngine::renderTiles() { static uint64_t lasttime = 0; int width = this->width, height = this->height; int xOffset = this->xOffset, yOffset = this->yOffset; xOffset &= 0xfffffff0; yOffset &= 0xfffffff0; glBindTexture(GL_TEXTURE_2D, this->texture); GLenum filter = this->scale == 1.0f ? GL_NEAREST : GL_LINEAR; glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter); // do the actual drawing glBegin(GL_QUADS); for(int y=yOffset; y <= this->yMax; y+=16) { for(int x=xOffset; x <= this->xMax; x+=16) { int tileX = x>>4; int tileY = y>>4; if(tileX < 0 || tileX >= WORLD_W || tileY < 0 || tileY >= WORLD_H) continue; int tile = *(unsigned short*)(this->tiles + ROW_BYTES*tileY + COL_BYTES*tileX) & LOMASK; renderTile(x, y, tile); } } glEnd(); if(lasttime) printf("FPS: %f\r", 1000000.0/(ClockGetTime()-lasttime)); lasttime = ClockGetTime(); }
/*! \brief Render an image from data and color map. For each pixel of area the value is mapped into a color. \param xMap X-Scale Map \param yMap Y-Scale Map \param area Requested area for the image in scale coordinates \param imageSize Size of the requested image \return A QImage::Format_Indexed8 or QImage::Format_ARGB32 depending on the color map. \sa QwtRasterData::value(), QwtColorMap::rgb(), QwtColorMap::colorIndex() */ QImage QwtPlotSpectrogram::renderImage( const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &area, const QSize &imageSize ) const { if ( imageSize.isEmpty() || d_data->data == NULL || d_data->colorMap == NULL ) { return QImage(); } const QwtInterval intensityRange = d_data->data->interval( Qt::ZAxis ); if ( !intensityRange.isValid() ) return QImage(); QImage::Format format = ( d_data->colorMap->format() == QwtColorMap::RGB ) ? QImage::Format_ARGB32 : QImage::Format_Indexed8; QImage image( imageSize, format ); if ( d_data->colorMap->format() == QwtColorMap::Indexed ) image.setColorTable( d_data->colorMap->colorTable( intensityRange ) ); d_data->data->initRaster( area, image.size() ); #if QT_VERSION >= 0x040400 && !defined(QT_NO_QFUTURE) uint numThreads = renderThreadCount(); if ( numThreads <= 0 ) numThreads = QThread::idealThreadCount(); if ( numThreads <= 0 ) numThreads = 1; const int numRows = imageSize.height() / numThreads; QList< QFuture<void> > futures; for ( uint i = 0; i < numThreads; i++ ) { QRect tile( 0, i * numRows, image.width(), numRows ); if ( i == numThreads - 1 ) { tile.setHeight( image.height() - i * numRows ); renderTile( xMap, yMap, tile, &image ); } else { futures += QtConcurrent::run( this, &QwtPlotSpectrogram::renderTile, xMap, yMap, tile, &image ); } } for ( int i = 0; i < futures.size(); i++ ) futures[i].waitForFinished(); #else // QT_VERSION < 0x040400 const QRect tile( 0, 0, image.width(), image.height() ); renderTile( xMap, yMap, tile, &image ); #endif d_data->data->discardRaster(); return image; }
/*! \brief Render an image from the data and color map. The area is translated into a rect of the paint device. For each pixel of this rect the intensity is mapped into a color. \param azimuthMap Maps azimuth values to values related to 0.0, M_2PI \param radialMap Maps radius values into painter coordinates. \param pole Position of the pole in painter coordinates \param rect Target rectangle of the image in painter coordinates \return A QImage::Format_Indexed8 or QImage::Format_ARGB32 depending on the color map. \sa QwtRasterData::intensity(), QwtColorMap::rgb(), QwtColorMap::colorIndex() */ QImage QwtPolarSpectrogram::renderImage( const QwtScaleMap &azimuthMap, const QwtScaleMap &radialMap, const QPointF &pole, const QRect &rect ) const { if ( d_data->data == NULL || d_data->colorMap == NULL ) return QImage(); QImage image( rect.size(), d_data->colorMap->format() == QwtColorMap::RGB ? QImage::Format_ARGB32 : QImage::Format_Indexed8 ); const QwtInterval intensityRange = d_data->data->interval( Qt::ZAxis ); if ( !intensityRange.isValid() ) return image; if ( d_data->colorMap->format() == QwtColorMap::Indexed ) image.setColorTable( d_data->colorMap->colorTable( intensityRange ) ); /* For the moment we only announce the composition of the image by calling initRaster(), but we don't pass any useful parameters. ( How to map rect into something, that is useful to initialize a matrix of values in polar coordinates ? ) */ d_data->data->initRaster( QRectF(), QSize() ); #if QT_VERSION >= 0x040400 && !defined(QT_NO_QFUTURE) uint numThreads = renderThreadCount(); if ( numThreads <= 0 ) numThreads = QThread::idealThreadCount(); if ( numThreads <= 0 ) numThreads = 1; const int numRows = rect.height() / numThreads; QVector<TileInfo> tileInfos; for ( uint i = 0; i < numThreads; i++ ) { QRect tile( rect.x(), rect.y() + i * numRows, rect.width(), numRows ); if ( i == numThreads - 1 ) tile.setHeight( rect.height() - i * numRows ); TileInfo tileInfo; tileInfo.imagePos = rect.topLeft(); tileInfo.rect = tile; tileInfo.image = ℑ tileInfos += tileInfo; } QVector< QFuture<void> > futures; for ( int i = 0; i < tileInfos.size(); i++ ) { if ( i == tileInfos.size() - 1 ) { renderTile( azimuthMap, radialMap, pole, &tileInfos[i] ); } else { futures += QtConcurrent::run( this, &QwtPolarSpectrogram::renderTile, azimuthMap, radialMap, pole, &tileInfos[i] ); } } for ( int i = 0; i < futures.size(); i++ ) futures[i].waitForFinished(); #else // QT_VERSION < 0x040400 renderTile( azimuthMap, radialMap, pole, rect.topLeft(), rect, &image ); #endif d_data->data->discardRaster(); return image; }
void renderTile_parallel(RenderTileTask* task, size_t threadIndex, size_t threadCount, size_t taskIndex, size_t taskCount, TaskScheduler::Event* event) { renderTile(taskIndex,task->pixels,task->width,task->height,task->time,task->vx,task->vy,task->vz,task->p,task->numTilesX,task->numTilesY); }