diff --git a/selfdrive/common/ipc.c b/selfdrive/common/ipc.c index 8d39107478..41b0cc0eaa 100644 --- a/selfdrive/common/ipc.c +++ b/selfdrive/common/ipc.c @@ -16,7 +16,7 @@ int ipc_connect(const char* socket_path) { int err; int sock = socket(AF_UNIX, SOCK_SEQPACKET, 0); - assert(sock >= 0); + if (sock < 0) return -1; struct sockaddr_un addr = { .sun_family = AF_UNIX, }; diff --git a/selfdrive/ui/linux.cc b/selfdrive/ui/linux.cc index 14ecfd6190..8e4a8492dc 100644 --- a/selfdrive/ui/linux.cc +++ b/selfdrive/ui/linux.cc @@ -25,9 +25,16 @@ FramebufferState* framebuffer_init( int *out_w, int *out_h) { glfwInit(); +#ifndef __APPLE__ glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_ES_API); glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0); +#else + glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); + glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); + glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); + glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2); +#endif glfwWindowHint(GLFW_RESIZABLE, 0); GLFWwindow* window; window = glfwCreateWindow(1920, 1080, "ui", NULL, NULL); @@ -39,7 +46,7 @@ FramebufferState* framebuffer_init( glfwSwapInterval(0); // clear screen - glClearColor(0.2f, 0.2f, 0.2f, 1.0f ); + glClearColor(0.2f, 0.2f, 0.2f, 1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); framebuffer_swap((FramebufferState*)window); @@ -54,6 +61,7 @@ void framebuffer_set_power(FramebufferState *s, int mode) { void framebuffer_swap(FramebufferState *s) { glfwSwapBuffers((GLFWwindow*)s); + glfwPollEvents(); } void touch_init(TouchState *s) { diff --git a/selfdrive/ui/paint.cc b/selfdrive/ui/paint.cc index d1a511f17a..6d7b24c346 100644 --- a/selfdrive/ui/paint.cc +++ b/selfdrive/ui/paint.cc @@ -890,41 +890,46 @@ void ui_draw(UIState *s) { } } +#ifdef NANOVG_GL3_IMPLEMENTATION static const char frame_vertex_shader[] = - "attribute vec4 aPosition;\n" - "attribute vec4 aTexCoord;\n" + "#version 150 core\n" + "in vec4 aPosition;\n" + "in vec4 aTexCoord;\n" "uniform mat4 uTransform;\n" - "varying vec4 vTexCoord;\n" + "out vec4 vTexCoord;\n" "void main() {\n" " gl_Position = uTransform * aPosition;\n" " vTexCoord = aTexCoord;\n" "}\n"; static const char frame_fragment_shader[] = + "#version 150 core\n" "precision mediump float;\n" "uniform sampler2D uTexture;\n" - "varying vec4 vTexCoord;\n" + "out vec4 vTexCoord;\n" + "out vec4 outColor;\n" "void main() {\n" - " gl_FragColor = texture2D(uTexture, vTexCoord.xy);\n" + " outColor = texture(uTexture, vTexCoord.xy);\n" "}\n"; - -static const char line_vertex_shader[] = +#else +static const char frame_vertex_shader[] = "attribute vec4 aPosition;\n" - "attribute vec4 aColor;\n" + "attribute vec4 aTexCoord;\n" "uniform mat4 uTransform;\n" - "varying vec4 vColor;\n" + "varying vec4 vTexCoord;\n" "void main() {\n" " gl_Position = uTransform * aPosition;\n" - " vColor = aColor;\n" + " vTexCoord = aTexCoord;\n" "}\n"; -static const char line_fragment_shader[] = +static const char frame_fragment_shader[] = "precision mediump float;\n" "uniform sampler2D uTexture;\n" - "varying vec4 vColor;\n" + "varying vec4 vTexCoord;\n" "void main() {\n" - " gl_FragColor = vColor;\n" + " gl_FragColor = texture2D(uTexture, vTexCoord.xy);\n" "}\n"; +#endif static const mat4 device_transform = {{ 1.0, 0.0, 0.0, 0.0, @@ -985,13 +990,6 @@ void ui_nvg_init(UIState *s) { s->frame_texture_loc = glGetUniformLocation(s->frame_program, "uTexture"); s->frame_transform_loc = glGetUniformLocation(s->frame_program, "uTransform"); - s->line_program = load_program(line_vertex_shader, line_fragment_shader); - assert(s->line_program); - - s->line_pos_loc = glGetAttribLocation(s->line_program, "aPosition"); - s->line_color_loc = glGetAttribLocation(s->line_program, "aColor"); - s->line_transform_loc = glGetUniformLocation(s->line_program, "uTransform"); - glViewport(0, 0, s->fb_w, s->fb_h); glDisable(GL_DEPTH_TEST); diff --git a/selfdrive/ui/ui.hpp b/selfdrive/ui/ui.hpp index b418a2ac29..65471c3632 100644 --- a/selfdrive/ui/ui.hpp +++ b/selfdrive/ui/ui.hpp @@ -199,10 +199,6 @@ typedef struct UIState { GLint frame_pos_loc, frame_texcoord_loc; GLint frame_texture_loc, frame_transform_loc; - GLuint line_program; - GLint line_pos_loc, line_color_loc; - GLint line_transform_loc; - int rgb_width, rgb_height, rgb_stride; size_t rgb_buf_len; mat4 rgb_transform;