Class: Roglew::Gdi32::PIXELFORMATDESCRIPTOR

Inherits:
FFI::Struct
  • Object
show all
Defined in:
lib/roglew/platform/windows/gdi32.rb

Constant Summary collapse

FLAGS_INV =
PFDFlags.to_hash.reduce(Hash.new{ |h,k| h[k] = [] }){ |h,(k,v)| h[v] << k; h }.freeze

Instance Method Summary collapse

Methods inherited from FFI::Struct

layout, layout_base

Constructor Details

#initializePIXELFORMATDESCRIPTOR

undef_method :nSize=



150
151
152
153
# File 'lib/roglew/platform/windows/gdi32.rb', line 150

def initialize
	super
	self[:nSize] = self.size
end

Instance Method Details

#dwFlagsObject



155
156
157
158
# File 'lib/roglew/platform/windows/gdi32.rb', line 155

def dwFlags
	val = self[:dwFlags]
	Set.new(FLAGS_INV.select { |k,_| val & k != 0 }.reduce([]) {|a,(_,v)| a << v}.flatten)
end

#dwFlags=(flags) ⇒ Object



160
161
162
# File 'lib/roglew/platform/windows/gdi32.rb', line 160

def dwFlags=(flags)
	self[:dwFlags] = [*flags].reduce(0) {|a,f| a | PFDFlags[f].to_i}
end

#to_sObject



164
165
166
# File 'lib/roglew/platform/windows/gdi32.rb', line 164

def to_s
	[:iPixelType, :cColorBits, :cAccumBits, :cDepthBits, :iLayerType, :dwFlags].map{|n| "#{n} = #{send(n).inspect}"}.join(', ')
end