**3**

# Matrices

###
#1
Members - Reputation: **122**

Posted 08 February 2011 - 08:43 AM

My language is C++

Thanks!

###
#2
Members - Reputation: **172**

Posted 08 February 2011 - 08:56 AM

Also nifty things from GLSL like vec3 m = vec3(vec2(1.0f, 2.0f), 1.0f); work.

It has also replacement functions for deprecated glOrtho and glTranslate etc.

Here a short usage sample:

// Send Projection Matrix glm::mat4 projMatrix = glm::mat4(1); projMatrix = glm::ortho<float>(0.0f, w, h, 0, -1.0f, 1.0f); glUniformMatrix4fv(m_perspective_id, 1, false, glm::value_ptr(projMatrix));And it is a header only library, so no need to compile it.

http://www.g-truc.ne...-0016.html#menu

HTH

http://nightlight2d.de/

###
#3
Members - Reputation: **122**

Posted 08 February 2011 - 09:17 AM

Use glm. This library is writte against the GLSL Spec and you can send them to your shaders directly.

Also nifty things from GLSL like vec3 m = vec3(vec2(1.0f, 2.0f), 1.0f); work.

It has also replacement functions for deprecated glOrtho and glTranslate etc.

Here a short usage sample:// Send Projection Matrix glm::mat4 projMatrix = glm::mat4(1); projMatrix = glm::ortho<float>(0.0f, w, h, 0, -1.0f, 1.0f); glUniformMatrix4fv(m_perspective_id, 1, false, glm::value_ptr(projMatrix));And it is a header only library, so no need to compile it.

http://www.g-truc.ne...-0016.html#menu

HTH

###
#4
Members - Reputation: **809**

Posted 08 February 2011 - 11:57 AM

The code would look something like

float mymatrix[16]; glhLoadIdentityf2(mymatrix); glhTranslatef2(mymatrix, 0.0, 5.0, 6.0); glhScalef2(mymatrix, 1.0, 1.0, 2.0); glhPerspectivef2(mymatrix, 45.0, aspectRatio, 0.1, 1000.0);

and mymatrix is ready. You send it to GL

glUniformMatrix4fv(m_perspective_id, 1, FALSE, mymatrix);

an open source GLU replacement library. Much more modern than GLU.

float matrix[16], inverse_matrix[16];

glhLoadIdentityf2(matrix);

glhTranslatef2(matrix, 0.0, 0.0, 5.0);

glhRotateAboutXf2(matrix, angleInRadians);

glhScalef2(matrix, 1.0, 1.0, -1.0);

glhQuickInvertMatrixf2(matrix, inverse_matrix);

glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);

glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

###
#6
Crossbones+ - Reputation: **12036**

Posted 08 February 2011 - 04:14 PM

It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.

###
#7
Members - Reputation: **1940**

Posted 08 February 2011 - 11:27 PM

Follow my RTS game ICBM

https://twitter.com/dpadam450

http://www.gamedev.net/blog/2202-dpadam450s-journal/

###
#8
Members - Reputation: **1940**

Posted 08 February 2011 - 11:36 PM

Follow my RTS game ICBM

https://twitter.com/dpadam450

http://www.gamedev.net/blog/2202-dpadam450s-journal/

###
#9
Members - Reputation: **809**

Posted 09 February 2011 - 03:11 PM

**dpadam450,**

It doesn't do a stack although I had that at one point, I removed it. Your own classes should store the matrix for your objects.

an open source GLU replacement library. Much more modern than GLU.

float matrix[16], inverse_matrix[16];

glhLoadIdentityf2(matrix);

glhTranslatef2(matrix, 0.0, 0.0, 5.0);

glhRotateAboutXf2(matrix, angleInRadians);

glhScalef2(matrix, 1.0, 1.0, -1.0);

glhQuickInvertMatrixf2(matrix, inverse_matrix);

glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);

glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

###
#10
Members - Reputation: **1940**

Posted 09 February 2011 - 03:44 PM

Follow my RTS game ICBM

https://twitter.com/dpadam450

http://www.gamedev.net/blog/2202-dpadam450s-journal/