summaryrefslogtreecommitdiff
path: root/src/main.h
blob: 3af681530754381a97433bd47faaab9dfa2485bf (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
44
45
46
47
48
#ifndef MAIN_H_INCLUDED
#define MAIN_H_INCLUDED

#define GL_GLEXT_PROTOTYPES

#include <caca.h>
#include <SDL2/SDL.h>
#include <SDL2/SDL_opengl.h>
#include <GL/glu.h>

#define EXPR_MIN_SIZE (shm->ge.w<80 || shm->ge.h<24)
#define TEXT_MIN_SIZE "80x24"
// 80x24 xterm as rendered on Debian 10 (size doen't matter so much, keep the right ratio)
#define FBUF_W 478
#define FBUF_H 371

#ifdef DEBUG
#define TRACE(hint) do { printf("%s(): %s\n", __func__, hint); } while(0)
#define TRACE_CALL_ONCE static int firsttime=1; if (firsttime) { printf("%s(): %s\n", __func__, "call"); firsttime=0; }
#else
#define TRACE(hint)
#define TRACE_CALL_ONCE
#endif

typedef struct {
	// libcaca
	caca_display_t *dp;
	caca_canvas_t *cv;
   	caca_dither_t *d;
	int w, h; // caca terminal size in characters
	// SDL worker
	SDL_Window* sdl_win;
	SDL_Renderer *sdl_rndr;
	SDL_Texture *sdl_target;
	// OpenGL worker
	SDL_Window* gl_win;
	SDL_GLContext gl_ctx;
	SDL_Renderer *gl_rndr;
	SDL_Texture *gl_target;
	// framebuffer to inject OpenGL or SDL result in caca canvas
	uint32_t raw_target[FBUF_W*FBUF_H];
	// Timing
	Uint32 sdl_ticks;
	Uint32 framecount;
	Uint32 sc_framecount;
} graphical_env_t;

#endif