////////////////////////////////////////////////////////
//
// TextureTest
//
////////////////////////////////////////////////////////
void TextureTest::performTestsPNG(const char* filename)
{
    struct timeval now;
    Texture2D *texture;
    auto cache = Director::getInstance()->getTextureCache();
    
    Texture2D::PixelFormat defaultFormat = Texture2D::getDefaultAlphaPixelFormat();

    log("RGBA 8888");
    Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGBA8888);
    gettimeofday(&now, NULL);
    texture = cache->addImage(filename);
    if( texture )
        log("  ms:%f", calculateDeltaTime(&now) );
    else
        log(" ERROR");
    cache->removeTexture(texture);

    log("RGBA 4444");
    Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGBA4444);
    gettimeofday(&now, NULL);
    texture = cache->addImage(filename);
    if( texture )
        log("  ms:%f", calculateDeltaTime(&now) );
    else
        log(" ERROR");
    cache->removeTexture(texture);

    log("RGBA 5551");
    Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGB5A1);
    gettimeofday(&now, NULL);
    texture = cache->addImage(filename);
    if( texture )
        log("  ms:%f", calculateDeltaTime(&now) );
    else
        log(" ERROR");
    cache->removeTexture(texture);

    log("RGB 565");
    Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGB565);
    gettimeofday(&now, NULL);    
    texture = cache->addImage(filename);
    if( texture )
        log("  ms:%f", calculateDeltaTime(&now) );
    else
        log(" ERROR");
    cache->removeTexture(texture);
    
    Texture2D::setDefaultAlphaPixelFormat(defaultFormat);
}
Ejemplo n.º 2
0
/* TextureXPanel::handleAction
 * Handles the action [id]. Returns true if the action was handled,
 * false otherwise
 *******************************************************************/
