Fix ui on mac (#1044)
* remove line_shader dead code * fix glfwCreateWindow * don't assert on ipc socket failure * window now appears on mac old-commit-hash: 811b3b7a9acbcd71ae3e80990cdf39e9e0289c55
This commit is contained in:
@@ -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,
|
||||
};
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -890,6 +890,28 @@ void ui_draw(UIState *s) {
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef NANOVG_GL3_IMPLEMENTATION
|
||||
static const char frame_vertex_shader[] =
|
||||
"#version 150 core\n"
|
||||
"in vec4 aPosition;\n"
|
||||
"in vec4 aTexCoord;\n"
|
||||
"uniform mat4 uTransform;\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"
|
||||
"out vec4 vTexCoord;\n"
|
||||
"out vec4 outColor;\n"
|
||||
"void main() {\n"
|
||||
" outColor = texture(uTexture, vTexCoord.xy);\n"
|
||||
"}\n";
|
||||
#else
|
||||
static const char frame_vertex_shader[] =
|
||||
"attribute vec4 aPosition;\n"
|
||||
"attribute vec4 aTexCoord;\n"
|
||||
@@ -907,24 +929,7 @@ static const char frame_fragment_shader[] =
|
||||
"void main() {\n"
|
||||
" gl_FragColor = texture2D(uTexture, vTexCoord.xy);\n"
|
||||
"}\n";
|
||||
|
||||
static const char line_vertex_shader[] =
|
||||
"attribute vec4 aPosition;\n"
|
||||
"attribute vec4 aColor;\n"
|
||||
"uniform mat4 uTransform;\n"
|
||||
"varying vec4 vColor;\n"
|
||||
"void main() {\n"
|
||||
" gl_Position = uTransform * aPosition;\n"
|
||||
" vColor = aColor;\n"
|
||||
"}\n";
|
||||
|
||||
static const char line_fragment_shader[] =
|
||||
"precision mediump float;\n"
|
||||
"uniform sampler2D uTexture;\n"
|
||||
"varying vec4 vColor;\n"
|
||||
"void main() {\n"
|
||||
" gl_FragColor = vColor;\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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user