Class: Mittsu::OpenGLDataTexture
- Inherits:
-
OpenGLTexture
- Object
- OpenGLTexture
- Mittsu::OpenGLDataTexture
- Defined in:
- lib/mittsu/renderers/opengl/textures/opengl_data_texture.rb
Instance Attribute Summary
Attributes inherited from OpenGLTexture
Instance Method Summary collapse
Methods inherited from OpenGLTexture
Constructor Details
This class inherits a constructor from Mittsu::OpenGLTexture
Instance Method Details
#update_specific ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/mittsu/renderers/opengl/textures/opengl_data_texture.rb', line 3 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 |