Class: Tea::Screen

Inherits:
Object
  • Object
show all
Extended by:
Blitting, Clipping, Grabbing, ImageSaving, Primitive
Defined in:
lib/tea/o_screen.rb

Overview

A Bitmap-like object that displays its contents on the screen when drawn to and updated.

Constant Summary collapse

BITS_PER_PIXEL =

Video buffer depth.

32

Constants included from Primitive

Primitive::BLEND_MIXER, Primitive::REPLACE_MIXER

Class Method Summary collapse

Methods included from Blitting

blit

Methods included from Clipping

clip

Methods included from Grabbing

grab, grabbing_clip

Methods included from ImageSaving

save

Methods included from Primitive

[], []=, circle, clear, line, rect

Class Method Details

.blitting_bufferObject



60
61
62
# File 'lib/tea/o_screen.rb', line 60

def Screen.blitting_buffer
  @screen
end

.clipping_bufferObject



65
66
67
# File 'lib/tea/o_screen.rb', line 65

def Screen.clipping_buffer
  @screen
end

.grabbing_bufferObject



70
71
72
# File 'lib/tea/o_screen.rb', line 70

def Screen.grabbing_buffer
  @screen
end

.hObject

Get the screen height in pixels.



50
51
52
# File 'lib/tea/o_screen.rb', line 50

def Screen.h
  @screen.h
end

.image_saving_bufferObject



75
76
77
# File 'lib/tea/o_screen.rb', line 75

def Screen.image_saving_buffer
  @screen
end

.mode_set?Boolean

Check if Screen.set_mode has been called yet.

Returns:

  • (Boolean)


33
34
35
# File 'lib/tea/o_screen.rb', line 33

def Screen.mode_set?
  @screen ? true : false
end

.primitive_bufferObject



80
81
82
# File 'lib/tea/o_screen.rb', line 80

def Screen.primitive_buffer
  @screen
end

.register_bitmap_for_optimizing(bitmap) ⇒ Object

Register a Bitmap object to be optimised to the Screen’s format when a screen mode is set.



39
40
41
# File 'lib/tea/o_screen.rb', line 39

def Screen.register_bitmap_for_optimizing(bitmap)
  @bitmaps_to_optimize << WeakRef.new(bitmap)
end

.set_mode(width, height) ⇒ Object

Set or change the screen video mode, giving a width * height screen buffer.



25
26
27
28
29
30
# File 'lib/tea/o_screen.rb', line 25

def Screen.set_mode(width, height)
  @screen = SDL::Screen.open(width, height, BITS_PER_PIXEL, SDL::SWSURFACE)
  optimize_bitmaps
rescue SDL::Error => e
  raise Tea::Error, e.message, e.backtrace
end

.updateObject

Update the screen so that things drawn on it are displayed.



55
56
57
# File 'lib/tea/o_screen.rb', line 55

def Screen.update
  @screen.flip
end

.wObject

Get the screen width in pixels.



45
46
47
# File 'lib/tea/o_screen.rb', line 45

def Screen.w
  @screen.w
end