# Ruby/Opengl and RUDL

**URL:** <https://www.ruby-forum.com/t/ruby-opengl-and-rudl/70942>\
**Category:** Ruby\
**Created:** [October 4, 2006, 4:32am UTC](https://www.ruby-forum.com/t/ruby-opengl-and-rudl/70942 "2006-10-04T04:32:01Z")\
**Posts on this page:** 6\
**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 4, 2006, 4:32am UTC](https://www.ruby-forum.com/t/ruby-opengl-and-rudl/70942/1 "2006-10-04T04:32:01Z")

</div>

I am using RUDL, to create a 2D engine in Opengl… I cant find anything  
that would cause for this great deal of lag I am getting, other then the  
fact I have 17 polygons. I’m… not sure why it would lag so much over  
only 17 polygons… I do not think there are any memory leaks, because  
textures and what not are initialized once, and are pretty safe.  
Although… there is still this huge lag… when I take away the  
polygons, the lag is gone, when I add them back in. The lag is back, and  
reasons this could be? Anything I could do to fix it? (dont ask me why  
im using opengl to make a 3D engine, I just want too. \>.\>’

---

<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 4, 2006, 8:07pm UTC](https://www.ruby-forum.com/t/ruby-opengl-and-rudl/70942/2 "2006-10-04T20:07:05Z")

</div>

From: “Kyle Pinkman” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

> I am using RUDL, to create a 2D engine in Opengl… I cant find anything  
> that would cause for this great deal of lag I am getting, other then the  
> fact I have 17 polygons. I’m… not sure why it would lag so much over  
> only 17 polygons… I do not think there are any memory leaks, because  
> textures and what not are initialized once, and are pretty safe.  
> Although… there is still this huge lag… when I take away the  
> polygons, the lag is gone, when I add them back in. The lag is back, and  
> reasons this could be? Anything I could do to fix it? (dont ask me why  
> im using opengl to make a 3D engine, I just want too. \>.\>’

Hi,

Is the lag the same, no matter what size the polygons are? I.e. if you  
draw 17 very small polygons, does it lag still?

Regards,

Bill

---

<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 4, 2006, 9:33pm UTC](https://www.ruby-forum.com/t/ruby-opengl-and-rudl/70942/3 "2006-10-04T21:33:11Z")

</div>

On 10/4/06, Bill K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > reasons this could be? Anything I could do to fix it? (dont ask me why
> 
> Bill

You’re gonna have to post your drawing code. Also, do you have a GFX? or  
are  
you running through Mesa?

---

<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 5, 2006, 2:28pm UTC](https://www.ruby-forum.com/t/ruby-opengl-and-rudl/70942/4 "2006-10-05T14:28:41Z")

</div>

> 

Your code looks fine, it’s using what’s called Immediate Mode and with  
only  
15 Quads, should be fast enough if you’ve got any semblance of hardware  
support. (For the record, 15 Quads gets translated internally to  
polygons,  
so you’re at about 30 polies). What are the system specs of your  
computer?  
By GFX I mean Graphics Card. If you don’t have hardware OpenGL support,  
then  
you’re running through Mesa, the OpenGL software renderer, which is  
extremely slow and on top of Ruby for what may be a slow system, then  
it’s  
not going to take long before your computer starts chugging. So if you  
can  
post your computer specs, we’ll see what’s going on.

Jason

---

<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 4, 2006, 11:52pm UTC](https://www.ruby-forum.com/t/ruby-opengl-and-rudl/70942/5 "2006-10-04T23:52:48Z")

</div>

Bill K. wrote:

> From: “Kyle Pinkman” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
> 
> > I am using RUDL, to create a 2D engine in Opengl… I cant find anything  
> > that would cause for this great deal of lag I am getting, other then the  
> > fact I have 17 polygons. I’m… not sure why it would lag so much over  
> > only 17 polygons… I do not think there are any memory leaks, because  
> > textures and what not are initialized once, and are pretty safe.  
> > Although… there is still this huge lag… when I take away the  
> > polygons, the lag is gone, when I add them back in. The lag is back, and  
> > reasons this could be? Anything I could do to fix it? (dont ask me why  
> > im using opengl to make a 3D engine, I just want too. \>.\>’
> 
> Hi,
> 
> Is the lag the same, no matter what size the polygons are? I.e. if you  
> draw 17 very small polygons, does it lag still?
> 
> Regards,
> 
> Bill

I was thinking it was most obviously the polygons size, and how close it  
was to the camra… although the size it only 640x480px or 6.4x4.8…  
although, that is only two polygons. Then there are 15 small ones, with  
the width of 640px and the height of 32px that run down the window  
equalling the size of the other two larger polygons…

The code is…  
GL.PushMatrix  
GL.Enable GL::TEXTURE\_2D  
GL.BindTexture(GL::TEXTURE\_2D, @layer\_2.draw);  
15.times do |i|  
GL.Begin(GL::QUADS);  
w = 0.625  
h = 0.46875  
y = 0.32 \* i  
oy = i \* (h/15)  
GL.TexCoord 0, 0  
GL.Vertex 0, 0,1.99  
GL.TexCoord w, 0  
GL.Vertex 6.4, 0,1.99  
GL.TexCoord w,oy  
GL.Vertex 6.4, y,1.99  
GL.TexCoord 0,oy  
GL.Vertex 0.0, y,1.99  
GL.End();  
end  
GL.Disable GL::TEXTURE\_2D  
GL.PopMatrix  
although, thats only for the 15 polygons that run down…

If it is(most like is) the size of the polygons, wich is causing the  
lag, is there any way to fix that?

…

and…

> You’re gonna have to post your drawing code. Also, do you have a GFX? or  
> are  
> you running through Mesa?

I am not sure what you mean…

---

<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 5, 2006, 3:20pm UTC](https://www.ruby-forum.com/t/ruby-opengl-and-rudl/70942/6 "2006-10-05T15:20:52Z")

</div>

Jason R. wrote:

> > 
> 
> Your code looks fine, it’s using what’s called Immediate Mode and with  
> only  
> 15 Quads, should be fast enough if you’ve got any semblance of hardware  
> support. (For the record, 15 Quads gets translated internally to  
> polygons,  
> so you’re at about 30 polies). What are the system specs of your  
> computer?  
> By GFX I mean Graphics Card. If you don’t have hardware OpenGL support,  
> then  
> you’re running through Mesa, the OpenGL software renderer, which is  
> extremely slow and on top of Ruby for what may be a slow system, then  
> it’s  
> not going to take long before your computer starts chugging. So if you  
> can  
> post your computer specs, we’ll see what’s going on.
> 
> Jason

I do not have a graphics card… but im not sure if that would explain  
the lagging, because I have had people test it as well and it lagged for  
them, and alot of them have nice graphics cards and lots of ram… also,  
I have made this simular thing in c to test, and it didnt lag at all in  
C… so im not sure.
