mittsu 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (154) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/build-workflow.yml +5 -44
  3. data/Gemfile +0 -4
  4. data/README.md +16 -130
  5. data/bin/console +0 -4
  6. data/lib/mittsu/cameras/cube_camera.rb +1 -1
  7. data/lib/mittsu/core/geometry.rb +3 -3
  8. data/lib/mittsu/core/object_3d.rb +29 -47
  9. data/lib/mittsu/core/uniform.rb +23 -0
  10. data/lib/mittsu/core.rb +1 -0
  11. data/lib/mittsu/loaders/obj_loader.rb +11 -5
  12. data/lib/mittsu/loaders/stl_loader.rb +186 -0
  13. data/lib/mittsu/loaders.rb +1 -0
  14. data/lib/mittsu/math/box3.rb +4 -4
  15. data/lib/mittsu/objects/line.rb +1 -3
  16. data/lib/mittsu/objects/mesh.rb +9 -12
  17. data/lib/mittsu/objects/point_cloud.rb +3 -3
  18. data/lib/mittsu/textures/render_target.rb +93 -0
  19. data/lib/mittsu/textures/render_target_cube.rb +8 -0
  20. data/lib/mittsu/textures/texture.rb +1 -1
  21. data/lib/mittsu/textures.rb +2 -0
  22. data/lib/mittsu/version.rb +1 -1
  23. data/lib/mittsu.rb +0 -1
  24. data/mittsu.gemspec +8 -12
  25. metadata +33 -204
  26. data/install-glfw.ps1 +0 -13
  27. data/lib/mittsu/renderers/generic_lib.rb +0 -122
  28. data/lib/mittsu/renderers/glfw_lib.rb +0 -62
  29. data/lib/mittsu/renderers/glfw_window.rb +0 -233
  30. data/lib/mittsu/renderers/opengl/core/buffer_geometry.rb +0 -11
  31. data/lib/mittsu/renderers/opengl/core/geometry.rb +0 -346
  32. data/lib/mittsu/renderers/opengl/core/object_3d.rb +0 -134
  33. data/lib/mittsu/renderers/opengl/lights/ambient_light.rb +0 -26
  34. data/lib/mittsu/renderers/opengl/lights/directional_light.rb +0 -35
  35. data/lib/mittsu/renderers/opengl/lights/hemisphere_light.rb +0 -39
  36. data/lib/mittsu/renderers/opengl/lights/light.rb +0 -55
  37. data/lib/mittsu/renderers/opengl/lights/point_light.rb +0 -36
  38. data/lib/mittsu/renderers/opengl/lights/spot_light.rb +0 -47
  39. data/lib/mittsu/renderers/opengl/materials/line_basic_material.rb +0 -16
  40. data/lib/mittsu/renderers/opengl/materials/material.rb +0 -274
  41. data/lib/mittsu/renderers/opengl/materials/mesh_basic_material.rb +0 -21
  42. data/lib/mittsu/renderers/opengl/materials/mesh_lambert_material.rb +0 -33
  43. data/lib/mittsu/renderers/opengl/materials/mesh_phong_material.rb +0 -44
  44. data/lib/mittsu/renderers/opengl/materials/opengl_material_basics.rb +0 -57
  45. data/lib/mittsu/renderers/opengl/materials/point_cloud_material.rb +0 -27
  46. data/lib/mittsu/renderers/opengl/materials/shader_material.rb +0 -11
  47. data/lib/mittsu/renderers/opengl/objects/group.rb +0 -9
  48. data/lib/mittsu/renderers/opengl/objects/line.rb +0 -45
  49. data/lib/mittsu/renderers/opengl/objects/mesh.rb +0 -70
  50. data/lib/mittsu/renderers/opengl/objects/point_cloud.rb +0 -39
  51. data/lib/mittsu/renderers/opengl/objects/sprite.rb +0 -12
  52. data/lib/mittsu/renderers/opengl/opengl_buffer.rb +0 -13
  53. data/lib/mittsu/renderers/opengl/opengl_debug.rb +0 -81
  54. data/lib/mittsu/renderers/opengl/opengl_default_target.rb +0 -50
  55. data/lib/mittsu/renderers/opengl/opengl_geometry_group.rb +0 -758
  56. data/lib/mittsu/renderers/opengl/opengl_geometry_like.rb +0 -132
  57. data/lib/mittsu/renderers/opengl/opengl_helper.rb +0 -161
  58. data/lib/mittsu/renderers/opengl/opengl_implementations.rb +0 -37
  59. data/lib/mittsu/renderers/opengl/opengl_lib.rb +0 -19
  60. data/lib/mittsu/renderers/opengl/opengl_light_renderer.rb +0 -43
  61. data/lib/mittsu/renderers/opengl/opengl_mittsu_params.rb +0 -53
  62. data/lib/mittsu/renderers/opengl/opengl_program.rb +0 -250
  63. data/lib/mittsu/renderers/opengl/opengl_shader.rb +0 -58
  64. data/lib/mittsu/renderers/opengl/opengl_state.rb +0 -205
  65. data/lib/mittsu/renderers/opengl/plugins/shadow_map_plugin.rb +0 -417
  66. data/lib/mittsu/renderers/opengl/plugins/sprite_fragment.glsl +0 -38
  67. data/lib/mittsu/renderers/opengl/plugins/sprite_plugin.rb +0 -250
  68. data/lib/mittsu/renderers/opengl/plugins/sprite_vertex.glsl +0 -31
  69. data/lib/mittsu/renderers/opengl/scenes/scene.rb +0 -9
  70. data/lib/mittsu/renderers/opengl/textures/compressed_texture.rb +0 -20
  71. data/lib/mittsu/renderers/opengl/textures/cube_texture.rb +0 -77
  72. data/lib/mittsu/renderers/opengl/textures/data_texture.rb +0 -21
  73. data/lib/mittsu/renderers/opengl/textures/texture.rb +0 -107
  74. data/lib/mittsu/renderers/opengl_render_target.rb +0 -201
  75. data/lib/mittsu/renderers/opengl_renderer.rb +0 -1028
  76. data/lib/mittsu/renderers/shaders/rbsl_loader.rb +0 -166
  77. data/lib/mittsu/renderers/shaders/shader_chunk/alphamap_fragment.glsl +0 -5
  78. data/lib/mittsu/renderers/shaders/shader_chunk/alphamap_pars_fragment.glsl +0 -5
  79. data/lib/mittsu/renderers/shaders/shader_chunk/alphatest_fragment.glsl +0 -5
  80. data/lib/mittsu/renderers/shaders/shader_chunk/bumpmap_pars_fragment.glsl +0 -40
  81. data/lib/mittsu/renderers/shaders/shader_chunk/color_fragment.glsl +0 -5
  82. data/lib/mittsu/renderers/shaders/shader_chunk/color_pars_fragment.glsl +0 -5
  83. data/lib/mittsu/renderers/shaders/shader_chunk/color_pars_vertex.glsl +0 -5
  84. data/lib/mittsu/renderers/shaders/shader_chunk/color_vertex.glsl +0 -5
  85. data/lib/mittsu/renderers/shaders/shader_chunk/common.glsl +0 -60
  86. data/lib/mittsu/renderers/shaders/shader_chunk/default_vertex.glsl +0 -15
  87. data/lib/mittsu/renderers/shaders/shader_chunk/defaultnormal_vertex.glsl +0 -21
  88. data/lib/mittsu/renderers/shaders/shader_chunk/envmap_fragment.glsl +0 -62
  89. data/lib/mittsu/renderers/shaders/shader_chunk/envmap_pars_fragment.glsl +0 -21
  90. data/lib/mittsu/renderers/shaders/shader_chunk/envmap_pars_vertex.glsl +0 -7
  91. data/lib/mittsu/renderers/shaders/shader_chunk/envmap_vertex.glsl +0 -17
  92. data/lib/mittsu/renderers/shaders/shader_chunk/fog_fragment.glsl +0 -26
  93. data/lib/mittsu/renderers/shaders/shader_chunk/fog_pars_fragment.glsl +0 -15
  94. data/lib/mittsu/renderers/shaders/shader_chunk/lightmap_fragment.glsl +0 -5
  95. data/lib/mittsu/renderers/shaders/shader_chunk/lightmap_pars_fragment.glsl +0 -6
  96. data/lib/mittsu/renderers/shaders/shader_chunk/lightmap_pars_vertex.glsl +0 -5
  97. data/lib/mittsu/renderers/shaders/shader_chunk/lightmap_vertex.glsl +0 -5
  98. data/lib/mittsu/renderers/shaders/shader_chunk/lights_lambert_pars_vertex.glsl +0 -43
  99. data/lib/mittsu/renderers/shaders/shader_chunk/lights_lambert_vertex.glsl +0 -196
  100. data/lib/mittsu/renderers/shaders/shader_chunk/lights_phong_fragment.glsl +0 -243
  101. data/lib/mittsu/renderers/shaders/shader_chunk/lights_phong_pars_fragment.glsl +0 -58
  102. data/lib/mittsu/renderers/shaders/shader_chunk/lights_phong_pars_vertex.glsl +0 -5
  103. data/lib/mittsu/renderers/shaders/shader_chunk/lights_phong_vertex.glsl +0 -5
  104. data/lib/mittsu/renderers/shaders/shader_chunk/linear_to_gamma_fragment.glsl +0 -2
  105. data/lib/mittsu/renderers/shaders/shader_chunk/logdepthbuf_fragment.glsl +0 -5
  106. data/lib/mittsu/renderers/shaders/shader_chunk/logdepthbuf_pars_fragment.glsl +0 -12
  107. data/lib/mittsu/renderers/shaders/shader_chunk/logdepthbuf_pars_vertex.glsl +0 -11
  108. data/lib/mittsu/renderers/shaders/shader_chunk/logdepthbuf_vertex.glsl +0 -15
  109. data/lib/mittsu/renderers/shaders/shader_chunk/map_fragment.glsl +0 -9
  110. data/lib/mittsu/renderers/shaders/shader_chunk/map_pars_fragment.glsl +0 -11
  111. data/lib/mittsu/renderers/shaders/shader_chunk/map_pars_vertex.glsl +0 -6
  112. data/lib/mittsu/renderers/shaders/shader_chunk/map_particle_fragment.glsl +0 -5
  113. data/lib/mittsu/renderers/shaders/shader_chunk/map_particle_pars_fragment.glsl +0 -6
  114. data/lib/mittsu/renderers/shaders/shader_chunk/map_vertex.glsl +0 -5
  115. data/lib/mittsu/renderers/shaders/shader_chunk/morphnormal_vertex.glsl +0 -12
  116. data/lib/mittsu/renderers/shaders/shader_chunk/morphtarget_pars_vertex.glsl +0 -13
  117. data/lib/mittsu/renderers/shaders/shader_chunk/morphtarget_vertex.glsl +0 -20
  118. data/lib/mittsu/renderers/shaders/shader_chunk/normalmap_pars_fragment.glsl +0 -27
  119. data/lib/mittsu/renderers/shaders/shader_chunk/shadowmap_fragment.glsl +0 -216
  120. data/lib/mittsu/renderers/shaders/shader_chunk/shadowmap_pars_fragment.glsl +0 -19
  121. data/lib/mittsu/renderers/shaders/shader_chunk/shadowmap_pars_vertex.glsl +0 -6
  122. data/lib/mittsu/renderers/shaders/shader_chunk/shadowmap_vertex.glsl +0 -9
  123. data/lib/mittsu/renderers/shaders/shader_chunk/skinbase_vertex.glsl +0 -8
  124. data/lib/mittsu/renderers/shaders/shader_chunk/skinning_pars_vertex.glsl +0 -47
  125. data/lib/mittsu/renderers/shaders/shader_chunk/skinning_vertex.glsl +0 -20
  126. data/lib/mittsu/renderers/shaders/shader_chunk/skinnormal_vertex.glsl +0 -20
  127. data/lib/mittsu/renderers/shaders/shader_chunk/specularmap_fragment.glsl +0 -12
  128. data/lib/mittsu/renderers/shaders/shader_chunk/specularmap_pars_fragment.glsl +0 -5
  129. data/lib/mittsu/renderers/shaders/shader_chunk/worldpos_vertex.glsl +0 -17
  130. data/lib/mittsu/renderers/shaders/shader_chunk.rb +0 -9
  131. data/lib/mittsu/renderers/shaders/shader_lib/basic/basic_fragment.rbsl +0 -37
  132. data/lib/mittsu/renderers/shaders/shader_lib/basic/basic_uniforms.rbslu +0 -3
  133. data/lib/mittsu/renderers/shaders/shader_lib/basic/basic_vertex.rbsl +0 -33
  134. data/lib/mittsu/renderers/shaders/shader_lib/cube/cube_fragment.rbsl +0 -12
  135. data/lib/mittsu/renderers/shaders/shader_lib/cube/cube_uniforms.rbslu +0 -2
  136. data/lib/mittsu/renderers/shaders/shader_lib/cube/cube_vertex.rbsl +0 -12
  137. data/lib/mittsu/renderers/shaders/shader_lib/depth_rgba/depth_rgba_fragment.rbsl +0 -26
  138. data/lib/mittsu/renderers/shaders/shader_lib/depth_rgba/depth_rgba_uniforms.rbslu +0 -0
  139. data/lib/mittsu/renderers/shaders/shader_lib/depth_rgba/depth_rgba_vertex.rbsl +0 -12
  140. data/lib/mittsu/renderers/shaders/shader_lib/lambert/lambert_fragment.rbsl +0 -56
  141. data/lib/mittsu/renderers/shaders/shader_lib/lambert/lambert_uniforms.rbslu +0 -7
  142. data/lib/mittsu/renderers/shaders/shader_lib/lambert/lambert_vertex.rbsl +0 -37
  143. data/lib/mittsu/renderers/shaders/shader_lib/particle_basic/particle_basic_fragment.rbsl +0 -27
  144. data/lib/mittsu/renderers/shaders/shader_lib/particle_basic/particle_basic_uniforms.rbslu +0 -2
  145. data/lib/mittsu/renderers/shaders/shader_lib/particle_basic/particle_basic_vertex.rbsl +0 -25
  146. data/lib/mittsu/renderers/shaders/shader_lib/phong/phong_fragment.rbsl +0 -45
  147. data/lib/mittsu/renderers/shaders/shader_lib/phong/phong_uniforms.rbslu +0 -11
  148. data/lib/mittsu/renderers/shaders/shader_lib/phong/phong_vertex.rbsl +0 -43
  149. data/lib/mittsu/renderers/shaders/shader_lib.rb +0 -43
  150. data/lib/mittsu/renderers/shaders/shader_templates/fragment.glsl.erb +0 -105
  151. data/lib/mittsu/renderers/shaders/shader_templates/vertex.glsl.erb +0 -143
  152. data/lib/mittsu/renderers/shaders/uniforms_lib.rb +0 -106
  153. data/lib/mittsu/renderers/shaders/uniforms_utils.rb +0 -31
  154. data/lib/mittsu/renderers.rb +0 -1
