About the REALbasic RBGL library

RBGL is a drawing library for REALbasic that extends REALbasic's drawing capabilities with new, faster and more powerful commands powered by OpenGL.

RBGL is not a simple collection of declares, or an attempt to expose the raw OpenGL API as REALbasic functions and constants (if this is what you are looking for, check out our GL Declares library), instead RBGL shields you from the complexity of OpenGL, providing most of the power of OpenGL, but wrapped up in a friendly and familiar API based on REALbasic's own graphics classes.

RBGL is cross-platform and does not rely on any plugins, either internal or external. RBGL also forms the basis of the RBGLSprites and RBGL3D libraries, which extend its functionality with 2D and 3D gaming capabilities respectively.

Donations

If you find RBGL useful, please support us by making a small donation. Your funding will help to ensure continued development of these tools.

Acknowledgements

Thanks go to Christopher of FUS, Inc for helping me figure out how to attach an OpenGL context to a Canvas on Windows, and to Thomas Cunningham, without whom it would never have occured to me to try using OpenGL with REALbasic. Thanks also go to David Birns and Eric Pousse for helping me track down some bugs in the library.

RBGL was written from scratch using the OpenGL specification, it is not derived from any existing REALbasic OpenGL libraries or examples.

FAQ

What is this for?
The RBGL library is intended to allow REALbasic developers to implement enhanced graphics in their REALbasic projects.
What's REALbasic, and where can I get hold of it?
REALbasic is a visual programming environment for writing desktop applications for Mac OS, Windows and linux. Unlike RBGL it is not free, however you can download a free time-limited trial version from www.realbasic.com.
What versions of REALbasic does RBGL support?
RBGL is tested with REALbasic 2007r5 and 2008r5. It is assumed to work on all versions in between, but these are not always tested individually.
What platforms does RBGL support?
RBGL works on Windows and Mac OS X (PPC and Intel). A linux port is planned, but will not be ready for some time.
How does RBGL work?
RBGL uses declares to link to the OpenGL library found on all modern Macintosh and Windows machines. The OpenGL library provides hardware-accelerated 3D and 2D graphics capabilities, a subset of which are exposed by the RBGL API.
What is the point of RBGL? Why not just use OpenGL declares directly?
OpenGL is a low-level API and is quite different from REALbasic's built-in drawing capabilities. If you are comfortable with the OpenGL API then use it, but RBGL is designed to give you some of the power of OpenGL without any of the complexity.
Why is RBGL better than other OpenGL abstractions such as SuperSpriteSurface?
Depending on your needs, it may not be. However the goals of RBGL are significantly different from those of SuperSpriteSurface - for one thing, RBGL mimics the REALbasic Graphics API, making it easy to port existing code.
What if I really need access to the raw power and complexity of OpenGL?
If have "mad OpenGL skillz" and aren't afraid to use them, try our GL Declares library, which provides a complete set of declares for the OpenGL 1.1 specification. GL Declares and RBGL can be used together, although some care must be taken when switching between the two in your code.
I've looked at your code and it's spaghetti! Why is everything duplicated everywhere?
Part of the philosophy of RBGL is to keep the interfaces as simple as possible, keep the class count as low as possible, and to try to expose only the functions and properties that the end user needs to use. This sometimes means duplicating code or jumping through hoops to avoid exposing private details of a class. We know that this is poor software engineering practice, but it makes for a better end-user experience. Basically, we write messy code so you don't have to!
Does RBGL require any plugins?
No, RBGL uses only pure REALbasic code. We have also been careful to avoid using any of REALbasic's own internal plugins, so RBGL projects can still compile to a single .exe file on Windows.
Is RBGL free?
Yes, free and completely open source. You may use it without restriction in both free and commercial projects, and may redistribute the source as long as you do not misrepresent its origins. If you do find RBGL useful however, we would appreciate a small donation, which you can make using the PayPal link at the top and bottom of this page.

Release Notes

1.6.2
  • [fix] Fixed a glitch when drawing images with ScaleToPowerOfTwo setting
1.6.1
  • [fix] Fixed an issue when drawing non-cached images.
  • [fix] Fixed a bug in the caching mechanism that caused the cache limit to be ignored unless set to zero.
  • [fix] Fixed a rendering glitch when generating textures from 16-bit images.
1.6
  • [new] Added a new constructor to the RBGLContext class for creating offscreen drawing contexts. Currently this only works correctly on Mac OS (beta feature).
  • [new] The RBGLContext.IsExtensionSupported method now also checks for WGL extensions (Windows only).
  • [fix] RBGLPictures no longer have a white halo when the source image has the Transparent property set and has dimensions that are not a power of two.
  • [fix] RBGL methods no longer crash when called from within a thread.
  • [fix] RBGLCanvas.Visible property is now respected.
  • [fix] RBGLContextOptions.DepthBufferBits property now works correctly on Mac OS.
  • [chg] RBGLContextOptions.DepthBufferBits now defaults to zero as the depth buffer is not used by any of the RBGL classes or methods. You can override this in the Init method of RBGLCanvas if you wish to use the depth buffer.
  • [imp] RBGLContext now uses AGL_SWAP_INTERVAL on Mac OS to sync with the display refresh and eliminate tearing and flicker.
  • [chg] RBGLPicture objects no longer stretch the source image dimensions to a power-of-two by default - the image is padded instead. This eliminates the fuzziness caused by scaling.
  • [new] RBGLPicture constructors now take an optional RBGLPictureOptions parameter that allows you to specify features such as wrapping mode and mip-mapping.
  • [chg] Removed the MipMap parameter from the RBGLPicture constructor - use the Options parameter instead.
  • [fix] Fixed bug in RBGLPicture constructor that would assume white pixels should be treated as transparent if the image format was set to RGBA.
  • [opt] RBGLPicture constructor now checks if image contains any white pixels and only uses RGBA format by default if it does, even if the Picture.Transparent property is set on the source image. This improves performance for opaque images, particularly when used with the RBGL3D library.
