summaryrefslogtreecommitdiff
path: root/shared_cpp/OrthographicRenderer.h
blob: cef5305bb183552e469489c51dd6b1c190b30099 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#pragma once

#include "WebglContext.h"
#include "types.h"
#include "Shader.h"
#include "mathlib.h"

struct WebglContext;

struct OrthographicRenderer {
	Mat4x4 projection;
	uint32 shader;

	struct {
		int32 position;
		int32 color;
	} attributes;

	struct {
		int32 projection;
		int32 model;
	} uniforms;

	void load(WebglContext* context);
	void render();
	void unload();
};

struct OrthographicVertex {
	Vector2 position;
	Vector4 color;
};

struct OrthographicShape {
	uint32 vao;
	uint32 vbo;
	uint32 numVertices = 0;
	Mat4x4 model;

	void load(OrthographicVertex* vertices, uint32 numVertices, OrthographicRenderer* renderer);
	void render(OrthographicRenderer* renderer, GLenum drawType = GL_TRIANGLES);
	void unload();
};