rudl_video_display_surface

Back to index

# Index

DisplaySurface < Surface
Class Methods
`DisplaySurface.new( [w,h] )`
`DisplaySurface.new( [w,h], flags )`
`DisplaySurface.new( [w,h], flags, depth )`
`DisplaySurface.destroy`
`DisplaySurface.modes`
`DisplaySurface.modes( bitdepth )`
`DisplaySurface.modes( bitdepth, flags )`
`DisplaySurface.mode_ok?`
`DisplaySurface.best_mode_info`
Instance Methods
`DisplaySurface#info`
`DisplaySurface#driver`
`DisplaySurface#update`
`DisplaySurface#update( rect )`
`DisplaySurface#flip`
`DisplaySurface#active?`
`DisplaySurface#caption`
`DisplaySurface#set_caption( title )`
`DisplaySurface#set_caption( title, icontitle )`
`DisplaySurface#iconify`
`DisplaySurface#gamma=([r,g,b])`
`DisplaySurface#gamma=(intensity)`
`DisplaySurface#toggle_fullscreen`
`DisplaySurface.gl_set_attribute( name, value )`
`DisplaySurface.gl_get_attribute( name )`

# DisplaySurface < Surface

The DisplaySurface is the surface that represents the window or the full screen that you will be drawing and blitting on. Since it is inherited from Surface, it can be used just like an ordinary surface. You will need to create a DisplaySurface to show anything on your screen.

## Class Methods

`DisplaySurface.new( [w,h] )`
`DisplaySurface.new( [w,h], flags )`
`DisplaySurface.new( [w,h], flags, depth )`

Return value: the new DisplaySurface object

- [w,h] is the requested size for the new display.
- flags is a combination of the following:
  - SWSURFACE, to create the display in normal memory,
  - HWSURFACE, to create the display in the memory of your video hardware, if possible,
  - ASYNCBLIT, to (i quote) "enable the use of asynchronous to the display surface. This will usually slow down blitting on single CPU machines, but may provide a speed increase on SMP systems."
  - RESIZABLE, to make a resizable display (see events to find the event that it sends),
  - HWPALETTE, to grab the system palette,
  - DOUBLEBUF, to enable double buffered hardware pageflipping. Use flip with this.
  - FULLSCREEN, attempts to grab all of the screen,
  - NOFRAME, in RUDL 0.3 and up, leaves the frame off the window.
  - OPENGL, to create an OpenGL window.
- depth selects the bits per pixel value (8 is 256 colors, 16 is thousands of colors, 24 and 32 are millions of colors). If it is not supplied, a good one will be selected for you.

`DisplaySurface.destroy`

Destroys the display, removing the window or returning from fullscreen mode. Do not call methods on a destroyed DisplaySurface

`DisplaySurface.modes`
`DisplaySurface.modes( bitdepth )`
`DisplaySurface.modes( bitdepth, flags )`

Lists available modes for a certain bitdepth and optionally only those modes that can do flags. Flags are like those in DisplaySurface.new. No flags is the same as passing FULLSCREEN. Returns an array with arrays of [w, h], or nil. nil means any mode is ok, an empty array means no mode is supported.

`DisplaySurface.mode_ok?`

Like DisplaySurface.new, but doesn't set the mode, only returns true if the mode can be set, and false if it can't.

`DisplaySurface.best_mode_info`

This method return a hash filled with information about the video hardware.

These entries are true or false:

- hardware surfaces available
- window manager available
- hardware to hardware blits accelerated
- hardware to hardware colorkey blits accelerated
- hardware to hardware alpha blits accelerated
- software to hardware blits accelerated
- software to hardware colorkey blits accelerated
- software to hardware alpha blits accelerated
- color fills accelerated

This is in kilobytes:

- video memory

There is currently no difference between best_mode_info and info, except that one is a class method and the other an instance method, but there may be differences in the future.

## Instance Methods

`DisplaySurface#info`

See DisplaySurface.best_mode_info

`DisplaySurface#driver`

Returns the name of the videodriver that is being used.

`DisplaySurface#update`
`DisplaySurface#update( rect )`

This call will update a section (or sections) of the display screen. You must update an area of your display when you change its contents. rect is, starting from v0.4, an array of rectangles. If passed with no arguments, this will update the entire display surface.

This call cannot be used on OPENGL displays, and will generate an exception.

`DisplaySurface#flip`

This will update the contents of the entire display. If your display mode is using the flags HWSURFACE and DOUBLEBUF, this will wait for a vertical retrace (if the video driver supports it) and swap the surfaces. If you are using a different type of display mode, it will simply update the entire contents of the surface.

`DisplaySurface#active?`

Returns true if the application is active.

`DisplaySurface#caption`
`DisplaySurface#set_caption( title )`
`DisplaySurface#set_caption( title, icontitle )`

caption= sets the title of the window (if the application runs in a window) to title. Sets the title of the icon that shows when the application is iconified to icontitle, or title if icontitle is not supplied. caption returns the title and icontitle of the window.

`DisplaySurface#iconify`

Iconifies the application. Returns true if it is succesfull.

`DisplaySurface#gamma=([r,g,b])`
`DisplaySurface#gamma=(intensity)`

Sets the gamma value for the display when this is supported. Intensity is a shortcut for values where r=g=b.

`DisplaySurface#toggle_fullscreen`

Toggles between fullscreen and windowed mode. The code is experimental, please report problems if found.

`DisplaySurface.gl_set_attribute( name, value )`

Set an attribute of the OpenGL subsystem before intialization.

Returns self.

`DisplaySurface.gl_get_attribute( name )`

From the SDL documentation:

Get an attribute of the OpenGL subsystem from the windowing interface, such as glX. This is of course different from getting the values from SDL's internal OpenGL subsystem, which only stores the values you request before initialization.

Developers should track the values they pass into SDL_GL_SetAttribute themselves if they want to retrieve these values.

Back to index