bool TextureXPanel::handleAction(string id)
{
	// Don't handle if hidden
	if (!tx_editor->IsShown() || !IsShown())
		return false;

	// Only interested in "txed_" events
	if (!id.StartsWith("txed_"))
		return false;

	// Handle action
	if (id == "txed_new")
		newTexture();
	else if (id == "txed_delete")
		removeTexture();
	else if (id == "txed_new_patch")
		newTextureFromPatch();
	else if (id == "txed_new_file")
		newTextureFromFile();
	else if (id == "txed_up")
		moveUp();
	else if (id == "txed_down")
		moveDown();
	else if (id == "txed_sort")
		sort();
	else if (id == "txed_copy")
		copy();
	else if (id == "txed_cut")
	{
		copy();
		removeTexture();
	}
	else if (id == "txed_paste")
		paste();
	else if (id == "txed_export")
		exportTexture();
	else if (id == "txed_extract")
		extractTexture();
	else if (id == "txed_rename")
		renameTexture();
	else if (id == "txed_rename_each")
		renameTexture(true);
	else if (id == "txed_offsets")
		modifyOffsets();
	else
		return false;	// Not handled here

	return true;
}
Ejemplo n.º 3
0
unsigned TextureManager::requestTexture(TextureToken token, IntSize size, unsigned format, bool* newTexture)
{
    if (size.width() > m_maxTextureSize || size.height() > m_maxTextureSize)
        return 0;

    TextureMap::iterator it = m_textures.find(token);
    if (it != m_textures.end()) {
        ASSERT(it->second.size != size || it->second.format != format);
        removeTexture(token, it->second);
    }

    size_t memoryRequiredBytes = memoryUseBytes(size, format);
    if (memoryRequiredBytes > m_memoryLimitBytes || !reduceMemoryToLimit(m_memoryLimitBytes - memoryRequiredBytes))
        return 0;

    unsigned textureId = m_context->createTexture();
    GLC(m_context.get(), textureId = m_context->createTexture());
    GLC(m_context.get(), m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, textureId));
    // Do basic linear filtering on resize.
    GLC(m_context.get(), m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, GraphicsContext3D::LINEAR));
    GLC(m_context.get(), m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, GraphicsContext3D::LINEAR));
    // NPOT textures in GL ES only work when the wrap mode is set to GraphicsContext3D::CLAMP_TO_EDGE.
    GLC(m_context.get(), m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::CLAMP_TO_EDGE));
    GLC(m_context.get(), m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE));
    GLC(m_context.get(), m_context->texImage2DResourceSafe(GraphicsContext3D::TEXTURE_2D, 0, format, size.width(), size.height(), 0, format, GraphicsContext3D::UNSIGNED_BYTE));
    TextureInfo info;
    info.size = size;
    info.format = format;
    info.textureId = textureId;
    info.isProtected = true;
    addTexture(token, info);
    return textureId;
}
Ejemplo n.º 4
0
void TextureList::clearList()
{
    for(int i = 0; i < 256; i++)
    {
        removeTexture(i);
    }
};
Ejemplo n.º 5
0
void TextureManager::removeTexture(std::string name)
{
        if ( textureexists(name) ) {
                std::map<std::string, Texture*>::iterator itt = textures.find(name);
                removeTexture(itt);
        }
}
Ejemplo n.º 6
0
bool TextureManager::requestTexture(TextureToken token, IntSize size, unsigned format)
{
    if (size.width() > m_maxTextureSize || size.height() > m_maxTextureSize)
        return false;

    TextureMap::iterator it = m_textures.find(token);
    if (it != m_textures.end()) {
        ASSERT(it->second.size != size || it->second.format != format);
        removeTexture(token, it->second);
    }

    size_t memoryRequiredBytes = memoryUseBytes(size, format);
    if (memoryRequiredBytes > m_maxMemoryLimitBytes)
        return false;

    reduceMemoryToLimit(m_maxMemoryLimitBytes - memoryRequiredBytes);
    if (m_memoryUseBytes + memoryRequiredBytes > m_maxMemoryLimitBytes)
        return false;

    TextureInfo info;
    info.size = size;
    info.format = format;
    info.textureId = 0;
    info.isProtected = true;
#ifndef NDEBUG
    info.allocator = 0;
#endif
    addTexture(token, info);
    return true;
}
Ejemplo n.º 7
0
void Renderer::deleteTexture(const int index){
	if (textures[index].texID != TEXTURE_UNDEFINED){
		removeTexture(textures[index]);

		if (!textures[index].isRenderTarget){
			switch (textures[index].textureKind){
			case TEXKIND_1D:
			case TEXKIND_2D:
				delete textures[index].images[0];
				break;
			case TEXKIND_CUBEMAP:
				int i;
				for (i = 0; i < 6; i++) delete textures[index].images[i];
				break;
#ifndef NO_TEX3D
			case TEXKIND_3D:
				delete textures[index].image3D;
				break;
#endif
			}
		}
		
		textures[index].texID = TEXTURE_UNDEFINED;
	}
}
Ejemplo n.º 8
0
void LevelTextures::cleanup()
{
    for(int i = 0; i < 256; i++)
    {
        unallocateTextures(i);
        removeTexture(i);
    }
};
Ejemplo n.º 9
0
 unsigned int ResourceManager::clear()
 {
     unsigned int size = m_textures.size();
     //m_textures.clear();
     std::map<std::string, TexturePtr>::iterator it=m_textures.begin();
     while(it != m_textures.end())
     {
         removeTexture(it->first);
         it = m_textures.begin();
     }
     
     return size;
 }
Ejemplo n.º 10
0
//-----------------------------------------------------------------------------
void GUILayerBasic::setTexture(int id, LPDIRECT3DTEXTURE9 d3d_texture) {
  if (d3d_texture != NULL) {
    GUITexture* gui_texture = getTexture(id);
    if (!gui_texture) {
      gui_texture = new GUITexture();
      textures_.insert(TextureMap::value_type(id, gui_texture));
    }
    gui_texture->acquire(d3d_texture);
  } else {
    removeTexture(id);
    textures_.insert(TextureMap::value_type(id, NULL));
  }
}
Ejemplo n.º 11
0
	void releaseTexture(const QString& filename)
	{
		if (m_textures.contains(filename))
		{
			if (m_textures[filename].counter > 1)
			{
				--m_textures[filename].counter;
			}
			else
			{
				removeTexture(filename);
			}
		}
	}
