Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7736255
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T07:41:57+00:00 2026-06-01T07:41:57+00:00

In my gallery app, I asynchronously load images frequently, which are dumped into the

  • 0

In my gallery app, I asynchronously load images frequently, which are dumped into the CCTextureCache referenced by their filename. The thing is, I need to mask my textures — and this masking really only needs to be done once, so ideally, I figured the best place to put it would be in the selector that addImageAsync calls. I had to modify CCTexture by adding in a boolean variable which notifies me if the specific texture has already been masked or not, and that works very well.

In fact, even the masking code itself (which is accomplished using a CCRenderTexture following Ray’s masking tutorial) also works well inside the selector code. The issue I am having now is, once I’ve applied my mask logic, I have the CCRenderTexture.sprite.texture and I need to update my CCTextureCache with this updated, masked texture so that in the future, any other Sprite or call that references the specified file name will make use of the fully prepared texture.

How can I update the texture data in CCTextureCache? Or more specifically, how can I replace an existing, cached texture with the one stored in my render texture?

I know the textures themselves (their data) is actually stored in OpenGL and not within the Cocos2D classes; so I’d imagine something along the lines of removing the OpenGL texture with the name (GLuint) of the cached texture, and then setting the cached texture’s name (GLuint) to the name of the RenderTexture’s sprite.texture… but I’m at a loss on how to go about actually accomplishing that (opengl code, cocos2d thread safe code, altering the cctexturecache’s dictionary, etc).

Or maybe there is a simpler way to go about it without altering Cocos2D (eg utilizing opengl to replace the texture referenced by the texture cache with the render texture’s texture, then letting the local RT variable die and get cleaned up automatically?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T07:41:58+00:00Added an answer on June 1, 2026 at 7:41 am

    How can I update the texture data in CCTextureCache?

    This is how you remove a texture from the cache:

    CCTextureCache* cache = [CCTextureCache sharedTextureCache];
    [cache removeTexture:tex];
    // or:
    [cache removeTextureForKey:@"someimage.png"];
    

    You can then re-add the texture in any way you see fit, and it will force the cache to reload the texture.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm loading images from my phone gallery and loading it into my app gallery,
Hi I have a gallery in my app which shows the image in an
I'm using original Gallery app from the ICS source code. And Now the thing
I a writing a gallery app in php. The images are dynamically displayed through
I want to upload images to a gallery app. I want the user to
I was thinking about starting a gallery app with the ability to search/filter images
I am messing around with my own gallery app that loads images (thumbs and
I have about 20-ish high quality images (~3840x5800 px) that I need to load
I have used gallery in my app. In that i have two images in
I have an app which wants to view an image in the gallery app.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.