From 743e2595ac191f014e3da8a100ced524f53aabfd Mon Sep 17 00:00:00 2001 From: Mike Kazantsev Date: Wed, 25 Jul 2018 15:34:35 +0500 Subject: [PATCH] Add layer option to evgInit --- example/hello.c | 4 ++-- python/evg.py | 2 +- python/hello.py | 2 +- src/libshapes.c | 3 ++- src/libshapes.h | 2 +- src/oglinit.c | 2 +- src/oglinit.h | 3 +++ 7 files changed, 11 insertions(+), 7 deletions(-) diff --git a/example/hello.c b/example/hello.c index 3208ce6..61a9c87 100644 --- a/example/hello.c +++ b/example/hello.c @@ -14,8 +14,8 @@ int main() { /* We have to initialise the OpenVG canvas and renderer by using * `init(&w, &h)`. */ - evgInit(&width, &height); - evgBegin(width, height); + evgInit(&width, &height, 0); + evgBegin(); { evgBackground(0, 0, 0); evgFill(44, 77, 232, 1); diff --git a/python/evg.py b/python/evg.py index 4303ca8..ce5875f 100644 --- a/python/evg.py +++ b/python/evg.py @@ -38,7 +38,7 @@ class LibShapes(object): evgSaveEnd(char *) evgBackground(unsigned int, unsigned int, unsigned int) evgBackgroundRGB(unsigned int, unsigned int, unsigned int, VGfloat) - evgInit(int *, int *) + evgInit(int *, int *, int) evgFinish() evgSetFill(VGfloat[4]) evgSetStroke(VGfloat[4]) diff --git a/python/hello.py b/python/hello.py index 14cde62..098c164 100644 --- a/python/hello.py +++ b/python/hello.py @@ -7,7 +7,7 @@ evg = LibShapes() w, h = evg.c_int(), evg.c_int() -evg.init(w, h) +evg.init(w, h, 0) evg.begin() evg.background(0, 0, 0) diff --git a/src/libshapes.c b/src/libshapes.c index 1e78921..289084c 100644 --- a/src/libshapes.c +++ b/src/libshapes.c @@ -249,13 +249,14 @@ void evgInitWindowSize(int x, int y, unsigned int w, unsigned int h) { } // init sets the system to its initial state -void evgInit(int *w, int *h) { +void evgInit(int *w, int *h, int layer) { bcm_host_init(); memset(state, 0, sizeof(*state)); state->window_x = init_x; state->window_y = init_y; state->window_width = init_w; state->window_height = init_h; + state->layer = (int32_t) layer; oglinit(state); SansTypeface = loadfont(DejaVuSans_glyphPoints, DejaVuSans_glyphPointIndices, diff --git a/src/libshapes.h b/src/libshapes.h index 35c788b..9bde1f4 100644 --- a/src/libshapes.h +++ b/src/libshapes.h @@ -35,7 +35,7 @@ extern "C" { extern void evgSaveEnd(const char *); extern void evgBackground(unsigned int, unsigned int, unsigned int); extern void evgBackgroundRGB(unsigned int, unsigned int, unsigned int, VGfloat); - extern void evgInit(int *, int *); + extern void evgInit(int *, int *, int); extern void evgFinish(); extern void evgSetFill(VGfloat[4]); extern void evgSetStroke(VGfloat[4]); diff --git a/src/oglinit.c b/src/oglinit.c index a880d15..39b0250 100644 --- a/src/oglinit.c +++ b/src/oglinit.c @@ -132,7 +132,7 @@ void oglinit(EVG_STATE_T * state) { dispman_display = vc_dispmanx_display_open(0 /* LCD */ ); dispman_update = vc_dispmanx_update_start(0); - dispman_element = vc_dispmanx_element_add(dispman_update, dispman_display, 0 /*layer */ , &dst_rect, 0 /*src */ , + dispman_element = vc_dispmanx_element_add(dispman_update, dispman_display, state->layer, &dst_rect, 0 /*src */ , &src_rect, DISPMANX_PROTECTION_NONE, &alpha, 0 /*clamp */ , 0 /*transform */ ); diff --git a/src/oglinit.h b/src/oglinit.h index d3d27af..a3c2160 100644 --- a/src/oglinit.h +++ b/src/oglinit.h @@ -22,6 +22,9 @@ typedef struct { /** Window height, in pixels. */ uint32_t window_height; + /** Layer on which to draw stuff. */ + int32_t layer; + DISPMANX_ELEMENT_HANDLE_T element; // EGL data