如何在GLSL 1.3和OpenGL 2.1中使用位操作 [英] How to use bit operations in GLSL 1.3 with OpenGL 2.1

查看:479
本文介绍了如何在GLSL 1.3和OpenGL 2.1中使用位操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写使用许多位操作的着色器.实际上从glsl 1.30开始就支持它们,但是我仅在OpenGL 2.1上使用.

I'm trying to write a shader that uses many bit operations. In fact they are supported since glsl 1.30, but I'm only on OpenGL 2.1.

在我的OpenGL版本中可以使用位操作吗?

Is there any way to use bit operations with my OpenGL version?

推荐答案

所有与SM3兼容(〜OpenGL 2.1)的硬件都支持 limited 整数功能.通常,这是通过模拟带有浮点数的整数来完成的, not 不包括位运算.

All SM3 compatible (~OpenGL 2.1) hardware supports limited integer functionality. This is usually done by emulating integers with floats and does not include bit operations.

对于位操作,您需要GLSL 1.3或 EXT_gpu_shader4 .

For bit operations, you need either GLSL 1.3 or EXT_gpu_shader4.

如果只有OpenGL 2.1的原因是您的驱动程序有些过时,那么您仍然可以拥有EXT_gpu_shader4(在这种情况下,更新驱动程序可能是个好主意).

If the reason that you have only OpenGL 2.1 is that your driver is somewhat outdated, you may be lucky to still have EXT_gpu_shader4 (updating drivers might be a good idea though, in that case).

如果原因是您的图形卡根本不支持更好的功能,那您就不走运了.

If the reason is that your graphics card simply does not support anything better, you are out of luck.

如果您确实有EXT_gpu_shader4(检查扩展名字符串),则可以添加:

If you do have EXT_gpu_shader4 (check extension string), you can add:

#extension EXT_gpu_shader4 : require

到您的GLSL 1.2着色器,它应该可以工作.

to your GLSL 1.2 shaders, and it should work.

这篇关于如何在GLSL 1.3和OpenGL 2.1中使用位操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