Constructor
new Renderer()
(DO NOT USE) Internal use by Hummingbird only, all methods are available on HB.renderer.
- Source
Members
(readonly) maxIndexCount
(DO NOT USE) Internal variable to keep track of max indices in one batch, default is 6000.
- Source
(readonly) maxVertexCount
(DO NOT USE) Internal variable to keep track of max vertices in one batch, default is 4000.
- Source
(readonly) textureUnits
(DO NOT USE) This is the amount of texture units available, for increased compatibility/performance.
- Source
Methods
clear(color)
Method for clearing the screen with a certain color, can only be called when a batch has been started.
| Name | Type | Description |
|---|---|---|
color | glMatrix. | Color to clear the screen with. |
- Source
colorEllipse(pos, size, color)
Method for drawing a colored ellipse on screen, can only be called when a batch has been started.
| Name | Type | Description |
|---|---|---|
pos | glMatrix. | Top-left position of the ellipse. |
size | glMatrix. | Size of the ellipse's individual axes. |
color | glMatrix. | Color of the ellipse. |
- Source
colorLine(vectorA, vectorB, thickness, color)
Method for drawing a colored line on screen from one point to another, can only be called when a batch has been started.
| Name | Type | Description |
|---|---|---|
vectorA | glMatrix. | First point of the line. |
vectorB | glMatrix. | Second point of the line. |
thickness | number | The thickness of the line in pixels. |
color | glMatrix. | Color of the rectangle. |
- Source
colorPoint(pos, size, color)
Method for drawing a colored point on screen, can only be called when a batch has been started.
| Name | Type | Default | Description |
|---|---|---|---|
pos | glMatrix. | Center position at which to draw the point. | |
size | number | 1 | Size of the point, the point is a square defaulting to 1 pixel. |
color | glMatrix. | Color of the point. |
- Source
colorPolygon(points, color, center)
Method for drawing a colored polygon on screen, can only be called when a batch has been started.
| Name | Type | Default | Description |
|---|---|---|---|
points | Array | Array of glMatrix.vec2s with positions of all points. | |
color | glMatrix. | Color of the polygon. | |
center | number | 0 | Element of points Array which indicates the center of the polygon, only needed occasionally for concave polygons. |
- Source
colorRectangle(pos, size, color)
Method for drawing a colored rectangle on screen, can only be called when a batch has been started.
| Name | Type | Description |
|---|---|---|
pos | glMatrix. | Top-left position of the rectangle. |
size | glMatrix. | Size of the rectangle. |
color | glMatrix. | Color of the rectangle. |
- Source
colorText(string, pos, size, align, color) → {number}
Method for drawing colored text on screen, can only be called when a batch has been started.
| Name | Type | Default | Description |
|---|---|---|---|
string | string | ASCII text to be rendered, see the charset in https://projects.brandond.nl/Hummingbird/assets/arial_pretty.json for all characters. | |
pos | glMatrix. | Position of the text, anchor-point determined by the align parameter. | |
size | number | 12 | Pixel size (height) of the text. |
align | string | "start-start" | Where to place the anchor-point, this is a string formatted as "'x-anchor'-'y-anchor'", e.g. "end-center". Possible values are [start, center, end], modelled after this. |
color | glMatrix. | Color of the text. |
- Source
Final width of the rendered text.
- Type:
- number
delete()
(DO NOT USE) Internal method for cleaning up all renderer related objects (textures, shader, buffers, etc.), is automatically called when the window is closed.
- Source
drawArbitraryBatchedQuad(x0, y0, x1, y1, x2, y2, x3, y3, tex, col, textRange, sx, sy, sw, sh)
(DO NOT USE) Internal, most basic method for drawing a quad on screen. Use any of the quad methods instead (HB.Renderer#colorRectangle, HB.Renderer#textureRectangle, etc.). Can only be called when a batch has been started.
| Name | Type | Default | Description |
|---|---|---|---|
x0 | number | Top-left x-coordinate. | |
y0 | number | Top-left y-coordinate. | |
x1 | number | Top-right x-coordinate. | |
y1 | number | Top-right y-coordinate. | |
x2 | number | Bottom-right x-coordinate. | |
y2 | number | Bottom-right y-coordinate. | |
x3 | number | Bottom-left x-coordinate. | |
y3 | number | Bottom-left y-coordinate. | |
tex | number | 0 | Optional internal batch-specific texture ID. |
col | glMatrix. | {@link | HB.Colors.White} - Optional color of the quad. |
textRange | number | 0 | Optional value to check whether text is being rendered and anti-alias it. |
sx | number | 0 | UV x-coordinate of the texture, 0-1. |
sy | number | 0 | UV y-coordinate of the texture, 0-1. |
sw | number | 1 | UV width of the texture, 0-1. |
sh | number | 1 | UV height of the texture, 0-1. |
- Source
drawBatchedQuad(x, y, w, h, tex, col, textRange, sx, sy, sw, sh)
(DO NOT USE) Internal method for drawing a quad on screen. Use any of the quad methods instead (HB.Renderer#colorRectangle, HB.Renderer#textureRectangle, etc.). Can only be called when a batch has been started.
| Name | Type | Description |
|---|---|---|
x | number | X-coordinate of the quad. |
y | number | Y-coordinate of the quad. |
w | number | Width of the quad. |
h | number | Height of the quad. |
tex | number | Optional internal batch-specific texture ID. |
col | glMatrix. | Optional color of the quad. |
textRange | number | Optional value to check whether text is being rendered and anti-alias it. |
sx | number | UV x-coordinate of the texture, 0-1. |
sy | number | UV y-coordinate of the texture, 0-1. |
sw | number | UV width of the texture, 0-1. |
sh | number | UV height of the texture, 0-1. |
- Source
drawBatchedTriangle(x1, y1, x2, y2, x3, y3, color)
(DO NOT USE) Internal method for drawing a triangle on screen. Use HB.Renderer#colorPolygon instead. Can only be called when a batch has been started.
| Name | Type | Description |
|---|---|---|
x1 | number | X-coordinate of the first point. |
y1 | number | Y-coordinate of the first point. |
x2 | number | X-coordinate of the second point. |
y2 | number | Y-coordinate of the second point. |
x3 | number | X-coordinate of the third point. |
y3 | number | Y-coordinate of the third point. |
color | glMatrix. | Color of the triangle. |
- Source
drawIndexedTriangles(indexCount)
(DO NOT USE) Internal method with the final draw call, is automatically called by HB.Renderer#flushBatch.
| Name | Type | Description |
|---|---|---|
indexCount | number | Amount of indices to be rendered. |
- Source
drawRectangleWithRotation(pos, size, angle, texture, color)
(DO NOT USE) Internal method for drawing a rotated rectangle on screen. Use HB.Renderer#rotatedColorRectangle or HB.Renderer#rotatedTextureRectangle instead. Can only be called when a batch has been started.
| Name | Type | Default | Description |
|---|---|---|---|
pos | glMatrix. | Top-left position of the rectangle. | |
size | glMatrix. | Size of the rectangle. | |
angle | number | Angle in radians with which the rectangle gets rotated around its center (pos[0] + (size[0] / 2), pos[1] + (size[1] / 2)). | |
texture | HB. | 0 | If available, HB.Texture instance to texture with. |
color | glMatrix. | {@link | HB.Colors.White} - If available, color of the rectangle. |
- Source
endBatch()
Method for ending the rendering batch, is automatically called in HB.internalUpdate.
- Source
flushBatch()
(DO NOT USE) Internal method for rendering the current batch's contents, is automatically called by HB.Renderer#endBatch or HB.Renderer#flushBatchIfBufferFilled.
- Source
flushBatchIfBufferFilled(vertices, indices) → {boolean}
(DO NOT USE) Internal method to test whether the batch has to rendered to the screen, this happens whenever either the Vertex- or IndexBuffer is filled. Can only be called when a batch has been started.
| Name | Type | Default | Description |
|---|---|---|---|
vertices | number | 4 | Amount of vertices to add to buffer for check. |
indices | number | 6 | Amount of indices to add to buffer for check. |
- Source
Whether the batch had to be rendered.
- Type:
- boolean
getBatchTextureIndex(texture) → {number}
(DO NOT USE) Internal method to get a batch-specific texture ID. Can only be called when a batch has been started.
| Name | Type | Description |
|---|---|---|
texture | HB. | HB.Texture instance to texture with. |
- Source
Internal batch-specific texture ID.
- Type:
- number
resetBatch()
(DO NOT USE) Internal method for resetting the rendering batch's variables, is automatically called by HB.Renderer#startBatch.
- Source
rotatedColorRectangle(pos, size, angle, color)
Method for drawing a rotated colored rectangle on screen, can only be called when a batch has been started.
| Name | Type | Description |
|---|---|---|
pos | glMatrix. | Top-left position of the rectangle. |
size | glMatrix. | Size of the rectangle. |
angle | number | Angle in radians with which the rectangle gets rotated around its center (pos[0]+size[0]/2, pos[1]+size[1]/2). |
color | glMatrix. | Color of the rectangle. |
- Source
rotatedTextureRectangle(pos, size, angle, texture)
Method for drawing a rotated textured rectangle on screen, can only be called when a batch has been started.
| Name | Type | Description |
|---|---|---|
pos | glMatrix. | Top-left position of the rectangle. |
size | glMatrix. | Size of the rectangle. |
angle | number | Angle in radians with which the rectangle gets rotated around its center (pos[0] + (size[0] / 2), pos[1] + (size[1] / 2)). |
texture | HB. | HB.Texture instance to texture with. |
- Source
startBatch()
Method for starting a new rendering batch, is automatically called in HB.internalUpdate.
- Source
textureRectangle(pos, size, texture)
Method for drawing a textured rectangle on screen, can only be called when a batch has been started.
| Name | Type | Description |
|---|---|---|
pos | glMatrix. | Top-left position of the rectangle. |
size | glMatrix. | Size of the rectangle. |
texture | HB. | HB.Texture instance to texture with. |
- Source
(static) init()
(DO NOT USE) Internal method for creating the HB.renderer instance.
- Source