Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add round linecap #35

Open
wants to merge 84 commits into
base: transparency
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
1dfb1f0
Fixed transparency alpha blending.
corbanbrook Mar 4, 2011
a1328f1
Added screenshot to README
corbanbrook Mar 4, 2011
a5541c5
Adding blending fix for chrome.
corbanbrook Mar 4, 2011
cd8ad7d
Added strokeRect()
corbanbrook Mar 5, 2011
4822c6a
optimized fillRect() and strokeRect() less bufferData and bindBuffer …
corbanbrook Mar 5, 2011
41c39be
Added live demo link to README
corbanbrook Mar 5, 2011
731e7d1
Replaced color array with uniform4f, removed unnecessary 'new Float32…
cjcliffe Mar 5, 2011
10fcd47
1. Updated getters and setters for fillStyle and strokeStyle
corbanbrook Mar 5, 2011
e47ffb9
Replaced color array with uniform4f, removed unnecessary 'new Float32…
cjcliffe Mar 6, 2011
cc8b33c
Adding fix for colorStringToVec4 alpha parsing
corbanbrook Mar 6, 2011
341736a
Added globalAlpha and globalCompostiteOp attribute stubs.
corbanbrook Mar 6, 2011
6d2e71c
stubs for beginPath, closePath, lineTo, moveTo, stroke, fill
corbanbrook Mar 6, 2011
f2841aa
transform and setTransform stubs.
corbanbrook Mar 6, 2011
0d11163
working subpath code for beginPath, closePath, lineTo, moveTo, rect
corbanbrook Mar 6, 2011
406b287
1. Added stubs for createImageData, getImageData, and putImagedata.
secretrobotron Mar 7, 2011
6a98e61
added drawImage(img, x, y);
corbanbrook Mar 7, 2011
9672999
Merge remote-tracking branch 'bobby/master'
corbanbrook Mar 7, 2011
981b39c
Updating supported function list.
corbanbrook Mar 7, 2011
f5aa105
1. putImageData function implemented
secretrobotron Mar 7, 2011
80901b5
Merge remote-tracking branch 'bobby/master'
corbanbrook Mar 7, 2011
4e0f5a7
added texture caching to drawImage and fixed bug in useTexture not re…
corbanbrook Mar 7, 2011
d09b36c
Added support for scaling drawImage(image, dx, dy, dw, dh)
corbanbrook Mar 7, 2011
319de60
Removed duplicate TEXTURE_MIN_FILTER param.
corbanbrook Mar 7, 2011
8fc3b01
Updated feature list.
corbanbrook Mar 7, 2011
3e629cf
created examples directory.
corbanbrook Mar 7, 2011
5a98b9b
Added JSLint to support dir and linted source.
corbanbrook Mar 7, 2011
dde730f
1. Added example transform_stack.html.
secretrobotron Mar 7, 2011
1baebd5
1. Added example transform_stack.html.
secretrobotron Mar 7, 2011
0c6aa6b
Removed superfluous params in initShaders.
corbanbrook Mar 7, 2011
c17e4ae
Added texture optimizations.
corbanbrook Mar 7, 2011
0a130ba
1. Shader does transformation stack-crunching.
secretrobotron Mar 7, 2011
34f58f1
Merge remote-tracking branch 'corban/master'
secretrobotron Mar 7, 2011
a2f4746
minor lint error.
corbanbrook Mar 7, 2011
0bcbb6d
Fixed context issue with shaderPool, was global but needed to be cont…
cjcliffe Mar 7, 2011
36ef689
Added shader pool expandability (shader masks), removed branching cod…
cjcliffe Mar 8, 2011
760bf40
linting fixes.
corbanbrook Mar 8, 2011
6c5beef
Fixed getImageData by specifying gl.readPixels buffer to be Uint8Array.
secretrobotron Mar 8, 2011
7fe6693
modification and clean up of examples.
corbanbrook Mar 8, 2011
c3321d1
added basic drawImage benchmark.
corbanbrook Mar 8, 2011
fa15e2b
Optimizing textureCache lookup.
corbanbrook Mar 8, 2011
5c486b8
Fixes situation where WebGL.enable is called more then once on same c…
corbanbrook Mar 9, 2011
5607fcf
Adding .gitignore
Mar 9, 2011
8f590ab
Added html5 canvas test suite modified for webgl-2d.
Mar 9, 2011
05cfa67
Updated Makefile to work with test suite.
Mar 9, 2011
286fa42
Merge remote-tracking branch 'humph/master'
corbanbrook Mar 9, 2011
eff4337
Fixing recursion issue with tests-core.js.
Mar 9, 2011
2b1c4aa
Added force option WebGL2D.enable(canvas, {force: true}); to force co…
corbanbrook Mar 9, 2011
49e7f0b
Merge remote-tracking branch 'humph/master'
corbanbrook Mar 9, 2011
d6fa9a9
Fixed string formatting of fillStyle and strokeStyle.
corbanbrook Mar 9, 2011
9ba018f
Improve minification of global Math.
Mar 9, 2011
e09ef50
Deal with canvas width=height=0 and webgl failure.
Mar 9, 2011
7dc953d
Added saveDrawState and restoreDrawState.
corbanbrook Mar 9, 2011
bae1ab2
Adding stubs for missing context functions and properties.
corbanbrook Mar 9, 2011
aa11294
Added remaining properties to drawState object. 2d.state Testing green.
corbanbrook Mar 9, 2011
0eda982
Added color support for hex3 and hex6 (#fff and #ffffff) colors.
corbanbrook Mar 9, 2011
81a0614
changed case on document.createElement
corbanbrook Mar 9, 2011
fb62aac
Added cropping support to drawImage and shader
cjcliffe Mar 10, 2011
9c2f6d5
Merge remote-tracking branch 'cj/master'
corbanbrook Mar 10, 2011
b30507b
comments for drawImage
corbanbrook Mar 10, 2011
f6eb9f0
Added maximum image->texture size with automatic scale-down -- fixes …
cjcliffe Mar 10, 2011
6bb434a
Added adaptive maximum texture size with gl.getParameter(gl.MAX_TEXTU…
cjcliffe Mar 10, 2011
c486bb1
Merge remote-tracking branch 'cj/master'
corbanbrook Mar 10, 2011
74b5cc7
Adding Kevin Roast's asteroidsbench to benchmark suite.
corbanbrook Mar 10, 2011
124a945
Adding benchmarks blurb to README.
corbanbrook Mar 10, 2011
e0ef190
Updating README to reflect function support.
corbanbrook Mar 10, 2011
78505e4
restoreDrawState fix and texture code cleanup.
corbanbrook Mar 10, 2011
4ac11ac
Merge remote-tracking branch 'humph/master'
Mar 10, 2011
9c654c9
Enables mip mapping on POT textures for improved scaling performance.
corbanbrook Mar 10, 2011
170d951
Fixing isPOT function for value == 0 case.
corbanbrook Mar 10, 2011
96f4b2d
basic stroke path support for lines and rects
corbanbrook Mar 15, 2011
cb27967
Added basic fill support for lines and rects
corbanbrook Mar 16, 2011
4bd668b
Adding new supported functions to README.
corbanbrook Mar 16, 2011
8050b20
Organizing code, optimized saveDrawState with a much much faster clon…
corbanbrook Mar 16, 2011
96b88f7
Optimization for mat3.multiply.
corbanbrook Mar 17, 2011
ebf63e9
Optimized mat3.multiply by allocating a reusable scratch space for th…
corbanbrook Mar 17, 2011
c906f97
Reverted last commit.
corbanbrook Mar 17, 2011
a459adf
Matrix tranform optimizations.
corbanbrook Mar 17, 2011
688ed12
inlining and manually creating the drawState clone in saveDrawState.
corbanbrook Mar 17, 2011
7e4b664
Fix for restoring shadowColor draw state.
corbanbrook Apr 1, 2011
7468b89
Fix for hex3 color.
corbanbrook Apr 1, 2011
4bc72ea
Fixed clamping bug with rgb(a) color strings.
corbanbrook Apr 1, 2011
346dea9
Added support for SVG color keywords.
corbanbrook Apr 1, 2011
dbc3e4c
More color fixes.
corbanbrook Apr 1, 2011
9a7ec26
Added HSL color support and other color fixes.
corbanbrook Apr 2, 2011
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*~
test/philip.html5.org/tests.js
.DS_Store
27 changes: 27 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# WebGL-2D

# Make sure $JSSHELL points to your js shell binary in .profile or .bashrc
# Most targets use commands that need a js shell path specified
JSSHELL ?= $(error Specify a valid path to a js shell binary in ~/.profile: export JSSHELL=C:\path\js.exe or /path/js)

# Version number used in naming release files.
VERSION ?= $(error Specify a version for your release (e.g., VERSION=0.5))

# Run JSLINT
check-lint:
${JSSHELL} -m -j -p -e "load('./support/jslint.js'); load('./support/jslint-cmdline.js'); runJslint(read('webgl-2d.js'));"

WEBGL2DJS=webgl-2d.js
TESTS=./test
CANVASTESTS=${TESTS}/philip.html5.org
CANVASTESTSJS=${CANVASTESTS}/tests.js

${CANVASTESTSJS}: ${WEBGL2DJS}
@@cat webgl-2d.js ${CANVASTESTS}/tests-core.js > ${CANVASTESTSJS}
@@echo "Created ${CANVASTESTSJS}"

# Create webgl-2d enabled tests.js
tests: ${CANVASTESTSJS}

clean:
rm ${CANVASTESTSJS}
44 changes: 44 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ WebGL-2D is a proof of concept and attempts to ascertain performance improvement

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

Check out a [LIVE DEMO!](http://weare.buildingsky.net/webgl-2d/example.html)

![20110304-qfkhgf9hjin5uk3we9rmgpwtf8.jpg](https://img.skitch.com/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");
Expand All @@ -28,9 +35,46 @@ WebGL-2D is a work in progress and currently supports a very small subset of the

* 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](http://twitter.com/kevinroast) 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](http://www.kevs3d.co.uk/) for other HTML5 canvas demos as
well as the [asteroids game](http://www.kevs3d.co.uk/dev/asteroids/)
13 changes: 13 additions & 0 deletions benchmarks/asteroidsbench/COPYING
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Copyright (c) 2011 All Rights Reserved - Kevin Roast http://www.kevs3d.co.uk/

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 http://www.kevs3d.co.uk/ for other HTML5 canvas demos as
well as the asteroids game http://www.kevs3d.co.uk/dev/asteroids/

Twitter @kevinroast http://twitter.com/kevinroast
Binary file added benchmarks/asteroidsbench/images/asteroid1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added benchmarks/asteroidsbench/images/asteroid2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added benchmarks/asteroidsbench/images/asteroid3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added benchmarks/asteroidsbench/images/asteroid4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added benchmarks/asteroidsbench/images/bg3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added benchmarks/asteroidsbench/images/enemyship1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added benchmarks/asteroidsbench/images/player.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added benchmarks/asteroidsbench/images/shield.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
58 changes: 58 additions & 0 deletions benchmarks/asteroidsbench/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Copyright (c) 2011 All Rights Reserved - Kevin Roast http://www.kevs3d.co.uk/ -->
<title>Asteroids HTML5 Canvas 2D Rendering and JavaScript Benchmark by Kevin Roast</title>
<script type="text/javascript" src="../../webgl-2d.js"></script>
<script type="text/javascript" src="scripts/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="scripts/mathlib-min.js"></script>
<script type="text/javascript" src="scripts/gamelib-min.js"></script>
<script type="text/javascript" src="scripts/asteroids-min.js"></script>
<style type="text/css">
body { font-family: Arial, Helvetica; color: lightblue }
.title { padding-top: 6px; text-align: center; font-weight: bold; color: red }
P { padding-left: 2em; padding-top: 0; padding-bottom: 0; line-height: 1.2em }
P.left { padding-left: 1em; line-height: 1.4em }
.bold { font-weight: bold }
.small { text-align:center; font-size: 0.75em }
a, a:visited, a:active, a:hover { color: #ffffff }
.results { color: white }
.results-wrapper {display:none; border: 2px solid grey; background-color: #333333; margin-left: 1em}
.button-overlay { float: right }
</style>
<meta name="description" content="Asteroids HTML5 Canvas 2D Rendering and JavaScript Benchmark by Kevin Roast" />
</head>

<body onload="onloadHandler();" style="background-color: #000000">

<div class="title">Asteroids HTML5 Canvas 2D Rendering and JavaScript Benchmark</div>
<div style="padding: 12px; min-width: 900px">
<table align="center">
<tr>
<td>
<canvas id="canvas" width="640" height="640" style="border: 2px solid #aaaaaa;"></canvas>
</td>
<td>
<div>
<p class="left bold">Benchmark Info:</p>
<p>Tests the 2D canvas rendering performance for commonly used operations in HTML5 games: drawImage, drawImage scaling, alpha, composition, shadows and text functions.
</div>
<div id="results-wrapper" class="results-wrapper">
<p class="left bold">Benchmark Results:</p>
<div class="results" id="results"></div>
</div>
<div style="padding-top:12px">
<p class="left">Run the test with <a href="http://www.google.co.uk/chrome" target="new">Chrome</a> or <a href="http://www.mozilla.com/firefox" target="new">FireFox</a> or <a href="http://www.apple.com/safari/download" target="new">Safari</a> or <a href="http://www.opera.com/download" target="new">Opera</a>.</p>
</div>
<div>
<p class="left"><a href="../index.html">See more HTML5 Canvas demos!</a></p>
<p class="left"><a href="../asteroids">Play the Asteroids game!</a></p>
</div>
</td>
</tr>
</table>
</div>
<div class="small">
<a href="http://twitter.com/kevinroast" target="new">Follow me on Twitter</a>- Last updated: 9/9/2010</div>
</body>
</html>
2 changes: 2 additions & 0 deletions benchmarks/asteroidsbench/scripts/asteroids-min.js

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions benchmarks/asteroidsbench/scripts/gamelib-min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading