2

I followed this post to play with OpenGL (programmable pipeline) on Ruby

Basically, I'm just trying to create a blue window, and here's the code.

Ray::GL.major_version = 3
Ray::GL.minor_version = 2
Ray::GL.core_profile  = true # if you want/need one

window = Ray::Window.new("Test Window", [800, 600])
window.make_current

glClearColor(0, 0, 1, 1);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glEnable(GL_DEPTH_TEST);

Instead, I got a white window created. This indicated that I was missing something, but I couldn't figure out what I was missing as the resources for OpenGL on Ruby seemed limited. I have been searching all over the web, but all I found was fixed-pipeline OpenGL stuff for Ruby.

Yes, I could use Ray's built-in functions to set the background color and draw stuff, but I didn't want to do that. I just wanted to use Ray to setup the window, then called OpenGL APIs directly. However, I couldn't figure out what I was missing in the code above.

I would greatly appreciate any hint or pointer to this (maybe I needed to swap the buffer? but then I didn't know how to do it with Ray). Is there any body familiar with using Ray that can give me some hints on this?

Or, are there any other tools that would allow me to setup OpenGL binding (for none fixed-pipeline)?

Community
  • 1
  • 1
TATN
  • 1,249
  • 2
  • 12
  • 26

1 Answers1

1

It would appear that you set the clear color to be blue, then cleared the back buffer to make it blue. But, as you said, you have not swapped the buffers to put the back buffer onto your screen. As far as swapping buffers goes, here's another answer from stack overflow

"Swapping the front and back buffer of a double buffered window is a function provided by the underlying graphics system, i.e. Win32 GDI, or X11 GLX. The function's you're looking for are wglSwapBuffers and/or glXSwapBuffers. On MacOS X NSOpenGLViews are automatically swapped.

However most likely you're using some framework, like GLUT, GLFW or Qt, which provide a portable wrapper around those functions. Read the framework's documentation."

I've never used Ray, so I'd say just keep rooting around in the documentation or look through example projects to see how buffer swapping is done.

Joe Runde
  • 253
  • 2
  • 8
  • Thank you for the comment. Yes, glutSwapBuffers() worked when I used it with my C++ app. However, this time, I'm using Ruby with Ray, so I'm hoping I don't have to resort to GLUT (then, I would need to bring in GLEW as well). I have looked through Ray's documentation, but I couldn't find the wrapper that let me swap the buffers - maybe I haven't looked hard enough. I'll keep looking and also trying to see if there's any way I can get around this. – TATN Apr 16 '13 at 23:35