Giter Site home page Giter Site logo

webgl-2d's Introduction

WebGL-2D

HTML5 Canvas2D API in WebGL.

Authors:

This project aims to be a complete port of the Canvas2D API implemented in a WebGL context. WebGL-2D is a proof of concept and attempts to ascertain performance improvements over Canvas2D.

It should allow most Canvas2D applications to be switched to a WebGL context.

20110304-qfkhgf9hjin5uk3we9rmgpwtf8.jpg

Usage

Switching your Canvas2D sketch to a WebGL2D is very simple and only requires one additional line of code:

var cvs = document.getElementById("myCanvas");

WebGL2D.enable(cvs); // adds "webgl-2d" context to cvs

var ctx = cvs.getContext("webgl-2d"); // easily switch between "webgl-2d" and "2d" contexts

Supported Canvas2D Features

WebGL-2D is a work in progress and currently supports a very small subset of the Canvas2D API.

  • strokeStyle
  • fillStyle
  • strokeRect
  • fillRect
  • translate
  • rotate
  • scale
  • save
  • restore
  • lineWidth
  • drawImage
  • createImageData
  • getImageData
  • putImageData
  • beginPath
  • closePath
  • moveTo
  • lineTo
  • rect
  • fill*
  • stroke*

*fill and stroke only work on straight line paths supported above, arc, and curves are not yet supported.

All other properties or functions are currently stubbed. Properties are set to their defaults and functions are empty.

Benchmarks

WebGL-2D should be faster than Canvas2D at certain things and slower at others. It is important that you know what to expect when using WebGL-2D with your project.

The benchmarks directory contains benchmarks for testing performance

asteroidsbench/

Kevin Roast has graciously given permission to include this benchmark in the WebGL-2D project.

This benchmark is perfect for testing real world canvas usage in game engine. It relies heavily on 9 arg drawImage cropping to implement scrolling backgrounds and stripstrip animations.

Visit his website for other HTML5 canvas demos as well as the asteroids game

webgl-2d's People

Contributors

cjcliffe avatar corbanbrook avatar secretrobotron avatar syntagmatic avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar

webgl-2d's Issues

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.