GrooveStomp's 3D Software Renderer  0.1.0
Macros | Functions
graphics.h File Reference
#include "SDL2/SDL.h"
Include dependency graph for graphics.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define GRAPHICS_VERSION   "0.1.0"
 include guard
 

Functions

struct graphicsGraphicsInit (char *title, int width, int height, int scale)
 Creates and initializes a new graphics object isntance. More...
 
void GraphicsDeinit (struct graphics *graphics)
 De-initializes and frees memory for the given graphics object. More...
 
void GraphicsBegin (struct graphics *graphics)
 Initializes the graphics subsystem for drawing routines. More...
 
void GraphicsEnd (struct graphics *graphics)
 Prepares the graphics subsystem for presentation, then presents. More...
 
void GraphicsClearScreen (struct graphics *graphics, unsigned int color)
 Sets all pixels in the screen to the given color. More...
 
void GraphicsTriangleWireframe (struct graphics *graphics, struct triangle triangle, unsigned int color)
 Draw a triangle with the given set of x and y coordinates. More...
 
void GraphicsTriangleSolid (struct graphics *graphics, struct triangle triangle, unsigned int color)
 Draw a triangle with the given set of x and y coordinates. More...
 
void GraphicsTriangleTextured (struct graphics *graphics, struct triangle tri, struct texture *texture)
 Draw a textured triangle with the given set of x and y coordinates. More...
 

Detailed Description

Drawing interface to the operating system.

Function Documentation

◆ GraphicsBegin()

void GraphicsBegin ( struct graphics graphics)

Initializes the graphics subsystem for drawing routines.

Internally locks streaming texture for direct manipulation.

Parameters
[in,out]graphicsGraphics state to be manipulated

◆ GraphicsClearScreen()

void GraphicsClearScreen ( struct graphics graphics,
unsigned int  color 
)

Sets all pixels in the screen to the given color.

Parameters
[in,out]graphicsGraphics state to be manipulated
[in]color32-bit color with 8-bits per component: (R,G,B,A)

◆ GraphicsDeinit()

void GraphicsDeinit ( struct graphics graphics)

De-initializes and frees memory for the given graphics object.

Parameters
[in,out]graphicsThe initialized opcode object to be cleaned and reclaimed

◆ GraphicsEnd()

void GraphicsEnd ( struct graphics graphics)

Prepares the graphics subsystem for presentation, then presents.

Internally unlocks streaming texture then calls presentation routines.

Parameters
[in,out]graphicsGraphics state to be manipulated.

◆ GraphicsInit()

struct graphics* GraphicsInit ( char *  title,
int  width,
int  height,
int  scale 
)

Creates and initializes a new graphics object isntance.

Scale can be specified as a non-negative number. This value is used to multiply both the width and the height and the pixel size of any drawing operations.

For example, specifying a scale of 2 would multiply the width by 2, the height by 2, and every pixel would be 2x2; so the total scale factor ends up being scale^2

Parameters
[in]titleThe title displayed in the window titlebar
[in]widthWidth of the display area of the window, in pixels
[in]heightHeight of the display are of the window, in pixels
[in]scaleSize and rendering scale, natural number multiple
Returns
The initialized graphics object

◆ GraphicsTriangleSolid()

void GraphicsTriangleSolid ( struct graphics graphics,
struct triangle  triangle,
unsigned int  color 
)

Draw a triangle with the given set of x and y coordinates.

Fills the specified polygon with the given color.

Parameters
[in,out]graphicsGraphics state to be changed
[in]triangleThe triangle to draw
[in]colorWhat color the solid triangle should be rendered with
See also
Source: http://www.sunshine2k.de/coding/java/TriangleRasterization/TriangleRasterization.html

◆ GraphicsTriangleTextured()

void GraphicsTriangleTextured ( struct graphics graphics,
struct triangle  tri,
struct texture texture 
)

Draw a textured triangle with the given set of x and y coordinates.

Fills the specified polygon with the given texture.

Parameters
[in,out]graphicsGraphics state to be changed
[in]triThe triangle to draw
[in]textureWhat texture to sample while drawing the solid triangle
See also
Source: https://github.com/OneLoneCoder/videos/blob/master/OneLoneCoder_olcEngine3D_Part4.cpp

◆ GraphicsTriangleWireframe()

void GraphicsTriangleWireframe ( struct graphics graphics,
struct triangle  triangle,
unsigned int  color 
)

Draw a triangle with the given set of x and y coordinates.

Only draws the lines, doesn't fill the polygon.

Parameters
[in,out]graphicsGraphics state to be changed
[in]triangleThe triangle to draw
[in]colorWhat color the wireframe should be rendered with