• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

What is the relationship between WebGL and HTML5?

 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If I'm not mistaken, when people talk about the HTML5 canvas component we're talking more of a 2D rendering area right. Something analogous to say Java2D?

Now I see there's a push for WebGL; which seems like a separate thing, a way to have OpenGL semantics on the browser (rendering on the canvas component?).

So what's the relationship of WebGL to HTML5, or more specifically the canvas component? Is it just an extension or an integral part of canvas? One thing that is evident is that it's not fully supported in most browsers, so it doesn't seem that useful currently for cross browser game development (I'm not aware of a mobile implementation either).
 
author
Posts: 35
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Augusto,

Canvas2D is an immediate mode API meaning that the browser doesn't implicitly remember what was drawn after you finished drawing.

WebGL is a 3D API based on OpenGL ES (version of OpenGL used in consoles and handheld mobile devices).

WebGL is a technology that is considered part of HTML5. It uses the Canvas tag for displaying graphics.

Re: Support, it depends on why you ask. Chrome and Firefox are well supported. Opera and Safari have a decent amount of support as well. IE is left in the code. I believe it is a good option for cross browser development if you are focusing on 3D.

So in summary:
Canvas (tag) : how Canvas2D and WebGL scenes are displayed in a web page
Canvas2D: 2D API
WebGL: 3D API
 
Augusto Sellhorn
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for that response James, that clarifies a lot.

BTW, can you mix graphics drawing with Canvas2D and WebGL? For example, if I have a menu system that draws in a Canvas2D over a 3D WebGL background (actual game engine)?

Thanks!
 
James Williams
author
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Each canvas tag has to be one or the other. You could however use an off-screen Canvas to render something in 3D and then composite it (by saving to an image) with 2D content.
 
James Williams
author
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I forgot to mention that a WebGL canvas can be hardware accelerated whereas a Canvas2D canvas can not.
 
Hug your destiny! And hug this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic