Wtf i cant loop vertecies

Started by
7 comments, last by Duekiller 20 years, 1 month ago
how come this peice of code doesnt work CustomVertex Vertex[]= { for(float location;location<100;location++) { { location, 50.0f, 0.5f, 0x000000, }, { location, 250.0f, 0.5f, 0x000000, } } };
Advertisement
Sorry, but I''m not even going to begin to touch this one...

Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse

quote:Original post by superpig
Sorry, but I''m not even going to begin to touch this one...


y not, is it really that bad?
Hmmm....

What do you get when you use the REF device?
quote:Original post by Anonymous Poster
Hmmm....

What do you get when you use the REF device?


LMAO, AP

Duekiller: try this code:

CustomVertex Vertex[100];
for(int location; location<100; location+=2)
{
Vertex[location].x = location;
Vertex[location].y = 50.0f;
Vertex[location].z = 0.5f;
Vertex[location].diffuse = 0x00000000;

Vertex[location+1].x = location;
Vertex[location+1].y = 250.0f;
Vertex[location+1].z = 0.5f;
Vertex[location+1].diffuse = 0x00000000;
}


Richard "Superpig" Fine
Smoother than a greased baby
[TBRF|GP&T|Enginuity1|Enginuity2|Enginuity3|Enginuity4|Enginuity5]

Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse

Or, duekiller, to answer your question:

If you''re declaring something like a customvertex array, you can not have a for loop, or ANY loop at all for that matter, in the declaration. You can only have numbers. YOu have to declare it, then loop like superpig did.
This really has nothing to do with DirectX. It''s an introductory C/C++ question.

Stay Casual,

Ken
Drunken Hyena
Stay Casual,KenDrunken Hyena
Holly crap I knew that. I feel like an idiot.

ROTFL.
quote:Original post by shadowman13131
Or, duekiller, to answer your question:

If you''re declaring something like a customvertex array, you can not have a for loop, or ANY loop at all for that matter, in the declaration. You can only have numbers. YOu have to declare it, then loop like superpig did.

Just to make sure the OP understands *why* he can''t have loops. The reason is that the compiler has to determine the contents of that array at compile-time, and it can''t evaluate loops or whatever and use their output to fill it.

Muhammad Haggag

This topic is closed to new replies.

Advertisement