PDA

View Full Version : global array with initialization



hbuel
12-10-2006, 04:33 AM
Hi,

in HLSL it's possible to do something like

vec2 array[] = { (0.0, 1.0), (2.0, 3.0) }I don't really care so much about the {-brackets but if it is somehow possible to declare an global array and assign values to it.

So I can call from every function array[1] and get vec2(0.0, 1.0).

Is this possible?

thanks :)

Mars_999
12-10-2006, 03:52 PM
Yes it is, but you need to do this

vec2 array[] = { vec2(0.0, 1.0), vec2(2.0, 3.0) };

sqrt[-1]
12-10-2006, 05:37 PM
I think it is only available in the latest GLSL 1.2 specs, so you may have to update your driver.

hbuel
12-11-2006, 02:28 AM
Thank you both! When I tried the
vec2 array[] = { vec2(0.0, 1.0), vec2(2.0, 3.0) };
this didn't work and the GLSL Syntax Validator reported an error. Does anyone know since which driver version GLSL 1.2 is supported by the ATI and nVidia cards?

ehart
12-11-2006, 05:33 AM
The 97 series drivers from NVIDIA support version 1.2 in beta form. It can be enabled under Windows with NVEmulate, and under unix-like operating systems by editing a config file (see the GLSL release notes). The links to NVemulate and the GLSL release notes are below:

NVemulate
http://developer.nvidia.com/object/nvemulate.html

GLSL Release notes
http://developer.download.nvidia.com/opengl/glsl/glsl_release_notes.pdf

As a quick note of caution, NVIDIA has not yet released a 97 series driver for pre-8800 cards on Windows, and with special branches it might be possible to run across a 97 series driver without the beta 1.2 support. The GLSL release notes point out the versions recommended for use at this time.

-Evan

Mars_999
12-11-2006, 09:00 AM
Oops my bad, I have the 97.02 driver and a 8800GTX. :)

hbuel
12-12-2006, 02:07 AM
Thanks. Then I will probably wait :) Only have an 6800GT.

Is it possible to do something like thing in an uniform array? Calculate the values on the CPU and pass an array of the sort:
uniform vec2 uarray[100];
to the glsl shaders?

sqrt[-1]
12-12-2006, 05:15 PM
Yes that is valid.