ObjectivelyMVC
Object oriented MVC framework for SDL3 and GNU C
Loading...
Searching...
No Matches
Renderer.h
Go to the documentation of this file.
1/*
2 * ObjectivelyMVC: Object oriented MVC framework for SDL3 and C.
3 * Copyright (C) 2014 Jay Dolan <jay@jaydolan.com>
4 *
5 * This software is provided 'as-is', without any express or implied
6 * warranty. In no event will the authors be held liable for any damages
7 * arising from the use of this software.
8 *
9 * Permission is granted to anyone to use this software for any purpose,
10 * including commercial applications, and to alter it and redistribute it
11 * freely, subject to the following restrictions:
12 *
13 * 1. The origin of this software must not be misrepresented; you must not
14 * claim that you wrote the original software. If you use this software
15 * in a product, an acknowledgment in the product documentation would be
16 * appreciated but is not required.
17 *
18 * 2. Altered source versions must be plainly marked as such, and must not be
19 * misrepresented as being the original software.
20 *
21 * 3. This notice may not be removed or altered from any source distribution.
22 */
23
24#pragma once
25
26#include <SDL3/SDL_gpu.h>
27
28#include <Objectively/Object.h>
29#include <Objectively/Vector.h>
30
31#include <ObjectivelyGPU.h>
32
33#include "Types.h"
34
42typedef struct Renderer Renderer;
43typedef struct RendererInterface RendererInterface;
44
48typedef struct {
50 vec2 uv;
51 SDL_Color color;
53
58typedef struct {
59 Texture *texture;
60 SDL_Rect scissor;
61 Uint32 firstVertex;
62 Uint32 vertexCount;
63} MVC_DrawArrays;
64
70struct Renderer {
71
75 Object object;
76
81 RendererInterface *interface;
82
87 CommandBuffer *commands;
88
92 RenderDevice *device;
93
98 Vector *drawArrays;
99
105 Framebuffer *framebuffer;
106
111 GraphicsPipeline *pipeline;
112
119 Sampler *sampler;
120
125 SDL_Rect scissor;
126
131 Vector *vertices;
132
137 Buffer *vertexBuffer;
138
143 Uint32 vertexBufferCapacity;
144
149 Texture *white;
150};
151
155struct RendererInterface {
156
160 ObjectInterface objectInterface;
161
172 void (*beginFrame)(Renderer *self);
173
182 void (*beginFrameWith)(Renderer *self, CommandBuffer *commands, Framebuffer *framebuffer);
183
192 void (*drawLine)(const Renderer *self, const SDL_Point *points, const SDL_Color *color);
193
203 void (*drawLines)(const Renderer *self, const SDL_Point *points, size_t count, const SDL_Color *color);
204
213 void (*drawRect)(const Renderer *self, const SDL_Rect *rect, const SDL_Color *color);
214
223 void (*drawRectFilled)(const Renderer *self, const SDL_Rect *rect, const SDL_Color *color);
224
234 void (*drawTexture)(const Renderer *self, Texture *texture, const SDL_Rect *dest, const SDL_Color *color);
235
243 void (*drawView)(Renderer *self, View *view);
244
253 void (*endFrame)(Renderer *self);
254
263 Renderer *(*initWithDevice)(Renderer *self, RenderDevice *device);
264
277 void (*pushDrawArrays)(const Renderer *self, const MVC_Vertex *verts, size_t count,
278 Texture *texture, const SDL_Color *color);
279
286 void (*renderDeviceDidReset)(Renderer *self);
287
294 void (*renderDeviceWillReset)(Renderer *self);
295
304 void (*setClippingFrame)(Renderer *self, const SDL_Rect *clippingFrame);
305};
306
OBJECTIVELYMVC_EXPORT Class * _Renderer(void)
Definition Renderer.c:522
ObjectivelyMVC base types.
#define OBJECTIVELYMVC_EXPORT
Definition Types.h:40
static SDL_Rect clippingFrame(const View *self)
Definition View.c:546
Interleaved position + texcoord + color vertex for GPU upload.
Definition Renderer.h:48
SDL_Color color
Definition Renderer.h:51
vec2 uv
Definition Renderer.h:50
vec2 position
Definition Renderer.h:49
Renderer extends Object with ObjectivelyMVC's UI rendering layer.
Definition Renderer.h:70
RenderDevice * device
The backing RenderDevice.
Definition Renderer.h:92
Object object
The superclass.
Definition Renderer.h:75
RendererInterface * interface
The interface.
Definition Renderer.h:81
Views are the fundamental building blocks of ObjectivelyMVC user interfaces.
Definition View.h:134