File: glfwtest.rb

package info (click to toggle)
ruby-opengl 0.60.1%2Bdfsg2-1~wheezy1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 2,048 kB
  • sloc: ansic: 24,676; ruby: 9,400; sh: 12; makefile: 10
file content (30 lines) | stat: -rw-r--r-- 690 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
require 'opengl'
require 'glfw'

#init
Glfw.glfwOpenWindow( 500,500, 0,0,0,0, 32,0, Glfw::GLFW_WINDOW )

# main loop
while true
	if( Glfw.glfwGetWindowParam( Glfw::GLFW_OPENED ) == false ||
		  Glfw.glfwGetKey(Glfw::GLFW_KEY_ESC) == Glfw::GLFW_PRESS )
		break
	end

	Gl.glClear( Gl::GL_COLOR_BUFFER_BIT | Gl::GL_DEPTH_BUFFER_BIT )

	Gl.glBegin( Gl::GL_POLYGON )
	Gl.glColor3f( 1.0, 0.0, 0.0 )
	Gl.glVertex2f( -0.5, -0.5 )
	Gl.glColor3f( 0.0, 1.0, 0.0 )
	Gl.glVertex2f( -0.5,  0.5 )
	Gl.glColor3f( 0.0, 0.0, 1.0 )
	Gl.glVertex2f(  0.5,  0.5 )
	Gl.glColor3f( 1.0, 0.0, 1.0 )
	Gl.glVertex2f(  0.5, -0.5 )
	Gl.glEnd

  Glfw.glfwSwapBuffers()

	sleep 0.01 # to avoid consuming all CPU power
end