RUDL Surface to OpenGL Texture.

A

apviper

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.
 
P

Peter Thoman

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/rudloidWIP4.jpg
http://landesjugendtheater.at/misc/rudloidEditWIP3.jpg

- Peter
 
A

apviper

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top