【问题标题】:glsl es const mat2 arrayglsl es const mat2 数组
【发布时间】:2014-02-19 18:08:30
【问题描述】:

我尝试在 Open GL ES 2.0(在 RenderMonkey 中)编译以下代码:

const mat2 ma[2] =  mat2[2](
                     mat2( vec2(0.0, -1.0), vec2(1.0, 0.0) ),
                     mat2( vec2(0.0, -1.0), vec2(1.0, 0.0) )
                    );

但是编译器说:

OpenGL ES Preview Window: Compiling vertex shader API(OpenGL ES) /Effect Group 1/Effect1/Pass 0/Vertex Program/ ... failure
   COMPILE ERROR: API(OpenGL ES) /Effect Group 1/Effect1/Pass 0/Vertex Program/ (13): ERROR: 0:13: 'constructor' : if a matrix argument is given to a matrix constructor, it is an error to have any other arguments. 
   COMPILE ERROR: API(OpenGL ES) /Effect Group 1/Effect1/Pass 0/Vertex Program/ (10): ERROR: 0:10: '=' :  cannot assign to 'const array of 2X2 matrix of float'

我做错了什么?

【问题讨论】:

    标签: opengl-es glsl glsles rendermonkey


    【解决方案1】:

    [编辑]

    在 webgl/chrome 中,我得到了这个:

    ERROR: 0:4: 'ma' : arrays may not be declared constant since they cannot be initialized 
    ERROR: 0:4: '=' : syntax error 
    

    看起来不太好。

    可能相关:How to define constant array in GLSL (OpenGL ES 2.0)?


    桌面 GL...

    你的代码对我有用,但是我没有设置版本就得到了这个:

    warning C7551: OpenGL first class arrays require #version 120
    

    你能在 RenderMonkey 中提供一个#version 字符串吗?

    我怀疑是这种情况,但真的旧卡或驱动程序可能是一个因素。

    我认为你也不需要第二个2const mat2 ma[2] = mat2[](... 很好

    【讨论】:

    • 您应该尝试在 GL ES 设备上运行它,例如 android 或 webGL。在 RenderMonkey 上确保使用 GL ES 效果组。如果是这样 - 您只能使用 #version 100。#version 120 - 用于桌面 GL
    • @tower120 糟糕,我完全错过了 GL ES 部分。我不确定这是否可能,但不确定。刚刚在 webgl 中尝试过。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-04-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多