Giter Site home page Giter Site logo

jagenjo / canvas2dtowebgl Goto Github PK

View Code? Open in Web Editor NEW
304.0 15.0 54.0 316 KB

Ports (almost) all Canvas2D functions to the GPU so it can be mixed with a WebGL canvas.

License: MIT License

CSS 0.05% JavaScript 98.74% HTML 1.21%
canvas2d javascript webgl canvas2d-functions canvasrenderingcontext2d canvas

canvas2dtowebgl's People

Contributors

jagenjo avatar mattdoiron avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

canvas2dtowebgl's Issues

Resize

Hi what an awesome project!
Maybe you can add resizing support?
I added gl.viewport(0, 0, gl.canvas.width, gl.canvas.height); into start2d function.
Is it good idea?

performance and color?

Hi Javi,

I am trying to use this library in my project for drawing canvas.
I noticed the drawing speed is actually slower than 2d canvas. Am I doing something wrong? or this library is not suitable for my purpose?
Thank you.

Does not support fonts with Cyrillic.

Hello! Your library is very convenient and supports many functions, but does not support fonts with Cyrillic or does not have the ability to change the font via ctx.font. Can this be fixed somehow?

[disclaimer] It won't boost your app

If you got here and think it will boost your 2d context it won't. Cloning and changing render_benchmark_fillRect example to iterate over 10000 instead of 1000, 2d context handles better then using webgl. There is no dreaming 2d api to perform like gpu rendering - sad =/

// modified example from this repo
function render_benchmark_fillRect(canvas, ctx) {
    ctx.clearRect(0, 0, canvas.width, canvas.height);
    for (var i = 0; i < 10000; i++) {
        ctx.fillRect(500, 500, 2, 2);
    }
}

WebGL2 support

Will this ever support webgl2? I'd like to work with some gl.RGBA16UI data.

Drawing between canvases

Thanks for your cool lib!
I tried it for fun as a drop-in replacement for canvas2D just to see if we could get a performance boost on our game.
Everything worked actually really fine out of the box except for when we draw stuff between canvases (since we're using only canvas I've made some functions to apply effects to images, like brighten, darken, dissolve etc, and here we use a buffer canvas where we manipulate the pixels directly). Of course, this could (and should, if we're using webgl) converted to just use fragment shaders instead, but I was wondering if you've tried to draw a canvas on another context with your solution?

What happens is that it basically seems to cache the original image and then all other calls to our per-pixel functions that uses the same canvas only get that same image back, however we manipulate the pixel data.

I could put together a super-basic minimal example of the problem (our game is not super-basic sadly) if this is something you would be interested in.

Implementing shadowblur

Hi, awesome project!
are there plans to implement the shadowblur from the canvas2d/is there any issues implementing it?

the benchmark problem

just now, i try it in windows, the all of webgl benchmark is 60fps, but in osx, it really slower than canvas, i read your code, it cache the texture but it call draw method everytime, so i check the inspector result with webgl inspector, i find drawArray too often.

the same time, i test the pixi's bunny benchmark example, i find it call drawElement method once and it has prepare module to prevent upload too many textures in one requestAnimationFrame call.

so, it case the benchmark performance bad?

not support Chinese!

Wow, great job.
I simply tested some functions and found that the filltext() function does not support Chinese double bytes. I hope it can be repaired as soon as possible. I will use it in my game project. Please!

filltext( ‘你好中文’,50,50,50)

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.