backend for all rendering purposes More...
#include <engine.h>
Public Member Functions | |
| engine (const uint32_t &x, const uint32_t &y) | |
| constructor and opengl draw surface initialization More... | |
| ~engine () | |
| destructor More... | |
| void | clear () |
| clear all drawing surface More... | |
| void | draw () |
| send framebuffer from cpu to gpu as texture to be able to render using opengl More... | |
| color | getcolor (const Vertex2 &v, Mesh *mesh) const |
| essentially a fragment shader : inputs fragment position and information and outputs color value for the fragment More... | |
| void | makeRequiredTriangles (const std::vector< Vertex > &vertices, const std::vector< uint32_t > &indices, const mat4f &modelmat) |
| fill triangles array by doing required clipping and culling More... | |
| void | setTime (float time) |
Public Attributes | |
| framebuffer * | fboCPU |
| uint32_t | vao |
| uint32_t | vbo |
| uint32_t | ibo |
| uint32_t | tex |
| uint32_t | shader |
| std::vector< std::tuple< std::array< Vertex2, 3 >, Mesh * > > | triangles |
| set of triangles to be drawn to screen More... | |
| float | nearPlane = 1.0f |
| nearplane of camera for clipping and culling More... | |
| bool | cullBackface = true |
| switch for backface culling More... | |
| Mesh * | currentMesh = nullptr |
| which material to use for further render calls More... | |
| float | ambientLightIntensity = 0.1f |
| lights. More... | |
| color | ambientLightColor = color(255) |
| dirLight | dirlight |
| std::vector< pointLight > | pointLights |
| camera * | cam = nullptr |
| camera More... | |
| bool | wireframe = false |
| float | lightRenderDistance = 0.05 |
| bool | printed = false |
Private Member Functions | |
| color | CalcDirLight (const vec3 &normal, const vec3 &viewdir, const color &col, const Material *material) const |
| function to calculate effect of directional light in a fragment with color col More... | |
| void | makeRequiredTrianglesHelper (std::array< Vertex, 3 > &points, const mat4f &modelmat, const mat4f &view, const mat4f &per) |
| void | putpixel_adjusted (int x, int y, float z, const color &col=color(255)) |
| putpixel assuming middle of screen to be the origin More... | |
| float | getpixelZ_adjusted (int x, int y) const |
| get z value of specified pixel from framebuffer More... | |
| void | draw_bresenham_adjusted (int x1, int y1, int x2, int y2, const color &col=color(0)) |
| bresenham line drawing function to draw wireframe of objects More... | |
| void | clip1 (const std::array< vec4, 3 > &tris, unsigned char which, float &u1, float &u2) const |
| void | clip2 (const std::array< vec4, 3 > &tris, unsigned char idx1, unsigned char idx2, unsigned char rem, float &u1, float &u2) const |
| void | clip2helper (const mat4f &per, const std::array< EXTRA_VERTEX_INFO, 3 > &extraInfoAboutVertex, const std::array< vec4, 3 > &modelviewTransformed, Vertex *points, unsigned char idx1, unsigned char idx2, unsigned char rem, std::array< Vertex2, 3 > &t) |
| clips and perspective transforms input triangle vertices if two points are out of clip space More... | |
| void | clip1helper (const mat4f &per, const std::array< EXTRA_VERTEX_INFO, 3 > &extraInfoAboutVertex, const std::array< vec4, 3 > &modelviewTransformed, Vertex *points, unsigned char idx1, std::array< Vertex2, 3 > &t, std::vector< std::tuple< std::array< Vertex2, 3 >, Mesh * > > &triangles) |
| clips and perspective transforms input triangle vertices if one point is out of the clip space More... | |
| void | fillBottomFlatTriangle (const Vertex2 &v0, const Vertex2 &v1, const Vertex2 &v2, Mesh *mesh) |
| rasterize BottomFlatTriangle: v2 is top unique and v1.x > v0.x More... | |
| void | fillTopFlatTriangle (const Vertex2 &v0, const Vertex2 &v1, const Vertex2 &v2, Mesh *mesh) |
| rasterize TopFlatTriangle: v0 is bottom unique and v2.x > v1.x More... | |
| void | calculateBarycentricCoordinates (const vec2 &p, const vec4 &v1, const vec4 &v2, const vec4 &v3, std::array< float, 3 > &values) |
| void | fillBottomFlatTriangleBary (const Vertex2 &v0, const Vertex2 &v1, const Vertex2 &v2, Mesh *mesh) |
| rasterize BottomFlatTriangle: v2 is top unique and v1.x > v0.x More... | |
| void | fillTopFlatTriangleBary (const Vertex2 &v0, const Vertex2 &v1, const Vertex2 &v2, Mesh *mesh) |
| void | rasterizeTrianglesHelper (std::tuple< std::array< Vertex2, 3 >, Mesh * > &tris) |
| void | rasterizeTriangles () |
| helper function to rasterize triangles in vector of triangles. More... | |
Static Private Member Functions | |
| static float | max (const float &first, const float &second) |
| static vec3 | reflect (const vec3 &I, const vec3 &N) |
| static color | CalcPointLight (const pointLight &light, const vec3 &normal, const vec3 &fragPos, const vec3 &viewDir, const color &diffuseColor, float int_by_at, const Material *material) |
| function to calculate effect of a point light in a fragment with color col More... | |
Private Attributes | |
| thread_pool | pool |
| const char * | vertexShaderSource |
| const char * | fragmentShaderSource |
| float | vertices [20] |
| uint32_t | indices [6] |
| std::unordered_map< uint8_t, float > | greenTimeMap = {{0, 0}, {1, 0.1}, {2, 0.3}, {3, 0.3}, {4, 0.35}, {5, 0.4}, {6, 0.5}, {7, 0.55}, {8, 0.6}, {9, 1}, {10, 1}, {11, 1}, {12, 1}, {13, 1}, {14, 1}, {15, 1}, {16, 1}, {17, 0.8}, {18, 0.5}, {19, 0.4}, {20, 0.3}, {21, 0.25}, {22, 0.1}, {23, 0.06}, {24, 0}} |
| std::unordered_map< uint8_t, float > | blueTimeMap = {{0, 0}, {1, 0}, {2, 0}, {3, 0.05}, {4, 0.06}, {5, 0.1}, {6, 0.15}, {7, 0.25}, {8, 0.35}, {9, 0.75}, {10, 0.8}, {11, 1}, {12, 1}, {13, 1}, {14, 1}, {15, 1}, {16, 0.8}, {17, 0.6}, {18, 0.4}, {19, 0.1}, {20, 0.01}, {21, 0}, {22, 0}, {23, 0}, {24, 0}} |
| std::mutex | fboCPUMutex |
|
inline |
|
inlineprivate |
|
inlineprivate |
|
inlineprivate |
|
inlineprivate |
|
inline |
|
inlineprivate |
|
inlinestaticprivate |
|
inlineprivate |
|
private |
| bool engine::cullBackface = true |
| Mesh* engine::currentMesh = nullptr |
| framebuffer* engine::fboCPU |
|
private |
|
private |
|
private |
| float engine::nearPlane = 1.0f |
| std::vector<pointLight> engine::pointLights |
|
private |
|
private |
|
private |