Ejemplo n.º 12
0
//===========================================================================
bool cWorld::deleteTexture(cTexture2D* a_texture)
{
    // remove texture from list
    bool result = removeTexture(a_texture);

    // if operation succeeds, delete object
    if (result)
    {
        delete a_texture;
    }

    // return result
    return (result);
}
Ejemplo n.º 13
0
void TextureManager::onUnloaded( const ResourceEvent& event )
{
    ImageHandle handleImage = HandleCast<Image>(event.handle);
    Image* image = handleImage.Resolve();

    if( image->getResourceGroup() != ResourceGroup::Images )
        return;

    if( textures.Find(image) == textures.End() )
        return;

    LogDebug( "Removing texture '%s'", image->getPath().CString() );

    removeTexture(image);
}
Ejemplo n.º 14
0
bool ShaderParams::loadTexture(int index, QString filename)
{
	QImageReader reader(filename);
	reader.setAutoTransform(true);
	const QImage image = reader.read();
	if (!image.isNull()) {
		if (!material.getTexture().empty())
			removeTexture(index);
		float ratio = (float)image.width() / (float)image.height();
		material.setRatio(ratio);
		material.setTexture(filename.toStdString());
		textures[index] = loadTexture(image);
		return true;
	} else
		return false;
}
Ejemplo n.º 15
0
void VideoTextureCache::removeVideo(const char *path)
{
    _threadEnd = true;
    VideoDecode* pVideoDecode = (VideoDecode*)m_pVideoDecodes->at(path);
    if(pVideoDecode) {
        unsigned int rcount =  pVideoDecode->getReferenceCount();
        if(rcount == 1) {
            unsigned int frames = pVideoDecode->getFrames();
            for(; frames > 0; frames--) {
                removeTexture(path, frames);
            }
            m_pVideoDecodes->erase(path);
        } else {
            pVideoDecode->release();
        }
    }
}
Ejemplo n.º 16
0
void TextureManager::reduceMemoryToLimit(size_t limit)
{
    while (m_memoryUseBytes > limit) {
        ASSERT(!m_textureLRUSet.isEmpty());
        bool foundCandidate = false;
        for (ListHashSet<TextureToken>::iterator lruIt = m_textureLRUSet.begin(); lruIt != m_textureLRUSet.end(); ++lruIt) {
            TextureToken token = *lruIt;
            TextureInfo info = m_textures.get(token);
            if (info.isProtected)
                continue;
            removeTexture(token, info);
            foundCandidate = true;
            break;
        }
        if (!foundCandidate)
            return;
    }
}
Ejemplo n.º 17
0
void PathCache::remove(SkPath* path) {
    // TODO: Linear search...
    Vector<size_t> pathsToRemove;
    for (size_t i = 0; i < mCache.size(); i++) {
        if (mCache.getKeyAt(i).path == path) {
            pathsToRemove.push(i);
            removeTexture(mCache.getValueAt(i));
        }
    }

    mCache.setOnEntryRemovedListener(NULL);
    for (size_t i = 0; i < pathsToRemove.size(); i++) {
        // This will work because pathsToRemove is sorted
        // and because the cache is a sorted keyed vector
        mCache.removeAt(pathsToRemove.itemAt(i) - i);
    }
    mCache.setOnEntryRemovedListener(this);
}
Ejemplo n.º 18
0
bool TextureManager::requestTexture(TextureToken token, IntSize size, unsigned format, unsigned& textureId)
{
    textureId = 0;

    if (size.width() > m_maxTextureSize || size.height() > m_maxTextureSize)
        return false;

    TextureMap::iterator it = m_textures.find(token);
    if (it != m_textures.end()) {
        ASSERT(it->second.size != size || it->second.format != format);
        removeTexture(token, it->second);
    }

    size_t memoryRequiredBytes = memoryUseBytes(size, format);
    if (memoryRequiredBytes > m_maxMemoryLimitBytes)
        return false;

    reduceMemoryToLimit(m_maxMemoryLimitBytes - memoryRequiredBytes);
    if (m_memoryUseBytes + memoryRequiredBytes > m_maxMemoryLimitBytes)
        return false;

    TextureInfo info;
    info.size = size;
    info.format = format;
    info.textureId = 0;
    info.isProtected = true;
#ifndef NDEBUG
    info.allocator = 0;
#endif
    // Avoid churning by reusing the texture if it is about to be reclaimed and
    // it has the same size and format as the requesting texture.
    if (m_memoryUseBytes + memoryRequiredBytes > m_preferredMemoryLimitBytes) {
        textureId = replaceTexture(token, info);
        if (textureId)
            return true;
    }
    addTexture(token, info);
    return true;
}
Ejemplo n.º 19
0
Texture *TextureManager::LoadTexture(Texture *texture) {
	// See if the texture has already been loaded
	texture->calculateHash();
	Texture *found = findTexture(texture);
	if (found != NULL) {
		if (found->isMissMatch(texture)) {
			Con_DPrintf("GL_LoadTexture: cache mismatch\n");
			removeTexture(found);
			delete found;
		} else {
			delete texture;
			return found;
		}
	}

	if (!isDedicated) {
		texture->upload();
	}

	checkGLError("Loading texture");

	addTexture(texture);
	return texture;
}
Ejemplo n.º 20
0
/* TextureXPanel::onBtnRemoveTexture
 * Called when the 'Remove Texture' button is clicked
 *******************************************************************/
