Sign in to follow this  
giugio

webgl matrix

Recommended Posts

giugio    246
hello.
I would understand how i can assign a value to an index in a webgl matrix.
I tryed with
var mx = mat4.create();
mx[0][0] = 0.31312312 or
mx[1][0] = 0.2222222

but don't work.
the matrices in webgl are row major or column major?
I think that i must do with only one index from 0 to 15 , but how i can calculate the indexes?

thanks

Share this post


Link to post
Share on other sites
capricorn    139
[quote name='giugio' timestamp='1312632094' post='4845401']
the matrices in webgl are row major or column major?
I think that i must do with only one index from 0 to 15 , but how i can calculate the indexes?
[/quote]

OpenGL matrices are column major, so given matrix M with R rows and C columns, for element Mi,j the index is calculated as follows:

[code]
index = j*R + i
[/code]

with i = [ 0 .. R ), j = [ 0 .. C )

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this