サンプル移植中 その2

私が使っているテンプレート

require 'opengl'
include Gl,Glu,Glut
#初期設定なんか
def init()
end

#画面を作る場所
display = proc do
end

#再描写なんかだっけ?
reshape = proc do |w, h|
end

keyBoard = proc do |key, x, y|
case(key)
when ?\e
exit(0)
else
end
end

mouse = proc do |key, state, x, y|
end

motion = proc do |x, y|
end



glutInit
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH)
init()
glutInitWindowSize(400, 300)
glutInitWindowPosition(0,0)
glutCreateWindow("3D half spherical")
glutDisplayFunc(display)
glutReshapeFunc(reshape)
glutKeyboardFunc(keyBoard)
glutMotionFunc(motion)
glutMouseFunc(mouse)
glutMainLoop()

結構楽々に移植できる。
さてと、ファイル読み込みが楽なんだかよくわからない。

if(((File.exist?("pcat_face.dat"))&&(File.exist?("tcat_face.dat")))==true)
File.open("pcat_face.dat"){|file|
while line = file.gets
line = line.split(/,/)
d1 = line[0]
d2 = line[1]
@pdat[pn][0] = d1.to_f * @m
@pdat[pn][1] = d2.to_f * @m
pn +=1
end
}
end

でどうにか読めた、明日にはどうにか、サンプル移植終わりそうかな。

Rubyレシピブック 第2版 268の技

Rubyレシピブック 第2版 268の技

ruby移植するのに使っている。
サンプルとにらっめこすれば楽勝