PDA

View Full Version : help on features HLSL has but GLSL doesn't



Sarwinnie
05-24-2008, 07:47 PM
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

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

Brolingstanz
05-24-2008, 08:54 PM
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.

Brolingstanz
05-25-2008, 07:05 AM
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")...

Seth Hoffert
05-25-2008, 07:08 AM
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).

147-2
06-11-2008, 10:32 AM
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.