2017-01-10 11 views
0

編集: 私はQT/QMLとAndroidアプリケーション開発では初めです。シェーダは、Androidで動作していないAndroidで動作しないシェーダー - QT/QMLアプリケーション

- QT/QMLアプリケーション

は、私は、開発者QT/QMLを使用してアプリケーションを持っているとのAndriodにアプリケーションを移植しました。

私はアプリケーションでシェーダを使用しました。

Androidシェーダでの展開は機能しません。

QOpenGLShader::compile(Fragment): ERROR: 0:11: ':' : wrong operand types no operation ':' exists that takes a left-hand operand of type 'float' and a right operand of type 'const int' (or there is no acceptable conversion) 

varying highp vec2 qt_TexCoord0; // The coords within the source item     uniform sampler2D source;   // The source item texture 

編集

ShaderEffect { 
      anchors.fill: wrapper 
      id:shader 
      // Any property you add to the ShaderEffectItem is accessible as a 
      // "uniform" value in the shader program. See GLSL doc for details. 
      // Essentially, this is a value you pass to the fragment shader, 
      // which is the same for every pixel, thus its name. 

      // Here we add a source item (the scene) as a uniform value. Within the 
      // shader, we can access it as a sampler2D which is the type used to 
      // access pixels in a texture. So the source item becomes a texture. 
      property variant source: ShaderEffectSource 
      { 
      sourceItem: scene // The item you want to apply the effect to 
      hideSource: true // Only show the modified item, not the original 
     } 
     property real dividerValue: 0.9 
     // This is the fragment shader code in GLSL (GL Shading Language) 
     fragmentShader: " 
     varying highp vec2 qt_TexCoord0; // The coords within the source item 
     uniform sampler2D source;   // The source item texture 
     uniform float dividerValue; 
     void main(void) 
     { 
      // Read the source color of the pixel 
      vec4 sourceColor = texture2D(source, qt_TexCoord0); 

      // The alpha value of the mask 
      float alpha = (qt_TexCoord0.x>dividerValue)?1.0:((qt_TexCoord0.x>(dividerValue-.1))?((qt_TexCoord0.x-(dividerValue-0.1))/0.1):0); // = 0.0 at left, 1.0 at right border 
       // float alpha = (qt_TexCoord0.x>dividerValue)?1.0:qt_TexCoord0.x/dividerValue; 
      // Multiply the alpha mask on the color to be drawn: 
      sourceColor *= alpha; 

      // Write the pixel to the output image 
      gl_FragColor = sourceColor; 
     } 
     " 
+2

あなた、あなたは5年です。少なくともこのコードのサラダを再フォーマットして質問を明確にすることはできますか? – folibis

答えて

2
float alpha = (qt_TexCoord0.x > dividerValue) 
        ? 1.0 
        : ((qt_TexCoord0.x > (dividerValue-.1)) 
         ? ((qt_TexCoord0.x-(dividerValue-0.1))/0.1) 
         : 0); 

エラーがここでの問題について非常に明確である:正確に右、左とintfloatを取ると何のオペレータ:はありません:オペレータ(((qt_TexCoord0.x-(dividerValue-0.1))/0.1)))の左側がfloatである最後の条件付きのケースですが、右t側(0)はintです。 00.0(または.0)に変更すると、それはfloatとなり、動作するはずです。

Android搭載デバイスのシェーダコンパイラは、暗黙的な変換についてもっと気になります。

+1

@ダニエル:どうもありがとう。これは私の問題を完全に解決しました。 –

関連する問題