### Home Classes Methods

### In Files

- lib/rubygame/gl.rb

### Methods

- ::get_attrib
- ::set_attrib
- ::swap_buffers

### Files

- CREDITS
- LICENSE
- NEWS
- README
- ROADMAP
- custom_sdl_load_paths.rdoc
- getting_started.rdoc
- keyboard_symbols.rdoc
- macosx_install.rdoc
- managing_framerate.rdoc
- surface_palettes.rdoc
- windows_install.rdoc

### Class/Module Index

Quicksearch

- Rubygame
- Rubygame::ActiveEvent
- Rubygame::Clock
- Rubygame::Color
- Rubygame::Color::ColorBase
- Rubygame::Color::ColorHSL
- Rubygame::Color::ColorHSV
- Rubygame::Color::ColorRGB
- Rubygame::Color::Palette
- Rubygame::Event
- Rubygame::EventActions
- Rubygame::EventActions::BlockAction
- Rubygame::EventActions::MethodAction
- Rubygame::EventActions::MultiAction
- Rubygame::EventHandler
- Rubygame::EventHandler::HasEventHandler
- Rubygame::EventHook
- Rubygame::EventQueue
- Rubygame::EventTriggers
- Rubygame::EventTriggers::AndTrigger
- Rubygame::EventTriggers::AttrTrigger
- Rubygame::EventTriggers::BlockTrigger
- Rubygame::EventTriggers::InstanceOfTrigger
- Rubygame::EventTriggers::KeyPressTrigger
- Rubygame::EventTriggers::KeyReleaseTrigger
- Rubygame::EventTriggers::KindOfTrigger
- Rubygame::EventTriggers::MouseMoveTrigger
- Rubygame::EventTriggers::MousePressTrigger
- Rubygame::EventTriggers::MouseReleaseTrigger
- Rubygame::EventTriggers::OrTrigger
- Rubygame::EventTriggers::TickTrigger
- Rubygame::EventTriggers::YesTrigger
- Rubygame::Events
- Rubygame::Events::ClockTicked
- Rubygame::Events::InputFocusGained
- Rubygame::Events::InputFocusLost
- Rubygame::Events::JoystickAxisMoved
- Rubygame::Events::JoystickBallMoved
- Rubygame::Events::JoystickButtonEvent
- Rubygame::Events::JoystickButtonPressed
- Rubygame::Events::JoystickButtonReleased
- Rubygame::Events::JoystickHatMoved
- Rubygame::Events::KeyPressed
- Rubygame::Events::KeyReleased
- Rubygame::Events::KeyboardEvent
- Rubygame::Events::MouseButtonEvent
- Rubygame::Events::MouseFocusGained
- Rubygame::Events::MouseFocusLost
- Rubygame::Events::MouseMoved
- Rubygame::Events::MousePressed
- Rubygame::Events::MouseReleased
- Rubygame::Events::QuitRequested
- Rubygame::Events::WindowExposed
- Rubygame::Events::WindowMinimized
- Rubygame::Events::WindowResized
- Rubygame::Events::WindowUnminimized
- Rubygame::ExposeEvent
- Rubygame::Ftor
- Rubygame::GL
- Rubygame::Hotspot
- Rubygame::JoyAxisEvent
- Rubygame::JoyBallEvent
- Rubygame::JoyDownEvent
- Rubygame::JoyHatEvent
- Rubygame::JoyUpEvent
- Rubygame::Joystick
- Rubygame::Key
- Rubygame::KeyDownEvent
- Rubygame::KeyUpEvent
- Rubygame::MailQueue
- Rubygame::MediaBag
- Rubygame::Mixer
- Rubygame::Mixer::Music
- Rubygame::Mixer::Sample
- Rubygame::Mouse
- Rubygame::MouseDownEvent
- Rubygame::MouseMotionEvent
- Rubygame::MouseUpEvent
- Rubygame::Music
- Rubygame::NamedResource
- Rubygame::NamedResource::NamedResourceClassMethods
- Rubygame::QuitEvent
- Rubygame::Rect
- Rubygame::ResizeEvent
- Rubygame::SDLError
- Rubygame::SFont
- Rubygame::Screen
- Rubygame::Sound
- Rubygame::Sprites
- Rubygame::Sprites::DepthSortGroup
- Rubygame::Sprites::Group
- Rubygame::Sprites::LimitGroup
- Rubygame::Sprites::Sprite
- Rubygame::Sprites::UpdateGroup
- Rubygame::Surface
- Rubygame::TTF

