OpenGL when it draws has a few choices of the ‘topology’ it uses to render. One of them is GL_Points. See Table 2.1. Another is GL_Lines. Our engine at this stage is using lines to render the triangles. This project adds the ability to draw points. It’s a very simple drawing method that replaces our current call to the Rb Graphics class call to DrawLine(…..) with the call to FillOval(……). I’d like to add the other topology calls that OpenGL uses, but for now will just stay to these two choices. If you press the ‘W’ key key you can toggle between the two different drawing calls in this project.
One other little tweak that I’ve done, but not here in this project, is to replace the Rb call to DrawLine with declare calls to the Carbon and Cocoa calls that draw lines. I’m trying to keep this group of projects as cross platform as possible, so I won’t include them here. But, if you’re following this blog and you have some time to explore, one area are these final draw routines. If you do an internet search of ‘Bresenaham’, you will find code that is based on his work on drawing lines. In Rb you can apply this ‘raw’ line drawing routine using the Graphics.Pixel(…..) call. This is one link. Another routine along this thought process is to code up an anti-aliasing line drawing routine. OpenGL implements this with a GL_SMOOTH constant. Just a thought or two.
Happy New Year!!