i am trying stuff with philogl library, and when i wrote,
<!DOCTYPE html>
<html>
<head>
<title>PGL2</title>
<script type="text/javascript" src="PhiloGL.js"></script>
<script type="text/javascript">
function webGLStart(){
alert('I m alive');
}
</script>
</head>
<body onload="webGLStart();">
<canvas id="c" style="width:500px; height:500px;"></canvas>
</body>
</html>
everything works fine, but if i write some philogl in it like,
<!DOCTYPE html>
<html>
<head>
<title>PGL2</title>
<script type="text/javascript" src="PhiloGL.js"></script>
<script type="text/javascript">
function webGLStart(){
var triangle = new PhiloGL.O3D.Model({
vertices: [[0,1,0],[-1,-1,0],[1,-1,0]],
colors: [[1,0,0,1],[0,1,0,1],[0,0,1,1]]
});
var square = new PhiloGL.O3D.Model({
vertices: [[1,1,0],[-1,1,0],[1,-1,0],[-1,-1,0]],
colors: [[0.5,0.5,1,1],[0.5,0.5,1,1]],[0.5,0.5,1,1]
});
}
</script>
</head>
<body onload="webGLStart();">
<canvas id="c" style="width:500px; height:500px;"></canvas>
</body>
</html>
chrome and firefox gives me an error that says webGLStart() is not defined. What is wrong with my code?
This line:
colors: [[0.5,0.5,1,1],[0.5,0.5,1,1]],[0.5,0.5,1,1]
is syntactically incorrect: a closing "]" is in the wrong place. Thus the function definition "failed", so to speak, and the function doesn't really exist.
I literally just woke up so I'm not sure what's wrong with me that I could spot that.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With