Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > static/local array

Reply
Thread Tools

static/local array

 
 
Chris Forone
Guest
Posts: n/a
 
      01-10-2013
hello,

i have some strange behavior in my multithreaded app. i do some
matrix-multiplications in a methode. if i use local arrays there it
works, but if i use a static member array (some kind of reusable array)
it doesnt work anymore. some code snippets:

[matrix multiplication]
template <typename T>
inline void MultiplyMatrix(T(&first)[16], T(&second)[16])
{
GLfloat result[16];

for (std::size_t i(0); i < 16; i += 4)
for (std::size_t j(0); j < 4; ++j)
result[i + j] = first[i] * second[j]
+ first[i + 1] * second[j + 4]
+ first[i + 2] * second[j + 8]
+ first[i + 3] * second[j + 12];

std::copy(result, result + 16, first);
}

[here i use matrix multiplication, write to local/static array]
void Object:raw() const
{
GLfloat localTempMatrix[] =
{
1.0f, 0.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f, 0.0f,
0.0f, 0.0f, 1.0f, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f
};

localTempMatrix[12] = position[Coordinate::X];
localTempMatrix[13] = position[Coordinate::Y];
MultiplyMatrix(localTempMatrix, projectionMatrix);

GLint programId(0);
glGetIntegerv(GL_CURRENT_PROGRAM, &programId);

glUniformMatrix4fv(glGetUniformLocation(programId, "matrix"), 1,
GL_FALSE, localTempMatrix);
....
}

thanks a lot!

cheers, chris
 
Reply With Quote
 
 
 
 
Chris Forone
Guest
Posts: n/a
 
      01-10-2013
ok, i now use the new std::array<float, 16> and it works perfect. thanks
a lot!

cheers, chris
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
const and array of array (of array ...) Mara Guida C Programming 3 09-03-2009 07:54 AM
length of an array in a struct in an array of structs in a struct in an array of structs Tuan Bui Perl Misc 14 07-29-2005 02:39 PM
Length of Array of Array of Array Tom Perl Misc 3 12-20-2004 05:23 PM
How to combine 2 int Array into ONE int Array ? S300 Java 4 08-19-2003 07:04 PM
hashed array in array need the keys... and length Daniel Perl 1 08-14-2003 06:49 PM



Advertisments