Module: Engine
- Defined in:
- lib/engine/font.rb,
lib/engine/mesh.rb,
lib/engine/path.rb,
lib/engine/input.rb,
lib/engine/camera.rb,
lib/engine/cursor.rb,
lib/engine/engine.rb,
lib/engine/shader.rb,
lib/engine/window.rb,
lib/engine/texture.rb,
lib/engine/material.rb,
lib/engine/component.rb,
lib/engine/debugging.rb,
lib/engine/autoloader.rb,
lib/engine/quaternion.rb,
lib/engine/video_mode.rb,
lib/engine/game_object.rb,
lib/engine/polygon_mesh.rb,
lib/engine/screenshoter.rb,
lib/engine/importers/obj_file.rb,
lib/engine/tangent_calculator.rb,
lib/engine/importers/obj_importer.rb,
lib/engine/importers/font_importer.rb
Defined Under Namespace
Modules: AutoLoader, Components, Debugging, Physics Classes: Camera, Component, Cursor, Font, FontImporter, GameObject, Input, Material, Mesh, NoEarsException, ObjFile, ObjImporter, Path, PolygonMesh, Quaternion, Screenshoter, Shader, TangentCalculator, Texture, VideoMode, Window
Class Method Summary collapse
- .close ⇒ Object
- .engine_started? ⇒ Boolean
- .fps ⇒ Object
- .main_game_loop(&first_frame_block) ⇒ Object
- .open_window ⇒ Object
- .start(&first_frame_block) ⇒ Object
- .stop_game ⇒ Object
Class Method Details
.close ⇒ Object
94 95 96 97 98 99 |
# File 'lib/engine/engine.rb', line 94 def self.close GameObject.destroy_all Component.erase_destroyed_components GameObject.erase_destroyed_objects GLFW.SetWindowShouldClose(Window.window, 1) end |
.engine_started? ⇒ Boolean
15 16 17 |
# File 'lib/engine/engine.rb', line 15 def self.engine_started? @engine_started end |
.fps ⇒ Object
90 91 92 |
# File 'lib/engine/engine.rb', line 90 def self.fps @fps end |
.main_game_loop(&first_frame_block) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/engine/engine.rb', line 39 def self.main_game_loop(&first_frame_block) @game_stopped = false @old_time = Time.now @time = Time.now @fps = 0 Window.get_framebuffer_size GL.Clear(GL::COLOR_BUFFER_BIT | GL::DEPTH_BUFFER_BIT) until GLFW.WindowShouldClose(Window.window) == GLFW::TRUE || @game_stopped if first_frame_block first_frame_block.call first_frame_block = nil end @old_time = @time || Time.now @time = Time.now delta_time = @time - @old_time print_fps(delta_time) Physics::PhysicsResolver.resolve GameObject.update_all(delta_time) @swap_buffers_promise.wait! if @swap_buffers_promise GL.Clear(GL::COLOR_BUFFER_BIT | GL::DEPTH_BUFFER_BIT) GL.Enable(GL::DEPTH_TEST) GL.DepthFunc(GL::LESS) Rendering::RenderPipeline.draw unless @game_stopped GL.Disable(GL::DEPTH_TEST) GameObject.render_ui(delta_time) if Screenshoter.scheduled_screenshot Screenshoter.take_screenshot end Window.get_framebuffer_size if OS.windows? GLFW.SwapBuffers(Window.window) else @swap_buffers_promise = Concurrent::Promise.new do GLFW.SwapBuffers(Window.window) end @swap_buffers_promise.execute end Engine::Input.update_key_states GLFW.PollEvents end end |
.open_window ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/engine/engine.rb', line 19 def self.open_window @old_time = Time.now @time = Time.now Window.create_window GLFW.MakeContextCurrent(Window.window) Input.init GL.load_lib set_opengl_blend_mode @engine_started = true GL.ClearColor(0.0, 0.0, 0.0, 1.0) GL.Enable(GL::CULL_FACE) GL.CullFace(GL::BACK) GLFW.SwapInterval(0) end |
.start(&first_frame_block) ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/engine/engine.rb', line 6 def self.start(&first_frame_block) Engine::AutoLoader.load return if ENV["BUILDING"] == "true" open_window main_game_loop(&first_frame_block) terminate end |
.stop_game ⇒ Object
101 102 103 104 105 106 107 |
# File 'lib/engine/engine.rb', line 101 def self.stop_game @game_stopped = true @swap_buffers_promise.wait! if @swap_buffers_promise && !@swap_buffers_promise.complete? GameObject.destroy_all Component.erase_destroyed_components GameObject.erase_destroyed_objects end |