Ogre传入数组到cg程序中

1.material文件

不需要定义变量

2.cg文件

定义数组参数:uniform float4 arr

注意:cg中必须使用传入的数组,否则会报错。

3.主程序中更新数组信息

float m_arr[10][4];

Ogre::MaterialPtr mat =  Ogre::MaterialManager::getSingleton().getByName("materialName");

mat->getTechnique(0)->getPass(0)->getFragmentProgramParameters()->setNamedConstant("arr", m_arr[0], 10);

关键API:
/** Sets a multiple value constant floating-point parameter to the program.
        @par
            Some systems only allow constants to be set on certain boundaries,
            e.g. in sets of 4 values for example. The 'multiple' parameter allows
            you to control that although you should only change it if you know
            your chosen language supports that (at the time of writing, only
            GLSL allows constants which are not a multiple of 4).
        @note
            This named option will only work if you are using a parameters object created
            from a high-level program (HighLevelGpuProgram).
        @param name The name of the parameter
        @param val Pointer to the values to write
        @param count The number of 'multiples' of floats to write
        @param multiple The number of raw entries in each element to write,
            the default is 4 so count = 1 would write 4 floats.
        */

void setNamedConstant(const String& name, const float *val, size_t count,
            size_t multiple = 4);

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值