-
Notifications
You must be signed in to change notification settings - Fork 1
/
graphics.h
executable file
·78 lines (62 loc) · 2.43 KB
/
graphics.h
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#pragma once
#include "GLES2/gl2.h"
#include "EGL/egl.h"
#include "EGL/eglext.h"
#include "lodepng.h"
void InitGraphics();
void ReleaseGraphics();
void BeginFrame();
void EndFrame();
class GfxShader
{
GLchar* Src;
GLuint Id;
GLuint GlShaderType;
public:
GfxShader() : Src(NULL), Id(0), GlShaderType(0) {}
~GfxShader() { if(Src) delete[] Src; }
bool LoadVertexShader(const char* filename);
bool LoadFragmentShader(const char* filename);
GLuint GetId() { return Id; }
};
class GfxProgram
{
GfxShader* VertexShader;
GfxShader* FragmentShader;
GLuint Id;
public:
GfxProgram() {}
~GfxProgram() {}
bool Create(GfxShader* vertex_shader, GfxShader* fragment_shader);
GLuint GetId() { return Id; }
};
class GfxTexture
{
int Width;
int Height;
GLuint Id;
bool IsRGBA;
GLuint FramebufferId;
public:
GfxTexture() : Width(0), Height(0), Id(0), FramebufferId(0) {}
~GfxTexture() {}
bool CreateRGBA(int width, int height, const void* data = NULL);
bool CreateGreyScale(int width, int height, const void* data = NULL);
bool GenerateFrameBuffer();
void SetPixels(const void* data);
GLuint GetId() { return Id; }
GLuint GetFramebufferId() { return FramebufferId; }
int GetWidth() {return Width;}
int GetHeight() {return Height;}
void Save(const char* fname);
};
void SaveFrameBuffer(const char* fname);
void DrawTextureRect(GfxTexture* texture, float x0, float y0, float x1, float y1, GfxTexture* render_target);
void DrawYUVTextureRect(GfxTexture* ytexture, GfxTexture* utexture, GfxTexture* vtexture, float x0, float y0, float x1, float y1, GfxTexture* render_target);
void DrawBlurredRect(GfxTexture* texture, float x0, float y0, float x1, float y1, GfxTexture* render_target);
void DrawSobelRect(GfxTexture* texture, float x0, float y0, float x1, float y1, GfxTexture* render_target);
void DrawMedianRect(GfxTexture* texture, float x0, float y0, float x1, float y1, GfxTexture* render_target);
void DrawMultRect(GfxTexture* texture, float x0, float y0, float x1, float y1, float r, float g, float b, GfxTexture* render_target);
void DrawThreshRect(GfxTexture* texture, float x0, float y0, float x1, float y1, float r, float g, float b, GfxTexture* render_target);
void DrawDilateRect(GfxTexture* texture, float x0, float y0, float x1, float y1, GfxTexture* render_target);
void DrawErodeRect(GfxTexture* texture, float x0, float y0, float x1, float y1, GfxTexture* render_target);