Install shader files

pull/14/head
Andri Yngvason 2020-02-11 21:05:05 +00:00
parent a8d49f3022
commit c274c81fa3
2 changed files with 35 additions and 7 deletions

View File

@ -9,6 +9,7 @@ project(
) )
buildtype = get_option('buildtype') buildtype = get_option('buildtype')
prefix = get_option('prefix')
c_args = [ c_args = [
'-D_GNU_SOURCE', '-D_GNU_SOURCE',
@ -74,6 +75,17 @@ dependencies = [
client_protos, client_protos,
] ]
config = configuration_data()
config.set('PREFIX', '"' + prefix + '"')
configure_file(
output: 'config.h',
configuration: config,
)
install_subdir('shaders', install_dir: 'share/wayvnc')
executable( executable(
'wayvnc', 'wayvnc',
sources, sources,

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2019 Andri Yngvason * Copyright (c) 2019 - 2020 Andri Yngvason
* *
* Permission to use, copy, modify, and/or distribute this software for any * Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above * purpose with or without fee is hereby granted, provided that the above
@ -31,9 +31,12 @@
#include "logging.h" #include "logging.h"
#include "render.h" #include "render.h"
#include "dmabuf.h" #include "dmabuf.h"
#include "config.h"
#define MAYBE_UNUSED __attribute__((unused)) #define MAYBE_UNUSED __attribute__((unused))
#define SHADER_PATH PREFIX "share/wayvnc/shaders"
enum { enum {
ATTR_INDEX_POS = 0, ATTR_INDEX_POS = 0,
ATTR_INDEX_TEXTURE, ATTR_INDEX_TEXTURE,
@ -216,9 +219,22 @@ alloc_failure:
return NULL; return NULL;
} }
static int gl_load_shader_from_file(GLuint* dst, const char* path, GLenum type) static char* read_file_at_path(const char* prefix, const char* file)
{ {
char* source = read_file(path); char path[256];
snprintf(path, sizeof(path), "%s/%s", prefix, file);
path[sizeof(path) - 1] = '\0';
return read_file(path);
}
static int gl_load_shader_from_file(GLuint* dst, const char* file, GLenum type)
{
char* source = read_file_at_path("shaders", file);
if (!source)
source = read_file_at_path(SHADER_PATH, file);
if (!source) if (!source)
return -1; return -1;
@ -381,13 +397,13 @@ int renderer_init(struct renderer* self, uint32_t width, uint32_t height)
goto late_extension_failure; goto late_extension_failure;
if (gl_compile_shader_program(&self->dmabuf_shader_program, if (gl_compile_shader_program(&self->dmabuf_shader_program,
"shaders/dmabuf-vertex.glsl", "dmabuf-vertex.glsl",
"shaders/dmabuf-fragment.glsl") < 0) "dmabuf-fragment.glsl") < 0)
goto shader_failure; goto shader_failure;
if (gl_compile_shader_program(&self->texture_shader_program, if (gl_compile_shader_program(&self->texture_shader_program,
"shaders/texture-vertex.glsl", "texture-vertex.glsl",
"shaders/texture-fragment.glsl") < 0) "texture-fragment.glsl") < 0)
goto shader_failure; goto shader_failure;
self->width = width; self->width = width;