私のコードは、(無効メインの内側)である:私はちょうどi/15.0
を書く場合intをGLSL(WebGL)で浮動小数点にキャストする方法は?
float res;
for(int i=0; i<15; i++) {
res = float(i)/15.0;
//...
}
は、残念ながら私はfloat(i)/15.0
で構文エラーを取得し、エラーがある:
wrong operand types no operation '/' exists that takes a left-hand operand of type 'mediump int' and a right operand of type 'const float' (or there is no acceptable conversion)
の場合私はちょうどi/15
を試して、結果は整数ですが、私はフロートを取得したいと思います。
キャストはどのように可能ですかint
からfloat
?
この変換は自動的に行われます - res = i/15; – jeff
これはGLSLであり、JavaScriptではありません。 –
私は[上のコードをglslsandbox.comに貼り付けて、うまく動作します](http://glslsandbox.com/e#28445.0)。シェーダの別の行からそのエラーを受け取っていないと確信していますか? – gman