void TextureManager::requestBundle(Node* forNode) { if (forNode->hasBundleName()) { for (int i = 0; i < 6; i++) { std::vector<int> arrayOfCoordinates; // We ensure the texture is properly stretched, so we take the default cube size // TODO: This setting should be obtained from the Config class int coords[] = {0, 0, kDefTexSize, 0, kDefTexSize, kDefTexSize, 0, kDefTexSize}; unsigned arraySize = sizeof(coords) / sizeof(int); arrayOfCoordinates.assign(coords, coords + arraySize); Spot* spot = new Spot(arrayOfCoordinates, i, kSpotClass); Texture* texture = new Texture; spot->setTexture(texture); spot->texture()->setIndexInBundle(i); // In this case, the filename is generated from the name // of the texture spot->texture()->setName(forNode->bundleName().c_str()); registerTexture(spot->texture()); forNode->addSpot(spot); } } // Possibly raise an error if this fails }
bool TextureManager::updatePreloader() { if (_roomToPreload) { if (_roomToPreload->hasNodes()) { _roomToPreload->beginIteratingNodes(); do { Node* node = _roomToPreload->iterator(); if (node->hasSpots()) { node->beginIteratingSpots(); do { Spot* spot = node->currentSpot(); if (spot->hasTexture()) { if (!spot->texture()->isLoaded()) { spot->texture()->loadBitmap(); //_arrayOfActiveTextures.push_back(spot->texture()); } } } while (node->iterateSpots()); } } while (_roomToPreload->iterateNodes()); } } return true; }
void Scene::drawSpots(bool disableVideos) { bool processed = false; if (_canDrawSpots) { Node* currentNode = _currentRoom->currentNode(); if (currentNode->isEnabled()) { renderManager.enablePostprocess(); renderManager.clearView(); currentNode->updateFade(); renderManager.setAlpha(currentNode->fadeLevel()); currentNode->beginIteratingSpots(); do { Spot* spot = currentNode->currentSpot(); if (spot->hasTexture() && spot->isEnabled()) { if (spot->texture()->isLoaded()) { // FIXME: This was the culprit of a crash that should be investigated someday if (spot->hasVideo()) { // If it has a video, we need to check if it's playing if (spot->isPlaying()) { // FIXME: Must stop the spot later! if (spot->video()->hasNewFrame() && !disableVideos) { DGFrame* frame = spot->video()->currentFrame(); Texture* texture = spot->texture(); texture->loadRawData(frame->data, frame->width, frame->height); } spot->texture()->bind(); renderManager.drawPolygon(spot->arrayOfCoordinates(), spot->face()); } } else { // Draw right away... spot->texture()->bind(); renderManager.drawPolygon(spot->arrayOfCoordinates(), spot->face()); } } } } while (currentNode->iterateSpots()); if (config.showSpots) { renderManager.disableTextures(); currentNode->beginIteratingSpots(); do { Spot* spot = currentNode->currentSpot(); if (spot->hasColor() && spot->isEnabled()) { renderManager.setColor(0x2500AAAA); renderManager.drawPolygon(spot->arrayOfCoordinates(), spot->face()); } } while (currentNode->iterateSpots()); renderManager.enableTextures(); } renderManager.disablePostprocess(); processed = true; } } // Blends, gamma, etc. cameraManager.beginOrthoView(); if (processed) renderManager.drawPostprocessedView(); renderManager.blendView(); }