# Ruby,SDL,OpenGL

**URL:** <https://www.ruby-forum.com/t/ruby-sdl-opengl/71229>\
**Category:** Ruby\
**Created:** [October 6, 2006, 7:56am UTC](https://www.ruby-forum.com/t/ruby-sdl-opengl/71229 "2006-10-06T07:56:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pinkman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/41988e/32.png) [@pinkman](https://www.ruby-forum.com/u/pinkman)\
**Post date:** [October 6, 2006, 7:56am UTC](https://www.ruby-forum.com/t/ruby-sdl-opengl/71229/1 "2006-10-06T07:56:51Z")

</div>

## This is in regards to my last topic, where I was having problems with lag, I got around to thinking that maybe it was just the way RUDL handled opengl, and somehow caused lag, so I thought I’d go ahead and try in normal SDL, now… so far I am running 32 polygons, and am at 200+ fps, rather then the old 20+ fps, it seems to be working perfectly now, all for the fact SDL doesnt give me a good error message… IE:

## rubyw.exe - Application Error

The exception Breakpoint

A breakpoint has been reached.

(0x80000003) occurred in the application at location 0x7c901230.

## Click on OK to terminate the program Click on CANCEL to debug the program

## OK Cancel

although, I know where the problem is located, just not sure what to do  
to fix it, seeing how that error is no help. It could be anything. But I  
at least know its because of my code, I cant seem to load a texture  
inopengl with the SDL library… my code so far is

def load\_texture(texture,arr)  
if (texture.nil?)  
exit  
end  
#texture.convert!  
texture.setColorKey SDL::SRCCOLORKEY, texture[0,0]  
texture = texture.displayFormat  
image = SDL::Surface.new(SDL::SRCCOLORKEY | SDL::SRCALPHA,  
[texture.w,texture.h], 32, [0x000000FF, 0x0000FF00, 0x00FF0000,  
0xFF000000])  
#image.fill [0,0,0,0]  
image.put(texture, [0,0])  
image = image.displayFormat  
GL.BindTexture(GL::TEXTURE\_2D,arr[0]);  
GL.TexParameter(GL::TEXTURE\_2D, GL::TEXTURE\_MAG\_FILTER, GL::LINEAR);  
GL.TexParameter(GL::TEXTURE\_2D, GL::TEXTURE\_MIN\_FILTER, GL::LINEAR);  
GL.TexImage2D(GL::TEXTURE\_2D, 0, GL::RGBA,image.w, image.h, 0,  
GL::RGBA, GL::UNSIGNED\_BYTE, image.pixels)  
end

wich is a quick transformation from the RUDL version to SDL… if anyone  
knows how to load textures with SDL, tell me… I am achen to get this to  
work.

---

<div class="post-metadata">

**Author:** ![pinkman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/41988e/32.png) [@pinkman](https://www.ruby-forum.com/u/pinkman)\
**Post date:** [October 7, 2006, 11:25am UTC](https://www.ruby-forum.com/t/ruby-sdl-opengl/71229/2 "2006-10-07T11:25:54Z")

</div>

Maybe running your program in opengl would help, you would know if the  
problem was opengl or sdl.

I have opengl from yoshi running on my mac if you want me to try your  
program, or if you are on pc, maybe you could download and install it

Please post what you learn, there are not many people working with  
opengl/ruby who post on the list.

---

<div class="post-metadata">

**Author:** ![pinkman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/41988e/32.png) [@pinkman](https://www.ruby-forum.com/u/pinkman)\
**Post date:** [October 7, 2006, 2:01pm UTC](https://www.ruby-forum.com/t/ruby-sdl-opengl/71229/3 "2006-10-07T14:01:04Z")

</div>

anne001 wrote:

> Maybe running your program in opengl would help, you would know if the  
> problem was opengl or sdl.
> 
> I have opengl from yoshi running on my mac if you want me to try your  
> program, or if you are on pc, maybe you could download and install it
> 
> Please post what you learn, there are not many people working with  
> opengl/ruby who post on the list.

it isnt my opengl code its the sdl… just need to know how to make the  
correct surface to load in the opengl texture module
