Class Context¶
Defined in File context.hpp
Class Documentation¶
-
class
nyx
::
Context
¶ Context is how everything in Nyx is drawn. Contexts have multiple methods that are used to draw things, including primitives and textures. Each context has persistent state, meaning that when objects are added to them, they are kept buffered in OpenGL until the
clear()
method is called. This allows incredibly fast rendering as scenes don’t need to be redrawn every frame.Public Functions
-
Context
()¶ Create a new Context, should not be used directly, instead ask a Window to create a context for you.
-
~Context
()¶
-
void
clear
()¶ Reset the state of the context, clearing the OpenGL buffers and all objects this Context currently draws to the screen.
-
void
pixel
(float x, float y, Color color)¶ Draw a pixel at (x, y) using the specified Color.
- Parameters
x
: x coordinate of the pixely
: y coordinate of the pixelcolor
: the color to draw the pixel with
-
void
line
(float x1, float y1, float x2, float y2, Color color)¶ Draw a line from the point (x1, y1) to (x2, y2) using the specified Color.
- Parameters
x1
: x coordinate of first pointy1
: y coordinate of first pointx2
: x coordinate of second pointy2
: y coordinate of second pointcolor
: the color to draw the line with
-
void
triangle
(float x1, float y1, float x2, float y2, float x3, float y3, float angle, Color color)¶ Draw a triangle with the points (x1, y1), (x2, y2), and (x3, y3), rotated at angle, using the specified color.
- Parameters
x1
: x coordinate of first pointy1
: y coordinate of first pointx2
: x coordinate of second pointy2
: y coordinate of second pointx3
: x coordinate of third pointy3
: y coordinate of third pointangle
: angle in degreescolor
: the color to draw the triangle with
-
void
triangle
(float x1, float y1, float x2, float y2, float x3, float y3, Color color)¶ Draw a triangle with the points (x1, y1), (x2, y2), and (x3, y3) using the specified color.
- Parameters
x1
: x coordinate of first pointy1
: y coordinate of first pointx2
: x coordinate of second pointy2
: y coordinate of second pointx3
: x coordinate of third pointy3
: y coordinate of third pointcolor
: the color to draw the triangle with
-
void
rectangle
(float x, float y, float w, float h, float angle, Color color)¶ Draw a rectangle at (x, y) with a size of (w, h), rotated at angle, using the specified color.
- Parameters
x
: the x coordinatey
: the y coordinatew
: the widthh
: the heightangle
: angle in degreescolor
: the color to draw the rectangle with
-
void
rectangle
(float x, float y, float w, float h, Color color)¶ Draw a rectangle at (x, y) with a size of (w, h), using the specified color.
- Parameters
x
: the x coordinatey
: the y coordinatew
: the widthh
: the heightcolor
: the color to draw the rectangle with
-
void
asset
(std::string const &name, std::string const &path, Color mask, bool retro = false)¶ Load an asset (texture)
- Parameters
name
: the name to give the assetpath
: the path to the assetmask
: the color mask to use with the assetretro
: if true, use nearest-neighbor filtering
-
void
asset
(std::string const &name, std::string const &path, bool retro = false)¶ Load an asset (texture), using color mask 0xff00ffff (magenta)
- Parameters
name
: the name to give the assetpath
: the path to the assetretro
: if true, use nearest-neighbor filtering
-
void
texture
(std::string const &path, float x, float y, Color color = Color(0xffffffff))¶ Draw a texture at full size at (x, y)
- Parameters
path
: the name of the texturex
: the x coordinatey
: the y coordinatecolor
: the color to multiply into the texture
-
void
texture
(std::string const &path, float x, float y, float angle, Color color = Color(0xffffffff))¶ Draw a texture at full size at (x, y) at an angle.
- Parameters
path
: the name of the texturex
: the x coordinatey
: the y coordinateangle
: angle in degreescolor
: the color to multiply into the texture
-
void
texture
(std::string const &path, float x, float y, float w, float h, Color color = Color(0xffffffff))¶ Draw a texture at (x, y) with size (w, h)
- Parameters
path
: the name of the texturex
: the x coordinatey
: the y coordinatew
: the width to scale toh
: the height to scale tocolor
: the color to multiply into the texture
-
void
texture
(std::string const &path, float x, float y, float w, float h, float angle, Color color = Color(0xffffffff))¶ Draw a texture at (x, y) with size (w, h) at an angle.
- Parameters
path
: the name of the texturex
: the x coordinatey
: the y coordinatew
: the width to scale toh
: the height to scale toangle
: angle in degreescolor
: the color to multiply into the texture
-
void
texture
(std::string const &path, float x, float y, float sx, float sy, float sw, float sh, Color color = Color(0xffffffff))¶ Draw a portion of a texture at (x, y), using the portion at (sx, sy) with a size of (sw, sh)
- Parameters
path
: the name of the texturex
: the x coordinatey
: the y coordinatesx
: the source xsy
: the source ysw
: the source widthsh
: the source heightcolor
: the color to multiply into the texture
-
void
texture
(std::string const &path, float x, float y, float sx, float sy, float sw, float sh, float angle, Color color = Color(0xffffffff))¶ Draw a portion of a texture at (x, y), using the portion at (sx, sy) with a size of (sw, sh), at an angle.
- Parameters
path
: the name of the texturex
: the x coordinatey
: the y coordinatesx
: the source xsy
: the source ysw
: the source widthsh
: the source heightangle
: angle in degreescolor
: the color to multiply into the texture
-
void
texture
(std::string const &path, float x, float y, float w, float h, float sx, float sy, float sw, float sh, Color color = Color(0xffffffff))¶ Draw a portion of a texture at (x, y) with a size of (w, h), using the portion at (sx, sy) with a size of (sw, sh)
- Parameters
path
: the name of the texturex
: the x coordinatey
: the y coordinatew
: the width to scale toh
: the height to scale tosx
: the source xsy
: the source ysw
: the source widthsh
: the source heightcolor
: the color to multiply into the texture
-
void
texture
(std::string const &path, float x, float y, float w, float h, float sx, float sy, float sw, float sh, float angle, Color color = Color(0xffffffff))¶ Draw a portion of a texture at (x, y) with a size of (w, h), using the portion at (sx, sy) with a size of (sw, sh), at an angle.
- Parameters
path
: the name of the texturex
: the x coordinatey
: the y coordinatew
: the width to scale toh
: the height to scale tosx
: the source xsy
: the source ysw
: the source widthsh
: the source heightangle
: angle in degreescolor
: the color to multiply into the texture
-