# devices. It is used to position the sprites in `App::ui_sprites`.
#
# See the sample game at `contrib/asteronits/` and the basic project template
-# at `lib/gamnit/examples/template_flat/`.
+# at `lib/gamnit/examples/template/`.
module flat
import glesv2
intrude import geometry::points_and_lines # For _x, _y and _z
+intrude import matrix
import matrix::projection
import more_collections
import performance_analysis
import gamnit
-import gamnit::cameras
+import gamnit::cameras_cache
import gamnit::dynamic_resolution
import gamnit::limit_fps
import gamnit::camera_control
redef fun frame_core(display)
do
- # Prepare to draw, clear buffers
- glClear(gl_COLOR_BUFFER_BIT | gl_DEPTH_BUFFER_BIT)
-
# Check errors
var gl_error = glGetError
assert gl_error == gl_NO_ERROR else print_error gl_error
else
rot = new Matrix.rotation(sprite.rotation, 0.0, 0.0, 1.0)
end
- data.fill_from(rot.items, o+15)
+ data.fill_from_matrix(rot, o+15)
o += float_per_vertex
end
#
# array.add "E"
# assert array.to_s == "[A,B,c,D,E]"
-# assert array.capacity == 5
+# assert array.capacity == 6
# assert array.length == 5
#
# array.remove "A"
return ss.join
end
end
+
+redef class GLfloatArray
+ private fun fill_from_matrix(matrix: Matrix, dst_offset: nullable Int)
+ do
+ dst_offset = dst_offset or else 0
+ var mat_len = matrix.width*matrix.height
+ assert length >= mat_len + dst_offset
+ native_array.fill_from_matrix_native(matrix.items, dst_offset, mat_len)
+ end
+end
+
+redef class NativeGLfloatArray
+ private fun fill_from_matrix_native(matrix: matrix::NativeDoubleArray, dst_offset, len: Int) `{
+ int i;
+ for (i = 0; i < len; i ++)
+ self[i+dst_offset] = (GLfloat)matrix[i];
+ `}
+end