Class: OpenGL::TestCase

Inherits:
MiniTest::Unit::TestCase
  • Object
show all
Defined in:
lib/opengl/test_case.rb

Constant Summary collapse

WINDOW_SIZE =
512

Instance Method Summary collapse

Instance Method Details

#assert_each_in_delta(expected, actual, epsilon = 0.01) ⇒ Object



72
73
74
75
76
77
78
# File 'lib/opengl/test_case.rb', line 72

def assert_each_in_delta expected, actual, epsilon = 0.01
  assert_equal expected.length, actual.length, 'array lengths do not match'

  expected.flatten.zip(actual.flatten).each_with_index do |(e, a), i|
    assert_in_delta e, a, epsilon, "element #{i}"
  end
end

#setupObject



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/opengl/test_case.rb', line 44

def setup
  glutInitWindowPosition 1, 1
  glutInitWindowSize WINDOW_SIZE, WINDOW_SIZE
  @window = glutCreateWindow "test"

  glPushAttrib GL_ALL_ATTRIB_BITS
  glPushClientAttrib GL_CLIENT_ALL_ATTRIB_BITS
  glMatrixMode GL_MODELVIEW
  glLoadIdentity
  glMatrixMode GL_PROJECTION
  glLoadIdentity

  glClearColor 0, 0, 0, 0
  glClear GL_COLOR_BUFFER_BIT
end

#supported?(funcs) ⇒ Boolean

Returns:

  • (Boolean)


80
81
82
83
84
# File 'lib/opengl/test_case.rb', line 80

def supported? funcs
  Array(funcs).each do |name| # convert to array if it isn't already
    skip "#{name} is not supported" unless Gl.is_available? name
  end
end

#teardownObject



60
61
62
63
64
65
66
67
68
69
70
# File 'lib/opengl/test_case.rb', line 60

def teardown
  glPopAttrib
  glPopClientAttrib
  glRenderMode GL_RENDER

  # in case there is an GL error that escaped error checking routines ...
  error = glGetError
  assert_equal 0, error, gluErrorString(error)

  glutDestroyWindow @window
end