24 #include <EGL/eglext.h> 26 #include <GLES3/gl3.h> 32 #define Centimeter(x) (Meter(x) / 100.0f) 33 #define Millimeter(x) (Meter(x) / 1000.0f) 42 #define Num_Views Num_Eyes * 2 45 #define Screen_Resolution_X 2560 46 #define Screen_Resolution_Y 1440 47 #define Screen_Size_X Meter(0.125f) 48 #define Screen_Size_Y Meter(0.072f) 54 #define Eye_Fb_Resolution_X 1280 55 #define Eye_Fb_Resolution_Y 1440 59 #define Multisample_Samples 4 66 #define Eye_IPD Millimeter(61.0f) 70 #define Lens_IPD Millimeter(64.0f) 74 #define Eye_Display_Distance Centimeter(8.0f) 77 #ifndef GL_TEXTURE_BORDER_COLOR_EXT 78 #define GL_TEXTURE_BORDER_COLOR_EXT 0x1004 81 #ifndef GL_CLAMP_TO_BORDER_EXT 82 #define GL_CLAMP_TO_BORDER_EXT 0x812D 85 #include <android/log.h> 86 #define LOG_TAG "ARMVR" 87 #define LOGI(...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__) 88 #define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__) 89 #define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__) 184 #define GL_CHECK(x) \ 187 GLenum glError = glGetError(); \ 188 if(glError != GL_NO_ERROR) { \ 189 LOGE("glGetError() = %i (0x%.8x) at %s:%i\n", glError, glError, __FILE__, __LINE__); \ 193 #define get_attrib_location(prog, name) \ 194 app->a_##prog##_##name = GL_CHECK(glGetAttribLocation(app->program_##prog, #name)); \ 195 if (app->a_##prog##_##name < 0) { \ 196 LOGE("Invalid or unused attribute %s\n", #name); \ 198 #define get_uniform_location(prog, name) \ 199 app->u_##prog##_##name = GL_CHECK(glGetUniformLocation(app->program_##prog, #name)); \ 200 if (app->u_##prog##_##name < 0) { \ 201 LOGE("Invalid or unused uniform %s\n", #name); \ 203 #define attribfv(prog, name, n, stride, offset) \ 204 GL_CHECK(glEnableVertexAttribArray(app->a_##prog##_##name)); \ 205 GL_CHECK(glVertexAttribPointer(app->a_##prog##_##name, n, GL_FLOAT, GL_FALSE, \ 206 stride * sizeof(GLfloat), (void*)(offset * sizeof(GLfloat)))); 207 #define attribiv(prog, name, n, stride, offset) \ 208 GL_CHECK(glEnableVertexAttribArray(app->a_##prog##_##name)); \ 209 GL_CHECK(glVertexAttribPointer(app->a_##prog##_##name, n, GL_INT, GL_FALSE, \ 210 stride * sizeof(GLint), (void*)(offset * sizeof(GLint)) )); 211 #define uniform1f(prog, name, value) GL_CHECK(glUniform1f(app->u_##prog##_##name, value)); 212 #define uniform2f(prog, name, x, y) GL_CHECK(glUniform2f(app->u_##prog##_##name, x, y)); 213 #define uniform2fv(prog, name, value) GL_CHECK(glUniform2fv(app->u_##prog##_##name, 1, &value[0])); 214 #define uniform3fv(prog, name, value) GL_CHECK(glUniform3fv(app->u_##prog##_##name, 1, &value[0])); 215 #define uniform1i(prog, name, value) GL_CHECK(glUniform1i(app->u_##prog##_##name, value)); 216 #define uniformm4(prog, name, value) GL_CHECK(glUniformMatrix4fv(app->u_##prog##_##name, 1, GL_FALSE, value.value_ptr())); 217 #define uniformm4array(prog, name, value, arraySize) GL_CHECK(glUniformMatrix4fv(app->u_##prog##_##name, arraySize, GL_FALSE, value.value_ptr()));
DistortionCoefficients coefficients_green
GLuint u_distort_framebuffer
void gl_check(const char *msg)
DistortionCoefficients coefficients_red
void app_update_and_render(App *app)
GLuint a_distort_position
GLuint a_distort_uv_green_high_res
void app_initialize(App *app)
GLuint a_distort_uv_green_low_res
GLuint a_distort_uv_blue_low_res
GLuint u_distort_layer_index
DistortionCoefficients coefficients_blue
GLuint a_distort_uv_blue_high_res
GLuint a_distort_uv_red_low_res
GLuint a_distort_uv_red_high_res