So I just got my program to use the mesh and shader to grab information from a file and properly create and texture it. Next i wanted to be able to grab the size of the array's i needed by creating a header in the file so i could allocate the memory for each individual object at creation. Below I've just put out some code that i thought would work for creating a dynamic array so i could use non constant integer values to determine how big the array should be. But i get an error saying the operator where i declare the array byte to a zero value does not take a right hand operand of type int. Any suggestions would be much appreciated.
correct the structure stores x y z w and uv coordinates for position, color and texture. And they are float values so i can't use an int it seems like for assigning.
Reread what PrintFDebugger posted, hes assigning to the members of array element q, vertices[q].x, vertices[q].y, vertices[q].z, etc. Youre trying assign to the entire element with 0, unless youve overloaded the assignment operator to make sense of int assignment, this wont make sense. Has nothing to do with assigning 0 to float, that can be done, float f = 0, 0 in binary is the same as 0.0. What youre trying to do is
struct SomeStruct { float x, y, z; float tu, tv; }; SomeStruct ss; ss = 0; // whats int assignment on your new type SomeStuct mean? nothing right now.
Yea sorry late, i got what PrintFDebugger was saying. I changed the example to assign zero to an array element and it works to an extent. The decleration of the array size still is not working properly. It's only showing 1 array slot instead of the 776 i need, even though i made VertexSize hold the correct value instead of relying on the file input for debugging purposes.
With the size thing, the best thing I've done for myself in ages is upgrade to using vectors. Instant resizing with the same access as arrays, plus a whole heap of great member functions like push, pop, size, etc. Highly recommend you jump on the msdn and look into them.
The high cost of living hasn't affected its popularity.
I guess the question would be can i even reasonably create a dynamic array using this structure, because it contains so many vector elements. Or is there just a better direction to go for handling multiple objects / reading in information.
Quote:Original post by Smigss The decleration of the array size still is not working properly. It's only showing 1 array slot instead of the 776 i need, even though i made VertexSize hold the correct value instead of relying on the file input for debugging purposes.
If you're using the debugger, it'll only show 1 element because you have a pointer, not an array. If you want to view the array contents in the variable watch window, put "vertices, 776" (no quotes obviously) in the watch window.
Ah i see what your saying Evil Steve. I see this method of creating a pointer to a new array of a custom structure and i just get an exception handle when i try and call mesh->setVertexData(0, vertices).