-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRenderer.h
63 lines (53 loc) · 1.29 KB
/
Renderer.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
#pragma once
#include "Utility/GL_Program.h"
#ifdef LINUX
#include <SDL.h>
#endif
#ifdef ANDROID
struct ANativeWindow;
#endif
struct Document;
class Window;
class GUI;
class Renderer
{
public:
Renderer(Document &doc, Window &window, GUI &gui,
#ifdef LINUX
SDL_Window *sdl_window, SDL_GLContext context
#else
ANativeWindow *jni_window
#endif
);
~Renderer();
void draw();
void image_changed();
private:
Document &doc;
Window &window;
GUI &gui;
#ifdef ANDROID
const EGLContext context; // which GL context do all our objects live in?
ANativeWindow *jni_window = NULL; // only to call ANativeWindow_release on it
#else
SDL_Window *sdl_window = NULL;
SDL_GLContext sdl_context = 0;
#endif
void alloc_puzzle_VOs(bool free_old_buffers); // realloc when puzzle.N changes
void draw_background();
void draw_puzzle();
void draw_buttons();
void draw_gui();
int current_buf = 0; // we use double buffering for data to avoid stalls in glMap
int current_N = 0; // from last alloc_puzzle_VOs call
bool gui_init_done = false;
void init_gui();
GL_Program program;
GLuint VBO[2] = {0,0}, VAO[2] = {0,0};
GLuint texture = 0;
GL_Program bg_program;
GLuint bg_VAO = 0;
GL_Program button_program;
GLuint button_VBO[2] = {0,0}, button_VAO[2] = {0,0};
GLuint button_texture = 0;
};