我有这段代码:
function setupWebGL() {
gl.clearColor(0.1, 0.5, 0.1, 1.0);
gl.clear(gl.COLOR_BUFFER_BIT);
gl.viewport(0,0,400,300);
mat4.perspective(45, 400 / 300, 0.1, 100.0, pMatrix);
mat4.identity(mvMatrix);
mat4.translate(mvMatrix, [0, 0, -2.0]);
}
Run Code Online (Sandbox Code Playgroud)
除了最后一行之外,代码中的所有内容都会运行
mat4.translate(mvMatrix, [0, 0, -2.0]);
Run Code Online (Sandbox Code Playgroud)
我知道这是因为我在每一行之后都设置了警报功能,直到它们无法运行(我需要一种更好的调试方式,在Chrome中,有什么建议?)
我正在使用这里的gl-Matrix库https://github.com/toji/gl-matrix/blob/master/dist/gl-matrix-min.js
关于为什么该行停止代码执行的任何想法?
这是完整的代码:
<!doctype html>
<html>
<head>
<title>WebGL - Chapter One - Lol</title>
<style>
body{ background-color: grey; }
canvas{ background-color: white; }
</style>
<script src = "gl-matrix-min.js"></script>
<script src = "raf_polyfill.js"></script>
<script id="shader-vs" type="x-shader/x-vertex">
attribute vec3 aVertexPosition;
attribute vec3 aVertexColor;
uniform mat4 uMVMatrix;
uniform mat4 uPMatrix;
varying highp vec4 vColor; …Run Code Online (Sandbox Code Playgroud) 所以我试图将一个Key转换为一个字符串,这样我就可以用System.out显示它,然后我想把它转换回一个Key.我能够将它转换为带有BASE64Encoder的字符串,但是我将它转换回来时遇到了问题.这是我的源代码:
public class Encryption extends Applet {
Key keyOrig;
BASE64Decoder decoder = new BASE64Decoder();
BASE64Encoder encoder = new BASE64Encoder();
public void init() {
try {
keyOrig = generateKey();
String keyString = encoder.encode(keyOrig.getEncoded());
System.out.println("Key: "+keyString);
Key key = new SecretKeySpec(keyString.getBytes(),0,keyString.getBytes().length, "DES");
String message = "This is hacker proof!";
System.out.println("Message is: "+message);
String encryptedMessage = encrypt(message,key);
System.out.println("Message encrypted: "+ encryptedMessage);
String decryptedMessage = decrypt(encryptedMessage,key);
System.out.println("Message decrypted: "+ decryptedMessage);
} catch (Exception e) {
e.printStackTrace();
}
}
public Key generateKey() throws NoSuchAlgorithmException { …Run Code Online (Sandbox Code Playgroud) 所以我在我的代码中遇到了一个小问题:
synchronized(clients)
clients.remove(this);
}
Run Code Online (Sandbox Code Playgroud)
当客户端断开连接时,但现在我需要能够将该客户端的名称发送给所有其他客户端,并且要做到这一点我必须要做类似的事情
synchronized(clients)
broadcast("Remove:"+clients.get(this).name);
clients.remove(this);
}
Run Code Online (Sandbox Code Playgroud)
但显然我无法获得带有"this"的索引,那么我该如何获得正确的客户名称呢?谢谢!