2016-08-10 06:28:17 +00:00
|
|
|
#include "buffer.h"
|
|
|
|
#include "model.h"
|
|
|
|
#include "shader.h"
|
2016-09-21 07:55:53 +00:00
|
|
|
#include "../matrix.h"
|
|
|
|
|
|
|
|
#ifndef LOVR_GRAPHICS_TYPES
|
|
|
|
#define LOVR_GRAPHICS_TYPES
|
|
|
|
typedef vec_t(mat4) vec_mat4_t;
|
2016-09-27 06:48:09 +00:00
|
|
|
|
2016-09-29 03:11:58 +00:00
|
|
|
#define LOVR_COLOR(r, g, b, a) ((a << 0) | (b << 8) | (g << 16) | (r << 24))
|
|
|
|
#define LOVR_COLOR_R(c) (c >> 24 & 0xff)
|
|
|
|
#define LOVR_COLOR_G(c) (c >> 16 & 0xff)
|
|
|
|
#define LOVR_COLOR_B(c) (c >> 8 & 0xff)
|
|
|
|
#define LOVR_COLOR_A(c) (c >> 0 & 0xff)
|
|
|
|
|
2016-09-29 04:47:36 +00:00
|
|
|
typedef struct {
|
|
|
|
int x;
|
|
|
|
int y;
|
|
|
|
int width;
|
|
|
|
int height;
|
|
|
|
} ScissorRectangle;
|
|
|
|
|
2016-09-27 06:48:09 +00:00
|
|
|
typedef struct {
|
|
|
|
Shader* activeShader;
|
2016-09-28 02:56:36 +00:00
|
|
|
Shader* defaultShader;
|
2016-09-27 06:48:09 +00:00
|
|
|
vec_mat4_t transforms;
|
|
|
|
mat4 lastTransform;
|
|
|
|
mat4 projection;
|
|
|
|
mat4 lastProjection;
|
2016-09-29 03:11:58 +00:00
|
|
|
unsigned int color;
|
|
|
|
unsigned int lastColor;
|
2016-09-29 02:38:58 +00:00
|
|
|
unsigned char colorMask;
|
2016-09-29 04:47:36 +00:00
|
|
|
char isScissorEnabled;
|
|
|
|
ScissorRectangle scissor;
|
2016-09-29 07:00:02 +00:00
|
|
|
GLuint shapeArray;
|
|
|
|
GLuint shapeBuffer;
|
|
|
|
vec_float_t shapeData;
|
2016-09-27 06:48:09 +00:00
|
|
|
} GraphicsState;
|
2016-09-21 07:55:53 +00:00
|
|
|
#endif
|
2016-07-07 07:04:24 +00:00
|
|
|
|
2016-08-10 06:28:17 +00:00
|
|
|
void lovrGraphicsInit();
|
2016-09-28 03:20:08 +00:00
|
|
|
void lovrGraphicsReset();
|
2016-09-17 03:11:11 +00:00
|
|
|
void lovrGraphicsClear(int color, int depth);
|
2016-08-10 06:28:17 +00:00
|
|
|
void lovrGraphicsPresent();
|
2016-09-24 03:58:56 +00:00
|
|
|
void lovrGraphicsPrepare();
|
2016-09-28 04:37:46 +00:00
|
|
|
void lovrGraphicsGetBackgroundColor(float* r, float* g, float* b, float* a);
|
|
|
|
void lovrGraphicsSetBackgroundColor(float r, float g, float b, float a);
|
2016-09-29 03:11:58 +00:00
|
|
|
void lovrGraphicsGetColor(unsigned char* r, unsigned char* g, unsigned char* b, unsigned char* a);
|
|
|
|
void lovrGraphicsSetColor(unsigned char r, unsigned char g, unsigned char b, unsigned char a);
|
2016-09-29 02:38:58 +00:00
|
|
|
void lovrGraphicsGetColorMask(unsigned char* r, unsigned char* g, unsigned char* b, unsigned char* a);
|
|
|
|
void lovrGraphicsSetColorMask(unsigned char r, unsigned char g, unsigned char b, unsigned char a);
|
2016-09-29 04:47:36 +00:00
|
|
|
char lovrGraphicsIsScissorEnabled();
|
|
|
|
void lovrGraphicsSetScissorEnabled(char isEnabled);
|
|
|
|
void lovrGraphicsGetScissor(int* x, int* y, int* width, int* height);
|
|
|
|
void lovrGraphicsSetScissor(int x, int y, int width, int height);
|
2016-09-14 00:02:23 +00:00
|
|
|
Shader* lovrGraphicsGetShader();
|
2016-08-10 06:28:17 +00:00
|
|
|
void lovrGraphicsSetShader(Shader* shader);
|
2016-09-27 06:48:09 +00:00
|
|
|
void lovrGraphicsSetProjection(float near, float far, float fov);
|
2016-09-27 07:24:28 +00:00
|
|
|
void lovrGraphicsSetProjectionRaw(mat4 projection);
|
2016-09-21 07:55:53 +00:00
|
|
|
int lovrGraphicsPush();
|
|
|
|
int lovrGraphicsPop();
|
2016-09-21 22:26:05 +00:00
|
|
|
void lovrGraphicsOrigin();
|
2016-09-23 04:53:17 +00:00
|
|
|
void lovrGraphicsTranslate(float x, float y, float z);
|
|
|
|
void lovrGraphicsRotate(float w, float x, float y, float z);
|
|
|
|
void lovrGraphicsScale(float x, float y, float z);
|
2016-09-29 07:21:38 +00:00
|
|
|
void lovrGraphicsTransform(mat4 transform);
|
2016-09-29 05:10:03 +00:00
|
|
|
void lovrGraphicsGetDimensions(int* width, int* height);
|
2016-09-29 07:00:02 +00:00
|
|
|
void lovrGraphicsSetShapeData(float* data, int count);
|
|
|
|
void lovrGraphicsDrawShape();
|
2016-09-17 22:38:13 +00:00
|
|
|
Buffer* lovrGraphicsNewBuffer(int size, BufferDrawMode drawMode, BufferUsage usage);
|
2016-08-10 06:28:17 +00:00
|
|
|
Model* lovrGraphicsNewModel(const char* path);
|
|
|
|
Shader* lovrGraphicsNewShader(const char* vertexSource, const char* fragmentSource);
|