Sha256: 4afa4efb2c7112de56607c8e42977038be1ed72feafb125fc9866d3d627346ba

Contents?: true

Size: 883 Bytes

Versions: 1

Compression:

Stored size: 883 Bytes

Contents

module Mittsu
  class OpenGLDataTexture < OpenGLTexture
    def update_specific
      gl_format = GL_MITTSU_PARAMS[@texture.format]
      gl_type = GL_MITTSU_PARAMS[@texture.type]
      mipmaps = @texture.mipmaps
      image = @texture.image
      is_image_power_of_two = Math.power_of_two?(image.width) && Math.power_of_two?(image.height)

      # use manually created mipmaps if available
      # if there are no manual mipmaps
      # set 0 level mipmap and then use GL to generate other mipmap levels

      if !mipmaps.empty? && is_image_power_of_two
        mipmaps.each_with_index do |mipmap, i|
          glTexImage2D(GL_TEXTURE_2D, i, gl_format, mipmap.width, mipmap.height, 0, gl_format, gl_type, mipmap.data)
        end
      else
        glTexImage2D(GL_TEXTURE_2D, 0, gl_format, image.width, image.height, 0, gl_format, gl_type, image.data)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mittsu-0.1.2 lib/mittsu/renderers/opengl/textures/opengl_data_texture.rb