This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
xuma202's profile picture

[CCGPU] Basic Shapes API [v1.0]

Started by xuma202, 03 June 2012 - 10:17 AM
xuma202 #1
Posted 03 June 2012 - 12:17 PM
Hi,

This is a simple API for the CCGPU peripheral. I mad this for those not familiar with OpenGL.

Link to Code

You can use it like this:


Code = LineCode(x1, y1, x2, y2, r, g, :)/>/>..CircleCode(x, y, radius, r, g, :D/>/>
drawFrame("back", 1, Code)


Functions:

PointCode(x, y, r, g, b )

  The x, y of the Pixel.
  The RGB-Values of the pixels color (range 0-1).

  Will return a String containing the OpenGL Code.

LineCode(x1, y1, x2, y2, r, g, b )

  The Points (x1|y1), (x2|y2) to line up.
  The RGB-Values of the lines color (range 0-1).

  Will return a String containing the OpenGL Code.


RectangleCode(x1, y1, x2, y2, r, g, b )

  The left- and top-most Point (x1|y1).
  The right- and bottom-most Point (x2|y2).

  The RGB-Values of the rectangles color (range 0-1).

  Will return a String containing the OpenGL Code.


TriangleCode(x1, y1, x2, y2, x3, y3 r, g, b )

  The 1st Point (x1|y1).
  The 2nd Point (x2|y2).
  The 3rd Point (x3|y3).

  The RGB-Values of the triangles color (range 0-1).

  Will return a String containing the OpenGL Code.


CircleCode(x, y, rad, r, g, b )

  The center of the Circle (x|y).
  The radius of the circle rad.

  The RGB-Values of the circles color (range 0-1).

  Will return a String containing the OpenGL Code.

  NOTE: This will generate the outline of a circle. To draw a filled circle use filledCircleCode!


filledCircleCode(x, y, rad, r, g, b )

  The center of the Circle (x|y).
  The radius of the circle rad.

  The RGB-Values of the circles color (range 0-1).

  Will return a String containing the OpenGL Code.

DrawFrame(side, mon_id, code)

  The side on which the GPU is attached to.
  The mon_id.
  The OpenGL code.

  NOTE you can simply concat the functions results.



The Monitors Coordinate system starts with 0 on the x-axis and ends with 127. For the y-axis it starts with 1 and ends with 128. This is caused by the mod itself.

DEMO:

Code = filledCircleCode(63.5, 64.5, 64, 1, 1, 0)..filledCircleCode(32, 32, 8, 1, 1, 1)..filledCircleCode(96, 32, 8, 1, 1, 1)..filledCircleCode(32, 32, 2, 0, 0, 0)..filledCircleCode(96, 32, 2, 0, 0, 0)..TriangleCode(57, 57, 70, 57, 63.5, 70, 0, 1, 0)..LineCode(40, 80, 87, 80, 1, 0, 0)..LineCode(40, 82, 87, 82, 1, 0, 0)

drawFrame("left", 1, Code)

Will generate a this:



xuma202
con2000 #2
Posted 03 June 2012 - 12:37 PM
Nice.
Megolas #3
Posted 04 June 2012 - 03:27 PM
The CCGPU doesnt work for the current version, does it?
xuma202 #4
Posted 04 June 2012 - 04:12 PM
No it doesn't. But I'm not responsible for that. Hopefully Mast3rPlan will update it soon.
xuma202 #5
Posted 06 June 2012 - 10:25 PM
I'm currently working on a text output method. This will not be Texture based since there is no support yet but I'll add letters that will be drawn pixel by pixel
FuzzyPurp #6
Posted 09 August 2012 - 10:18 PM
Cloudy updated it, checked the 2nd to last page on the thread for 1.2.5 - Also moving this to the API section.