Difference between revisions of "GPU (API)"
From ComputerCraft Wiki
(→OpenGL Constants) |
(→OpenGL Methods) |
||
Line 53: | Line 53: | ||
|- | |- | ||
|glBegin(mode) | |glBegin(mode) | ||
− | | | + | |Begins drawing something. mode should be a constant like GL_QUADS or GL_TRIANGLES. You must invoke this function before setting vertices for the shape. |
|- | |- | ||
|glEnd() | |glEnd() | ||
− | | | + | |Invoke this when you've set all your vertices. |
|- | |- | ||
|glBindTexture(id) | |glBindTexture(id) | ||
Line 65: | Line 65: | ||
|- | |- | ||
|glVertex2f(x, y) | |glVertex2f(x, y) | ||
− | | | + | |Use this between glBegin(mode) and glEnd() to set a 2D vertex. |
|- | |- | ||
|glVertex3f(x, y, z) | |glVertex3f(x, y, z) | ||
− | | | + | |Use this between glBegin(mode) and glEnd() to set a 3D vertex. |
|- | |- | ||
|glColor3f(red, green, blue) | |glColor3f(red, green, blue) | ||
− | | | + | |Use this between glBegin(mode) and glEnd() to set the color. |
|- | |- | ||
|glColor4f(red, green, blue, alpha) | |glColor4f(red, green, blue, alpha) | ||
− | | | + | |Use this between glBegin(mode) and glEnd() to set the color with alpha (opacity). |
|} | |} | ||
Revision as of 01:17, 18 March 2012
The GPU api provides interaction with and is part of the CCGPU peripheral.
Arguments surrounded with square brackets are optional.
API Methods
These methods can be used in any ComputerCraft program if the CCGPU api is installed.
Method name | Description |
---|---|
gpu.getID([side]) | coming soon |
gpu.setRenderCode([side], renderCode) | Sets the gpu rendering code, this code is ran every frame. @param side the side the gpu is connected to |
gpu.setVar([side], name, value) | coming soon |
gpu.getLatestError([side]) | coming soon |
Render Methods
These methods can be used in render code when set using gpu.setRenderCode.
Method name | Description |
---|---|
gpuCreateBuffer(width, height) | Coming soon |
gpuClearBuffer() | Coming soon |
gpuBindBuffer(id) | Coming soon |
gpuBindOutputBuffer(id) | Coming soon |
gpuGetOutputResolution(id) | Coming soon |
OpenGL Methods
These methods are part of OpenGL and can only be used in render code when set using gpu.setRenderCode.
Method name | Description |
---|---|
glBegin(mode) | Begins drawing something. mode should be a constant like GL_QUADS or GL_TRIANGLES. You must invoke this function before setting vertices for the shape. |
glEnd() | Invoke this when you've set all your vertices. |
glBindTexture(id) | Coming soon |
glTexCoord2f(x, y) | Coming soon |
glVertex2f(x, y) | Use this between glBegin(mode) and glEnd() to set a 2D vertex. |
glVertex3f(x, y, z) | Use this between glBegin(mode) and glEnd() to set a 3D vertex. |
glColor3f(red, green, blue) | Use this between glBegin(mode) and glEnd() to set the color. |
glColor4f(red, green, blue, alpha) | Use this between glBegin(mode) and glEnd() to set the color with alpha (opacity). |
OpenGL Constants
These constants are part of OpenGL and can only be used in render code when set using gpu.setRenderCode.
Constant name | Description |
---|---|
GL_QUADS | Constant for drawing a quadrilateral. |
GL_TRIANGLES | Constant for drawing a triangle. |
GL_POINTS | Constant for drawing a pixel at each vertex given. |