void TextureXPanel::onBtnRemoveTexture(wxCommandEvent& e)
{
	removeTexture();
}
Ejemplo n.º 21
0
void LevelTextures::rebuildTexture(int texture,unsigned char* buffer)
{
    if(textures)
    {
        if(texture < textures->getNumTextures() && texture >= 0)
        {
            unallocateTextures(texture);
            removeTexture(texture);

            unsigned char* data;

            if(buffer == NULL)
            data = new unsigned char[256*256*4];
            else data = buffer;

            if(textures->getTexture(texture)->usesPalette())
            {
                int numPalettes = 1;
                DriverPalette* palette;
                DriverPalette temppal;
                for(int i = 0; i < 256; i++)
                {
                    temppal.colors[i].r = i;
                    temppal.colors[i].g = i;
                    temppal.colors[i].b = i;
                    temppal.colors[i].a = 255;
                }
                if(d3d)
                {
                    D3DEntry* entry = d3d->getTextureEntry(texture);
                    if(entry)
                    numPalettes = entry->getNumPaletteIndicies();
                    else numPalettes = 0;

                    if(numPalettes <= 0)
                    numPalettes = 1;
                }

                GLuint* texlist = new GLuint[numPalettes];
                glGenTextures(numPalettes, texlist);

                for(int i = 0; i < numPalettes; i++)
                {
                    if(d3d)
                    {
                        D3DEntry* entry = d3d->getTextureEntry(texture);
                        if(entry)
                        palette = textures->getIndexedPalette(entry->getPaletteIndex(i));
                        else palette = NULL;

                        if(!palette)
                        {
                            palette = &temppal;
                        }
                    }
                    else
                    {
                        if(textures->getNumPalettes() > 0)
                        {
                            palette = textures->getPalette(0);
                        }
                        else palette = &temppal;
                    }

                    const DriverTexture* tex = textures->getTexture(texture);
                    for(int k = 0; k < 0x10000; k++)
                    {
                        unsigned int index = (int)*(unsigned char*)(tex->getData()+k);
                        *(unsigned int*)(data+4*k) = palette->colors[index].r+(palette->colors[index].g<<8)+(palette->colors[index].b<<16);
                        //if(tex->hasTransparency())
                        //*(unsigned int*)(data+4*k)+=(palette->colors[index].a<<24);
                        *(unsigned int*)(data+4*k)+=(0xFF<<24);
                    }

                    glBindTexture(GL_TEXTURE_2D, texlist[i]);
                    glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA,256,256,0,GL_RGBA,GL_UNSIGNED_BYTE,data);
                    glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,GL_REPEAT);
                    glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,GL_REPEAT);
                    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
                    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
                }
                addTexture(texture,texlist,numPalettes);
                delete[] texlist;
            }
            else
            {
                for(unsigned int j = 0; j < 0x10000; j++)
                {
                    unsigned short color = *(unsigned short*)(textures->getTexture(texture)->getData()+j*2);
                    if(color == 33825)
                    {
                        *(unsigned int*)(data+4*j) = 0;
                    }
                    else *(unsigned int*)(data+4*j) = (((color&0x7C00)>>10)*256/32)+((((color&0x03E0)>>5)*256/32)<<8)+(((color&0x001F)*256/32)<<16)+(0xFF<<24);
                }

                GLuint texture_num;
                glGenTextures( 1, &texture_num );
                glBindTexture( GL_TEXTURE_2D, texture_num );
                glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA,256,256,0,GL_RGBA,GL_UNSIGNED_BYTE,data);
                glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,GL_REPEAT);
                glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,GL_REPEAT);
                glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
                glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
                addTexture(texture,texture_num);
            }

            if(buffer == NULL)
            delete[] data;
        }
    }
