Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > OpenGl and ruby

Reply
Thread Tools

OpenGl and ruby

 
 
Thijs Leeflang
Guest
Posts: n/a
 
      09-07-2009
Hello all,

i have been working with ruby for less than a month now so sory if this
is a stupid mistake

i have been trying to get ruby to work with opengl,
i found an app which integrates ruby with gosu and opengl which is great
for me

but,
im trying to make a simple tile engine with opengl to show the actual
tiles
so i used gosu to load the tiles
and then in opengl drawing it,

i have been messing with the code a lot so i'ts bugy,
this is the class i have so far
i know this should just draw one tile and not a whole range but that´s
something i want to program myself.

can anybody please help me?


class OpenGL
def initialize(window)
@TextureImage = Gosu::Image.load_tiles(window, "Media/Tiles.bmp",
32, 32, true)
glClearColor(0.0, 0.0, 0.0, 0)
glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST); # Really Nice
Perspective Calculations
glHint(GL_POINT_SMOOTH_HINT,GL_NICEST);
gluPerspective(45.0, 800 / 600, 0.1, 100.0)

draw_gl(0,0,1)
end

def draw_gl(x, y, tile)
info = @TextureImage[tile].gl_tex_info
return unless info
glDepthFunc(GL_GEQUAL)
glEnable(GL_DEPTH_TEST)
glEnable(GL_BLEND)

glMatrixMode(GL_PROJECTION)
glLoadIdentity
glFrustum(-0.10, 0.10, -0.075, 0.075, 1, 100)

glMatrixMode(GL_MODELVIEW)
glLoadIdentity
glTranslate(0, 0, 1)

glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST)
glHint(GL_POINT_SMOOTH_HINT,GL_NICEST)
glEnable(GL_TEXTURE_2D)
glBindTexture(GL_TEXTURE_2D, info.tex_name)
glBegin(GL_TRIANGLE_STRIP)
glColor4d(1, 1, 1, 0)
glTexCoord2d(info.left, info.top)
glVertex3d(-0.5, -0.5, 0)

glColor4d(1, 255, 1, 0)
glTexCoord2d(info.left, info.bottom)
glVertex3d(-0.5, 0.5, 0)

glColor4d(1, 1, 255, 0)
glTexCoord2d(info.right, info.top)
glVertex3d(0.5, -0.5, 0)

glColor4d(255, 1, 1, 0)
glTexCoord2d(info.right, info.bottom)
glVertex3d(0.5, 0.5, 0)
glEnd
end
end
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Embedded Ruby and OpenGL Matthew Carlin Ruby 0 07-26-2006 09:28 PM
OpenGL and Ruby? anne001 Ruby 7 01-16-2006 05:00 PM
Ruby and Opengl samples Robert Maus Ruby 0 01-09-2006 06:58 PM
OpenGL and Ruby: Experiences, comments, examples David Ross Ruby 1 09-14-2004 05:47 PM
ruby-opengl, ruby-glut Alwin Blok Ruby 5 01-21-2004 12:58 PM



Advertisments
 



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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57