Added gl_wcb interface to abstract out glfw and glx usage
This commit is contained in:
71
render.h
71
render.h
@@ -1,4 +1,7 @@
|
||||
|
||||
#ifndef RENDER_H
|
||||
#define RENDER_H
|
||||
|
||||
struct gl_data;
|
||||
|
||||
typedef struct renderer {
|
||||
@@ -15,9 +18,65 @@ void rd_update (struct renderer*, float* lb, float* rb,
|
||||
void rd_destroy (struct renderer*);
|
||||
void rd_time (struct renderer*);
|
||||
void* rd_get_impl_window(struct renderer*);
|
||||
void rd_get_fbsize (struct renderer*, int* w, int* h);
|
||||
void rd_get_wpos (struct renderer*, int* x, int* y);
|
||||
#ifdef GLAVA_RDX11
|
||||
Display* rd_get_x11_display(struct renderer*);
|
||||
Window rd_get_x11_window (struct renderer*);
|
||||
#endif
|
||||
struct gl_wcb* rd_get_wcb (struct renderer*);
|
||||
|
||||
/* gl_wcb - OpenGL Window Creation Backend interface */
|
||||
struct gl_wcb {
|
||||
const char* name;\
|
||||
void (*init) (void);
|
||||
void* (*create_and_bind)(const char* name, const char* class,
|
||||
const char* type, const char** states,
|
||||
size_t states_sz,
|
||||
int w, int h,
|
||||
int x, int y,
|
||||
int version_major, int version_minor);
|
||||
bool (*should_close) (void* ptr);
|
||||
bool (*swap_buffers) (void* ptr);
|
||||
void (*set_swap) (void* ptr, int interval);
|
||||
void (*get_pos) (void* ptr, int* x, int* y);
|
||||
void (*get_fbsize) (void* ptr, int* w, int* h);
|
||||
void (*set_geometry) (void* ptr, int x, int y, int w, int h);
|
||||
void (*set_floating) (void* ptr, bool floating);
|
||||
void (*set_decorated) (void* ptr, bool decorated);
|
||||
void (*set_focused) (void* ptr, bool focused);
|
||||
void (*set_maximized) (void* ptr, bool maximized);
|
||||
void (*set_transparent)(void* ptr, bool transparent);
|
||||
double (*get_time) (void* ptr);
|
||||
void (*set_time) (void* ptr, double time);
|
||||
void (*set_visible) (void* ptr, bool visible);
|
||||
#ifdef GLAVA_RDX11
|
||||
Display* (*get_x11_display)(void);
|
||||
Window (*get_x11_window) (void* ptr);
|
||||
#else /* define placeholders to ensure equal struct size */
|
||||
void* _X11_DISPLAY_PLACEHOLDER;
|
||||
void* _X11_WINDOW_PLACEHOLDER;
|
||||
#endif
|
||||
};
|
||||
|
||||
#define WCB_FUNC(F) \
|
||||
.F = (typeof(((struct gl_wcb*) NULL)->F)) &F
|
||||
|
||||
#define WCB_ATTACH(B, N) \
|
||||
struct gl_wcb N = { \
|
||||
.name = B, \
|
||||
WCB_FUNC(init), \
|
||||
WCB_FUNC(create_and_bind), \
|
||||
WCB_FUNC(should_close), \
|
||||
WCB_FUNC(swap_buffers), \
|
||||
WCB_FUNC(set_swap), \
|
||||
WCB_FUNC(get_pos), \
|
||||
WCB_FUNC(get_fbsize), \
|
||||
WCB_FUNC(set_geometry), \
|
||||
WCB_FUNC(set_floating), \
|
||||
WCB_FUNC(set_decorated), \
|
||||
WCB_FUNC(set_focused), \
|
||||
WCB_FUNC(set_maximized), \
|
||||
WCB_FUNC(set_transparent), \
|
||||
WCB_FUNC(set_time), \
|
||||
WCB_FUNC(get_time), \
|
||||
WCB_FUNC(set_visible), \
|
||||
WCB_FUNC(get_x11_display), \
|
||||
WCB_FUNC(get_x11_window) \
|
||||
}
|
||||
|
||||
#endif /* RENDER_H */
|
||||
|
||||
Reference in New Issue
Block a user