Giter VIP home page Giter VIP logo

Comments (4)

dyorgio avatar dyorgio commented on August 27, 2024

Possible solution for image update problem:

on GLG2DImageHelper:

void updateImage(Image image, int x, int y, int width, int height, Color bgColor, Buffer buffer);

on AbstractImageHelper:

public void updateImage(Image image, int x, int y, int width, int height, Color bgColor, Buffer buffer) {
        Texture texture = cache.get(image);
        if (texture != null) {
            begin(texture, null, bgColor);
            g2d.getGLContext().getGL().glTexSubImage2D(GL.GL_TEXTURE_2D, 0, 0, 0, image.getWidth(null), image.getHeight(null), GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, buffer);
            drawImage(image, x, y, width, height, bgColor, null);
            end(texture);
        }
    }

The code is compatible with GL2 and ES2 (glTexSubImage2D),
I use for video update on textures..

from glg2d.

brandonborkholder avatar brandonborkholder commented on August 27, 2024

My custom WeakHashMap is a holdover from when I had some additional
functionality, I think I can expunge it.

There are two reasons I've stuck with clearing the cache on every paint.

  • an Image may not have all its data at the time of painting in which
    case we want to paint with new data the next time
  • an application may be painting custom Images then discarding them, in
    which case we don't want to cache longer than we have to

But I do like your idea of using a RenderingHint to enable developers to
keep the cache from being cleared after each draw. Another option might be
a multi-level cache, where Images that do have all the data are kept across
draws and the cache has some maximum size.

from glg2d.

dyorgio avatar dyorgio commented on August 27, 2024

Is a big problem a new texture generation for every video frame :(

from glg2d.

brandonborkholder avatar brandonborkholder commented on August 27, 2024

I fixed this with 831147a. The new default cache policy is to never clear the cache. You can control this with the new GLG2DRenderingHints class. So if you draw the same icon each frame, it won't generate a new texture each time.

from glg2d.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.