| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/ru/docs/Web/API/WebGL_API/Tutorial/Getting_started_with_WebGL | [Back] [Original] |
Get to know MDN better
This page was translated from English by the community. Learn more and join the MDN Web Docs community.
WebGL - API, OpenGL ES 2.0, HTML canvas , . WebGL , JavaScript ( ), . WebGL HTML- - -.
WebGL. , . OpenGL.
, WebGL 3D - canvas. HTML canvas onload, WebGL.
<body >
<canvas id="glcanvas" width="640" height="480">
Your browser doesn't appear to support the HTML5
<code><canvas></code> element.
</canvas>
</body>
start(), JavaScript- . - WebGL .
var gl; // WebGL
function start() {
var canvas = document.getElementById("glcanvas");
gl = initWebGL(canvas); // GL
// WebGL
if (gl) {
gl.clearColor(0.0, 0.0, 0.0, 1.0); // ,
gl.enable(gl.DEPTH_TEST); //
gl.depthFunc(gl.LEQUAL); // :
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); // .
}
}
, - canvas, canvas. , canvas, , .
canvas, initWebGL(); , - WebGL.
, gl . , ( ) , . , . , , .
. .
initWebGL() :
function initWebGL(canvas) {
gl = null;
try {
// . , .
gl = canvas.getContext("webgl") || canvas.getContext("experimental-webgl");
} catch (e) {}
// GL,
if (!gl) {
alert("Unable to initialize WebGL. Your browser may not support it.");
gl = null;
}
return gl;
}
WebGL canvas, canvas "webgl". , , "experimental-webgl". , , , WebGL. , . gl null (, WebGL ), WebGL , .
: , "experimental-webgl" - , . , "webgl".
, WebGL, , .
WebGL canvas, CSS. canvas , . canvas . , WebGL , , , WebGL viewport(), .
WebGL gl canvas, :
gl.viewport(0, 0, canvas.width, canvas.height);
canvas , , , , CSS, . CSS , ; ( super sample antialiasing - SSAA) ( ). (MSAA) , , , , , .
This page was last modified on 17 . 2024 . by MDN contributors.
WebGLRenderingContextWebGLBufferWebGLFramebufferWebGLRenderbufferWebGLObjectWebGLProgramWebGLShaderWebGLTextureWebGLUniformLocationWebGLActiveInfoWebGLShaderPrecisionFormatWebGLContextEventWebGLQueryWebGLSamplerWebGLSyncWebGLTransformFeedbackWebGLVertexArrayObjectWebGL2RenderingContextWEBGL_compressed_texture_s3tcWEBGL_compressed_texture_s3tc_srgbWEBGL_compressed_texture_etc1WEBGL_compressed_texture_pvrtcWEBGL_debug_renderer_infoWEBGL_debug_shadersWEBGL_depth_textureOES_element_index_uintEXT_frag_depthWEBGL_lose_contextEXT_texture_filter_anisotropicEXT_sRGBOES_standard_derivativesOES_texture_floatWEBGL_draw_buffersOES_texture_float_linearEXT_shader_texture_lodOES_texture_half_floatOES_texture_half_float_linearWEBGL_color_buffer_floatEXT_color_buffer_half_floatOES_vertex_array_objectANGLE_instanced_arraysEXT_blend_minmaxEXT_disjoint_timer_queryOES_draw_buffers_indexedYour blueprint for a better internet.
Portions of this content are 19982026 by individual mozilla.org contributors. Content available under a Creative Commons license.
| Web Proxy Viewer | New URL | Original Page |