no gl inside nvg frame

pull/2643/head
Adeeb Shihadeh 2020-11-27 14:25:52 -08:00
parent f66fac1a0b
commit b9c14c92a7
1 changed files with 17 additions and 5 deletions

View File

@ -486,7 +486,7 @@ void ui_draw_vision_alert(UIState *s, cereal::ControlsState::AlertSize va_size,
}
}
static void ui_draw_vision(UIState *s) {
static void ui_draw_vision_frame(UIState *s) {
const UIScene *scene = &s->scene;
const Rect &viz_rect = scene->viz_rect;
@ -498,6 +498,10 @@ static void ui_draw_vision(UIState *s) {
glDisable(GL_SCISSOR_TEST);
glViewport(0, 0, s->fb_w, s->fb_h);
}
static void ui_draw_vision(UIState *s) {
const UIScene *scene = &s->scene;
// Draw augmented elements
if (!scene->frontview && scene->world_objects_visible) {
@ -533,14 +537,22 @@ void ui_draw(UIState *s) {
s->scene.ui_viz_ro = -(sbr_w - 6 * bdr_s);
}
const bool draw_vision = s->started && s->active_app == cereal::UiLayoutState::App::NONE &&
s->status != STATUS_OFFROAD && s->vision_connected;
// GL drawing functions
ui_draw_background(s);
if (draw_vision) {
ui_draw_vision_frame(s);
}
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glViewport(0, 0, s->fb_w, s->fb_h);
// NVG drawing functions - should be no GL inside NVG frame
nvgBeginFrame(s->vg, s->fb_w, s->fb_h, 1.0f);
ui_draw_sidebar(s);
if (s->started && s->active_app == cereal::UiLayoutState::App::NONE &&
s->status != STATUS_OFFROAD && s->vision_connected) {
if (draw_vision) {
ui_draw_vision(s);
}
nvgEndFrame(s->vg);