No matching classes.

# Rubygame::GL

The GL module provides an interface to SDL's OpenGL-related functions, allowing a Rubygame application to create hardware-accelerated 3D graphics with OpenGL.

Please note that Rubygame itself does not provide an interface to OpenGL functions -- only functions which allow Rubygame to work together with OpenGL. You will need to use another library, for example ruby-opengl, to actually create graphics with OpenGL.

Users who wish to use Rubygame Surfaces as textures in OpenGL should see also the Surface#pixels method.

### Constants

ACCUM_ALPHA_SIZE
ACCUM_BLUE_SIZE
ACCUM_GREEN_SIZE
ACCUM_RED_SIZE
ALPHA_SIZE
BLUE_SIZE
BUFFER_SIZE
DEPTH_SIZE
DOUBLEBUFFER
GREEN_SIZE
RED_SIZE
STENCIL_SIZE

### Public Class Methods

get_attrib( attrib ) click to toggle source

Return the value of the the SDL/OpenGL attribute identified by `attrib`, which should be one of the constants defined in the Rubygame::GL module. See set_attrib for a list of attribute constants.

This method is useful after using set_attrib and calling Screen#set_mode, to make sure the attribute is the expected value.

    # File lib/rubygame/gl.rb, line 45
    def self.get_attrib( attrib )
      result = SDL.GL_GetAttribute(attrib)
      if( result.nil? )
        raise Rubygame::SDLError, "GL get attribute failed: #{SDL.GetError()}"
      end
    end

set_attrib( attrib, value ) click to toggle source

Set the SDL/OpenGL attribute `attrib` to `value`. This should be called before you call Screen#set_mode with the OPENGL flag. You may wish to use get_attrib after calling Screen#set_mode to confirm that the attribute is set to the desired value.

The full list of SDL/OpenGL attribute identifier constants (located under the Rubygame::GL module) is as follows:

RED_SIZE | Size of framebuffer red component, in bits.
GREEN_SIZE | Size of framebuffer green component, in bits.
BLUE_SIZE | Size of framebuffer blue component, in bits.
ALPHA_SIZE | Size of framebuffer alpha (opacity) component, in bits.
BUFFER_SIZE | Size of framebuffer, in bits.
DOUBLEBUFFER | Enable or disable double-buffering.
DEPTH_SIZE | Size of depth buffer, in bits.
STENCIL_SIZE | Size of stencil buffer, in bits.
ACCUM_RED_SIZE | Size of accumulation buffer red component, in bits.
ACCUM_GREEN_SIZE | Size of accumulation buffer green component, in bits.
ACCUM_BLUE_SIZE | Size of accumulation buffer blue component, in bits.
ACCUM_ALPHA_SIZE | Size of accumulation buffer alpha component, in bits.

    # File lib/rubygame/gl.rb, line 75
    def self.set_attrib( attrib, value )
      result = SDL.GL_SetAttribute( attrib, value )
      if( result == -1 )
        raise Rubygame::SDLError, "GL set attribute failed: #{SDL.GetError()}"
      end
    end

swap_buffers() click to toggle source

Swap the back and front buffers, for double-buffered OpenGL displays. Should be safe to use (albeit with no effect) on single-buffered OpenGL displays.

    # File lib/rubygame/gl.rb, line 88
    def self.swap_buffers
      SDL.GL_SwapBuffers()
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.