Posted 26 December 2012 - 01:03 AM
ccGL is a project I'm currently working on to implement an OpenGL-like render toolkit and environment into the CCLights Peripheral by ds84182.
ccGL will eventually provide complete 2-dimensional (and perhaps some 3-dimensional + perspective) functionality - including rendering of things in classic OpenGL, such as GL_POINT, GL_LINE, GL_QUAD, and some more groovy things, such as custom polygons and primitives, creating gradients and binding textures - as well as the ability to create render contexts and functioning buffers - with the same (or practically identically similar) syntax as OpenGL - allowing for fast graphics rendering on CCLights devices and CCLight grids on Peripheral Cables. (I may eventually extend this to support monitors as well, however, monitors have a significantly lower bit-depth and aren't square pixels… or even pixels.)
ccGL currently supports all the code in the below demonstration - lines, points, clearing, colors (and partial undemonstrated quad support).
… produces this result (okay, don't let me show the picture, forums?).
ccGL will eventually provide complete 2-dimensional (and perhaps some 3-dimensional + perspective) functionality - including rendering of things in classic OpenGL, such as GL_POINT, GL_LINE, GL_QUAD, and some more groovy things, such as custom polygons and primitives, creating gradients and binding textures - as well as the ability to create render contexts and functioning buffers - with the same (or practically identically similar) syntax as OpenGL - allowing for fast graphics rendering on CCLights devices and CCLight grids on Peripheral Cables. (I may eventually extend this to support monitors as well, however, monitors have a significantly lower bit-depth and aren't square pixels… or even pixels.)
ccGL currently supports all the code in the below demonstration - lines, points, clearing, colors (and partial undemonstrated quad support).
Spoiler
Sample code. Note this will probably change a little per release.
api("glapi.lua", "GL")
GLMonitor = peripheral.wrap("top")
GL.glClearColor(128, 128, 128)
local monSize = {GLMonitor.getSize()}
local colorTest = {
{ 0, 0, 0},
{255, 0, 0},
{0, 255, 0},
{0, 0, 255},
{255, 255, 0},
{255, 0, 255},
{ 0, 255, 255},
{255, 255, 255} }
-- BEGINBLOCK-GL_POINTS
GL.glBegin(GLMonitor, GL.MODES.GL_POINTS)
for b=1,monSize[1] do
local _color = (255/monSize[1]) * b
GL.glColor3i(_color, 0, 0)
GL.glVertex2i(b, 8)
GL.glColor3i(0, _color, 0)
GL.glVertex2i(b, 9)
GL.glColor3i(0, 0, _color)
GL.glVertex2i(b, 10)
GL.glColor3i(_color, 255, 255)
GL.glVertex2i(b, 11)
GL.glColor3i(255, _color, 255)
GL.glVertex2i(b, 12)
GL.glColor3i(255, 255, _color)
GL.glVertex2i(b, 13)
end
for i,c in pairs(colorTest) do
GL.glColor3i(c[1], c[2], c[3])
GL.glVertex2i(i, 14)
end
for i=1,monSize[1] do
local _color = (255/monSize[1]) * i
GL.glColor3i(_color, _color, _color)
GL.glVertex2i(i, 15)
end
-- BEGINBLOCK-GL_LINES
GL.glBegin(GLMonitor, GL.MODES.GL_LINES)
GL.glColor3i(255, 0, 0)
GL.glVertex2i(3, 1)
GL.glVertex2i(1, 1)
GL.glColor3i(255, 255, 0)
GL.glVertex2i(4, 3)
GL.glVertex2i(4, 1)
GL.glColor3i(0, 255, 0)
GL.glVertex2i(2, 4)
GL.glVertex2i(4, 4)
GL.glColor3i(0, 0, 255)
GL.glVertex2i(1, 2)
GL.glVertex2i(1, 4)
-- BEGINBLOCK-GL_PUSH
GL.glEnd()
… produces this result (okay, don't let me show the picture, forums?).