5 * This work is licensed under the terms of 3-clause BSD license.
13 #define SCREEN_WIDTH 800
14 #define SCREEN_HEIGHT 480
16 #define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
18 void bcm_host_init(void)
22 void bcm_host_deinit(void)
26 uint32_t vc_dispmanx_display_open(uint32_t dev)
31 uint32_t vc_dispmanx_element_add()
36 uint32_t vc_dispmanx_update_start(int32_t prio)
41 int vc_dispmanx_update_submit_sync(uint32_t upd_handle)
43 //printf("%s\n", __func__);
47 int graphics_get_display_size(uint16_t dpy, uint32_t *w, uint32_t *h)
54 #ifndef SDL_FULLSCREEN
55 #define SDL_FULLSCREEN 0x80000000
56 #define SDL_RESIZABLE 0x00000010
59 static void *get_real_func(const char *name)
63 f = dlsym(RTLD_NEXT, name);
65 fprintf(stderr, "%s: %s\n", name, dlerror());
71 /* pandora's SGX driver can only run fullscreen */
72 void *SDL_SetVideoMode(int width, int height, int bpp, uint32_t flags)
74 static void * (*f)(int, int, int, uint32_t);
76 //printf("%s %d %x\n", __func__, bpp, flags);
78 width = height = bpp = 0;
79 flags &= ~SDL_RESIZABLE;
80 flags |= SDL_FULLSCREEN;
83 f = get_real_func(__func__);
85 return f(width, height, bpp, flags);
88 int SDL_PollEvent(void *e)
90 static int (*f)(void *);
94 f = get_real_func(__func__);
98 // event, SDL_KEYDOWN, SDLK_q
99 if (ret != 0 && e != NULL) {
100 if (*(uint8_t *)e == 2 && ((uint32_t *)e)[2] == 113)
101 *(uint8_t *)e = 12; // SDL_QUIT
107 /* can't use 8bits/channel on pandora, must filter out confing */
109 #define EGL_NONE 0x3038
110 #define EGL_RED_SIZE 0x3024
111 #define EGL_GREEN_SIZE 0x3023
112 #define EGL_BLUE_SIZE 0x3022
113 #define EGL_ALPHA_SIZE 0x3021
114 #define EGL_SURFACE_TYPE 0x3033
117 int eglChooseConfig(void *dpy, const int32_t *attrib_list,
118 void *configs, int32_t config_size, int32_t *num_config)
120 static int (*f)(void *, const int32_t *,
121 void *, int32_t, int32_t *);
122 int32_t attrib_list_c[64];
125 //printf("%s\n", __func__);
128 f = get_real_func(__func__);
130 for (i = o = 0; o < ARRAY_SIZE(attrib_list_c) - 2; i += 2) {
131 if (attrib_list == NULL || attrib_list[i] == EGL_NONE)
134 switch (attrib_list[i]) {
138 case EGL_SURFACE_TYPE:
143 attrib_list_c[o++] = attrib_list[i + 0];
144 attrib_list_c[o++] = attrib_list[i + 1];
146 attrib_list_c[o++] = EGL_NONE;
148 return f(dpy, attrib_list_c, configs, config_size, num_config);
151 void *eglCreateWindowSurface(void *dpy, void *config, void *win,
152 const int32_t *attrib_list)
154 static void * (*f)(void *, void *, void *, const int32_t *);
156 //printf("%s\n", __func__);
159 f = get_real_func(__func__);
161 return f(dpy, config, NULL, attrib_list);