26 #define BASE_ASSET_PATH "/data/data/com.arm.developer.vrsdk.simplevr/files/" 27 #define SHADER_PATH(name) BASE_ASSET_PATH name 31 FILE *file = fopen(filename,
"rb");
34 LOGE(
"Failed to open file %s\n", filename);
37 fseek(file, 0, SEEK_END);
38 long length = ftell(file);
39 fseek(file, 0, SEEK_SET);
40 char *data = (
char *)calloc(length + 1,
sizeof(
char));
43 LOGE(
"Failed to allocate memory for file data %s\n", filename);
46 size_t read = fread(data,
sizeof(
char), length, file);
49 LOGE(
"Failed to read whole file %s\n", filename);
58 GLuint result = glCreateShader(type);
59 glShaderSource(result, 1, (
const GLchar**)&source, NULL);
60 glCompileShader(result);
62 glGetShaderiv(result, GL_COMPILE_STATUS, &status);
63 if (status == GL_FALSE) {
65 glGetShaderiv(result, GL_INFO_LOG_LENGTH, &length);
66 GLchar *info =
new GLchar[length];
67 glGetShaderInfoLog(result, length, NULL, info);
68 LOGE(
"[COMPILE] %s\n", info);
76 GLuint program = glCreateProgram();
77 for (
int i = 0; i < count; ++i)
78 glAttachShader(program, shaders[i]);
79 glLinkProgram(program);
80 for (
int i = 0; i < count; ++i)
81 glDetachShader(program, shaders[i]);
83 glGetProgramiv(program, GL_LINK_STATUS, &status);
84 if (status == GL_FALSE) {
86 glGetProgramiv(program, GL_INFO_LOG_LENGTH, &length);
87 GLchar *info =
new GLchar[length];
88 glGetProgramInfoLog(program, length, NULL, info);
89 LOGE(
"[LINK] %s\n", info);
GLuint compile_shader(const char *source, GLenum type)
void load_distort_shader(App *app)
char * read_file(const char *filename)
void load_cube_shader(App *app)
void load_assets(App *app)
GLuint link_program(GLuint *shaders, int count)
#define SHADER_PATH(name)