[WebGL] Setting Up WebGL
2024-08-27 08:11:34
In this lesson we cover setting up WebGL for use, including creating a canvas, getting the WebGL rendering context and clearing the canvas to a particular color.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Setup</title> </head>
<body>
<canvas id="canvas" width="600" height="600"></canvas>
<script src="./mian.js"></script>
</body>
</html>
var gl; initGL();
draw(); function initGL(){
var canvas = document.getElementById("canvas");
gl = canvas.getContext("webgl"); gl.viewport(0,0,canvas.width, canvas.height);
gl.clearColor(1,0,0,1); //red, blue, green, alpha
} function draw(){
gl.clear(gl.COLOR_BUFFER_BIT); //Paint the color to the canvas
}
最新文章
- 封装一个函数获取匹配特定的css选择符
- C#客户端的异步操作
- 使用PHPMailer发送邮件
- RMQ 数据结构
- iOS应用架构谈(三):网络层设计方案(上)
- 更改form字段内容颜色
- Java对象的复制
- Cannot find class [org.apache.commons.dbcp.BasicDataSource]
- android 开发工具(android studio)
- python 路径
- 使用Velocity 模板引擎快速生成代码
- Linux第六节随笔 输入输出重定向 、管道、通配符、wc / grep / tr / sort / cut / which /whereis /locate /find /
- [Swift]LeetCode10. 正则表达式匹配 | Regular Expression Matching
- blfs(systemd版本)学习笔记-安装、配置和使用wpa_supplicant无线网络连接工具
- 自动化测试基础篇--Selenium文件上传send_keys
- IIS安装、配置 发布网站 报错解决方案
- Python3编写网络爬虫08-数据存储方式一-文件存储
- IDEA配置SVN,Git,GitLab
- siege 高并发测试工具
- Enterprise Library 5.0 参考源码索引