@@ -1,12 +0,0 @@
1
- module Mittsu
2
- class Sprite
3
- def project(renderer)
4
- @renderer = renderer
5
- return unless visible
6
- init
7
- # TODO!!! FIXME!!!
8
- @renderer.instance_variable_get(:@sprites) << self
9
- project_children
10
- end
11
- end
12
- end
@@ -1,13 +0,0 @@
1
- module Mittsu
2
- class OpenGLBuffer < Struct.new(:buffer, :object, :material, :z)
3
- attr_accessor :render, :transparent, :opaque
4
-
5
- def name
6
- "BUFFER(#{object.name})"
7
- end
8
-
9
- def id
10
- object.id
11
- end
12
- end
13
- end
@@ -1,81 +0,0 @@
1
- require 'opengl'
2
-
3
- ERROR_STRINGS = {
4
- OpenGL::GL_NO_ERROR => 'NO_ERROR',
5
- OpenGL::GL_INVALID_ENUM => 'INVALID_ENUM',
6
- OpenGL::GL_INVALID_VALUE => 'INVALID_VALUE',
7
- OpenGL::GL_INVALID_OPERATION => 'INVALID_OPERATION',
8
- OpenGL::GL_STACK_OVERFLOW => 'STACK_OVERFLOW',
9
- OpenGL::GL_STACK_UNDERFLOW => 'STACK_UNDERFLOW',
10
- OpenGL::GL_OUT_OF_MEMORY => 'OUT_OF_MEMORY',
11
- # OpenGL::GL_TABLE_TOO_LARGE => 'TABLE_TOO_LARGE'
12
- }
13
-
14
- module OpenGLDebug
15
- class DebugShader
16
- def initialize(handle)
17
- @handle = handle
18
- @uniforms = {}
19
- end
20
-
21
- def set_uniform(handle, name)
22
- @uniforms[handle] = name
23
- end
24
-
25
- def get_uniform_name(handle)
26
- @uniforms[handle]
27
- end
28
- end
29
-
30
- module OpenGLProxy
31
- extend OpenGL
32
- end
33
-
34
- def self.load_lib(*args)
35
- OpenGL.load_lib(*args)
36
- end
37
-
38
- OpenGL.constants.each do |c|
39
- const_set c, OpenGL.const_get(c)
40
- end
41
-
42
- def call_debug_method m, called_from = caller[0], *args
43
- if m.to_s.start_with?('glUniform')
44
- uniform_name = @@current_shader.get_uniform_name(args.first)
45
- call = "#{m}('#{uniform_name}',#{args[1..-1].map { |s| s.to_s[0..20] }.join(', ')})"
46
- else
47
- call = "#{m}(#{args.map { |s| s.to_s[0..20] }.join(', ')})"
48
- end
49
- print call
50
- r = OpenGLProxy.send(m, *args)
51
- ret = r.nil? ? '' : " => #{r}"
52
- puts "#{ret} (#{called_from})"
53
- e = OpenGLProxy.glGetError
54
- raise "ERROR: #{m} => #{ERROR_STRINGS[e]}" unless e == OpenGL::GL_NO_ERROR
55
- r
56
- end
57
-
58
- OpenGL.instance_methods.each do |m|
59
- define_method m do |*args|
60
- self.call_debug_method(m, caller[0], *args)
61
- end
62
- end
63
-
64
- def glCreateProgram
65
- call_debug_method(:glCreateProgram, caller[0]).tap do |handle|
66
- @@shaders ||= {}
67
- @@shaders[handle] = DebugShader.new(handle)
68
- end
69
- end
70
-
71
- def glUseProgram(handle)
72
- @@current_shader = @@shaders[handle]
73
- call_debug_method(:glUseProgram, caller[0], handle)
74
- end
75
-
76
- def glGetUniformLocation(program, name)
77
- call_debug_method(:glGetUniformLocation, caller[0], program, name).tap do |handle|
78
- @@shaders[program].set_uniform(handle, name)
79
- end
80
- end
81
- end
@@ -1,50 +0,0 @@
1
- module Mittsu
2
- class OpenGLDefaultTarget
3
- attr_accessor :viewport_width, :viewport_height, :viewport_x, :viewport_y
4
- alias :width :viewport_width
5
- alias :height :viewport_height
6
-
7
- def initialize renderer
8
- @renderer = renderer
9
- @viewport_width = 0
10
- @viewport_height = 0
11
- @viewport_x = 0
12
- @viewport_y = 0
13
- end
14
-
15
- def framebuffer
16
- 0
17
- end
18
-
19
- def update_mipmap
20
- # NOOP
21
- end
22
-
23
- def setup_buffers
24
- # NOOP
25
- end
26
-
27
- def use
28
- glBindFramebuffer(GL_FRAMEBUFFER, 0)
29
- use_viewport
30
- end
31
-
32
- def use_viewport
33
- glViewport(@viewport_x, @viewport_y, @viewport_width, @viewport_height)
34
- end
35
-
36
- def set_and_use_viewport(x, y, width, height)
37
- set_viewport(x, y, width, height)
38
- use_viewport
39
- end
40
-
41
- def set_viewport(x, y, width, height)
42
- @viewport_x, @viewport_y = x, y
43
- set_viewport_size(width, height)
44
- end
45
-
46
- def set_viewport_size(width, height)
47
- @viewport_width, @viewport_height = width, height
48
- end
49
- end
50
- end