Thursday, February 26, 2009

Shaders

So it helps when you initialize the array of classes. Now the multiple shaders work!

You create your array of pointers in the .h file:
Atom **atomArray; // ** designates an array of pointers

Initialize them in the .ccp file:
atomArray = new Atom*[numAtoms]; //creates the array

create the objects like so:
if (key == '1'){
atomArray[numAtoms] = new Atom(0,0,0,"brick");
numAtoms++;
}

call the methods:

for (int i=0;i < numAtoms;i++){
atomArray[i] -> draw();
}


and then things don't crash so often.

Onward and forward!

I realize this post is labeled Shaders and does not talk about them other than they are working.

0 Comments:

Post a Comment

<< Home