Class: RenderTexture

Inherits:
Object
  • Object
show all
Defined in:
src/ruby/models/render_texture.rb,
mrb_doc/models/render_texture.rb

Overview

The RenderTexture class is used to draw things to a texture

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(width, height) ⇒ RenderTexture

Creates a new instance of RenderTexture

Parameters:

  • width (Integer)
  • height (Integer)


7
8
9
10
11
# File 'mrb_doc/models/render_texture.rb', line 7

def initialize(width, height)
  # mrb_RenderTexture_initialize
  # src/mruby_integration/models/render_texture.cpp
  RenderTexture.new
end

Instance Attribute Details

#heightInteger (readonly)

Returns:

  • (Integer)


7
8
9
# File 'src/ruby/models/render_texture.rb', line 7

def height
  @height
end

#textureTexture2D (readonly)

Returns:



4
5
6
# File 'src/ruby/models/render_texture.rb', line 4

def texture
  @texture
end

#widthInteger (readonly)

Returns:

  • (Integer)


7
8
9
# File 'src/ruby/models/render_texture.rb', line 7

def width
  @width
end

Instance Method Details

#drawing { ... } ⇒ nil

Instead of rending to the screen, render to this RenderTexture

Yields:

  • The block that calls your rendering logic

Returns:

  • (nil)


22
23
24
25
26
27
# File 'src/ruby/models/render_texture.rb', line 22

def drawing(&block)
  begin_texture_mode(self)
  block.call
ensure
  end_texture_mode
end

#to_hHash

Return the object represented by a Hash

Returns:

  • (Hash)


11
12
13
14
15
16
17
# File 'src/ruby/models/render_texture.rb', line 11

def to_h
  {
    texture: texture.to_h,
    width: width,
    height: height,
  }
end

#unloadnil

Unloads the render texture from memory

Returns:

  • (nil)


15
16
17
18
# File 'mrb_doc/models/render_texture.rb', line 15

def unload
  # src/mruby_integration/models/render_texture.cpp
  nil
end