/// @description The rest here in the draw event (to save space for the purposes of this demo)
// The draw event
// Quit on 'escape' key press
if(keyboard_check_pressed(vk_escape))
game_end();
// If the video has started playing, create the surface at the same size as the video
if(!surface_exists(video_surface) && video_get_duration() > 0)
{
video_surface = surface_create(video_get_width(), video_get_height());
video_draw(); // Pre-draw sets up internal texture mapping after video has confirmed to have started.
}
// Once the surface exists and video is playing, set the surface as the render
// target and draw the video to it. Then we can draw back to the screen.
if(surface_exists(video_surface))
{
shader_set(shader0);
surface_set_target(video_surface)
result_draw = video_draw();
surface_reset_target();
draw_surface_ext(video_surface, 0, 0, 1.0, 1.0, 0, c_white, 1);
shader_reset();
}
// Calculate the movement of the mouse
mouse_x_diff = display_mouse_get_x() - display_get_width() / 2;
mouse_y_diff = display_mouse_get_y() - display_get_height() / 2;
display_mouse_set(display_get_width() / 2, display_get_height() / 2);
// Move the 3D camera around in relation to mouse movement
rot -= mouse_x_diff / 20;
pitch += mouse_y_diff / 20;
if(pitch >= 90)
pitch = 90;
if(pitch <= -90)
pitch = -90;
mat_world = matrix_build(0,0,0,pitch,rot,0,1,1,1);
mat_proj = matrix_build_projection_perspective_fov(60, fov, 0, 100);
mat_view = matrix_build_lookat(0,0,00,0,0,-1000,0,-1,0);
matrix_set(matrix_world, mat_world);
matrix_set(matrix_projection, mat_proj);
matrix_set(matrix_view, mat_view);
// Draw the skydome with the video as the texture
shader_set(shader0);
vertex_submit(vertex_buffer, pr_trianglelist, surface_get_texture(video_surface));
shader_reset();
// Reset the world matrix back to normal or everything else drawn from this point will likely
// not look the way you want it to.
matrix_set(matrix_world, matrix_build_identity());