module Roglew

Constants

LOGGER
PLATFORM
VERSION
VERSION_CODENAME

Public Class Methods

BaseContext(obj_type) click to toggle source
# File lib/roglew/contexts/base.rb, line 65
def self.BaseContext(obj_type)
  BaseContext.new(obj_type)
end
Contextual(context_class) click to toggle source
# File lib/roglew/contextual.rb, line 54
def self.Contextual(context_class)
  Contextual.new(context_class)
end

Public Instance Methods

extension_list_platform() click to toggle source
# File lib/roglew/platform/linux/render_handle.rb, line 54
def extension_list_platform
  (respond_to?(:glXQueryExtensionsString) ? glXQueryExtensionsString(@display, @screen) : '').split.map!(&:to_sym)
end
get_proc_address(name) click to toggle source
# File lib/roglew/platform/linux/render_handle.rb, line 58
def get_proc_address(name)
  func = begin
    GLX.attach_function :glXGetProcAddress, [:string], :pointer
  rescue FFI::NotFoundError
    GLX.attach_function :glXGetProcAddressARB, [:string], :pointer
  end
  define_singleton_method(:get_proc_address, ->(n) { func.(n) })
  send(:get_proc_address, name)
end
initialize_pixel_format() click to toggle source
# File lib/roglew/platform/windows/render_handle.rb, line 50
def initialize_pixel_format
  pfd = Gdi32::PIXELFORMATDESCRIPTOR.new
  pfd.dwFlags = [:DOUBLEBUFFER, :SUPPORT_OPENGL, :DRAW_TO_WINDOW]
  pfd.cColorBits = 24
  pfd.cAlphaBits = 8
  pfd.cDepthBits = 32

  pxfmt = Gdi32.ChoosePixelFormat(@hdc, pfd)
  raise InvalidPixelFormatError, "(ChoosePixelFormat) GetLastError returned #{Kernel32.GetLastError}" if pxfmt == 0

  #NOTE: Don't use DescribePixelFormat.

  return if Gdi32.SetPixelFormat(@hdc, pxfmt, pfd)

  raise InvalidPixelFormatError, "(SetPixelFormat) GetLastError returned #{Kernel32.GetLastError}"
end
make_current() click to toggle source
# File lib/roglew/platform/linux/render_handle.rb, line 68
def make_current
  GLX.MakeCurrent(@display, @window, @context)
end
remove_current() click to toggle source
# File lib/roglew/platform/linux/render_handle.rb, line 72
def remove_current
  GLX.MakeCurrent(@display, 0, nil)
end
swap_buffers() click to toggle source
# File lib/roglew/platform/linux/render_handle.rb, line 76
def swap_buffers
  #TODO
  raise NotImplementedError
end
upgrade_context() click to toggle source
# File lib/roglew/platform/linux/render_handle.rb, line 81
def upgrade_context
  load_extension :GLX_ARB_create_context

  raise 'undefined function wglCreateContextAttribsARB' unless respond_to?(:glXCreateContextAttribsARB)

  attribs = [GLX::CONTEXT_MAJOR_VERSION_ARB, @version[0],
             GLX::CONTEXT_MINOR_VERSION_ARB, @version[1],
             GLX::CONTEXT_FLAGS_ARB,         GLX::CONTEXT_FORWARD_COMPATIBLE_BIT_ARB,
             0]
  ptr_attribs = FFI::MemoryPointer.new(:int, attribs.length)
  ptr_attribs.write_array_of_int(attribs)
  glXCreateContextAttribsARB(@context, nil, ptr_attribs)
end