Linux系统中 如何系统排错 二之文件引导阶段(引导腾讯分分彩源码出售文件丢失)!
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了Linux系统中 如何系统排错 二之文件引导阶段(引导腾讯分分彩源码出售文件丢失)!,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含5523字,纯文字阅读大概需要8分钟。
内容图文
所有的课程源代码在我上传腾讯分分彩源码出售QQ2952777280【话仙源码论坛】hxforum.com 的资源里面,本来想设置开源,好像不行!博客和专栏同步!
如有错别字或有理解不到位的地方,可以留言或者加微信15250969798,在下会及时修改!!!!!
上一节课我们学习了 三维空间-可视空间的设置
这一节课我们将学习 三维空间-键盘来改变视点修复版缺失的三角形
上节课我们知道可视空间的重要性,前面用键盘控制视点来改变三角形发现极左或者极右的时候会缺失一个角
其中的原因就是可视空间的问题,远截面过于接近视点,也可以看做三角形的那个不在可视空间里面,所以你看不到了
那么怎么去解决了,很简单,只要我们把远截点设置得远点就好了
先来看运行案例:
具体看代码:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>webgl第32课-用键盘来改变视点补缺版</title>
</head>
<body onl oad="main()">
<canvas id="webgl" width="400" height="400">
Please use a browser that supports "canvas"
</canvas>
<script src="../lib/webgl-utils.js"></script>
<script src="../lib/webgl-debug.js"></script>
<script src="../lib/cuon-utils.js"></script>
<script src="../lib/cuon-matrix.js"></script>
<script src="LookAtTrianglesWithKeys_ViewVolume.js"></script>
</body>
</html>
// 顶点着色器
var VSHADER_SOURCE =
'attribute vec4 a_Position;\n' +
'attribute vec4 a_Color;\n' +
'uniform mat4 u_ViewMatrix;\n' +
'uniform mat4 u_ProjMatrix;\n' +
'varying vec4 v_Color;\n' +
'void main() {\n' +
' gl_Position = u_ProjMatrix * u_ViewMatrix * a_Position;\n' +
' v_Color = a_Color;\n' +
'}\n';
// 片元着色器
var FSHADER_SOURCE =
'#ifdef GL_ES\n' +
'precision mediump float;\n' +
'#endif\n' +
'varying vec4 v_Color;\n' +
'void main() {\n' +
' gl_FragColor = v_Color;\n' +
'}\n';
function main() {
// Retrieve <canvas> element
var canvas = document.getElementById('webgl');
// Get the rendering context for WebGL
var gl = getWebGLContext(canvas);
if (!gl) {
console.log('Failed to get the rendering context for WebGL');
return;
}
// Initialize shaders
if (!initShaders(gl, VSHADER_SOURCE, FSHADER_SOURCE)) {
console.log('Failed to intialize shaders.');
return;
}
// Set the vertex coordinates and color (the blue triangle is in the front)
var n = initVertexBuffers(gl);
if (n < 0) {
console.log('Failed to specify the vertex infromation');
return;
}
// Specify the color for clearing <canvas>
gl.clearColor(0.0, 0.0, 0.0, 1.0);
// 获取u ViewMatrix和u ProiMatrix变量的存储位置
var u_ViewMatrix = gl.getUniformLocation(gl.program, 'u_ViewMatrix');
var u_ProjMatrix = gl.getUniformLocation(gl.program, 'u_ProjMatrix');
if (!u_ViewMatrix || !u_ProjMatrix) {
console.log('Failed to get u_ViewMatrix or u_ProjMatrix');
return;
}
// 创建视图矩阵
var viewMatrix = new Matrix4();
// 注册键盘事件响应函数
document.onkeydown = function(ev){ keydown(ev, gl, n, u_ViewMatrix, viewMatrix); };
// 创建指定可视空间的矩阵并传个给u_ProjMatrix变量
var projMatrix = new Matrix4();
//这里设置远截点为2.0来修复缺失的三角形角
projMatrix.setOrtho(-1.0, 1.0, -1.0, 1.0, 0.0, 2.0);
gl.uniformMatrix4fv(u_ProjMatrix, false, projMatrix.elements);
draw(gl, n, u_ViewMatrix, viewMatrix); // Draw the triangles
}
function initVertexBuffers(gl) {
var verticesColors = new Float32Array([
// 顶点坐标和颜色
0.0, 0.5, -0.4, 0.4, 1.0, 0.4, // The back green one
-0.5, -0.5, -0.4, 0.4, 1.0, 0.4,
0.5, -0.5, -0.4, 1.0, 0.4, 0.4,
0.5, 0.4, -0.2, 1.0, 0.4, 0.4, // The middle yellow one
-0.5, 0.4, -0.2, 1.0, 1.0, 0.4,
0.0, -0.6, -0.2, 1.0, 1.0, 0.4,
0.0, 0.5, 0.0, 0.4, 0.4, 1.0, // The front blue one
-0.5, -0.5, 0.0, 0.4, 0.4, 1.0,
0.5, -0.5, 0.0, 1.0, 0.4, 0.4,
]);
var n = 9;
// Create a buffer object
var vertexColorbuffer = gl.createBuffer();
if (!vertexColorbuffer) {
console.log('Failed to create the buffer object');
return -1;
}
// Write vertex information to buffer object
gl.bindBuffer(gl.ARRAY_BUFFER, vertexColorbuffer);
gl.bufferData(gl.ARRAY_BUFFER, verticesColors, gl.STATIC_DRAW);
var FSIZE = verticesColors.BYTES_PER_ELEMENT;
// Assign the buffer object to a_Position and enable the assignment
var a_Position = gl.getAttribLocation(gl.program, 'a_Position');
if(a_Position < 0) {
console.log('Failed to get the storage location of a_Position');
return -1;
}
gl.vertexAttribPointer(a_Position, 3, gl.FLOAT, false, FSIZE * 6, 0);
gl.enableVertexAttribArray(a_Position);
// Assign the buffer object to a_Color and enable the assignment
var a_Color = gl.getAttribLocation(gl.program, 'a_Color');
if(a_Color < 0) {
console.log('Failed to get the storage location of a_Color');
return -1;
}
gl.vertexAttribPointer(a_Color, 3, gl.FLOAT, false, FSIZE * 6, FSIZE * 3);
gl.enableVertexAttribArray(a_Color);
return n;
}
//视点位置
var g_EyeX = 0.20, g_EyeY = 0.25, g_EyeZ = 0.25; // Eye position
//键盘事件函数
function keydown(ev, gl, n, u_ViewMatrix, viewMatrix) {
if(ev.keyCode == 39) { // 按下右键
g_EyeX += 0.01;
} else
if (ev.keyCode == 37) { // 按下左键
g_EyeX -= 0.01;
} else { return; } // 其他直接返回
draw(gl, n, u_ViewMatrix, viewMatrix);
}
//绘制函数
function draw(gl, n, u_ViewMatrix, viewMatrix) {
// Set the matrix to be used for to set the camera view
viewMatrix.setLookAt(g_EyeX, g_EyeY, g_EyeZ, 0, 0, 0, 0, 1, 0);
// Pass the view projection matrix
gl.uniformMatrix4fv(u_ViewMatrix, false, viewMatrix.elements);
// Clear <canvas>
gl.clear(gl.COLOR_BUFFER_BIT);
// Draw the rectangle
gl.drawArrays(gl.TRIANGLES, 0, n);
}
版权声明:本文为博主原创文章,转载请附上博文链接!
内容总结
以上是互联网集市为您收集整理的Linux系统中 如何系统排错 二之文件引导阶段(引导腾讯分分彩源码出售文件丢失)!全部内容,希望文章能够帮你解决Linux系统中 如何系统排错 二之文件引导阶段(引导腾讯分分彩源码出售文件丢失)!所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。