WebGL(Web Graphics Library)은 플러그인을 사용하지 않고 웹 브라우저에서 상호작용 가능한 3D와 2D 그래픽을 표현하기 위한 JavaScript API입니다. WebGL은 HTML5 <canvas>
요소에서 사용할 수 있는, OpenGL ES 2.0을 대부분 충족하는 API를 제공합니다.
WebGL은 Firefox 4+, Google Chrome 9+, Opera 12+, Safari 5.1+, Internet Explorer 11+, Microsoft Edge build 10240+에서 사용할 수 있습니다. 그러나 사용자 장치의 하드웨어도 WebGL 기능을 지원해야 합니다.
참고서
표준 인터페이스
확장
ANGLE_instanced_arrays
EXT_blend_minmax
EXT_color_buffer_float
EXT_color_buffer_half_float
EXT_disjoint_timer_query
EXT_float_blend
EXT_frag_depth
EXT_sRGB
EXT_shader_texture_lod
EXT_texture_compression_bptc
EXT_texture_compression_rgtc
EXT_texture_filter_anisotropic
OES_element_index_uint
OES_fbo_render_mipmap
OES_standard_derivatives
OES_texture_float
OES_texture_float_linear
OES_texture_half_float
OES_texture_half_float_linear
OES_vertex_array_object
WEBGL_color_buffer_float
WEBGL_compressed_texture_astc
WEBGL_compressed_texture_atc
WEBGL_compressed_texture_etc
WEBGL_compressed_texture_etc1
WEBGL_compressed_texture_pvrtc
WEBGL_compressed_texture_s3tc
WEBGL_compressed_texture_s3tc_srgb
WEBGL_debug_renderer_info
WEBGL_debug_shaders
WEBGL_depth_texture
WEBGL_draw_buffers
WEBGL_lose_context
이벤트
상수와 자료형
WebGL 2
WebGL 2는 WebGL2RenderingContext
인터페이스를 통해 제공되는 WebGL 메이저 업데이트다. OpenGL ES 3.0 을 기반으로 하며 다음과 같은 특징을 포함한다:
- 3D textures,
- Sampler objects,
- Uniform Buffer objects,
- Sync objects,
- Query objects,
- Transform Feedback objects,
- WebGL 2의 핵심이 된 확장 기능: Vertex Array objects, instancing, multiple render targets, fragment depth.
"WebGL 2 lands in Firefox" 블로그 포스트와와 and webglsamples.org/WebGL2Samples 데모도 참고.
안내서와 자습서
안내서
- WebGL의 데이터
- WebGL 코드를 작성할 때 사용하는 변수, 버퍼와 그 외 다른 형태의 데이터를 알아봅니다.
- WebGL 우수 사례
- WebGL 콘텐츠의 품질, 성능, 안정성을 높일 수 있는 팁과 제안입니다.
- 확장 사용
- WebGL 확장을 사용하는 법을 알아봅니다.
자습서
- WebGL 자습서
- 초심자를 위한 WebGL 핵심 개념입니다. WebGL을 접해보지 않았다면 여기서 시작해보세요.
예제
- 기초 WebGL 2D 애니메이션 예제
- This example demonstrates the simple animation of a one-color shape. Topics examined are adapting to aspect ratio differences, a function to build shader programs from sets of multiple shaders, and the basics of drawing in WebGL.
- 예제로 알아보는 WebGL
- A series of live samples with short explanations that showcase WebGL concepts and capabilities. The examples are sorted according to topic and level of difficulty, covering the WebGL rendering context, shader programming, textures, geometry, user interaction, and more.
고급 자습서
- WebGL 모델 뷰 프로젝션
- A detailed explanation of the three core matrices that are typically used to represent a 3D object view: the model, view and projection matrices.
- 웹을 위한 행렬 계산
- A useful guide to how 3D transform matrices work, and can be used on the web — both for WebGL calculations and in CSS3 transforms.
참고자료
- Raw WebGL: An introduction to WebGL A talk by Nick Desaulniers that introduces the basics of WebGL. This is a great place to start if you've never done low-level graphics programming.
- Khronos WebGL site The main web site for WebGL at the Khronos Group.
- Learning WebGL A site with tutorials on how to use WebGL.
- WebGL Fundamentals A basic tutorial with fundamentals of WebGL.
- WebGL playground An online tool for creating and sharing WebGL projects. Good for quick prototyping and experimenting.
- WebGL Academy An HTML/JavaScript editor with tutorials to learn basics of webgl programming.
- WebGL Stats A site with statistics about WebGL capabilities in browsers on different platforms.
Libraries
- glMatrix is a JavaScript matrix and vector library for high-performance WebGL apps.
- PhiloGL is a WebGL framework for data visualization, creative coding, and game development.
- Pixi.js is a fast, open-source 2D WebGL renderer.
- PlayCanvas is an open-source game engine.
- Sylvester is an open-source library for manipulating vectors and matrices. Not optimized for WebGL but extremely robust.
- three.js is an open-source, fully featured 3D WebGL library.
- Phaser is a fast, free and fun open source framework for Canvas and WebGL powered browser games
명세
Specification | Status | Comment |
---|---|---|
WebGL 1.0 | Recommendation | Initial definition. Based on OpenGL ES 2.0 |
WebGL 2.0 | Editor's Draft | Builds on top of WebGL 1. Based on OpenGL ES 3.0. |
OpenGL ES 2.0 | Standard | |
OpenGL ES 3.0 | Standard |
브라우저 호환성
WebGL 1
BCD tables only load in the browser
WebGL 2
BCD tables only load in the browser
호환성 노트
브라우저 이외에 GPU 자체도 기능을 제공합니다. 따라서 예를들면 S3 텍스처 압축(S3TC)은 오직 테그라 기반 테블렛에서 사용가능합니다.
게코 노트
WebGL 디버깅과 테스팅
Gecko 10.0 (Firefox 10.0 / Thunderbird 10.0 / SeaMonkey 2.7)을 사용하면 WebGL의 호환성을 테스트 목적으로 제어할수 있도록 두 가지 환경설정을 할 수 있습니다.
webgl.min_capability_mode
- Boolean 속성으로 참일 경우 최소 호환성 모드로 사용 가능합니다. 이 모드에서 WebGL는 오직 최소한의 기능만 설정하고 WebGL 명세에서 필요한 기능만 지원하도록 설정되어 집니다. 이는 WebGL코드가 어떠한 디바이스나 브라우저에서 작동이 된다는 것을 보장합니다. 기본값으로는 거짓으로 설정되어 있습니다.
webgl.disable_extensions
- Boolean 속성으로 참일 경우 WebGL 확장을 비활성화 하고 기본값은 거짓입니다.