r/programming • • Dec 20 '10

A Christmas Tree in 1k of Javascript

http://www.romancortes.com/blog/how-i-did-the-1kb-christmas-tree/
1.1k Upvotes

221 comments sorted by

View all comments

Show parent comments

5

u/[deleted] Dec 21 '10

hint: a sprite is a textured polygon. you can very much take advantage of hardware acceleration using just sprites.

Although i doubt this tree example uses any hardware acceleration.

-2

u/ascendant512 Dec 21 '10

Yeah, thanks for the comment. I know that you can hardware-accelerate sprites by turning them into a textured polygon. Hardware accelerated sprites seem to be both common and rare. The only example I can think of is the mouse pointer.

It's just that usually when you see a game or something that uses sprites, it's not 3D accelerated. Even more so the older it is.

Perhaps someone can write a WebGL canvas version of this toy. It'll probably be faster >_>

2

u/ZorbaTHut Dec 21 '10

Actually, the vast majority of modern 2d games are hardware-accelerated. Software rendering is long since dead. I'd say you've got a 95%+ chance of any 2d game in the last five years being hardware-accelerated.

That's probably an underestimation.

0

u/ascendant512 Dec 21 '10

The vast majority of what you think are modern 2D games are not 2D. They are rendered in a 3D environment with a fixed camera perspective using 3D textured polygons (again, not sprites); not because it's easier to do it that way but because it's much, much faster. The rest of them use non-hardware accelerated java or non-hardware accelerated flash. Which use sprites. Which use the CPU.

You are wrong, go away.

5

u/phort99 Dec 21 '10

So, because hardware-accelerated 2D games use some GPU tricks that involve them being rendered in the same manner as 3D graphics, that makes them suddenly 3D? All it is is a different architecture for doing exactly the same thing. Because a shader and a textured quad get involved, suddenly it's 3D?

WebGL is not the only hardware acceleration tech making its way into browsers, canvas is also getting hardware acceleration. IE9 and chrome both use hardware accelerated canvas, from what I understand.

What exactly is the point you're trying to make? You started out arguing that hardware accelerated javascript does not exist. I don't see anybody trying to make the argument that it does.

It seems that javascript is one of the things that is fully output with software only. If there was hardware acceleration then it would be blazing fast.

This comment was probably not talking about hardware-accelerating javascript, it was talking about the output that javascript controls: when the script says "draw this image here," does the CPU set each pixel or does the GPU?

1

u/ascendant512 Dec 21 '10

Oh gosh, you're right

I misread the original comment by tgc1. But then ZorbaTHut came in with implications that more than just <canvas>, <video> and CSS is accelerated. I really should just stop replying to him.

There are also other commenters that chrome's hardware acceleration is responsible for differences in drawing speed for the Christmas tree and I was mixing up posts. That's really what made me lose it in the first place.

→ More replies (0)

5

u/ZorbaTHut Dec 21 '10

So what exactly is the difference between a 2D game and a game "rendered in a 3D environment with a fixed camera perspective using 3D textured polygons"?

If it looks like a duck and quacks like a duck, it's a duck. I'd call that a 2D game.

-3

u/ascendant512 Dec 21 '10

At this point, I suspect you're just being deliberately dense, but to help other redditors who might be confused:

It's a 3D game if it uses 3D rendering APIs such as Direct3D (a part of DirectX) or OpenGL and the accelerated 3D rendering pathways in the GPU for its rendering engine.

Real 2D games usually are stuff like solitaire and Linux games that use GTK and QT.

→ More replies (0)

1

u/altrego99 Dec 21 '10

The vast majority of what you think are modern 2D games are not 2D

I like Duke Nukem Manhattan project, which falls in this category :) Awesome game!