- Game Name
- N/A
- How long you been coding/hacking?
- 3 years / few months
Since these are pretty popular here's my version of corner boxes (corner boxes?) in opengl. If someone translates it to cpp consider posting it here aswell.
Code:
proc cornerBox(x, y, width, height: float, color, outlineColor: array[0..2, float32], lineWidth: float = 1) =
template drawCorner =
glBegin(GL_LINES)
# Lower Left
glVertex2f(x, y); glVertex2f(x + lineW, y)
glVertex2f(x, y); glVertex2f(x, y + lineH)
# Lower Right
glVertex2f(x + width, y); glVertex2f(x + width, y + lineH)
glVertex2f(x + width, y); glVertex2f(x + width - lineW, y)
# Upper Left
glVertex2f(x, y + height); glVertex2f(x, y + height - lineH)
glVertex2f(x, y + height); glVertex2f(x + lineW, y + height)
# Upper Right
glVertex2f(x + width, y + height); glVertex2f(x + width, y + height - lineH)
glVertex2f(x + width, y + height); glVertex2f(x + width - lineW, y + height)
glEnd()
let
lineW = width / 4
lineH = height / 3
glLineWidth(lineWidth + 2)
glColor3f(outlineColor[0], outlineColor[1], outlineColor[2])
drawCorner()
glLineWidth(lineWidth)
glColor3f(color[0], color[1], color[2])
drawCorner()
Last edited: