# How to load a Texture in Ruby-Opengl

**URL:** <https://www.ruby-forum.com/t/how-to-load-a-texture-in-ruby-opengl/140920>\
**Category:** Ruby\
**Created:** [June 19, 2008, 8:41pm UTC](https://www.ruby-forum.com/t/how-to-load-a-texture-in-ruby-opengl/140920 "2008-06-19T20:41:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [June 19, 2008, 8:41pm UTC](https://www.ruby-forum.com/t/how-to-load-a-texture-in-ruby-opengl/140920/1 "2008-06-19T20:41:10Z")

</div>

Hi,

I don’t get it working in Ruby. I try to load a texture which works  
pretty easy in other languages like c++ and there are plenty of  
examples in other languages but none for Ruby.

The file could be any format but I like to keep it simple: ppm or raw.  
Can anyone give me a hint or a snippet how to do it?

thanx ahead

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [June 20, 2008, 1:53pm UTC](https://www.ruby-forum.com/t/how-to-load-a-texture-in-ruby-opengl/140920/2 "2008-06-20T13:53:48Z")

</div>

On Thursday 19 June 2008 20:38:40 removed\_email\_address@domain.invalid wrote:

> Hi,
> 
> I don’t get it working in Ruby. I try to load a texture which works  
> pretty easy in other languages like c++ and there are plenty of  
> examples in other languages but none for Ruby.
> 
> The file could be any format but I like to keep it simple: ppm or raw.  
> Can anyone give me a hint or a snippet how to do it?

It works the same way as in C or other languages, you need library (like  
RMagick/ImageMagick,SDL\_image etc.) that decodes the image format to raw  
pixel data in memory (in ruby it’s represented as string), then pass it  
to  
the opengl functions (glTexImage\*).

Jan
