lovr/src/graphics/graphics.c

920 lines
29 KiB
C
Raw Normal View History

2016-11-19 09:28:01 +00:00
#include "graphics/graphics.h"
2017-12-10 20:31:50 +00:00
#include "resources/shaders.h"
2018-01-22 16:28:33 +00:00
#include "data/rasterizer.h"
#include "event/event.h"
#include "filesystem/filesystem.h"
2016-11-19 09:28:01 +00:00
#include "util.h"
2018-07-17 06:51:11 +00:00
#include "lib/glfw.h"
#include "lib/math.h"
2017-08-10 03:02:02 +00:00
#include "lib/stb/stb_image.h"
2016-09-27 07:24:28 +00:00
#define _USE_MATH_DEFINES
2016-07-16 05:39:17 +00:00
#include <stdlib.h>
2018-07-04 20:51:35 +00:00
#include <string.h>
2016-09-27 07:24:28 +00:00
#include <math.h>
2016-09-14 00:02:23 +00:00
#ifdef LOVR_USE_OCULUS_MOBILE
#include <EGL/egl.h>
#include <EGL/eglext.h>
#endif
2016-09-27 06:48:09 +00:00
static GraphicsState state;
2016-07-07 07:04:24 +00:00
#ifndef NO_WINDOW
static void onCloseWindow(GLFWwindow* window) {
if (window == state.window) {
2018-07-26 20:40:15 +00:00
lovrEventPush((Event) { .type = EVENT_QUIT, .data.quit = { false, 0 } });
}
}
#endif
static void onResizeWindow(GLFWwindow* window, int width, int height) {
if (window == state.window) {
state.width = width;
state.height = height;
2017-11-26 01:57:59 +00:00
}
}
2016-11-23 05:16:13 +00:00
// Base
void lovrGraphicsInit(bool gammaCorrect) {
state.gammaCorrect = gammaCorrect;
2016-09-28 03:20:08 +00:00
}
void lovrGraphicsDestroy() {
if (!state.initialized) return;
2018-07-17 22:04:34 +00:00
while (state.pipeline > 0) {
lovrGraphicsPopPipeline();
2017-08-09 04:02:28 +00:00
}
2017-08-09 05:39:00 +00:00
lovrGraphicsSetShader(NULL);
2017-08-09 00:53:03 +00:00
lovrGraphicsSetFont(NULL);
2018-08-27 04:36:07 +00:00
lovrGraphicsSetCanvas(NULL);
2018-07-17 06:51:11 +00:00
for (int i = 0; i < MAX_DEFAULT_SHADERS; i++) {
2018-02-26 08:59:03 +00:00
lovrRelease(state.defaultShaders[i]);
}
2018-02-26 08:59:03 +00:00
lovrRelease(state.defaultMaterial);
lovrRelease(state.defaultFont);
2018-07-17 06:51:11 +00:00
lovrRelease(state.defaultMesh);
2018-07-17 10:35:01 +00:00
lovrGpuDestroy();
memset(&state, 0, sizeof(GraphicsState));
2016-07-07 07:04:24 +00:00
}
2016-08-10 06:28:17 +00:00
void lovrGraphicsPresent() {
#ifndef NO_WINDOW
glfwSwapBuffers(state.window);
#endif
2018-07-17 10:35:01 +00:00
lovrGpuPresent();
2016-07-07 07:04:24 +00:00
}
2017-10-31 08:14:09 +00:00
void lovrGraphicsCreateWindow(int w, int h, bool fullscreen, int msaa, const char* title, const char* icon) {
lovrAssert(!state.window && !state.initialized, "Window is already created");
#ifndef NO_WINDOW
2018-02-23 09:28:42 +00:00
if ((state.window = glfwGetCurrentContext()) == NULL) {
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GLFW_TRUE);
2018-02-23 09:28:42 +00:00
glfwWindowHint(GLFW_SAMPLES, msaa);
glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE);
2018-02-23 09:28:42 +00:00
glfwWindowHint(GLFW_SRGB_CAPABLE, state.gammaCorrect);
2017-08-10 03:02:02 +00:00
2018-02-23 09:28:42 +00:00
GLFWmonitor* monitor = glfwGetPrimaryMonitor();
const GLFWvidmode* mode = glfwGetVideoMode(monitor);
if (fullscreen) {
glfwWindowHint(GLFW_RED_BITS, mode->redBits);
glfwWindowHint(GLFW_GREEN_BITS, mode->greenBits);
glfwWindowHint(GLFW_BLUE_BITS, mode->blueBits);
glfwWindowHint(GLFW_REFRESH_RATE, mode->refreshRate);
}
2018-02-23 09:28:42 +00:00
state.window = glfwCreateWindow(w ? w : mode->width, h ? h : mode->height, title, fullscreen ? monitor : NULL, NULL);
if (!state.window) {
glfwTerminate();
lovrThrow("Could not create window");
}
2018-02-12 03:16:40 +00:00
2018-02-23 09:28:42 +00:00
if (icon) {
GLFWimage image;
size_t size;
lovrAssert(lovrFilesystemIsFile(icon), "Could not read icon from %s", icon);
void* data = lovrFilesystemRead(icon, &size);
lovrAssert(data, "Could not read icon from %s", icon);
image.pixels = stbi_load_from_memory(data, size, &image.width, &image.height, NULL, 4);
lovrAssert(image.pixels, "Could not read icon from %s", icon);
2018-02-23 09:28:42 +00:00
glfwSetWindowIcon(state.window, 1, &image);
free(image.pixels);
free(data);
2018-02-23 09:28:42 +00:00
}
2017-10-21 21:32:41 +00:00
2018-02-23 09:28:42 +00:00
glfwMakeContextCurrent(state.window);
glfwSetWindowCloseCallback(state.window, onCloseWindow);
glfwSetWindowSizeCallback(state.window, onResizeWindow);
2017-10-21 21:32:41 +00:00
}
#endif
2017-10-21 21:32:41 +00:00
#if !(defined(EMSCRIPTEN) || defined(LOVR_USE_OCULUS_MOBILE))
2017-08-10 03:02:02 +00:00
glfwSwapInterval(0);
#endif
2018-08-29 06:05:09 +00:00
glfwGetFramebufferSize(state.window, &state.width, &state.height);
#if LOVR_USE_OCULUS_MOBILE
getGpuProcProc getProcAddress = eglGetProcAddress;
#else
getGpuProcProc getProcAddress = glfwGetProcAddress;
#endif
lovrGpuInit(state.gammaCorrect, getProcAddress);
2018-03-22 05:03:03 +00:00
VertexFormat format;
vertexFormatInit(&format);
vertexFormatAppend(&format, "lovrPosition", ATTR_FLOAT, 3);
vertexFormatAppend(&format, "lovrNormal", ATTR_FLOAT, 3);
vertexFormatAppend(&format, "lovrTexCoord", ATTR_FLOAT, 2);
state.defaultMesh = lovrMeshCreate(64, format, MESH_TRIANGLES, USAGE_STREAM);
2017-08-10 03:02:02 +00:00
lovrGraphicsReset();
state.initialized = true;
2016-09-24 03:58:56 +00:00
}
2018-08-29 06:05:09 +00:00
int lovrGraphicsGetWidth() {
return state.width;
}
2018-08-29 06:05:09 +00:00
int lovrGraphicsGetHeight() {
return state.height;
2018-07-17 21:53:21 +00:00
}
2017-08-10 03:02:02 +00:00
2018-07-17 06:51:11 +00:00
void lovrGraphicsSetCamera(Camera* camera, bool clear) {
2018-08-29 19:40:19 +00:00
if (state.camera.canvas && (!camera || camera->canvas != state.camera.canvas)) {
lovrCanvasResolve(state.camera.canvas);
2017-08-10 03:02:02 +00:00
}
2018-07-17 06:51:11 +00:00
if (!camera) {
state.camera.canvas = NULL;
state.camera.stereo = false;
2018-08-27 04:36:07 +00:00
for (int i = 0; i < 2; i++) {
mat4_identity(state.camera.viewMatrix[i]);
2018-08-29 06:05:09 +00:00
mat4_perspective(state.camera.projection[i], .01f, 100.f, 67 * M_PI / 180., (float) state.width / state.height);
2018-08-27 04:36:07 +00:00
}
2018-07-17 06:51:11 +00:00
} else {
state.camera = *camera;
2017-08-10 03:02:02 +00:00
}
2018-07-17 06:51:11 +00:00
if (clear) {
Color backgroundColor = lovrGraphicsGetBackgroundColor();
2018-08-20 03:48:45 +00:00
lovrGpuClear(state.camera.canvas, &backgroundColor, &(float) { 1. }, &(int) { 0 });
2017-08-10 03:02:02 +00:00
}
2018-07-17 06:51:11 +00:00
}
2017-08-10 03:02:02 +00:00
2016-11-23 05:16:13 +00:00
// State
2017-08-10 03:02:02 +00:00
2018-07-16 00:05:06 +00:00
void lovrGraphicsReset() {
2018-07-17 22:04:34 +00:00
while (state.pipeline > 0) {
lovrGraphicsPopPipeline();
}
2018-07-16 00:05:06 +00:00
state.transform = 0;
2018-07-17 06:51:11 +00:00
lovrGraphicsSetCamera(NULL, false);
lovrGraphicsSetBackgroundColor((Color) { 0, 0, 0, 1 });
2018-07-16 00:05:06 +00:00
lovrGraphicsSetBlendMode(BLEND_ALPHA, BLEND_ALPHA_MULTIPLY);
2018-08-27 04:36:07 +00:00
lovrGraphicsSetCanvas(NULL);
2018-07-17 06:51:11 +00:00
lovrGraphicsSetColor((Color) { 1, 1, 1, 1 });
2018-07-16 00:05:06 +00:00
lovrGraphicsSetCullingEnabled(false);
lovrGraphicsSetDefaultFilter((TextureFilter) { .mode = FILTER_TRILINEAR });
lovrGraphicsSetDepthTest(COMPARE_LEQUAL, true);
lovrGraphicsSetFont(NULL);
lovrGraphicsSetLineWidth(1);
lovrGraphicsSetPointSize(1);
lovrGraphicsSetShader(NULL);
lovrGraphicsSetStencilTest(COMPARE_NONE, 0);
lovrGraphicsSetWinding(WINDING_COUNTERCLOCKWISE);
lovrGraphicsSetWireframe(false);
lovrGraphicsOrigin();
2017-08-10 03:02:02 +00:00
}
2018-07-17 06:51:11 +00:00
void lovrGraphicsPushPipeline() {
lovrAssert(++state.pipeline < MAX_PIPELINES, "Unbalanced pipeline stack (more pushes than pops?)");
memcpy(&state.pipelines[state.pipeline], &state.pipelines[state.pipeline - 1], sizeof(Pipeline));
lovrRetain(state.pipelines[state.pipeline].canvas);
2018-07-17 22:04:34 +00:00
lovrRetain(state.pipelines[state.pipeline].font);
lovrRetain(state.pipelines[state.pipeline].shader);
2017-08-10 03:02:02 +00:00
}
2018-07-17 06:51:11 +00:00
void lovrGraphicsPopPipeline() {
lovrRelease(state.pipelines[state.pipeline].canvas);
2018-07-17 22:04:34 +00:00
lovrRelease(state.pipelines[state.pipeline].font);
lovrRelease(state.pipelines[state.pipeline].shader);
2018-07-17 06:51:11 +00:00
lovrAssert(--state.pipeline >= 0, "Unbalanced pipeline stack (more pops than pushes?)");
2017-08-10 03:02:02 +00:00
}
2017-08-02 08:25:56 +00:00
Color lovrGraphicsGetBackgroundColor() {
return state.pipelines[state.pipeline].backgroundColor;
2016-07-28 02:48:59 +00:00
}
2017-08-02 08:25:56 +00:00
void lovrGraphicsSetBackgroundColor(Color color) {
state.pipelines[state.pipeline].backgroundColor = color;
2016-07-28 02:48:59 +00:00
}
2017-03-12 11:03:36 +00:00
void lovrGraphicsGetBlendMode(BlendMode* mode, BlendAlphaMode* alphaMode) {
*mode = state.pipelines[state.pipeline].blendMode;
*alphaMode = state.pipelines[state.pipeline].blendAlphaMode;
2017-03-12 11:03:36 +00:00
}
void lovrGraphicsSetBlendMode(BlendMode mode, BlendAlphaMode alphaMode) {
state.pipelines[state.pipeline].blendMode = mode;
state.pipelines[state.pipeline].blendAlphaMode = alphaMode;
2017-03-12 11:03:36 +00:00
}
Canvas* lovrGraphicsGetCanvas() {
return state.pipelines[state.pipeline].canvas;
}
2017-03-12 11:03:36 +00:00
void lovrGraphicsSetCanvas(Canvas* canvas) {
2018-08-29 19:40:19 +00:00
if (state.pipelines[state.pipeline].canvas) {
lovrCanvasResolve(state.pipelines[state.pipeline].canvas);
2017-03-12 11:03:36 +00:00
}
2018-08-29 19:40:19 +00:00
state.pipelines[state.pipeline].canvas = canvas;
2017-03-12 11:03:36 +00:00
}
2017-08-02 08:25:56 +00:00
Color lovrGraphicsGetColor() {
return state.pipelines[state.pipeline].color;
2016-09-29 03:11:58 +00:00
}
2017-08-02 08:25:56 +00:00
void lovrGraphicsSetColor(Color color) {
state.pipelines[state.pipeline].color = color;
2016-09-29 03:11:58 +00:00
}
2017-10-31 08:14:09 +00:00
bool lovrGraphicsIsCullingEnabled() {
return state.pipelines[state.pipeline].culling;
2016-09-14 00:02:23 +00:00
}
2017-10-31 08:14:09 +00:00
void lovrGraphicsSetCullingEnabled(bool culling) {
state.pipelines[state.pipeline].culling = culling;
2016-07-16 02:17:27 +00:00
}
2017-08-02 07:54:33 +00:00
TextureFilter lovrGraphicsGetDefaultFilter() {
return state.defaultFilter;
2017-02-03 23:16:30 +00:00
}
2017-08-02 07:54:33 +00:00
void lovrGraphicsSetDefaultFilter(TextureFilter filter) {
state.defaultFilter = filter;
2017-02-03 23:16:30 +00:00
}
2018-02-09 05:50:47 +00:00
void lovrGraphicsGetDepthTest(CompareMode* mode, bool* write) {
*mode = state.pipelines[state.pipeline].depthTest;
*write = state.pipelines[state.pipeline].depthWrite;
2017-02-17 08:48:43 +00:00
}
2018-07-05 03:11:52 +00:00
void lovrGraphicsSetDepthTest(CompareMode mode, bool write) {
state.pipelines[state.pipeline].depthTest = mode;
state.pipelines[state.pipeline].depthWrite = write;
2016-11-27 02:58:58 +00:00
}
2017-08-08 08:36:29 +00:00
Font* lovrGraphicsGetFont() {
if (!state.pipelines[state.pipeline].font) {
2017-08-09 06:49:17 +00:00
if (!state.defaultFont) {
2018-01-22 16:28:33 +00:00
Rasterizer* rasterizer = lovrRasterizerCreate(NULL, 32);
state.defaultFont = lovrFontCreate(rasterizer);
lovrRelease(rasterizer);
2017-08-09 06:49:17 +00:00
}
2017-08-08 08:36:29 +00:00
lovrGraphicsSetFont(state.defaultFont);
}
return state.pipelines[state.pipeline].font;
2017-08-08 08:36:29 +00:00
}
void lovrGraphicsSetFont(Font* font) {
2018-02-26 08:59:03 +00:00
lovrRetain(font);
lovrRelease(state.pipelines[state.pipeline].font);
state.pipelines[state.pipeline].font = font;
2017-08-08 08:36:29 +00:00
}
bool lovrGraphicsIsGammaCorrect() {
return state.gammaCorrect;
}
2016-10-01 20:48:31 +00:00
float lovrGraphicsGetLineWidth() {
return state.pipelines[state.pipeline].lineWidth;
2016-10-01 20:48:31 +00:00
}
void lovrGraphicsSetLineWidth(float width) {
state.pipelines[state.pipeline].lineWidth = width;
2016-10-01 20:48:31 +00:00
}
2016-11-13 01:38:49 +00:00
float lovrGraphicsGetPointSize() {
return state.pipelines[state.pipeline].pointSize;
2016-11-13 01:38:49 +00:00
}
void lovrGraphicsSetPointSize(float size) {
state.pipelines[state.pipeline].pointSize = size;
2016-11-13 01:38:49 +00:00
}
2017-08-08 08:32:15 +00:00
Shader* lovrGraphicsGetShader() {
return state.pipelines[state.pipeline].shader;
2017-08-08 08:32:15 +00:00
}
void lovrGraphicsSetShader(Shader* shader) {
2018-08-09 01:07:48 +00:00
lovrAssert(!shader || lovrShaderGetType(shader) == SHADER_GRAPHICS, "Compute shaders can not be set as the active shader");
2018-07-17 06:51:11 +00:00
lovrRetain(shader);
lovrRelease(state.pipelines[state.pipeline].shader);
state.pipelines[state.pipeline].shader = shader;
2017-08-08 08:32:15 +00:00
}
void lovrGraphicsGetStencilTest(CompareMode* mode, int* value) {
*mode = state.pipelines[state.pipeline].stencilMode;
*value = state.pipelines[state.pipeline].stencilValue;
}
void lovrGraphicsSetStencilTest(CompareMode mode, int value) {
state.pipelines[state.pipeline].stencilMode = mode;
state.pipelines[state.pipeline].stencilValue = value;
}
2017-08-02 07:54:33 +00:00
Winding lovrGraphicsGetWinding() {
return state.pipelines[state.pipeline].winding;
2016-10-03 19:02:49 +00:00
}
2017-08-02 07:54:33 +00:00
void lovrGraphicsSetWinding(Winding winding) {
state.pipelines[state.pipeline].winding = winding;
2016-10-03 19:02:49 +00:00
}
2017-10-31 08:14:09 +00:00
bool lovrGraphicsIsWireframe() {
return state.pipelines[state.pipeline].wireframe;
2016-10-03 19:02:49 +00:00
}
2017-10-31 08:14:09 +00:00
void lovrGraphicsSetWireframe(bool wireframe) {
2017-08-02 07:54:33 +00:00
#ifndef EMSCRIPTEN
state.pipelines[state.pipeline].wireframe = wireframe;
2017-08-02 07:54:33 +00:00
#endif
2016-10-03 19:02:49 +00:00
}
2016-11-23 05:16:13 +00:00
// Transforms
void lovrGraphicsPush() {
2018-07-17 06:51:11 +00:00
lovrAssert(++state.transform < MAX_TRANSFORMS, "Unbalanced matrix stack (more pushes than pops?)");
mat4_init(state.transforms[state.transform], state.transforms[state.transform - 1]);
2016-09-21 07:55:53 +00:00
}
void lovrGraphicsPop() {
2018-07-17 06:51:11 +00:00
lovrAssert(--state.transform >= 0, "Unbalanced matrix stack (more pops than pushes?)");
2016-09-21 07:55:53 +00:00
}
2016-09-21 22:26:05 +00:00
void lovrGraphicsOrigin() {
2018-03-05 07:06:34 +00:00
mat4_identity(state.transforms[state.transform]);
2016-09-21 22:26:05 +00:00
}
2018-03-05 07:06:34 +00:00
void lovrGraphicsTranslate(float x, float y, float z) {
mat4_translate(state.transforms[state.transform], x, y, z);
}
2018-03-05 07:06:34 +00:00
void lovrGraphicsRotate(float angle, float ax, float ay, float az) {
mat4_rotate(state.transforms[state.transform], angle, ax, ay, az);
}
2018-03-05 07:06:34 +00:00
void lovrGraphicsScale(float x, float y, float z) {
mat4_scale(state.transforms[state.transform], x, y, z);
}
2018-03-05 07:06:34 +00:00
void lovrGraphicsMatrixTransform(mat4 transform) {
mat4_multiply(state.transforms[state.transform], transform);
2016-09-29 07:21:38 +00:00
}
void lovrGraphicsSetProjection(mat4 projection) {
mat4_set(state.camera.projection[0], projection);
mat4_set(state.camera.projection[1], projection);
}
// Rendering
2018-03-22 05:03:03 +00:00
VertexPointer lovrGraphicsGetVertexPointer(uint32_t count) {
2018-07-17 06:51:11 +00:00
lovrMeshResize(state.defaultMesh, count);
return lovrMeshMapVertices(state.defaultMesh, 0, count, false, true);
2017-02-03 23:16:30 +00:00
}
2018-07-16 00:05:06 +00:00
void lovrGraphicsClear(Color* color, float* depth, int* stencil) {
2018-07-17 06:51:11 +00:00
Pipeline* pipeline = &state.pipelines[state.pipeline];
Canvas* canvas = pipeline->canvas ? pipeline->canvas : state.camera.canvas;
lovrGpuClear(canvas, color, depth, stencil);
2017-02-03 23:16:30 +00:00
}
2018-10-26 16:14:57 +00:00
void lovrGraphicsDiscard(bool color, bool depth, bool stencil) {
Pipeline* pipeline = &state.pipelines[state.pipeline];
Canvas* canvas = pipeline->canvas ? pipeline->canvas : state.camera.canvas;
lovrGpuDiscard(canvas, color, depth, stencil);
}
2018-08-31 13:03:35 +00:00
void lovrGraphicsDraw(DrawCommand* draw) {
2018-07-16 00:05:06 +00:00
Mesh* mesh = draw->mesh;
if (!mesh) {
int drawCount = draw->range.count ? draw->range.count : (draw->index.count ? draw->index.count : draw->vertex.count);
2018-07-17 06:51:11 +00:00
mesh = state.defaultMesh;
2018-07-16 00:05:06 +00:00
lovrMeshSetDrawMode(mesh, draw->mode);
lovrMeshSetDrawRange(mesh, draw->range.start, drawCount);
if (draw->vertex.count) {
VertexPointer vertexPointer = lovrGraphicsGetVertexPointer(draw->vertex.count);
memcpy(vertexPointer.raw, draw->vertex.data, draw->vertex.count * 8 * sizeof(float));
if (draw->index.count) {
IndexPointer indexPointer = lovrMeshWriteIndices(mesh, draw->index.count, sizeof(uint16_t));
memcpy(indexPointer.shorts, draw->index.data, draw->index.count * sizeof(uint16_t));
} else {
lovrMeshWriteIndices(mesh, 0, 0);
}
}
}
2018-08-31 13:03:35 +00:00
if (draw->transform) {
lovrGraphicsPush();
lovrGraphicsMatrixTransform(draw->transform);
}
2018-07-16 00:05:06 +00:00
2018-08-31 13:03:35 +00:00
Pipeline* pipeline = &state.pipelines[state.pipeline];
2018-07-17 06:51:11 +00:00
2018-08-31 13:03:35 +00:00
Canvas* canvas = pipeline->canvas ? pipeline->canvas : state.camera.canvas;
bool stereo = !draw->forceMono && (canvas ? lovrCanvasIsStereo(canvas) : state.camera.stereo);
float w = (canvas ? lovrCanvasGetWidth(canvas) : state.width) >> stereo;
float h = canvas ? lovrCanvasGetHeight(canvas) : state.height;
float viewports[2][4] = { { 0, 0, w, h, }, { w, 0, w, h } };
int viewportCount = 1 + stereo;
Material* material = draw->material ? draw->material : state.defaultMaterial;
if (!material) material = state.defaultMaterial = lovrMaterialCreate();
if (!draw->material) {
2018-07-16 00:05:06 +00:00
for (int i = 0; i < MAX_MATERIAL_TEXTURES; i++) {
lovrMaterialSetTexture(material, i, draw->textures[i]);
}
}
2018-08-31 13:03:35 +00:00
Shader* shader = pipeline->shader ? pipeline->shader : state.defaultShaders[draw->shader];
if (!shader) shader = state.defaultShaders[draw->shader] = lovrShaderCreateDefault(draw->shader);
2018-08-29 04:16:19 +00:00
2018-08-31 13:03:35 +00:00
mat4 transform = state.transforms[state.transform];
lovrShaderSetMatrices(shader, "lovrModel", transform, 0, 16);
lovrShaderSetMatrices(shader, "lovrViews", state.camera.viewMatrix[0], 0, 32);
lovrShaderSetMatrices(shader, "lovrProjections", state.camera.projection[0], 0, 32);
float modelView[32];
mat4_multiply(mat4_set(modelView, state.camera.viewMatrix[0]), transform);
mat4_multiply(mat4_set(modelView + 16, state.camera.viewMatrix[1]), transform);
lovrShaderSetMatrices(shader, "lovrTransforms", modelView, 0, 32);
if (lovrShaderHasUniform(shader, "lovrNormalMatrices")) {
if (mat4_invert(modelView) && mat4_invert(modelView + 16)) {
mat4_transpose(modelView);
mat4_transpose(modelView + 16);
} else {
mat4_identity(modelView);
mat4_identity(modelView + 16);
}
float normalMatrices[18] = {
modelView[0], modelView[1], modelView[2],
modelView[4], modelView[5], modelView[6],
modelView[8], modelView[9], modelView[10],
modelView[16], modelView[17], modelView[18],
modelView[20], modelView[21], modelView[22],
modelView[24], modelView[25], modelView[26]
};
lovrShaderSetMatrices(shader, "lovrNormalMatrices", normalMatrices, 0, 18);
2016-09-30 06:18:51 +00:00
}
2016-09-29 07:00:02 +00:00
2018-08-31 13:03:35 +00:00
float* pose = lovrMeshGetPose(mesh);
if (pose) {
lovrShaderSetMatrices(shader, "lovrPose", pose, 0, MAX_BONES * 16);
2017-01-13 09:59:00 +00:00
} else {
2018-10-07 04:58:40 +00:00
lovrShaderSetMatrices(shader, "lovrPose", (float[16]) MAT4_IDENTITY, 0, 16);
2018-08-31 13:03:35 +00:00
}
lovrShaderSetInts(shader, "lovrViewportCount", &viewportCount, 0, 1);
lovrShaderSetColor(shader, "lovrColor", pipeline->color);
lovrShaderSetFloats(shader, "lovrPointSize", &pipeline->pointSize, 0, 1);
for (int i = 0; i < MAX_MATERIAL_SCALARS; i++) {
float value = lovrMaterialGetScalar(material, i);
lovrShaderSetFloats(shader, lovrShaderScalarUniforms[i], &value, 0, 1);
}
for (int i = 0; i < MAX_MATERIAL_COLORS; i++) {
lovrShaderSetColor(shader, lovrShaderColorUniforms[i], lovrMaterialGetColor(material, i));
2017-01-13 09:59:00 +00:00
}
2018-08-31 13:03:35 +00:00
for (int i = 0; i < MAX_MATERIAL_TEXTURES; i++) {
Texture* texture = lovrMaterialGetTexture(material, i);
lovrShaderSetTextures(shader, lovrShaderTextureUniforms[i], &texture, 0, 1);
}
2017-11-21 05:16:16 +00:00
2018-08-31 13:03:35 +00:00
lovrShaderSetMatrices(shader, "lovrMaterialTransform", material->transform, 0, 9);
// Bind
lovrCanvasBind(canvas, true);
lovrGpuBindPipeline(pipeline);
lovrMeshBind(mesh, shader, viewportCount);
// Draw
if (lovrGpuGetSupported()->singlepass) {
int instances = MAX(draw->instances, 1) * viewportCount;
lovrGpuSetViewports(&viewports[0][0], viewportCount);
lovrShaderBind(shader);
lovrMeshDraw(mesh, instances);
2017-01-13 09:59:00 +00:00
} else {
2018-08-31 13:03:35 +00:00
for (int i = 0; i < viewportCount; i++) {
lovrGpuSetViewports(&viewports[i][0], 1);
lovrShaderSetInts(shader, "lovrViewportIndex", &i, 0, 1);
lovrShaderBind(shader);
lovrMeshDraw(mesh, draw->instances);
}
2017-01-13 09:59:00 +00:00
}
2016-09-30 02:39:25 +00:00
2018-08-31 13:03:35 +00:00
if (draw->transform) {
lovrGraphicsPop();
}
2016-11-08 07:16:33 +00:00
}
2018-03-22 05:03:03 +00:00
void lovrGraphicsPoints(uint32_t count) {
2018-08-31 13:03:35 +00:00
lovrGraphicsDraw(&(DrawCommand) {
2018-07-14 00:12:30 +00:00
.mode = MESH_POINTS,
.range = { 0, count }
});
2016-09-29 07:00:02 +00:00
}
2018-03-22 05:03:03 +00:00
void lovrGraphicsLine(uint32_t count) {
2018-08-31 13:03:35 +00:00
lovrGraphicsDraw(&(DrawCommand) {
2018-07-14 00:12:30 +00:00
.mode = MESH_LINE_STRIP,
.range = { 0, count }
});
2016-09-29 07:00:02 +00:00
}
2017-03-12 23:57:27 +00:00
2018-03-22 05:03:03 +00:00
void lovrGraphicsTriangle(DrawMode mode, Material* material, float points[9]) {
2016-11-23 04:43:22 +00:00
if (mode == DRAW_MODE_LINE) {
2018-08-31 13:03:35 +00:00
lovrGraphicsDraw(&(DrawCommand) {
2018-07-15 06:50:06 +00:00
.material = material,
2018-07-14 00:12:30 +00:00
.mode = MESH_LINE_LOOP,
.vertex.count = 3,
.vertex.data = (float[]) {
points[0], points[1], points[2], 0, 0, 0, 0, 0,
points[3], points[4], points[5], 0, 0, 0, 0, 0,
points[6], points[7], points[8], 0, 0, 0, 0, 0
}
});
2016-11-23 04:43:22 +00:00
} else {
2017-01-20 02:50:51 +00:00
float normal[3];
vec3_cross(vec3_init(normal, &points[0]), &points[3]);
2018-08-31 13:03:35 +00:00
lovrGraphicsDraw(&(DrawCommand) {
2018-07-15 06:50:06 +00:00
.material = material,
2018-07-14 00:12:30 +00:00
.mode = MESH_TRIANGLES,
.vertex.count = 3,
.vertex.data = (float[]) {
points[0], points[1], points[2], normal[0], normal[1], normal[2], 0, 0,
points[3], points[4], points[5], normal[0], normal[1], normal[2], 0, 0,
points[6], points[7], points[8], normal[0], normal[1], normal[2], 0, 0
}
});
2016-11-23 04:43:22 +00:00
}
}
void lovrGraphicsPlane(DrawMode mode, Material* material, mat4 transform) {
2016-10-04 03:56:45 +00:00
if (mode == DRAW_MODE_LINE) {
2018-08-31 13:03:35 +00:00
lovrGraphicsDraw(&(DrawCommand) {
2018-07-14 00:12:30 +00:00
.transform = transform,
.material = material,
.mode = MESH_LINE_LOOP,
.vertex.count = 4,
.vertex.data = (float[]) {
-.5, .5, 0, 0, 0, 0, 0, 0,
.5, .5, 0, 0, 0, 0, 0, 0,
.5, -.5, 0, 0, 0, 0, 0, 0,
-.5, -.5, 0, 0, 0, 0, 0, 0
}
});
2016-10-04 03:56:45 +00:00
} else if (mode == DRAW_MODE_FILL) {
2018-08-31 13:03:35 +00:00
lovrGraphicsDraw(&(DrawCommand) {
2018-07-14 00:12:30 +00:00
.transform = transform,
.material = material,
.mode = MESH_TRIANGLE_STRIP,
.vertex.count = 4,
.vertex.data = (float[]) {
-.5, .5, 0, 0, 0, -1, 0, 1,
-.5, -.5, 0, 0, 0, -1, 0, 0,
.5, .5, 0, 0, 0, -1, 1, 1,
.5, -.5, 0, 0, 0, -1, 1, 0
}
});
2016-10-04 03:56:45 +00:00
}
2017-01-13 09:59:00 +00:00
}
void lovrGraphicsBox(DrawMode mode, Material* material, mat4 transform) {
2016-10-01 19:53:15 +00:00
if (mode == DRAW_MODE_LINE) {
2018-08-31 13:03:35 +00:00
lovrGraphicsDraw(&(DrawCommand) {
2018-07-14 00:12:30 +00:00
.transform = transform,
.material = material,
.mode = MESH_LINES,
.vertex.count = 8,
.vertex.data = (float[]) {
// Front
-.5, .5, -.5, 0, 0, 0, 0, 0,
.5, .5, -.5, 0, 0, 0, 0, 0,
.5, -.5, -.5, 0, 0, 0, 0, 0,
-.5, -.5, -.5, 0, 0, 0, 0, 0,
// Back
-.5, .5, .5, 0, 0, 0, 0, 0,
.5, .5, .5, 0, 0, 0, 0, 0,
.5, -.5, .5, 0, 0, 0, 0, 0,
-.5, -.5, .5, 0, 0, 0, 0, 0
},
.index.count = 24,
.index.data = (uint16_t[]) {
0, 1, 1, 2, 2, 3, 3, 0, // Front
4, 5, 5, 6, 6, 7, 7, 4, // Back
0, 4, 1, 5, 2, 6, 3, 7 // Connections
}
});
2016-10-01 19:10:38 +00:00
} else {
2018-08-31 13:03:35 +00:00
lovrGraphicsDraw(&(DrawCommand) {
2018-07-14 00:12:30 +00:00
.transform = transform,
.material = material,
.mode = MESH_TRIANGLE_STRIP,
.vertex.count = 26,
.vertex.data = (float[]) {
// Front
-.5, -.5, -.5, 0, 0, -1, 0, 0,
-.5, .5, -.5, 0, 0, -1, 0, 1,
.5, -.5, -.5, 0, 0, -1, 1, 0,
.5, .5, -.5, 0, 0, -1, 1, 1,
// Right
.5, .5, -.5, 1, 0, 0, 0, 1,
.5, .5, .5, 1, 0, 0, 1, 1,
.5, -.5, -.5, 1, 0, 0, 0, 0,
.5, -.5, .5, 1, 0, 0, 1, 0,
// Back
.5, -.5, .5, 0, 0, 1, 0, 0,
.5, .5, .5, 0, 0, 1, 0, 1,
-.5, -.5, .5, 0, 0, 1, 1, 0,
-.5, .5, .5, 0, 0, 1, 1, 1,
// Left
-.5, .5, .5, -1, 0, 0, 0, 1,
-.5, .5, -.5, -1, 0, 0, 1, 1,
-.5, -.5, .5, -1, 0, 0, 0, 0,
-.5, -.5, -.5, -1, 0, 0, 1, 0,
// Bottom
-.5, -.5, -.5, 0, -1, 0, 0, 0,
.5, -.5, -.5, 0, -1, 0, 1, 0,
-.5, -.5, .5, 0, -1, 0, 0, 1,
.5, -.5, .5, 0, -1, 0, 1, 1,
// Adjust
.5, -.5, .5, 0, 1, 0, 0, 1,
-.5, .5, -.5, 0, 1, 0, 0, 1,
// Top
-.5, .5, -.5, 0, 1, 0, 0, 1,
-.5, .5, .5, 0, 1, 0, 0, 0,
.5, .5, -.5, 0, 1, 0, 1, 1,
.5, .5, .5, 0, 1, 0, 1, 0
}
});
2016-10-01 19:10:38 +00:00
}
2016-09-30 06:18:51 +00:00
}
2016-10-24 22:02:23 +00:00
void lovrGraphicsArc(DrawMode mode, ArcMode arcMode, Material* material, mat4 transform, float theta1, float theta2, int segments) {
2017-11-22 19:32:30 +00:00
if (fabsf(theta1 - theta2) >= 2 * M_PI) {
theta1 = 0;
theta2 = 2 * M_PI;
}
2018-03-22 05:03:03 +00:00
bool hasCenterPoint = arcMode == ARC_MODE_PIE && fabsf(theta1 - theta2) < 2 * M_PI;
uint32_t count = segments + 1 + hasCenterPoint;
VertexPointer vertices = lovrGraphicsGetVertexPointer(count);
2018-07-17 06:51:11 +00:00
lovrMeshWriteIndices(state.defaultMesh, 0, 0);
2017-11-22 19:32:30 +00:00
2018-03-22 05:03:03 +00:00
if (hasCenterPoint) {
memcpy(vertices.floats, ((float[]) { 0, 0, 0, 0, 0, 1, .5, .5 }), 8 * sizeof(float));
2018-07-14 00:12:30 +00:00
vertices.floats += 8;
2017-11-22 19:32:30 +00:00
}
float theta = theta1;
float angleShift = (theta2 - theta1) / (float) segments;
2018-03-22 05:03:03 +00:00
for (int i = 0; i <= segments; i++) {
float x = cos(theta) * .5;
float y = sin(theta) * .5;
memcpy(vertices.floats, ((float[]) { x, y, 0, 0, 0, 1, x + .5, 1 - (y + .5) }), 8 * sizeof(float));
2018-07-14 00:12:30 +00:00
vertices.floats += 8;
2018-03-22 05:03:03 +00:00
theta += angleShift;
2017-11-22 04:53:34 +00:00
}
2018-08-31 13:03:35 +00:00
lovrGraphicsDraw(&(DrawCommand) {
2018-07-14 00:12:30 +00:00
.transform = transform,
.material = material,
.mode = mode == DRAW_MODE_LINE ? (arcMode == ARC_MODE_OPEN ? MESH_LINE_STRIP : MESH_LINE_LOOP) : MESH_TRIANGLE_FAN,
.range = { 0, count }
});
2017-11-22 04:53:34 +00:00
}
void lovrGraphicsCircle(DrawMode mode, Material* material, mat4 transform, int segments) {
lovrGraphicsArc(mode, ARC_MODE_OPEN, material, transform, 0, 2 * M_PI, segments);
2017-11-22 19:32:30 +00:00
}
void lovrGraphicsCylinder(Material* material, float x1, float y1, float z1, float x2, float y2, float z2, float r1, float r2, bool capped, int segments) {
2017-06-21 03:54:22 +00:00
float axis[3] = { x1 - x2, y1 - y2, z1 - z2 };
float n[3] = { x1 - x2, y1 - y2, z1 - z2 };
float p[3];
float q[3];
2018-03-22 05:03:03 +00:00
uint32_t vertexCount = ((capped && r1) * (segments + 2) + (capped && r2) * (segments + 2) + 2 * (segments + 1));
uint32_t indexCount = 3 * segments * ((capped && r1) + (capped && r2) + 2);
2017-06-21 03:54:22 +00:00
2018-03-22 05:03:03 +00:00
VertexPointer vertices = lovrGraphicsGetVertexPointer(vertexCount);
2018-07-17 06:51:11 +00:00
IndexPointer indices = lovrMeshWriteIndices(state.defaultMesh, indexCount, sizeof(uint32_t));
2018-03-22 05:03:03 +00:00
float* baseVertex = vertices.floats;
2017-06-21 03:54:22 +00:00
vec3_init(p, n);
if (n[0] == 0 && n[2] == 0) {
p[0] += 1;
} else {
p[1] += 1;
}
vec3_init(q, p);
vec3_cross(q, n);
vec3_cross(n, q);
vec3_init(p, n);
vec3_normalize(p);
vec3_normalize(q);
vec3_normalize(axis);
#define PUSH_CYLINDER_VERTEX(x, y, z, nx, ny, nz) \
2018-03-22 05:03:03 +00:00
*vertices.floats++ = x; \
*vertices.floats++ = y; \
*vertices.floats++ = z; \
*vertices.floats++ = nx; \
*vertices.floats++ = ny; \
*vertices.floats++ = nz; \
*vertices.floats++ = 0; \
*vertices.floats++ = 0;
2017-06-21 03:54:22 +00:00
#define PUSH_CYLINDER_TRIANGLE(i1, i2, i3) \
2018-03-22 05:03:03 +00:00
*indices.ints++ = i1; \
*indices.ints++ = i2; \
*indices.ints++ = i3; \
2017-06-21 03:54:22 +00:00
// Ring
for (int i = 0; i <= segments; i++) {
float theta = i * (2 * M_PI) / segments;
n[0] = cos(theta) * p[0] + sin(theta) * q[0];
n[1] = cos(theta) * p[1] + sin(theta) * q[1];
n[2] = cos(theta) * p[2] + sin(theta) * q[2];
PUSH_CYLINDER_VERTEX(x1 + r1 * n[0], y1 + r1 * n[1], z1 + r1 * n[2], n[0], n[1], n[2]);
PUSH_CYLINDER_VERTEX(x2 + r2 * n[0], y2 + r2 * n[1], z2 + r2 * n[2], n[0], n[1], n[2]);
}
// Top
2018-03-22 05:03:03 +00:00
int topOffset = (segments + 1) * 2;
2017-06-21 03:54:22 +00:00
if (capped && r1 != 0) {
PUSH_CYLINDER_VERTEX(x1, y1, z1, axis[0], axis[1], axis[2]);
for (int i = 0; i <= segments; i++) {
2018-03-22 05:03:03 +00:00
int j = i * 2 * 8;
PUSH_CYLINDER_VERTEX(baseVertex[j + 0], baseVertex[j + 1], baseVertex[j + 2], axis[0], axis[1], axis[2]);
2017-06-21 03:54:22 +00:00
}
}
// Bottom
2018-03-22 05:03:03 +00:00
int bottomOffset = (segments + 1) * 2 + (1 + segments + 1) * (capped && r1 != 0);
2017-06-21 03:54:22 +00:00
if (capped && r2 != 0) {
2018-03-22 05:03:03 +00:00
PUSH_CYLINDER_VERTEX(x2, y2, z1, -axis[0], -axis[1], -axis[2]);
2017-06-21 03:54:22 +00:00
for (int i = 0; i <= segments; i++) {
2018-03-22 05:03:03 +00:00
int j = i * 2 * 8 + 8;
PUSH_CYLINDER_VERTEX(baseVertex[j + 0], baseVertex[j + 1], baseVertex[j + 2], -axis[0], -axis[1], -axis[2]);
2017-06-21 03:54:22 +00:00
}
}
// Indices
for (int i = 0; i < segments; i++) {
2018-03-22 05:03:03 +00:00
int j = 2 * i;
2017-06-21 03:54:22 +00:00
PUSH_CYLINDER_TRIANGLE(j, j + 1, j + 2);
PUSH_CYLINDER_TRIANGLE(j + 1, j + 3, j + 2);
if (capped && r1 != 0) {
PUSH_CYLINDER_TRIANGLE(topOffset, topOffset + i + 1, topOffset + i + 2);
}
if (capped && r2 != 0) {
PUSH_CYLINDER_TRIANGLE(bottomOffset, bottomOffset + i + 1, bottomOffset + i + 2);
}
}
#undef PUSH_CYLINDER_VERTEX
#undef PUSH_CYLINDER_TRIANGLE
2018-03-22 05:03:03 +00:00
2018-08-31 13:03:35 +00:00
lovrGraphicsDraw(&(DrawCommand) {
2018-07-14 00:12:30 +00:00
.material = material,
.mode = MESH_TRIANGLES,
.range = { 0, indexCount }
});
2017-06-21 03:54:22 +00:00
}
void lovrGraphicsSphere(Material* material, mat4 transform, int segments) {
2018-03-22 05:03:03 +00:00
VertexPointer vertices = lovrGraphicsGetVertexPointer((segments + 1) * (segments + 1));
2018-07-17 06:51:11 +00:00
IndexPointer indices = lovrMeshWriteIndices(state.defaultMesh, segments * segments * 6, sizeof(uint32_t));
2017-06-22 06:10:45 +00:00
for (int i = 0; i <= segments; i++) {
float v = i / (float) segments;
for (int j = 0; j <= segments; j++) {
float u = j / (float) segments;
2017-08-16 04:21:49 +00:00
float x = sin(u * 2 * M_PI) * sin(v * M_PI);
2017-06-22 06:10:45 +00:00
float y = cos(v * M_PI);
2017-08-16 04:21:49 +00:00
float z = -cos(u * 2 * M_PI) * sin(v * M_PI);
memcpy(vertices.floats, ((float[]) { x, y, z, x, y, z, u, 1 - v }), 8 * sizeof(float));
2018-07-18 02:20:40 +00:00
vertices.floats += 8;
2017-06-22 06:10:45 +00:00
}
}
for (int i = 0; i < segments; i++) {
unsigned int offset0 = i * (segments + 1);
unsigned int offset1 = (i + 1) * (segments + 1);
for (int j = 0; j < segments; j++) {
2018-07-14 00:12:30 +00:00
unsigned int i0 = offset0 + j;
unsigned int i1 = offset1 + j;
memcpy(indices.ints, ((uint32_t[]) { i0, i1, i0 + 1, i1, i1 + 1, i0 + 1 }), 6 * sizeof(uint32_t));
2018-07-18 02:20:40 +00:00
indices.ints += 6;
2017-06-22 06:10:45 +00:00
}
}
2018-08-31 13:03:35 +00:00
lovrGraphicsDraw(&(DrawCommand) {
2018-07-14 00:12:30 +00:00
.transform = transform,
.material = material,
.mode = MESH_TRIANGLES,
.range = { 0, segments * segments * 6 }
});
2017-06-22 06:10:45 +00:00
}
2017-10-15 23:56:00 +00:00
void lovrGraphicsSkybox(Texture* texture, float angle, float ax, float ay, float az) {
TextureType type = lovrTextureGetType(texture);
2018-03-05 10:02:25 +00:00
lovrAssert(type == TEXTURE_CUBE || type == TEXTURE_2D, "Only 2D and cube textures can be used as skyboxes");
lovrGraphicsPushPipeline();
lovrGraphicsSetWinding(WINDING_COUNTERCLOCKWISE);
2018-08-31 13:03:35 +00:00
lovrGraphicsDraw(&(DrawCommand) {
2018-07-14 00:12:30 +00:00
.shader = type == TEXTURE_CUBE ? SHADER_CUBE : SHADER_PANO,
2018-08-22 19:09:51 +00:00
.textures[TEXTURE_DIFFUSE] = type == TEXTURE_2D ? texture : NULL,
.textures[TEXTURE_ENVIRONMENT_MAP] = type == TEXTURE_CUBE ? texture : NULL,
2018-07-14 00:12:30 +00:00
.mode = MESH_TRIANGLE_STRIP,
.vertex.count = 4,
.vertex.data = (float[]) {
-1, 1, 1, 0, 0, 0, 0, 0,
-1, -1, 1, 0, 0, 0, 0, 0,
1, 1, 1, 0, 0, 0, 0, 0,
1, -1, 1, 0, 0, 0, 0, 0
}
});
lovrGraphicsPopPipeline();
2016-10-24 22:02:23 +00:00
}
2017-02-03 23:16:30 +00:00
2017-03-16 03:12:56 +00:00
void lovrGraphicsPrint(const char* str, mat4 transform, float wrap, HorizontalAlign halign, VerticalAlign valign) {
2017-08-08 08:36:29 +00:00
Font* font = lovrGraphicsGetFont();
2017-08-02 02:58:24 +00:00
float scale = 1 / font->pixelDensity;
float offsety;
2018-03-22 05:03:03 +00:00
uint32_t vertexCount;
uint32_t maxVertices = strlen(str) * 6;
VertexPointer vertexPointer = lovrGraphicsGetVertexPointer(maxVertices);
lovrFontRender(font, str, wrap, halign, valign, vertexPointer, &offsety, &vertexCount);
2018-07-17 06:51:11 +00:00
lovrMeshWriteIndices(state.defaultMesh, 0, 0);
2017-08-02 02:58:24 +00:00
lovrGraphicsPush();
2018-03-05 07:06:34 +00:00
lovrGraphicsMatrixTransform(transform);
lovrGraphicsScale(scale, scale, scale);
lovrGraphicsTranslate(0, offsety, 0);
state.pipelines[state.pipeline].alphaCoverage = true;
2018-08-31 13:03:35 +00:00
lovrGraphicsDraw(&(DrawCommand) {
2018-07-14 00:12:30 +00:00
.shader = SHADER_FONT,
2018-07-15 06:50:06 +00:00
.textures[TEXTURE_DIFFUSE] = font->texture,
2018-07-14 00:12:30 +00:00
.mode = MESH_TRIANGLES,
.range = { 0, vertexCount }
});
state.pipelines[state.pipeline].alphaCoverage = false;
2017-08-02 02:58:24 +00:00
lovrGraphicsPop();
2017-02-03 23:16:30 +00:00
}
2017-08-08 09:13:07 +00:00
2018-10-01 01:40:51 +00:00
void lovrGraphicsFill(Texture* texture, float u, float v, float w, float h) {
lovrGraphicsPushPipeline();
lovrGraphicsSetDepthTest(COMPARE_NONE, false);
2018-08-31 13:03:35 +00:00
lovrGraphicsDraw(&(DrawCommand) {
2018-08-29 04:16:19 +00:00
.forceMono = true,
2018-07-14 00:12:30 +00:00
.shader = SHADER_FILL,
2018-07-15 06:50:06 +00:00
.textures[TEXTURE_DIFFUSE] = texture,
2018-07-14 00:12:30 +00:00
.mode = MESH_TRIANGLE_STRIP,
.vertex.count = 4,
.vertex.data = (float[]) {
2018-10-01 01:40:51 +00:00
-1, 1, 0, 0, 0, 0, u, v + h,
-1, -1, 0, 0, 0, 0, u, v,
1, 1, 0, 0, 0, 0, u + w, v + h,
1, -1, 0, 0, 0, 0, u + w, v
2017-10-21 20:06:23 +00:00
}
2018-07-14 00:12:30 +00:00
});
lovrGraphicsPopPipeline();
2017-12-10 04:07:32 +00:00
}