Class: Frusdl::SDL::Screen
- Inherits:
-
Object
- Object
- Frusdl::SDL::Screen
- Extended by:
- Low::SDL
- Defined in:
- lib/frusdl/sdl/screen.rb
Constant Summary
Constants included from Low::SDL
Low::SDL::AUDIO_S16, Low::SDL::AUDIO_S16LSB, Low::SDL::AUDIO_S16MSB, Low::SDL::AUDIO_S16SYS, Low::SDL::AUDIO_S8, Low::SDL::AUDIO_U16, Low::SDL::AUDIO_U16LSB, Low::SDL::AUDIO_U16MSB, Low::SDL::AUDIO_U16SYS, Low::SDL::AUDIO_U8, Low::SDL::KMOD_ALT, Low::SDL::KMOD_CAPS, Low::SDL::KMOD_CTRL, Low::SDL::KMOD_LALT, Low::SDL::KMOD_LCTRL, Low::SDL::KMOD_LMETA, Low::SDL::KMOD_LSHIFT, Low::SDL::KMOD_META, Low::SDL::KMOD_MODE, Low::SDL::KMOD_NONE, Low::SDL::KMOD_NUM, Low::SDL::KMOD_RALT, Low::SDL::KMOD_RCTRL, Low::SDL::KMOD_RESERVED, Low::SDL::KMOD_RMETA, Low::SDL::KMOD_RSHIFT, Low::SDL::KMOD_SHIFT, Low::SDL::RW_SEEK_CUR, Low::SDL::RW_SEEK_END, Low::SDL::RW_SEEK_SET, Low::SDL::SDLK_0, Low::SDL::SDLK_1, Low::SDL::SDLK_2, Low::SDL::SDLK_3, Low::SDL::SDLK_4, Low::SDL::SDLK_5, Low::SDL::SDLK_6, Low::SDL::SDLK_7, Low::SDL::SDLK_8, Low::SDL::SDLK_9, Low::SDL::SDLK_AMPERSAND, Low::SDL::SDLK_ASTERISK, Low::SDL::SDLK_AT, Low::SDL::SDLK_BACKQUOTE, Low::SDL::SDLK_BACKSLASH, Low::SDL::SDLK_BACKSPACE, Low::SDL::SDLK_BREAK, Low::SDL::SDLK_CAPSLOCK, Low::SDL::SDLK_CARET, Low::SDL::SDLK_CLEAR, Low::SDL::SDLK_COLON, Low::SDL::SDLK_COMMA, Low::SDL::SDLK_COMPOSE, Low::SDL::SDLK_DELETE, Low::SDL::SDLK_DOLLAR, Low::SDL::SDLK_DOWN, Low::SDL::SDLK_END, Low::SDL::SDLK_EQUALS, Low::SDL::SDLK_ESCAPE, Low::SDL::SDLK_EURO, Low::SDL::SDLK_EXCLAIM, Low::SDL::SDLK_F1, Low::SDL::SDLK_F10, Low::SDL::SDLK_F11, Low::SDL::SDLK_F12, Low::SDL::SDLK_F13, Low::SDL::SDLK_F14, Low::SDL::SDLK_F15, Low::SDL::SDLK_F2, Low::SDL::SDLK_F3, Low::SDL::SDLK_F4, Low::SDL::SDLK_F5, Low::SDL::SDLK_F6, Low::SDL::SDLK_F7, Low::SDL::SDLK_F8, Low::SDL::SDLK_F9, Low::SDL::SDLK_FIRST, Low::SDL::SDLK_GREATER, Low::SDL::SDLK_HASH, Low::SDL::SDLK_HELP, Low::SDL::SDLK_HOME, Low::SDL::SDLK_INSERT, Low::SDL::SDLK_KP0, Low::SDL::SDLK_KP1, Low::SDL::SDLK_KP2, Low::SDL::SDLK_KP3, Low::SDL::SDLK_KP4, Low::SDL::SDLK_KP5, Low::SDL::SDLK_KP6, Low::SDL::SDLK_KP7, Low::SDL::SDLK_KP8, Low::SDL::SDLK_KP9, Low::SDL::SDLK_KP_DIVIDE, Low::SDL::SDLK_KP_ENTER, Low::SDL::SDLK_KP_EQUALS, Low::SDL::SDLK_KP_MINUS, Low::SDL::SDLK_KP_MULTIPLY, Low::SDL::SDLK_KP_PERIOD, Low::SDL::SDLK_KP_PLUS, Low::SDL::SDLK_LALT, Low::SDL::SDLK_LAST, Low::SDL::SDLK_LCTRL, Low::SDL::SDLK_LEFT, Low::SDL::SDLK_LEFTBRACKET, Low::SDL::SDLK_LEFTPAREN, Low::SDL::SDLK_LESS, Low::SDL::SDLK_LMETA, Low::SDL::SDLK_LSHIFT, Low::SDL::SDLK_LSUPER, Low::SDL::SDLK_MENU, Low::SDL::SDLK_MINUS, Low::SDL::SDLK_MODE, Low::SDL::SDLK_NUMLOCK, Low::SDL::SDLK_PAGEDOWN, Low::SDL::SDLK_PAGEUP, Low::SDL::SDLK_PAUSE, Low::SDL::SDLK_PERIOD, Low::SDL::SDLK_PLUS, Low::SDL::SDLK_POWER, Low::SDL::SDLK_PRINT, Low::SDL::SDLK_QUESTION, Low::SDL::SDLK_QUOTE, Low::SDL::SDLK_QUOTEDBL, Low::SDL::SDLK_RALT, Low::SDL::SDLK_RCTRL, Low::SDL::SDLK_RETURN, Low::SDL::SDLK_RIGHT, Low::SDL::SDLK_RIGHTBRACKET, Low::SDL::SDLK_RIGHTPAREN, Low::SDL::SDLK_RMETA, Low::SDL::SDLK_RSHIFT, Low::SDL::SDLK_RSUPER, Low::SDL::SDLK_SCROLLOCK, Low::SDL::SDLK_SEMICOLON, Low::SDL::SDLK_SLASH, Low::SDL::SDLK_SPACE, Low::SDL::SDLK_SYSREQ, Low::SDL::SDLK_TAB, Low::SDL::SDLK_UNDERSCORE, Low::SDL::SDLK_UNDO, Low::SDL::SDLK_UNKNOWN, Low::SDL::SDLK_UP, Low::SDL::SDLK_WORLD_0, Low::SDL::SDLK_WORLD_1, Low::SDL::SDLK_WORLD_10, Low::SDL::SDLK_WORLD_11, Low::SDL::SDLK_WORLD_12, Low::SDL::SDLK_WORLD_13, Low::SDL::SDLK_WORLD_14, Low::SDL::SDLK_WORLD_15, Low::SDL::SDLK_WORLD_16, Low::SDL::SDLK_WORLD_17, Low::SDL::SDLK_WORLD_18, Low::SDL::SDLK_WORLD_19, Low::SDL::SDLK_WORLD_2, Low::SDL::SDLK_WORLD_20, Low::SDL::SDLK_WORLD_21, Low::SDL::SDLK_WORLD_22, Low::SDL::SDLK_WORLD_23, Low::SDL::SDLK_WORLD_24, Low::SDL::SDLK_WORLD_25, Low::SDL::SDLK_WORLD_26, Low::SDL::SDLK_WORLD_27, Low::SDL::SDLK_WORLD_28, Low::SDL::SDLK_WORLD_29, Low::SDL::SDLK_WORLD_3, Low::SDL::SDLK_WORLD_30, Low::SDL::SDLK_WORLD_31, Low::SDL::SDLK_WORLD_32, Low::SDL::SDLK_WORLD_33, Low::SDL::SDLK_WORLD_34, Low::SDL::SDLK_WORLD_35, Low::SDL::SDLK_WORLD_36, Low::SDL::SDLK_WORLD_37, Low::SDL::SDLK_WORLD_38, Low::SDL::SDLK_WORLD_39, Low::SDL::SDLK_WORLD_4, Low::SDL::SDLK_WORLD_40, Low::SDL::SDLK_WORLD_41, Low::SDL::SDLK_WORLD_42, Low::SDL::SDLK_WORLD_43, Low::SDL::SDLK_WORLD_44, Low::SDL::SDLK_WORLD_45, Low::SDL::SDLK_WORLD_46, Low::SDL::SDLK_WORLD_47, Low::SDL::SDLK_WORLD_48, Low::SDL::SDLK_WORLD_49, Low::SDL::SDLK_WORLD_5, Low::SDL::SDLK_WORLD_50, Low::SDL::SDLK_WORLD_51, Low::SDL::SDLK_WORLD_52, Low::SDL::SDLK_WORLD_53, Low::SDL::SDLK_WORLD_54, Low::SDL::SDLK_WORLD_55, Low::SDL::SDLK_WORLD_56, Low::SDL::SDLK_WORLD_57, Low::SDL::SDLK_WORLD_58, Low::SDL::SDLK_WORLD_59, Low::SDL::SDLK_WORLD_6, Low::SDL::SDLK_WORLD_60, Low::SDL::SDLK_WORLD_61, Low::SDL::SDLK_WORLD_62, Low::SDL::SDLK_WORLD_63, Low::SDL::SDLK_WORLD_64, Low::SDL::SDLK_WORLD_65, Low::SDL::SDLK_WORLD_66, Low::SDL::SDLK_WORLD_67, Low::SDL::SDLK_WORLD_68, Low::SDL::SDLK_WORLD_69, Low::SDL::SDLK_WORLD_7, Low::SDL::SDLK_WORLD_70, Low::SDL::SDLK_WORLD_71, Low::SDL::SDLK_WORLD_72, Low::SDL::SDLK_WORLD_73, Low::SDL::SDLK_WORLD_74, Low::SDL::SDLK_WORLD_75, Low::SDL::SDLK_WORLD_76, Low::SDL::SDLK_WORLD_77, Low::SDL::SDLK_WORLD_78, Low::SDL::SDLK_WORLD_79, Low::SDL::SDLK_WORLD_8, Low::SDL::SDLK_WORLD_80, Low::SDL::SDLK_WORLD_81, Low::SDL::SDLK_WORLD_82, Low::SDL::SDLK_WORLD_83, Low::SDL::SDLK_WORLD_84, Low::SDL::SDLK_WORLD_85, Low::SDL::SDLK_WORLD_86, Low::SDL::SDLK_WORLD_87, Low::SDL::SDLK_WORLD_88, Low::SDL::SDLK_WORLD_89, Low::SDL::SDLK_WORLD_9, Low::SDL::SDLK_WORLD_90, Low::SDL::SDLK_WORLD_91, Low::SDL::SDLK_WORLD_92, Low::SDL::SDLK_WORLD_93, Low::SDL::SDLK_WORLD_94, Low::SDL::SDLK_WORLD_95, Low::SDL::SDLK_a, Low::SDL::SDLK_b, Low::SDL::SDLK_c, Low::SDL::SDLK_d, Low::SDL::SDLK_e, Low::SDL::SDLK_f, Low::SDL::SDLK_g, Low::SDL::SDLK_h, Low::SDL::SDLK_i, Low::SDL::SDLK_j, Low::SDL::SDLK_k, Low::SDL::SDLK_l, Low::SDL::SDLK_m, Low::SDL::SDLK_n, Low::SDL::SDLK_o, Low::SDL::SDLK_p, Low::SDL::SDLK_q, Low::SDL::SDLK_r, Low::SDL::SDLK_s, Low::SDL::SDLK_t, Low::SDL::SDLK_u, Low::SDL::SDLK_v, Low::SDL::SDLK_w, Low::SDL::SDLK_x, Low::SDL::SDLK_y, Low::SDL::SDLK_z, Low::SDL::SDL_ACTIVEEVENT, Low::SDL::SDL_ADDEVENT, Low::SDL::SDL_ANYFORMAT, Low::SDL::SDL_ASYNCBLIT, Low::SDL::SDL_AUDIO_PAUSED, Low::SDL::SDL_AUDIO_PLAYING, Low::SDL::SDL_AUDIO_STOPPED, Low::SDL::SDL_BUTTON_LEFT, Low::SDL::SDL_BUTTON_MIDDLE, Low::SDL::SDL_BUTTON_RIGHT, Low::SDL::SDL_BUTTON_WHEELDOWN, Low::SDL::SDL_BUTTON_WHEELUP, Low::SDL::SDL_BYTEORDER, Low::SDL::SDL_DEFAULT_REPEAT_DELAY, Low::SDL::SDL_DEFAULT_REPEAT_INTERVAL, Low::SDL::SDL_DISABLE, Low::SDL::SDL_DOUBLEBUF, Low::SDL::SDL_ENABLE, Low::SDL::SDL_EVENT_RESERVED2, Low::SDL::SDL_EVENT_RESERVED3, Low::SDL::SDL_EVENT_RESERVED4, Low::SDL::SDL_EVENT_RESERVED5, Low::SDL::SDL_EVENT_RESERVED6, Low::SDL::SDL_EVENT_RESERVED7, Low::SDL::SDL_EVENT_RESERVEDA, Low::SDL::SDL_EVENT_RESERVEDB, Low::SDL::SDL_FULLSCREEN, Low::SDL::SDL_GETEVENT, Low::SDL::SDL_GRAB_FULLSCREEN, Low::SDL::SDL_GRAB_OFF, Low::SDL::SDL_GRAB_ON, Low::SDL::SDL_GRAB_QUERY, Low::SDL::SDL_HAT_CENTERED, Low::SDL::SDL_HAT_DOWN, Low::SDL::SDL_HAT_LEFT, Low::SDL::SDL_HAT_LEFTDOWN, Low::SDL::SDL_HAT_LEFTUP, Low::SDL::SDL_HAT_RIGHT, Low::SDL::SDL_HAT_RIGHTDOWN, Low::SDL::SDL_HAT_RIGHTUP, Low::SDL::SDL_HAT_UP, Low::SDL::SDL_HWPALETTE, Low::SDL::SDL_HWSURFACE, Low::SDL::SDL_IGNORE, Low::SDL::SDL_INIT_AUDIO, Low::SDL::SDL_INIT_CDROM, Low::SDL::SDL_INIT_EVENTTHREAD, Low::SDL::SDL_INIT_EVERYTHING, Low::SDL::SDL_INIT_JOYSTICK, Low::SDL::SDL_INIT_NOPARACHUTE, Low::SDL::SDL_INIT_TIMER, Low::SDL::SDL_INIT_VIDEO, Low::SDL::SDL_JOYAXISMOTION, Low::SDL::SDL_JOYBALLMOTION, Low::SDL::SDL_JOYBUTTONDOWN, Low::SDL::SDL_JOYBUTTONUP, Low::SDL::SDL_JOYHATMOTION, Low::SDL::SDL_KEYDOWN, Low::SDL::SDL_KEYUP, Low::SDL::SDL_LIL_ENDIAN, Low::SDL::SDL_MIX_MAXVOLUME, Low::SDL::SDL_MOUSEBUTTONDOWN, Low::SDL::SDL_MOUSEBUTTONUP, Low::SDL::SDL_MOUSEMOTION, Low::SDL::SDL_NOEVENT, Low::SDL::SDL_NOFRAME, Low::SDL::SDL_NUMEVENTS, Low::SDL::SDL_OPENGL, Low::SDL::SDL_OPENGLBLIT, Low::SDL::SDL_PEEKEVENT, Low::SDL::SDL_PRESSED, Low::SDL::SDL_QUERY, Low::SDL::SDL_QUIT, Low::SDL::SDL_RELEASED, Low::SDL::SDL_RESIZABLE, Low::SDL::SDL_SWSURFACE, Low::SDL::SDL_SYSWMEVENT, Low::SDL::SDL_TIMESLICE, Low::SDL::SDL_USEREVENT, Low::SDL::SDL_VIDEOEXPOSE, Low::SDL::SDL_VIDEORESIZE, Low::SDL::TIMER_RESOLUTION
Instance Attribute Summary collapse
-
#pointer ⇒ Object
readonly
Returns the value of attribute pointer.
Class Method Summary collapse
-
.check_mode(width, height, depth, flags) ⇒ Object
Check to see if a particular video mode is supported.
-
.driver_name ⇒ Object
Obtain the name of the video driver.
-
.get ⇒ Object
Returns the current display surface.
-
.get_gamma_ramp ⇒ Object
Gets the color gamma lookup tables for the display XXX: doesn’t work.
-
.info ⇒ Object
Returns information about the video hardware.
-
.list_modes(format, flags) ⇒ Object
Returns an array of available screen dimensions for the given format and video flags.
-
.open(width, height, bbp, flags) ⇒ Object
Set up a video mode with the specified width, height and bits-per-pixel.
-
.set_gamma(rgamma, ggamma, bgammma) ⇒ Object
Sets the color gamma function for the display.
-
.set_gamma_ramp(rgammas, ggammas, bgammas) ⇒ Object
Sets the color gamma lookup tables for the display XXX: doesn’t work like this.
-
.wrap(ptr) ⇒ Object
Wraps a low level ponter in a higher level struct.
Instance Method Summary collapse
-
#flip ⇒ Object
Swaps screen buffers.
-
#initialize(ptr) ⇒ Screen
constructor
A new instance of Screen.
-
#update_rect(x, y, w, h) ⇒ Object
Makes sure the given area is updated on the given screen.
-
#update_rects(*rects) ⇒ Object
Makes sure the given list of rectangles is updated on the given screen.
Methods included from Low::SDL
SDL_BlitSurface, SDL_LoadBMP, SDL_LoadWAV, SDL_RWclose, SDL_RWread, SDL_RWseek, SDL_RWtell, SDL_RWwrite, SDL_SaveBMP
Methods included from Wrap
Constructor Details
#initialize(ptr) ⇒ Screen
Returns a new instance of Screen.
14 15 16 |
# File 'lib/frusdl/sdl/screen.rb', line 14 def initialize(ptr) initialize_pointer(ptr, Frusdl::Low::SDL::SDL_Surface) end |
Instance Attribute Details
#pointer ⇒ Object (readonly)
Returns the value of attribute pointer.
12 13 14 |
# File 'lib/frusdl/sdl/screen.rb', line 12 def pointer @pointer end |
Class Method Details
.check_mode(width, height, depth, flags) ⇒ Object
Check to see if a particular video mode is supported. Returns supported bbp, or 0 if unsupported
52 53 54 |
# File 'lib/frusdl/sdl/screen.rb', line 52 def self.check_mode(width, height, depth, flags) return SDL_VideoModeOK(width, height, depth, flags) end |
.driver_name ⇒ Object
Obtain the name of the video driver
42 43 44 45 46 47 48 |
# File 'lib/frusdl/sdl/screen.rb', line 42 def self.driver_name size = 256 cstr = FFI::MemoryPointer.new(size) SDL_VideoDriverName(cstr, size) str = cstr.read_string return str end |
.get ⇒ Object
Returns the current display surface
24 25 26 27 |
# File 'lib/frusdl/sdl/screen.rb', line 24 def self.get ptr = SDL_GetVideoSurface() self.new(ptr) end |
.get_gamma_ramp ⇒ Object
Gets the color gamma lookup tables for the display XXX: doesn’t work
110 111 112 113 114 |
# File 'lib/frusdl/sdl/screen.rb', line 110 def self.get_gamma_ramp res = SDL_SetGammaRamp(rgammas, ggammas, bgammas) raise_error if res < 0 return rgammas, ggammas, bgammas end |
.info ⇒ Object
Returns information about the video hardware
30 31 32 33 |
# File 'lib/frusdl/sdl/screen.rb', line 30 def self.info ptr = SDL_GetVideoInfo() Frusdl::SDL::VideoInfo.new(ptr) end |
.list_modes(format, flags) ⇒ Object
Returns an array of available screen dimensions for the given format and video flags
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/frusdl/sdl/screen.rb', line 57 def self.list_modes(format, flags) formptr = format ? format.pointer : nil rectptrptr = SDL_ListModes(formptr, flags) return nil if rectptrptr.null? return true if rectptrptr.address == 4294967295 # This address means "all sizes allowed". Gotta love C! >_< aid = rectptrptr.get_int(0) return nil if aid == 0 return true if aid == -1 index = 0 result = [] ptrsize = FFI.type_size(:pointer) rectptr = rectptrptr.get_pointer(index * ptrsize) until rectptr.null? do rect = Frusdl::Low::SDL::SDL_Rect.new(rectptr) result << [ rect[:w], rect[:h] ] index += 1 rectptr = rectptrptr.get_pointer(index * ptrsize) end return result end |
.open(width, height, bbp, flags) ⇒ Object
Set up a video mode with the specified width, height and bits-per-pixel.
36 37 38 39 |
# File 'lib/frusdl/sdl/screen.rb', line 36 def self.open(width, height, bbp, flags) ptr = SDL_SetVideoMode(width, height, bbp, flags) self.new(ptr) end |
.set_gamma(rgamma, ggamma, bgammma) ⇒ Object
Sets the color gamma function for the display
103 104 105 106 |
# File 'lib/frusdl/sdl/screen.rb', line 103 def self.set_gamma(rgamma, ggamma, bgammma) res = SDL_SetGamma(rgamma, ggamma, bgamma) raise_error if res < 0 end |
.set_gamma_ramp(rgammas, ggammas, bgammas) ⇒ Object
Sets the color gamma lookup tables for the display XXX: doesn’t work like this
118 119 120 121 |
# File 'lib/frusdl/sdl/screen.rb', line 118 def self.set_gamma_ramp(rgammas, ggammas, bgammas) res = SDL_SetGammaRamp(rgammas, ggammas, bgammas) raise_error if res < 0 end |
.wrap(ptr) ⇒ Object
Wraps a low level ponter in a higher level struct
19 20 21 |
# File 'lib/frusdl/sdl/screen.rb', line 19 def self.wrap(ptr) return Frusdl::Low::SDL::SDL_Surface.new(ptr) end |
Instance Method Details
#flip ⇒ Object
Swaps screen buffers
81 82 83 |
# File 'lib/frusdl/sdl/screen.rb', line 81 def flip SDL_Flip(@pointer) end |
#update_rect(x, y, w, h) ⇒ Object
Makes sure the given area is updated on the given screen.
86 87 88 |
# File 'lib/frusdl/sdl/screen.rb', line 86 def update_rect(x, y, w, h) SDL_UpdateRect(@pointer, x, y, w, h) end |
#update_rects(*rects) ⇒ Object
Makes sure the given list of rectangles is updated on the given screen
91 92 93 94 95 96 97 98 99 100 |
# File 'lib/frusdl/sdl/screen.rb', line 91 def update_rects(*rects) count = rects.size rectptr = MemoryPointer.new(:pointer, count) index = 0 for rect in rects do rectptr.set_pointer(index, rect.pointer) index += 1 end SDL_UpdateRects(@pointer, index, rectptr) end |