float *array = 0;
array = new float[strlen(text)*20];
...
delete [] array;
More specific (New keyword)
Can someone tell me if these statements are valid inside a function.
If anyone knows I''d be thankful.
_____________________________
And the Phoenix shall rise from the ashes...
--Thunder_Hawk -- ¦þ
______________________________
I''ve been debuging a function for about 3hours now and I''m getting to the point where I believe that these statements have to be what''s messing it up.
_____________________________
And the Phoenix shall rise from the ashes...
--Thunder_Hawk -- ¦þ
______________________________
_____________________________
And the Phoenix shall rise from the ashes...
--Thunder_Hawk -- ¦þ
______________________________
Just had a peek on your code... what is the purpose for you to have strlen(text)*20 of floats?
To create room for an array. I need 20 numbers for each letter. (2texcoords+3vertexcoords)*4vertices = 20floats/character.
These kind of hard to track down errors don''t hapen as often when you use well defined data. If you use a class\struct in place of what your currently using you can still cast you data to a void* to say pass in to opengl later.
Without doing something like that it''s easy to write code that unintentionally over run the array.
I''d use a std::vector with a struct for the data members. Then there in no new \ delete and no chance that you''ve messed up the accessor code for finding the correct data member as the struct stores the offsets for you.
Chris Brodie
http:\\fourth.flipcode.com
Without doing something like that it''s easy to write code that unintentionally over run the array.
I''d use a std::vector with a struct for the data members. Then there in no new \ delete and no chance that you''ve messed up the accessor code for finding the correct data member as the struct stores the offsets for you.
Chris Brodie
http:\\fourth.flipcode.com
Aha! Somehow when I read your post gimp it just clicked! I shouldn''t be multiplying by 20 in drawelements. After all, there are only strlen(text) number of elements to draw. I think it was just the thought of overrunning arrays. I had thought that couldn''t be happening because I got it to work with a manual glBegin/glEnd and the vector forms of the functions. Then, I thought that maybe somehow I was telling OpenGL to overrun the array and voila (is that spelled right?). I don''t see how a struct or class would help me here, I would still need a method like this. Never mind, if I had put this in a structure the *20 part might have been handled automatically and I would have avoided my confusion. Oh well, thanks alot
_____________________________
And the Phoenix shall rise from the ashes...
--Thunder_Hawk -- ¦þ
______________________________
_____________________________
And the Phoenix shall rise from the ashes...
--Thunder_Hawk -- ¦þ
______________________________
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement