[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

RUDL Surface to OpenGL Texture.

apviper@gmail.com

4/11/2005 10:06:00 PM

I've been playing around with ruby-opengl lately, and I've run into a
hitch. While I found a way to load images via the imlib bindings
(found on this group:), I'd still like to be able to convert RUDL
surfaces to OpenGL texutres, just so I can use their bindings to
SDL_TTF for text manipulation.

Can anyone point me in the right direction? I've looked at the
rubynehe folder that came with RUDL, but that method seemed to work
with only certain surfaces.

2 Answers

Peter Thoman

4/12/2005 1:23:00 PM

0

apviper@gmail.com wrote:

>I've been playing around with ruby-opengl lately, and I've run into a
>hitch. While I found a way to load images via the imlib bindings
>(found on this group:), I'd still like to be able to convert RUDL
>surfaces to OpenGL texutres, just so I can use their bindings to
>SDL_TTF for text manipulation.
>
>Can anyone point me in the right direction? I've looked at the
>rubynehe folder that came with RUDL, but that method seemed to work
>with only certain surfaces.
>
From my RudloidGL game, ResourceMgr class (temp is a RUDL surface):

def ResourceMgr.tex_from_image(temp, name)
@textures[name]=GL.GenTextures(1)[0]
GL.BindTexture(GL::TEXTURE_2D, @textures[name])
GL.TexParameteri(GL::TEXTURE_2D, GL::TEXTURE_MAG_FILTER, GL::LINEAR)
GL.TexParameteri(GL::TEXTURE_2D, GL::TEXTURE_MIN_FILTER, GL::LINEAR)
GL.TexImage2D(GL::TEXTURE_2D, 0, GL::RGBA8, temp.w, temp.h, 0,
GL::RGBA, GL::UNSIGNED_BYTE, temp.pixels)
GLU.Build2DMipmaps(GL::TEXTURE_2D, 4, temp.w, temp.h, GL::RGBA,
GL::UNSIGNED_BYTE, temp.pixels)

debug_print "new texture: ",name," ---ID: ",@textures[name],"\n"
@textures[name]
end

Is that what you're looking for? (For RUDL surfaces without alpha you'll
have to use OpenGL constants without the 'A')
Perhaps I'll release my game someday, it's been in development for about
3 years now (5 days per year ;))
http://landesjugendtheater.at/misc/rudlo...
http://landesjugendtheater.at/misc/rudloidEd...

- Peter


apviper@gmail.com

4/13/2005 11:17:00 PM

0

Thanks a ton! That's exactly what I needed. Your game looks great,
try to up it to a week a year ;) I'd love to play it.