lib/mittsu/renderers/opengl_renderer.rb in mittsu-0.1.7 vs lib/mittsu/renderers/opengl_renderer.rb in mittsu-0.2.0

- old
+ new

@@ -17,10 +17,11 @@ require 'mittsu/renderers/opengl/opengl_geometry_group' require 'mittsu/renderers/opengl/opengl_light_renderer' require 'mittsu/renderers/opengl/opengl_default_target' require 'mittsu/renderers/opengl/opengl_buffer' require 'mittsu/renderers/opengl/plugins/shadow_map_plugin' +require 'mittsu/renderers/opengl/plugins/sprite_plugin' require 'mittsu/renderers/shaders/shader_lib' require 'mittsu/renderers/shaders/uniforms_utils' include ENV['DEBUG'] ? OpenGLDebug : OpenGL include Mittsu::OpenGLHelper @@ -258,17 +259,10 @@ end @state.disable_unused_attributes object.render_buffer(camera, lights, fog, material, geometry_group, buffers_need_update) - - # TODO: render particles - # when PointCloud - # glDrawArrays(GL_POINTS, 0, geometry_group.particle_count) - # - # @info[:render][:calls] += 1 - # @info[:render][:points] += geometry_group.particle_count end def compressed_texture_formats # TODO: needs extensions.get ... @@ -486,25 +480,10 @@ end end else object.update end - # TODO: when PointCloud exists - # elsif object.is_A? PointCloud - # # TODO: glBindVertexArray ??? - # material = object.buffer_material(geometry) - # custom_attributes_dirty = material.attributes && are_custom_attributes_dirty(material) - # - # if geometry.vertices_need_update || geometry.colors_need_update || custom_attributes_dirty - # set_particle_buffers(geometry, GL_DYNAMIC_DRAW, object) - # end - # - # geometry.vertices_need_update = false - # geometry.colors_need_update = false - # - # material.attributes && clear_custom_attributes(material) - # end end # FIXME: refactor def set_program(camera, lights, fog, material, object) @_used_texture_units = 0 @@ -603,12 +582,10 @@ # TODO: when all of these things exist # when LineDashedMaterial # refresh_uniforms_line(material_uniforms, material) # refresh_uniforms_dash(material_uniforms, material) - # when PointCloudMaterial - # refresh_uniforms_particle(material_uniforms, material) # when MeshDepthMaterial # material_uniforms.m_near.value = camera.near # material_uniforms.m_far.value = camera.far # material_uniforms.opacity.value = material.opacity # when MeshNormalMaterial @@ -804,12 +781,12 @@ @proj_screen_matrix.multiply_matrices(camera.projection_matrix, camera.matrix_world_inverse) @_frustum.set_from_matrix(@proj_screen_matrix) end def sort_objects_for_render - @opaque_objects.sort { |a,b| OpenGLHelper.painter_sort_stable(a,b) } - @transparent_objects.sort { |a,b| OpenGLHelper.reverse_painter_sort_stable(a,b) } + @opaque_objects.sort! { |a,b| OpenGLHelper.painter_sort_stable(a,b) } + @transparent_objects.sort! { |a,b| OpenGLHelper.reverse_painter_sort_stable(a,b) } end def set_matrices_for_immediate_objects(camera) @_opengl_objects_immediate.each do |opengl_object| object = opengl_object.object @@ -861,12 +838,13 @@ def render_custom_plugins_pre_pass(scene, camera) @shadow_map_plugin.render(scene, camera) end def render_custom_plugins_post_pass(scene, camera) + @sprite_plugin.render(scene, camera) + # TODO: when these custom plugins are implemented - # @sprite_plugin.render(scene, camera) # lens_flare_plugin.render(scene, camera, @_current_render_target.width, @_current_render_target.height) end def update_skeleton_objects(scene) # TODO: when SkinnedMesh is defined @@ -910,10 +888,11 @@ @max_morph_normals = 4 end def init_collections @lights = [] + @sprites = [] @_opengl_objects = {} @_opengl_objects_immediate = [] @opaque_objects = [] @@ -982,11 +961,12 @@ end def init_plugins @shadow_map_plugin = ShadowMapPlugin.new(self, @lights, @_opengl_objects, @_opengl_objects_immediate) + @sprite_plugin = SpritePlugin.new(self, @sprites) + # TODO: when these custom plugins are implemented - # @sprite_plugin = SpritePlugin.new(self, @sprites) # @lens_flare_plugin = LensFlarePlugin.new(self, @lens_flares) end def create_window # attributes = {