lovr/src/graphics/graphics.h

112 lines
3.8 KiB
C
Raw Normal View History

2016-11-19 09:28:01 +00:00
#include "graphics/buffer.h"
#include "graphics/model.h"
#include "graphics/shader.h"
#include "graphics/skybox.h"
#include "matrix.h"
2016-09-21 07:55:53 +00:00
#ifndef LOVR_GRAPHICS_TYPES
#define LOVR_GRAPHICS_TYPES
2016-09-27 06:48:09 +00:00
2016-09-29 04:47:36 +00:00
typedef struct {
int x;
int y;
int width;
int height;
} ScissorRectangle;
2016-09-30 02:39:25 +00:00
typedef enum {
2016-10-01 19:10:38 +00:00
DRAW_MODE_FILL,
DRAW_MODE_LINE
2016-09-30 02:39:25 +00:00
} DrawMode;
2016-10-03 19:02:49 +00:00
typedef enum {
POLYGON_WINDING_CLOCKWISE = GL_CW,
POLYGON_WINDING_COUNTERCLOCKWISE = GL_CCW
} PolygonWinding;
2016-11-23 04:59:11 +00:00
typedef enum {
COMPARE_EQUAL = GL_EQUAL,
COMPARE_NOT_EQUAL = GL_NOTEQUAL,
COMPARE_LESS = GL_LESS,
COMPARE_LEQUAL = GL_LEQUAL,
COMPARE_GEQUAL = GL_GEQUAL,
COMPARE_GREATER = GL_GREATER
} CompareMode;
2016-09-27 06:48:09 +00:00
typedef struct {
Shader* activeShader;
2016-09-28 02:56:36 +00:00
Shader* defaultShader;
2016-10-24 22:02:23 +00:00
Shader* skyboxShader;
2016-09-27 06:48:09 +00:00
vec_mat4_t transforms;
mat4 projection;
2016-09-29 03:11:58 +00:00
unsigned int color;
2016-10-03 18:41:31 +00:00
char colorMask;
2016-11-23 05:07:33 +00:00
int isScissorEnabled;
2016-09-29 04:47:36 +00:00
ScissorRectangle scissor;
2016-09-29 07:00:02 +00:00
GLuint shapeArray;
GLuint shapeBuffer;
2016-09-30 06:18:51 +00:00
GLuint shapeIndexBuffer;
2016-09-29 07:00:02 +00:00
vec_float_t shapeData;
2016-09-30 06:18:51 +00:00
vec_uint_t shapeIndices;
2016-10-01 20:48:31 +00:00
float lineWidth;
2016-11-13 01:38:49 +00:00
float pointSize;
2016-11-23 05:07:33 +00:00
int isCullingEnabled;
2016-10-03 19:02:49 +00:00
PolygonWinding polygonWinding;
2016-11-23 04:59:11 +00:00
CompareMode depthTest;
2016-11-23 05:07:33 +00:00
int isWireframe;
2016-09-27 06:48:09 +00:00
} GraphicsState;
2016-11-23 05:07:33 +00:00
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();
void lovrGraphicsDestroy();
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-10-03 18:41:31 +00:00
void lovrGraphicsGetColorMask(char* r, char* g, char* b, char* a);
void lovrGraphicsSetColorMask(char r, char g, char b, char a);
2016-11-23 05:07:33 +00:00
int lovrGraphicsIsScissorEnabled();
void lovrGraphicsSetScissorEnabled(int isEnabled);
2016-09-29 04:47:36 +00:00
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-10-01 20:48:31 +00:00
float lovrGraphicsGetLineWidth();
void lovrGraphicsSetLineWidth(float width);
2016-11-13 01:38:49 +00:00
float lovrGraphicsGetPointSize();
void lovrGraphicsSetPointSize(float size);
2016-11-23 05:07:33 +00:00
int lovrGraphicsIsCullingEnabled();
void lovrGraphicsSetCullingEnabled(int isEnabled);
2016-10-03 19:02:49 +00:00
PolygonWinding lovrGraphicsGetPolygonWinding();
void lovrGraphicsSetPolygonWinding(PolygonWinding winding);
2016-11-23 04:59:11 +00:00
CompareMode lovrGraphicsGetDepthTest();
void lovrGraphicsSetDepthTest(CompareMode depthTest);
2016-11-23 05:07:33 +00:00
int lovrGraphicsIsWireframe();
void lovrGraphicsSetWireframe(int wireframe);
2016-09-21 07:55:53 +00:00
int lovrGraphicsPush();
int lovrGraphicsPop();
2016-09-21 22:26:05 +00:00
void lovrGraphicsOrigin();
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-11-02 03:48:04 +00:00
void lovrGraphicsTransform(float tx, float ty, float tz, float sx, float sy, float sz, float angle, float ax, float ay, float az);
void lovrGraphicsMatrixTransform(mat4 transform);
int lovrGraphicsGetWidth();
int lovrGraphicsGetHeight();
2016-10-24 02:01:27 +00:00
void lovrGraphicsSetShapeData(float* data, int dataCount, unsigned int* indices, int indicesCount);
2016-10-07 06:34:35 +00:00
void lovrGraphicsDrawLinedShape(GLenum mode);
void lovrGraphicsDrawFilledShape();
2016-11-08 07:16:33 +00:00
void lovrGraphicsPoints(float* points, int count);
2016-09-30 02:39:25 +00:00
void lovrGraphicsLine(float* points, int count);
2016-11-23 04:43:22 +00:00
void lovrGraphicsTriangle(DrawMode mode, float* points);
2016-10-04 03:56:45 +00:00
void lovrGraphicsPlane(DrawMode mode, float x, float y, float z, float size, float nx, float ny, float nz);
2016-10-01 20:39:38 +00:00
void lovrGraphicsCube(DrawMode mode, float x, float y, float z, float size, float angle, float axisX, float axisY, float axisZ);
2016-10-24 22:02:23 +00:00
void lovrGraphicsSkybox(Skybox* skybox, float angle, float ax, float ay, float az);