OpenGl and ruby

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs