Help on features HLSL has but GLSL doesn't

Hi,

I’m working with HLSL and GLSL. HLSL has some features that I’d like to use with my GLSL code too. So, I’d like to ask if you have an idea how can I use

  • [li]Buffer - a data type []Register - used to assign a variable to a particular constant register []Packoffset - used to assign an element to a particular register subcomponent []the #include directive []type casting

I know they are not directly supported by GLSL, so, any idea on how I can work with them are mostly welcome.

Thanks a lot

For starters you really want to have a gander at the GLSL spec, which covers all the language features quite nicely.

Let’s see, the bindable uniform buffer is the cbuffer counterpart; there’s no register/packoffset equivalent; and there’s an #include mechanism on the way in GL3.

There’s also EXT_texture_buffer_object, which is similar in spirit to the “typeless” formats in dx10 (if that’s what you meant by “type casting”)…

You can cast in GLSL. For example, mat3(some_float) casts a float into a 3x3 matrix (some_float along the diagonal, 0s off the diagonal). Casting matrices to matrices: mat2(some_mat4) gives you the upper 2x2 portion of the 4x4 matrix. mat4(some_mat2) inserts the 2x2 matrix into the upper left of a 4x4 identity matrix. You can cast integers to floats and floats to integers: int(some_float), float(some_int).

Perhaps a look at NVidia’s Cg might also be helpful… I suspect you’ll have to do very little work to make your HLSL code work in Cg.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.