Skip to main content
gamedev.net
🔒 Locked

HLSL: array conversion error

Started by Bvandeweyer Aug 3, 2005 at 10:39 AM 4 replies 1.6k views
Original Post
Bvandeweyer
Bvandeweyer
I'm stuggling with arrays in HLSL. Even a simple code like this:

int Array[2],
Array[1] = 2,
Array[2] = 1;
gives me the following error: "Cannot convert from int to int[ ]..." This means I can't write any value in the array, but I have no idea why this happens. Somehow an integer or float can't be converted to be put into the array. Anyone knows why it gives this error, and how to solve this ? I've been trying to solve this for the past 3 days, but without any luck (even google let me down for the first time). Any help is highly appreciated ! Thanks.
Cypher19
Cypher19
Umm...
1) Shouldn't your lines be ending with semicolons?
2) If you have a size 2 array, the indices will be from 0 to 1, not 1 to 2.
Bvandeweyer
Bvandeweyer
Well, I thought that too...

but with the semicolons I receive:
"Syntax error: unexpected token '['"

and with the array range starting from 0:
"Error X3059: 'Array': array dimension must be between 1 and 65536"

So when I use the piece of code from my previous post, the syntax looks right, apart from that nasty conversion problem...

BTW, I'm using NVidia's FXComposer to write my shaders and thus get the errors there (but it doesn't work in the gameengine either though).

I think I'm going crazy... ;)

Thanks though.
Bvandeweyer
Bvandeweyer
Just a quick question to check if all my efforts were not in vain:

Is it possible that arrays in hlsl are read-only ?
benryves
benryves
Bear in mind that I know nothing about HLSL... but is "Array" a reserved keyword? Would it work if you changed "Array" to "my_array"?
Just a hunch. [smile] You did say any help...
[Website] [+++ Divide By Cucumber Error. Please Reinstall Universe And Reboot +++]
Bvandeweyer
Bvandeweyer
@ Ben: no, "array" isn't a reserved word... but thanks for the suggestion !

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.