# Generate texture

**URL:** <https://www.ruby-forum.com/t/generate-texture/116295>\
**Category:** Ruby\
**Created:** [October 4, 2007, 8:20am UTC](https://www.ruby-forum.com/t/generate-texture/116295 "2007-10-04T08:20:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tom](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/3d9bf3/32.png) [@tom](https://www.ruby-forum.com/u/tom)\
**Post date:** [October 4, 2007, 8:20am UTC](https://www.ruby-forum.com/t/generate-texture/116295/1 "2007-10-04T08:20:50Z")

</div>

I am trying to generate a texture.

When I execute: @texture = glGenTextures(1).first

I get the following error:

[BUG] Bus Error  
ruby 1.8.4 (2005-12-24) [i686-darwin8.8.1]

Any help would be great. Thanks.

Tom

Below is a more complete snippet of the code that I am using:

#!/usr/local/bin/ruby

require ‘rubygems’  
require ‘opengl’

include Gl  
include Glu  
include Glut

class GlutTest

def initialize  
puts “=== GlutTest.initialize ===”

```
@texture = glGenTextures(1).first

# Setup the GLUT display loop callback
@display = lambda do
  glClear(Gl::GL_COLOR_BUFFER_BIT | Gl::GL_DEPTH_BUFFER_BIT)

  gluOrtho2D(0.0, 128.0, 0.0, 128.0)

  glutSwapBuffers
end

```

…

end

---

<div class="post-metadata">

**Author:** ![tom](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/3d9bf3/32.png) [@tom](https://www.ruby-forum.com/u/tom)\
**Post date:** [October 4, 2007, 4:21pm UTC](https://www.ruby-forum.com/t/generate-texture/116295/2 "2007-10-04T16:21:55Z")

</div>

On Oct 4, 12:16 am, Tom [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> include Glu  
> @display = lambda do  
> glClear(Gl::GL\_COLOR\_BUFFER\_BIT | Gl::GL\_DEPTH\_BUFFER\_BIT)
> 
> ```
> gluOrtho2D(0.0, 128.0, 0.0, 128.0)
> 
> glutSwapBuffers
> end
> 
> ```
> 
> …
> 
> end

The issue was that the call to generate a texture must be inside of a  
glut call back.