1.5
  • [new] Added orientation argument to DrawPicture method. This allows images to be drawn rotated to an arbitrary angle.
  • [new] Added GetPicture method to RBGLPicture that converts it to a REALbasic Picture.
  • [new] Added GetPicture and GetRBGLPicture methods to RBGLGraphics and RBGLCanvas that can be used for extracting the rendered image or a subrectangle of it.
  • [new] Added StretchBackdrop property to RBGLCanvas, which stretches the backdrop image to fill the Canvas area.
  • [fix] Fixed bug in DrawPicture method when drawing a stretched picture.
  • [chg] Simplified RBGLCanvas interface by removing BackdropGL property.
  • [new] Added CachePictures and CacheStrings properties to the RBGLGraphics class. Use these to temporarily disable cachine when drawing pictures or strings that change frequently and will not benefit from caching.
  • [doc] Corrected references to RBGLTexture2D in the documentation.
1.4.1
  • [chg] Changed scope of AbstractGraphics and GraphicsWrapper to Global instead of Public.
1.4
  • [fix] Fixed an issue with masks being missaligned for pictures that used the Transparent property on Mac OS.
  • [fix] Fixed an issue with masks being removed from the source image when creating an RBGLPicture object (thanks go to David Birns for spotting it).
  • [fix] Fixed an issue with the image Mask property being ignored when creating an RBGLPicture if the Transparent property was set.
  • [chg] RBGLGraphics no longer inherits from the standard REALbasic Graphics class. This was the cause of a number of crashes that occured when the REALbasic compiler attempted to call the overridden Graphics methods instead of the ones in RBGLGraphics (thanks go to Eric Pousse for drawing my attention to this issue).
  • [new] RBGLGraphics.DrawPolygon/FillPolygon now accept an array of Doubles as a parameter as well as Integers or Singles.
1.3.1
  • [fix] The ClearRect method and the TextAscent, TextHeight and TextSize properties longer crash when called. This was caused by RB attempting to call the original graphics methods due to differences in the method signature.
1.3
  • [chg] Renamed RBGLTexture2D to RBGLPicture to better reflect its functionality
  • [opt] RBGLCanvas now has a caching feature which dramatically improves performance when drawing the same string or Picture multiple times. This feature may cause excessive memory consumption if not used correctly - check the instructions for more info.
  • [fix] RBGLPicture can now handle images without a graphics property, such as those added to a project's resources at design time.
  • [fix] RBGLPicture can now handle images with a bit depth less than 32 (they are automatically copied into a 32-bit image before processing).
  • [new] RBGLPicture now has a TilePicture method, allowing you to efficiently tile an image over a larger area.
  • [fix] Fixed a bug in RBGLPicture that meant all textures were created as RGBA even if they had no mask property.
  • [new] RBGLPicture now takes the Transparent (white = transparent) setting of a source picture into account and will generate a mask automatically.
  • [new] RBGLContext now has an Enable method for enabling or disabling certain OpenGL features such as depth testing.
  • [new] RBGLContext now has a ClearColor method, allowing you to specify the background colour independently of the containing Window.
  • [imp] Switching between contexts and canvases is now handled more cleanly. It should no longer be neccessary to call the Bind method manually.
1.2
  • [chg] RBGLGraphics is now a subclass of Graphics, which allows you to write dual-mode drawing code that can be passed either an RBGLGraphics or an ordinary Graphics class.
  • [opt] RBGLTexture2D now uses low-level coregraphics functions on Mac OS to extract the pixel data from a REALbasic Picture.
  • [new] Now supports multisampling (anti-aliasing) on Mac OS (wasn't able to get it working on Windows yet, despite some effort).
  • [fix] Fixed some bugs in the RBGLGraphics polygon drawing methods.
  • [fix] Fixed string drawing alignment bug.
  • [opt] Added optimisations for drawing when penwidth and height is set to 1 pixel.
  • [opt] Added a Blit method to RBGLTexture2D that may be used for efficiently drawing an image that will only be used once, rather than having to create and destroy a texture in video memory.
  • [new] Added an optional Blend parameter to the RBGLGraphics picture and string drawing functions that allows you to control whether the image is blended with the current Forecolor.
  • [new] Added Upscaling and Downscaling mode options to RBGLTexture2D, and modified default upscaling mode to GL_NEAREST, for sharper images.
  • [chg] RBGLTexture Width and Height now report size of original image. Use ActualWidth and ActualHeight for scaled (power of two) size.
1.1
  • [new] Added RBGLGraphics class
  • [new] Added support for textures with the RBGLTexture2D class
  • [new] Added support for drawing text with the RBGLStringTexture class
  • [chg] Now using XML format for version control
1.0
  • [new] Initial release.

Donations

If you find RBGL useful, please support us by making a small donation. Your funding will help to ensure continued development of these tools.