void Screen::drawSortFrames(byte *file) { uint i, j; // Sort the sort list. Used to be a separate function, but it was only // called once, right before calling drawSortFrames(). if (_curSort > 1) { for (i = 0; i < _curSort - 1; i++) { for (j = 0; j < _curSort - 1; j++) { if (_sortList[_sortOrder[j]].sort_y > _sortList[_sortOrder[j + 1]].sort_y) { SWAP(_sortOrder[j], _sortOrder[j + 1]); } } } } // Draw the sorted frames - layers, shrinkers & normal flat sprites for (i = 0; i < _curSort; i++) { if (_sortList[_sortOrder[i]].layer_number) { // it's a layer - minus 1 for true layer number // we need to know from the BuildUnit because the // layers will have been sorted in random order processLayer(file, _sortList[_sortOrder[i]].layer_number - 1); } else { // it's a sprite processImage(&_sortList[_sortOrder[i]]); } } }
void processImage() { processLayer(sim_width, sim_height, cuda_dest_resource); cudaArray *texture_ptr; cutilSafeCall(cudaGraphicsMapResources(1, &cuda_tex_result_resource, 0)); cutilSafeCall(cudaGraphicsSubResourceGetMappedArray(&texture_ptr, cuda_tex_result_resource, 0, 0)); int num_texels = sim_width * sim_height; int num_values = num_texels * 4; int size_tex_data = sizeof(GLubyte) * num_values; cutilSafeCall(cudaMemcpyToArray(texture_ptr, 0, 0, cuda_dest_resource, size_tex_data, cudaMemcpyDeviceToDevice)); cutilSafeCall(cudaGraphicsUnmapResources(1, &cuda_tex_result_resource, 0)); }
bool TMXLoader::Private::load(const char *f) { TinyXML::XMLDocument l_tmx; XMLElement *l_root; is_loaded = false; if (l_tmx.LoadFile(f) != XML_NO_ERROR) return(false); /* get parent directory */ base_directory = Core::Platform::PathDirectory(f); /* parse general map data */ if (!(l_root = l_tmx.RootElement()) || !processMap(*l_root)) return(false); /* parse tilesets */ XMLElement *l_tileset = l_root->FirstChildElement(TMXTILESET_NODE); while (l_tileset) { if (!processTileset(*l_tileset)) return(false); l_tileset = l_tileset->NextSiblingElement(TMXTILESET_NODE); } /* parse layers and object groups */ XMLElement *l_element = l_root->FirstChildElement(); while (l_element) { if (0 == strcmp(l_element->Value(), TMXLAYER_NODE) && !processLayer(*l_element)) return(false); else if (0 == strcmp(l_element->Value(), TMXOBJECTGROUP_NODE) && !processObjectGroup(*l_element)) return(false); l_element = l_element->NextSiblingElement(); } /* attach layers to scene */ Game::SharedSceneLayerList::iterator l_layer_i; for (l_layer_i = layers.begin(); l_layer_i != layers.end(); ++l_layer_i) scene.pushLayer(*l_layer_i); return(is_loaded = true); }
int KmlRenderer::startNewLayer(imageObj *img, layerObj *layer) { char *layerName=NULL; const char *value=NULL; LayerNode = xmlNewNode(NULL, BAD_CAST "Folder"); layerName = getLayerName(layer); xmlNewChild(LayerNode, NULL, BAD_CAST "name", BAD_CAST layerName); msFree(layerName); const char *layerVisibility = layer->status != MS_OFF ? "1" : "0"; xmlNewChild(LayerNode, NULL, BAD_CAST "visibility", BAD_CAST layerVisibility); const char *layerDsiplayFolder = msLookupHashTable(&(layer->metadata), "kml_folder_display"); if (layerDsiplayFolder == NULL) layerDsiplayFolder = msLookupHashTable(&(layer->map->web.metadata), "kml_folder_display"); if (!layerDsiplayFolder || strlen(layerDsiplayFolder)<=0) { xmlNewChild(LayerNode, NULL, BAD_CAST "styleUrl", BAD_CAST "#LayerFolder_check"); } else { if (strcasecmp(layerDsiplayFolder, "checkHideChildren") == 0) xmlNewChild(LayerNode, NULL, BAD_CAST "styleUrl", BAD_CAST "#LayerFolder_checkHideChildren"); else if (strcasecmp(layerDsiplayFolder, "checkOffOnly") == 0) xmlNewChild(LayerNode, NULL, BAD_CAST "styleUrl", BAD_CAST "#LayerFolder_checkOffOnly"); else if (strcasecmp(layerDsiplayFolder, "radioFolder") == 0) xmlNewChild(LayerNode, NULL, BAD_CAST "styleUrl", BAD_CAST "#LayerFolder_radioFolder"); else xmlNewChild(LayerNode, NULL, BAD_CAST "styleUrl", BAD_CAST "#LayerFolder_check"); } /*Init few things on the first layer*/ if (FirstLayer) { FirstLayer = MS_FALSE; map = layer->map; if (layer->map->mappath) snprintf(MapPath, sizeof(MapPath), "%s", layer->map->mappath); /*First rendered layer - check mapfile projection*/ checkProjection(layer->map); /*check for image path and image url*/ if (layer->map->debug && (layer->map->web.imageurl == NULL || layer->map->web.imagepath == NULL)) msDebug("KmlRenderer::startNewLayer: imagepath and imageurl should be set in the web object\n"); /*map rect for ground overlay*/ MapExtent = layer->map->extent; MapCellsize = layer->map->cellsize; BgColor = layer->map->imagecolor; xmlNewChild(DocNode, NULL, BAD_CAST "name", BAD_CAST layer->map->name); aggFormat = msSelectOutputFormat( layer->map, "png24"); aggFormat->transparent = MS_TRUE; } currentLayer = layer; if (!msLayerIsOpen(layer)) { if (msLayerOpen(layer) != MS_SUCCESS) { msSetError(MS_MISCERR, "msLayerOpen failed", "KmlRenderer::startNewLayer" ); return MS_FAILURE; } } /*pre process the layer to set things that make sense for kml output*/ if (img) processLayer(layer, img->format); else processLayer(layer, NULL); if (msLookupHashTable(&layer->metadata, "kml_description")) pszLayerDescMetadata = msLookupHashTable(&layer->metadata, "kml_description"); else if (msLookupHashTable(&layer->metadata, "ows_description")) pszLayerDescMetadata = msLookupHashTable(&layer->metadata, "ows_description"); value=msLookupHashTable(&layer->metadata, "kml_include_items"); if (!value) value=msLookupHashTable(&layer->metadata, "ows_include_items"); if (value) papszLayerIncludeItems = msStringSplit(value, ',', &nIncludeItems); value=msLookupHashTable(&layer->metadata, "kml_exclude_items"); if (!value) value=msLookupHashTable(&layer->metadata, "ows_exclude_items"); if (value) papszLayerExcludeItems = msStringSplit(value, ',', &nExcludeItems); if (msLookupHashTable(&layer->metadata, "kml_name_item")) pszLayerNameAttributeMetadata = msLookupHashTable(&layer->metadata, "kml_name_item"); /*get all attributes*/ if(msLayerWhichItems(layer, MS_TRUE, NULL) != MS_SUCCESS) { return MS_FAILURE; } NumItems = layer->numitems; if (NumItems) { Items = (char **)msSmallCalloc(NumItems, sizeof(char *)); for (int i=0; i<NumItems; i++) Items[i] = msStrdup(layer->items[i]); } const char* elevationAttribute = msLookupHashTable(&layer->metadata, "kml_elevation_attribute"); if( elevationAttribute ) { mElevationFromAttribute = true; for( int i = 0; i < layer->numitems; ++i ) { if( strcasecmp( layer->items[i], elevationAttribute ) == 0 ) { mElevationAttributeIndex = i; } } } setupRenderingParams(&layer->metadata); return MS_SUCCESS; }