Ejemplo n.º 22
0
/* TextureXPanel::onTextureListKeyDown
 * Called when a key is pressed in the texture list
 *******************************************************************/
void TextureXPanel::onTextureListKeyDown(wxKeyEvent& e)
{
	// Check if keypress matches any keybinds
	wxArrayString binds = KeyBind::getBinds(KeyBind::asKeyPress(e.GetKeyCode(), e.GetModifiers()));

	// Go through matching binds
	for (unsigned a = 0; a < binds.size(); a++)
	{
		string name = binds[a];

		// Copy
		if (name == "copy")
		{
			copy();
			return;
		}

		// Cut
		else if (name == "cut")
		{
			copy();
			removeTexture();
			return;
		}

		// Paste
		else if (name == "paste")
		{
			paste();
			return;
		}

		// Move texture up
		else if (name == "txed_tex_up")
		{
			moveUp();
			return;
		}

		// Move texture down
		else if (name == "txed_tex_down")
		{
			moveDown();
			return;
		}

		// New texture
		else if (name == "txed_tex_new")
		{
			newTexture();
			return;
		}

		// New texture from patch
		else if (name == "txed_tex_new_patch")
		{
			newTextureFromPatch();
			return;
		}

		// New texture from file
		else if (name == "txed_tex_new_file")
		{
			newTextureFromFile();
			return;
		}

		// Delete texture
		else if (name == "txed_tex_delete")
		{
			removeTexture();
			return;
		}
	}

	// Not handled here, send off to be handled by a parent window
	e.Skip();
}
Ejemplo n.º 23
0
// -----------------------------------------------------------------------------
// TextureXPanel class constructor
// -----------------------------------------------------------------------------
TextureXPanel::TextureXPanel(wxWindow* parent, TextureXEditor& tx_editor) :
	wxPanel{ parent, -1 },
	tx_editor_{ &tx_editor },
	undo_manager_{ tx_editor.getUndoManager() }
{
	// Setup sizer
	wxBoxSizer* sizer = new wxBoxSizer(wxHORIZONTAL);
	SetSizer(sizer);

	// Add textures list
	wxStaticBox*      frame      = new wxStaticBox(this, -1, "Textures");
	wxStaticBoxSizer* framesizer = new wxStaticBoxSizer(frame, wxVERTICAL);
	wxBoxSizer*       hbox       = new wxBoxSizer(wxHORIZONTAL);
	label_tx_format_             = new wxStaticText(this, -1, "Format:");
	hbox->Add(label_tx_format_, 0, wxALIGN_BOTTOM | wxRIGHT, UI::pad());
	btn_save_ = new SIconButton(this, "save", "Save");
	hbox->AddStretchSpacer();
	hbox->Add(btn_save_, 0, wxEXPAND);
	framesizer->Add(hbox, 0, wxEXPAND | wxLEFT | wxRIGHT, UI::pad());
	list_textures_ = new TextureXListView(this, &texturex_);
	framesizer->Add(list_textures_, 1, wxEXPAND | wxALL, UI::pad());
	sizer->Add(framesizer, 0, wxEXPAND | wxLEFT | wxTOP | wxBOTTOM, UI::pad());

	// Texture list filter
	text_filter_      = new wxTextCtrl(this, -1);
	btn_clear_filter_ = new SIconButton(this, "close", "Clear Filter");
	WxUtils::layoutHorizontally(
		framesizer,
		vector<wxObject*>{ WxUtils::createLabelHBox(this, "Filter:", text_filter_), btn_clear_filter_ },
		wxSizerFlags(0).Expand().Border(wxLEFT | wxRIGHT | wxBOTTOM, UI::pad()),
		0);

	// Add texture operations buttons
	wxGridBagSizer* gbsizer = new wxGridBagSizer(UI::pad(), UI::pad());
	framesizer->Add(gbsizer, 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, UI::pad());
	btn_move_up_        = new SIconButton(this, "up", "Move Up");
	btn_move_down_      = new SIconButton(this, "down", "Move Down");
	btn_new_texture_    = new SIconButton(this, "tex_new", "New");
	btn_remove_texture_ = new SIconButton(this, "tex_delete", "Remove");
	btn_new_from_patch_ = new SIconButton(this, "tex_newpatch", "New from Patch");
	btn_new_from_file_  = new SIconButton(this, "tex_newfile", "New from File");
	gbsizer->Add(btn_new_texture_, { 0, 0 }, { 1, 1 });
	gbsizer->Add(btn_new_from_patch_, { 0, 1 }, { 1, 1 });
	gbsizer->Add(btn_new_from_file_, { 0, 2 }, { 1, 1 });
	gbsizer->Add(btn_remove_texture_, { 0, 3 }, { 1, 1 });
	gbsizer->Add(btn_move_up_, { 0, 4 }, { 1, 1 });
	gbsizer->Add(btn_move_down_, { 0, 5 }, { 1, 1 });

	// Bind events
	list_textures_->Bind(wxEVT_LIST_ITEM_SELECTED, &TextureXPanel::onTextureListSelect, this);
	list_textures_->Bind(wxEVT_LIST_ITEM_RIGHT_CLICK, &TextureXPanel::onTextureListRightClick, this);
	list_textures_->Bind(wxEVT_KEY_DOWN, &TextureXPanel::onTextureListKeyDown, this);
	btn_new_texture_->Bind(wxEVT_BUTTON, [&](wxCommandEvent&) { newTexture(); });
	btn_new_from_patch_->Bind(wxEVT_BUTTON, [&](wxCommandEvent&) { newTextureFromPatch(); });
	btn_new_from_file_->Bind(wxEVT_BUTTON, [&](wxCommandEvent&) { newTextureFromFile(); });
	btn_remove_texture_->Bind(wxEVT_BUTTON, [&](wxCommandEvent&) { removeTexture(); });
	btn_move_up_->Bind(wxEVT_BUTTON, [&](wxCommandEvent&) { moveUp(); });
	btn_move_down_->Bind(wxEVT_BUTTON, [&](wxCommandEvent&) { moveDown(); });
	btn_save_->Bind(wxEVT_BUTTON, [&](wxCommandEvent&) { tx_editor_->saveChanges(); });
	Bind(wxEVT_SHOW, [&](wxShowEvent&) { tx_editor_->updateMenuStatus(); });
	text_filter_->Bind(wxEVT_TEXT, &TextureXPanel::onTextFilterChanged, this);
	btn_clear_filter_->Bind(wxEVT_BUTTON, &TextureXPanel::onBtnClearFitler, this);
}
Ejemplo n.º 24
0
void kore::ResourceManager::removeTexture(const Texture* texture) {
  removeTexture(texture->getID());
}
Ejemplo n.º 25
0
void TextureManager::evictTexture(TextureToken token, TextureInfo info)
{
    TRACE_EVENT("TextureManager::evictTexture", this, 0);
    removeTexture(token, info);
}
void PathCache::operator()(PathDescription& entry, PathTexture*& texture) {
    removeTexture(texture);
}
Ejemplo n.º 27
0
void ShaderParams::clearTextures()
{
	for (int i = 0; i < 4; i++)
		removeTexture(i);
}
Ejemplo n.º 28
0
void TextureManager::releaseToken(TextureToken token)
{
    TextureMap::iterator it = m_textures.find(token);
    if (it != m_textures.end())
        removeTexture(token, it->second);
}
Ejemplo n.º 29
0
bool GameScene::init()
{
    if (!Layer::init()) {
        return false;
    }

    _deviceOrientation = DeviceOrientation::Portrait;

    auto visibleSize = Director::getInstance()->getVisibleSize();

    //setContentSize(Size(visibleSize.width * 2, visibleSize.height));

    // 背景レイヤーの上にメインシーン、レポートシーンを含めるコンテナシーンを重ねて、コンテナシーンを移動させ、背景は固定されるようにする

    // 背景レイヤー
    auto bkgLayer = Layer::create();
    bkgLayer->setName(name::scene::game::BACKGROUND_LAYER);
    addChild(bkgLayer);

    auto cache = Director::getInstance()->getTextureCache();
    auto tex = cache->getTextureForKey(name::resource::GAME_BACKGROUND);
    auto spr = Sprite::createWithTexture(tex);
    cache->removeTexture(tex);
    //spr->setName(name::GAME_BACKGROUND);
    spr->setAnchorPoint(Vec2::ZERO);
    spr->setPosition(Vec2::ZERO);
    bkgLayer->addChild(spr);

    // コンテナレイヤー(メインシーンとレポートシーンを含める)
    auto containerLayer = Layer::create();
    containerLayer->setName(name::scene::game::CONTAINER_LAYER);
    addChild(containerLayer);

    auto mainScene = MainScene::create();
    mainScene->setName(name::scene::MAIN);
    mainScene->setAnchorPoint(Vec2::ZERO);
    mainScene->setPosition(Vec2::ZERO);
    containerLayer->addChild(mainScene);

    auto reportScene = ReportScene::create();
    reportScene->setName(name::scene::REPORT);
    reportScene->setAnchorPoint(Vec2::ZERO);
    reportScene->setPosition(Vec2(720, 0));
    containerLayer->addChild(reportScene);

    // 左スクロールイベント
    Director::getInstance()->getEventDispatcher()->addCustomEventListener(config::event::ScrollToLeftNotification, [this](EventCustom* evt) {
        auto vec = Vec2::ZERO;
        if (DeviceOrientation::Portrait == _deviceOrientation) {
            vec = Vec2(-720, 0);
        }
        else if (DeviceOrientation::Landscape == _deviceOrientation) {
            vec = Vec2(-1280, 0);
        }
        getChildByName(name::scene::game::CONTAINER_LAYER)->runAction(MoveBy::create(0.3f, vec));
    });
    // 右スクロールイベント
    Director::getInstance()->getEventDispatcher()->addCustomEventListener(config::event::ScrollToRightNotification, [this](EventCustom* evt) {
        auto vec = Vec2::ZERO;
        if (DeviceOrientation::Portrait == _deviceOrientation) {
            vec = Vec2(720, 0);
        }
        else if (DeviceOrientation::Landscape == _deviceOrientation) {
            vec = Vec2(1280, 0);
        }
        // スクロールしてスクロール完了を通知
        auto action = Sequence::createWithTwoActions(MoveBy::create(0.3f, vec), CallFunc::create([this]() {
            Director::getInstance()->getEventDispatcher()->dispatchCustomEvent(config::event::ScrollToRightCompletionNotification);
        }));
        getChildByName(name::scene::game::CONTAINER_LAYER)->runAction(action);
    });
    // 端末の向き変更イベント
    Director::getInstance()->getEventDispatcher()->addCustomEventListener(config::event::OrientationChangedNotification, [this](EventCustom* evt) {
        auto data = static_cast<ValueMap*>(evt->getUserData());
        auto w = data->at("w").asInt();
        auto h = data->at("h").asInt();

        auto glview = Director::getInstance()->getOpenGLView();
        // フレームサイズをセットしてから、デザイン解像度をセット
        glview->setFrameSize(w, h);
        if (w > h) {
            //CCLOG("(landscape) w: %d, h: %d", w, h);
            glview->setDesignResolutionSize(config::resolution::DESIGN_RESOLUTION_LONG_SPAN, config::resolution::DESIGN_RESOLUTION_SHORT_SPAN, config::resolution::DESIGN_POLICY);
            _deviceOrientation = DeviceOrientation::Landscape;
        }
        else {
            //CCLOG("(portrait) w: %d, h: %d", w, h);
            glview->setDesignResolutionSize(config::resolution::DESIGN_RESOLUTION_SHORT_SPAN, config::resolution::DESIGN_RESOLUTION_LONG_SPAN, config::resolution::DESIGN_POLICY);
            _deviceOrientation = DeviceOrientation::Portrait;
        }
        reArrangeChildrens();
    });

#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
    auto keyboardListener = EventListenerKeyboard::create();
    keyboardListener->onKeyPressed = [this](EventKeyboard::KeyCode keyCode, Event* event) {};
    keyboardListener->onKeyReleased = [this](EventKeyboard::KeyCode keyCode, Event* event) {
        if (EventKeyboard::KeyCode::KEY_V != keyCode && EventKeyboard::KeyCode::KEY_H != keyCode)
            return;

        auto data = ValueMap();
        if (EventKeyboard::KeyCode::KEY_V == keyCode) {
            data["w"] = 540;
            data["h"] = 960;
        }
        else if (EventKeyboard::KeyCode::KEY_H == keyCode) {
            data["w"] = 960;
            data["h"] = 540;
        }
        auto evtDispatcher = Director::getInstance()->getEventDispatcher();
        evtDispatcher->dispatchCustomEvent(config::event::OrientationChangedNotification, &data);
    };
    Director::getInstance()->getEventDispatcher()->addEventListenerWithSceneGraphPriority(keyboardListener, this);
#endif

    return true;
}