Practical difference between sequence and a C array

new topic     » topic index » view thread      » older message » newer message

Hello everyone, I have been slowly working on Mic's opengl library and wrapping all the needed functions for the modern OpenGl pipeline (VBO support, matrix math, etc.) and I am finding myself doing a LOT of matrix math. Since opengl just uses a length 16 c array to store these matrices I have to constantly convert my sequences into arrays. This obviously degrades performance.

I don't really know a lot about the internals of euphoria memory management so Im curious, how much different is the memory layout of a static, single dimension, sequence of length 16 (using floating pt) than a c array of length 16? Can I make small alterations to a sequence and convert it to an array without reading each element and then poking it directly?

Here is my current process:

function seq_to_matrixf(sequence s1)  -- s1 is a seq of floats of length 16	 
	atom x_array  
 
        if length(s1) != 16 then 
            return -1   -- not correct matrix dimension 
        end if 
	 
	x_array = allocate(64) -- float32s are 4 bytes each * 16 values  
  
	for i = 1 to length( s1 ) do  
    		poke( x_array + (i-1) * 4, atom_to_float32( s1[i] ) )  
	end for  
 
	return x_array 
end function 

Is there a faster way to convert same length and single dimensional sequences into arrays?

Thanks!

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu