2018-08-22 04:08:40 +00:00
|
|
|
#include "graphics/texture.h"
|
2018-12-19 07:53:51 +00:00
|
|
|
#include "graphics/opengl.h"
|
2018-08-22 04:08:40 +00:00
|
|
|
|
2018-02-15 08:37:02 +00:00
|
|
|
#pragma once
|
2017-12-07 07:50:52 +00:00
|
|
|
|
2018-08-24 01:28:37 +00:00
|
|
|
#define MAX_CANVAS_ATTACHMENTS 4
|
2018-08-22 04:08:40 +00:00
|
|
|
|
2019-04-05 11:58:29 +00:00
|
|
|
struct Texture;
|
|
|
|
struct TextureData;
|
|
|
|
|
2019-05-18 00:11:22 +00:00
|
|
|
typedef struct Attachment {
|
2019-04-05 11:58:29 +00:00
|
|
|
struct Texture* texture;
|
2019-05-20 21:34:03 +00:00
|
|
|
uint32_t slice;
|
|
|
|
uint32_t level;
|
2018-08-22 04:08:40 +00:00
|
|
|
} Attachment;
|
|
|
|
|
2018-08-24 21:43:39 +00:00
|
|
|
typedef struct {
|
2018-09-28 01:34:43 +00:00
|
|
|
struct {
|
|
|
|
bool enabled;
|
|
|
|
bool readable;
|
|
|
|
TextureFormat format;
|
|
|
|
} depth;
|
2018-08-25 01:38:46 +00:00
|
|
|
bool stereo;
|
2019-05-20 21:34:03 +00:00
|
|
|
uint32_t msaa;
|
2018-08-29 20:34:54 +00:00
|
|
|
bool mipmaps;
|
2018-08-24 21:43:39 +00:00
|
|
|
} CanvasFlags;
|
|
|
|
|
2019-04-05 11:58:29 +00:00
|
|
|
typedef struct Canvas {
|
2019-05-20 21:34:03 +00:00
|
|
|
uint32_t width;
|
|
|
|
uint32_t height;
|
2018-12-19 07:53:51 +00:00
|
|
|
CanvasFlags flags;
|
|
|
|
Attachment attachments[MAX_CANVAS_ATTACHMENTS];
|
|
|
|
Attachment depth;
|
2019-05-20 21:34:03 +00:00
|
|
|
uint32_t attachmentCount;
|
2018-12-19 07:53:51 +00:00
|
|
|
bool needsAttach;
|
|
|
|
bool needsResolve;
|
|
|
|
GPU_CANVAS_FIELDS
|
|
|
|
} Canvas;
|
2018-07-09 07:51:09 +00:00
|
|
|
|
2019-05-20 21:34:03 +00:00
|
|
|
Canvas* lovrCanvasInit(Canvas* canvas, uint32_t width, uint32_t height, CanvasFlags flags);
|
|
|
|
Canvas* lovrCanvasInitFromHandle(Canvas* canvas, uint32_t width, uint32_t height, CanvasFlags flags, uint32_t framebuffer, uint32_t depthBuffer, uint32_t resolveBuffer, uint32_t attachmentCount, bool immortal);
|
2018-12-19 08:25:20 +00:00
|
|
|
#define lovrCanvasCreate(...) lovrCanvasInit(lovrAlloc(Canvas), __VA_ARGS__)
|
|
|
|
#define lovrCanvasCreateFromHandle(...) lovrCanvasInitFromHandle(lovrAlloc(Canvas), __VA_ARGS__)
|
2018-02-26 08:59:03 +00:00
|
|
|
void lovrCanvasDestroy(void* ref);
|
2019-05-20 21:34:03 +00:00
|
|
|
const Attachment* lovrCanvasGetAttachments(Canvas* canvas, uint32_t* count);
|
|
|
|
void lovrCanvasSetAttachments(Canvas* canvas, Attachment* attachments, uint32_t count);
|
2018-08-29 19:40:19 +00:00
|
|
|
void lovrCanvasResolve(Canvas* canvas);
|
2018-08-29 04:16:19 +00:00
|
|
|
bool lovrCanvasIsStereo(Canvas* canvas);
|
2019-05-20 21:34:03 +00:00
|
|
|
uint32_t lovrCanvasGetWidth(Canvas* canvas);
|
|
|
|
uint32_t lovrCanvasGetHeight(Canvas* canvas);
|
|
|
|
uint32_t lovrCanvasGetMSAA(Canvas* canvas);
|
2019-04-05 11:58:29 +00:00
|
|
|
struct Texture* lovrCanvasGetDepthTexture(Canvas* canvas);
|
2019-05-20 21:34:03 +00:00
|
|
|
struct TextureData* lovrCanvasNewTextureData(Canvas* canvas, uint32_t index);
|