第一章 WebGL简介 Introduction

第一章 WebGL简介 Introduction

概述

webGL是一组用于在web html上下文中绘制3D图像的web接口

html Canvas对象所有绘制图像的舞台,通过使用CanvasRenderingContext2D接口进行绘制

WebGLRenderingContext是webGL的接口,通过它将开启webGL之门

webGL不同于其它web API提供了一些高级的但复杂的接口,相反,webGL提供的都是基础的接口,以应对不同需求,是业务无关的接口

webGL基于OpenGL® ES规范,所有但凡有冲突之处,均以后者为准


webGL介绍

webGL是一组用于在web页面绘制3D图形(动画)的API,继承自OpenGL® ES规范,提供了与其类似的渲染功能,区别在于webGL在html上下文中绘制.

webGL为渲染html中的Canvas对象而设计,HTML Canvas提供了一张可以用来渲染的画布,负责呈现不同的API绘制的效果.

CanvasRenderingContext2D是HTML Canvas对外提供的唯一的一个接口,在Canvas 规范的2D canvas rendering context章节定义

Canvas规范中还定义了另外一个接口:WebGLRenderingContext,通过这个接口将可以调用WebGL API

webGL与大多数web api的快速开发体验不同,面对复杂的3D应用需求,webGL选择提供最原始的功能(也是最灵活的)去应对千变万化的需求.

webGL可以在接口之上,再提供一些包装后的接口,为特定领域的使用提供量身打造的接口,添加这样的层使得使用起来更加舒服,并能加速开发效率和简化开发,但是由于webGL是继承自OpenGL® ES规范,应当考虑那些熟悉在桌面领域使用OpenGL或OpenGL ES2.0的开发者们,从桌面开发转到webGL开发时更简单一点

该文档介绍了很多功能并包含连接指向OpenGL ES页面,所有的努力都是为了使这些规范更加符合OpenGL ES规范.

文档中可能会包含一些错误.当出现了前后不一致,互相矛盾时,均以OpenGL ES规范为最终规范.

本文档剩余的章节期望与OpenGL SE2.0规范同步阅读(在写这篇文章时,最新版本为2.0.24,点击这里获取Khronos OpenGL ES API Registry)

如无特殊说明,每个方法的行为在OpenGL SE2.0中均有定义,本文档为了交互和安全性考虑可能与OpenGL SE2.0规范有一些分歧.

并且本文档经常定义那些规范中留给实现定义的部分,这些不同之处在统一在Differences Between WebGL and OpenGL ES 2.0章节说明


原文http://www.khronos.org/registry/webgl/specs/latest/#1

WebGL™ is an immediate mode 3D rendering API designed for the web. It is derived from OpenGL® ES 2.0, and provides similar rendering functionality, but in an HTML context. WebGL is designed as a rendering context for the HTML Canvas element. The HTML Canvas provides a destination for programmatic rendering in web pages, and allows for performing that rendering using different rendering APIs. The only such interface described as part of the Canvas specification is the 2D canvas rendering context, CanvasRenderingContext2D. This document describes another such interface, WebGLRenderingContext, which presents the WebGL API.

The immediate mode nature of the API is a divergence from most web APIs. Given the many use cases of 3D graphics, WebGL chooses the approach of providing flexible primitives that can be applied to any use case. Libraries can provide an API on top of WebGL that is more tailored to specific areas, thus adding a convenience layer to WebGL that can accelerate and simplify development. However, because of its OpenGL ES 2.0 heritage, it should be straightforward for developers familiar with modern desktop OpenGL or OpenGL ES 2.0 development to transition to WebGL development.

Many functions described in this document contain links to OpenGL ES man pages. While every effort is made to make these pages match the OpenGL ES 2.0 specification [GLES20], they may contain errors. In the case of a contradiction, the OpenGL ES 2.0 specification is the final authority.

The remaining sections of this document are intended to be read in conjunction with the OpenGL ES 2.0 specification (2.0.24 at the time of this writing, available from the Khronos OpenGL ES API Registry). Unless otherwise specified, the behavior of each method is defined by the OpenGL ES 2.0 specification. This specification may diverge from OpenGL ES 2.0 in order to ensure interoperability or security, often defining areas that OpenGL ES 2.0 leaves implementation-defined. These differences are summarized in the Differences Between WebGL and OpenGL ES 2.0 section.

原文地址:https://www.cnblogs.com/kkun/p/2124936.html