| 5 |
| 6 | static int is_initialized = 0; |
| 7 | static float _coefficientsX[TIMING_NUM][4], _coefficientsY[TIMING_NUM][4]; |
| 8 | static const float _c0x = 0.0; |
| 9 | static const float _c0y = 0.0; |
| 10 | static const float _c3x = 1.0; |
| 11 | static const float _c3y = 1.0; |
| 12 |
| 13 | float scale_factor; |
| 14 | int width, height; |
| 15 | int y_offset_absolute; |
| 16 | static TextureProgram texture_program; |
| 17 | static TextureProgram texture_program_one; |
| 18 | static TextureProgram texture_program_red; |
| 19 | static TextureProgram texture_program_blue; |
| 20 | static TextureProgram texture_program_light_red; |
| 21 | static TextureProgram texture_program_light_blue; |
| 22 | static TextureProgram *texture_program_temp; |
| 23 | static ColorProgram color_program; |
| 24 | static float y_offset; |
| 25 |
| 26 | #define BUFFER_OFFSET(i) ((void*)(i)) |
| 27 |
| 28 | static const vec4 black_color = {0.0f, 0.0f, 0.0f, 1.0f}; |
| 29 | static const vec4 white_color = {1.0f, 1.0f, 1.0f, 1.0f}; |
| 30 |
| 31 | static LayerParams ribbonLayer, privateLayer; |
| 32 |
| 33 | static TexturedShape spiral; |
| 34 | static Shape mask1; |
| 35 | static Shape cloud_extra_mask1; |
| 36 | static Shape cloud_extra_mask2; |
| 37 | static Shape cloud_extra_mask3; |
| 38 | static Shape cloud_extra_mask4; |
| 39 |
| 40 | static Shape cloud_cover; |
| 41 |
| 42 | static Shape free_bg; |
| 43 | static TexturedShape fast_body; |
| 44 | static TexturedShape fast_arrow_shadow; |
| 45 | static TexturedShape fast_arrow; |
| 46 |
| 47 | static TexturedShape free_knot1; |
| 48 | static TexturedShape free_knot2; |
| 49 | static TexturedShape free_knot3; |
| 50 | static TexturedShape free_knot4; |
| 51 |
| 52 | static Shape powerful_bg; |
| 53 | static TexturedShape powerful_mask, powerful_infinity, powerful_infinity_white; |
| 54 |
| 55 | static Shape private_bg; |
| 56 |
| 57 | static TexturedShape telegram_sphere, telegram_plane; |
| 58 |
| 59 | static Shape cloud_bg; |
| 60 |
| 61 | #define starsCount 80 |
| 62 | static TexturedShape star; |
| 63 | static Params stars[starsCount]; |
| 64 |
| 65 | static Shape ribbon1; |
| 66 | static Shape ribbon2; |
| 67 | static Shape ribbon3; |
| 68 | static Shape ribbon4; |
| 69 | static mat4x4 stars_matrix; |
| 70 | static mat4x4 main_matrix; |
| 71 | static mat4x4 ribbons_layer; |
| 72 |
| 73 | static TexturedShape ic_bubble_dot, ic_bubble, ic_cam_lens, ic_cam, ic_pencil, ic_pin, ic_smile_eye, ic_smile, ic_videocam; |
| 74 | static GLuint ic_bubble_dot_texture, ic_bubble_texture, ic_cam_lens_texture, ic_cam_texture, ic_pencil_texture, ic_pin_texture, ic_smile_eye_texture, ic_smile_texture, ic_videocam_texture; |
| 75 | static GLuint telegram_sphere_texture, telegram_plane_texture; |
| 76 | static GLuint fast_spiral_texture, fast_body_texture, fast_arrow_texture, fast_arrow_shadow_texture; |
| 77 | static GLuint free_knot_up_texture, free_knot_down_texture; |
| 78 | static GLuint powerful_mask_texture, powerful_star_texture, powerful_infinity_texture, powerful_infinity_white_texture; |
| 79 | static GLuint private_door_texture, private_screw_texture, private_keyhole_body_texture; |
| 80 | static Shape infinity; |
| 81 |
| 82 | static TexturedShape private_door, private_screw, private_keyhole_body; |
| 83 | static Shape private_stroke; |
| 84 |
| 85 | static Shape start_button; |
| 86 |
| 87 | static const float r1 = 58.5f; |
| 88 | static const float r2 = 70; |
| 89 | static double ms0; |
| 90 | static float date, date0; |
| 91 | static float duration_const = 0.3f; |
| 92 | static int direct; |
| 93 | static int i; |
| 94 | static int current_page, prev_page; |
| 95 | static float time; |
| 96 | static mat4x4 ic_matrix; |
| 97 | static LayerParams ic_pin_layer, ic_cam_layer, ic_videocam_layer, ic_smile_layer, ic_bubble_layer, ic_pencil_layer; |
| 98 | static float time_local = 0; |
| 99 | static float knot_delays[4]; |
| 100 | static float offset_y; |
| 101 | static float ribbonLength = 86.5f; |
| 102 | static int starsFar = 500; |
| 103 | static float scroll_offset; |
| 104 |
| 105 | static float calculated_speedometer_sin; |
| 106 | float ms0_anim; |
| 107 | int fps_anim; |
| 108 | int count_anim_fps; |
| 109 | static float speedometer_scroll_offset = 0, free_scroll_offset = 0, private_scroll_offset = 0; |
| 110 | float anim_pencil_start_time, anim_pencil_start_all_time, anim_pencil_start_all_end_time; |
| 111 | int anim_pencil_stage; |
| 112 | int anim_bubble_dots_stage; |
| 113 | int anim_bubble_dots_end_period; |
| 114 | float anim_videocam_start_time, anim_videocam_next_time, anim_videocam_duration, anim_videocam_angle, anim_videocam_old_angle; |
| 115 | float anim_cam_start_time, anim_cam_next_time, anim_cam_duration, anim_cam_angle, anim_cam_old_angle; |
| 116 | CPoint anim_cam_position, anim_cam_old_position; |
| 117 | int qShot; |
| 118 | float anim_camshot_start_time, anim_camshot_duration; |
| 119 | float anim_smile_start_time1, anim_smile_start_time2, anim_smile_blink_start_time; |
| 120 | int anim_smile_blink_one; |
| 121 | int anim_smile_stage; |
| 122 | static float scale; |
| 123 | float anim_pin_start_time, anim_pin_duration; |
| 124 | static int anim_pencil_period; |
| 125 | static mat4x4 private_matrix; |
| 126 | float cloud_scroll_offset; |
| 127 |
| 128 | static inline void vec2_add(vec2 r, vec2 a, vec2 b) { |
| 129 | int i; |
| 130 | for (i = 0; i < 2; ++i) { |
| 131 | r[i] = a[i] + b[i]; |
| 132 | } |
| 133 | } |
| 134 |
| 135 | static inline float vec2_mul_inner(vec2 a, vec2 b) { |
| 136 | float p = 0.f; |
| 137 | int i; |
| 138 | for (i = 0; i < 2; ++i) { |
| 139 | p += b[i]*a[i]; |
| 140 | } |
| 141 | return p; |
| 142 | } |
| 143 |
| 144 | static inline float vec2_len(vec2 v) { |
| 145 | return sqrtf(vec2_mul_inner(v, v)); |
| 146 | } |
| 147 |
| 148 | static inline void vec2_scale(vec2 r, vec2 v, float s) { |
| 149 | int i; |
| 150 | for (i = 0; i < 2; ++i) { |
| 151 | r[i] = v[i] * s; |
| 152 | } |
| 153 | } |
| 154 |
| 155 | static inline void vec2_norm(vec2 r, vec2 v) { |
| 156 | float k = 1.f / vec2_len(v); |
| 157 | vec2_scale(r, v, k); |
| 158 | } |
| 159 |
| 160 | static inline void mat4x4_identity(mat4x4 M) { |
| 161 | int i, j; |
| 162 | for (i = 0; i < 4; ++i) { |
| 163 | for (j = 0; j < 4; ++j) { |
| 164 | M[i][j] = i == j ? 1.f : 0.f; |
| 165 | } |
| 166 | } |
| 167 | } |
| 168 |
| 169 | static inline void mat4x4_dup(mat4x4 M, mat4x4 N) { |
| 170 | int i, j; |
| 171 | for (i = 0; i < 4; ++i) { |
| 172 | for (j = 0; j < 4; ++j) { |
| 173 | M[i][j] = N[i][j]; |
| 174 | } |
| 175 | } |
| 176 | } |
| 177 |
| 178 | static inline void vec4_scale(vec4 r, vec4 v, float s) { |
| 179 | int i; |
| 180 | for (i = 0; i < 4; ++i) { |
| 181 | r[i] = v[i] * s; |
| 182 | } |
| 183 | } |
| 184 |
| 185 | static inline void mat4x4_scale_aniso(mat4x4 M, mat4x4 a, float x, float y, float z) { |
| 186 | vec4_scale(M[0], a[0], x); |
| 187 | vec4_scale(M[1], a[1], y); |
| 188 | vec4_scale(M[2], a[2], z); |
| 189 | } |
| 190 |
| 191 | static inline void mat4x4_mul(mat4x4 M, mat4x4 a, mat4x4 b) { |
| 192 | int k, r, c; |
| 193 | for (c = 0; c < 4; ++c) { |
| 194 | for (r = 0; r < 4; ++r) { |
| 195 | M[c][r] = 0.f; |
| 196 | for (k = 0; k < 4; ++k) { |
| 197 | M[c][r] += a[k][r] * b[c][k]; |
| 198 | } |
| 199 | } |
| 200 | } |
| 201 | } |
| 202 |
| 203 | static inline void mat4x4_mul_vec4(vec4 r, mat4x4 M, vec4 v) { |
| 204 | int i, j; |
| 205 | for (j = 0; j < 4; ++j) { |
| 206 | r[j] = 0.f; |
| 207 | for (i = 0; i < 4; ++i) { |
| 208 | r[j] += M[i][j] * v[i]; |
| 209 | } |
| 210 | } |
| 211 | } |
| 212 |
| 213 | static inline void mat4x4_translate(mat4x4 T, float x, float y, float z) { |
| 214 | mat4x4_identity(T); |
| 215 | T[3][0] = x; |
| 216 | T[3][1] = y; |
| 217 | T[3][2] = z; |
| 218 | } |
| 219 |
| 220 | static inline void mat4x4_rotate_Z2(mat4x4 Q, mat4x4 M, float angle) { |
| 221 | float s = sinf(angle); |
| 222 | float c = cosf(angle); |
| 223 | mat4x4 R = { |
| 224 | {c, s, 0.f, 0.f}, |
| 225 | {-s, c, 0.f, 0.f}, |
| 226 | {0.f, 0.f, 1.f, 0.f}, |
| 227 | {0.f, 0.f, 0.f, 1.f} |
| 228 | }; |
| 229 | mat4x4_mul(Q, M, R); |
| 230 | } |
| 231 |
| 232 | static inline void mat4x4_rotate_Z(mat4x4 Q, float angle) { |
| 233 | mat4x4 temp; |
| 234 | mat4x4_dup(temp, Q); |
| 235 | mat4x4_rotate_Z2(Q, temp, angle); |
| 236 | } |
| 237 |
| 238 | static inline void mat4x4_translate_in_place(mat4x4 m, float x, float y, float z) { |
| 239 | int i; |
| 240 | for (i = 0; i < 4; ++i) { |
| 241 | m[3][i] += m[0][i] * x + m[1][i] * y + m[2][i] * z; |
| 242 | } |
| 243 | } |
| 244 |
| 245 | static inline float deg_to_radf(float deg) { |
| 246 | return deg * (float)M_PI / 180.0f; |
| 247 | } |
| 248 |
| 249 | static inline float MAXf(float a, float b) { |
| 250 | return a > b ? a : b; |
| 251 | } |
| 252 |
| 253 | static inline float MINf(float a, float b) { |
| 254 | return a < b ? a : b; |
| 255 | } |
| 256 |
| 257 | GLuint compile_shader(const GLenum type, const GLchar* source, const GLint length) { |
| 258 | GLuint shader_object_id = glCreateShader(type); |
| 259 | GLint compile_status; |
| 260 | glShaderSource(shader_object_id, 1, &source, &length); |
| 261 | glCompileShader(shader_object_id); |
| 262 | glGetShaderiv(shader_object_id, GL_COMPILE_STATUS, &compile_status); |
| 263 | return shader_object_id; |
| 264 | } |
| 265 |
| 266 | GLuint link_program(const GLuint vertex_shader, const GLuint fragment_shader) { |
| 267 | GLuint program_object_id = glCreateProgram(); |
| 268 | GLint link_status; |
| 269 | glAttachShader(program_object_id, vertex_shader); |
| 270 | glAttachShader(program_object_id, fragment_shader); |
| 271 | glLinkProgram(program_object_id); |
| 272 | glGetProgramiv(program_object_id, GL_LINK_STATUS, &link_status); |
| 273 | return program_object_id; |
| 274 | } |
| 275 |
| 276 | GLuint build_program(const GLchar * vertex_shader_source, const GLint vertex_shader_source_length, const GLchar * fragment_shader_source, const GLint fragment_shader_source_length) { |
| 277 | GLuint vertex_shader = compile_shader(GL_VERTEX_SHADER, vertex_shader_source, vertex_shader_source_length); |
| 278 | GLuint fragment_shader = compile_shader(GL_FRAGMENT_SHADER, fragment_shader_source, fragment_shader_source_length); |
| 279 | return link_program(vertex_shader, fragment_shader); |
| 280 | } |
| 281 |
| 282 | GLuint create_vbo(const size_t size, const GLvoid* data, const GLenum usage) { |
| 283 | GLuint vbo_object; |
| 284 | glGenBuffers(1, &vbo_object); |
| 285 | glBindBuffer(GL_ARRAY_BUFFER, vbo_object); |
| 286 | glBufferData(GL_ARRAY_BUFFER, (GLsizeiptr) size, data, usage); |
| 287 | glBindBuffer(GL_ARRAY_BUFFER, 0); |
| 288 | return vbo_object; |
| 289 | } |
| 290 |
| 291 | TextureProgram get_texture_program(GLuint program) { |
| 292 | return (TextureProgram) { |
| 293 | program, |
| 294 | glGetAttribLocation(program, "a_Position"), |
| 295 | glGetAttribLocation(program, "a_TextureCoordinates"), |
| 296 | glGetUniformLocation(program, "u_MvpMatrix"), |
| 297 | glGetUniformLocation(program, "u_TextureUnit"), |
| 298 | glGetUniformLocation(program, "u_Alpha")}; |
| 299 | } |
| 300 |
| 301 | ColorProgram get_color_program(GLuint program) { |
| 302 | return (ColorProgram) { |
| 303 | program, |
| 304 | glGetAttribLocation(program, "a_Position"), |
| 305 | glGetUniformLocation(program, "u_MvpMatrix"), |
| 306 | glGetUniformLocation(program, "u_Color"), |
| 307 | glGetUniformLocation(program, "u_Alpha")}; |
| 308 | } |
| 309 |
| 310 | float frand(float from, float to) { |
| 311 | return (float) (((double) random() / RAND_MAX) * (to - from) + from); |
| 312 | } |
| 313 |
| 314 | int irand(int from, int to) { |
| 315 | return (int) (((double) random() / RAND_MAX) * (to - from + 1) + from); |
| 316 | } |
| 317 |
| 318 | int signrand() { |
| 319 | return irand(0, 1) * 2 - 1; |
| 320 | } |
| 321 |
| 322 | static inline float evaluateAtParameterWithCoefficients(float t, float coefficients[]) { |
| 323 | return coefficients[0] + t*coefficients[1] + t*t*coefficients[2] + t*t*t*coefficients[3]; |
| 324 | } |
| 325 |
| 326 | static inline float evaluateDerivationAtParameterWithCoefficients(float t, float coefficients[]) { |
| 327 | return coefficients[1] + 2*t*coefficients[2] + 3*t*t*coefficients[3]; |
| 328 | } |
| 329 |
| 330 | static inline float calcParameterViaNewtonRaphsonUsingXAndCoefficientsForX(float x, float coefficientsX[]) { |
| 331 | float t = x; |
| 332 | int i; |
| 333 | for (i = 0; i < 10; i++) { |
| 334 | float x2 = evaluateAtParameterWithCoefficients(t, coefficientsX) - x; |
| 335 | float d = evaluateDerivationAtParameterWithCoefficients(t, coefficientsX); |
| 336 | float dt = x2 / d; |
| 337 | t = t - dt; |
| 338 | } |
| 339 | return t; |
| 340 | } |
| 341 |
| 342 | static inline float calcParameterUsingXAndCoefficientsForX (float x, float coefficientsX[]) { |
| 343 | return calcParameterViaNewtonRaphsonUsingXAndCoefficientsForX(x, coefficientsX); |
| 344 | } |
| 345 |
| 346 | float timing(float x, timing_type type) { |
| 347 | if (is_initialized == 0) { |
| 348 | is_initialized = 1; |
| 349 |
| 350 | float c[TIMING_NUM][4]; |
| 351 | c[Default][0] = 0.25f; |
| 352 | c[Default][1] = 0.1f; |
| 353 | c[Default][2] = 0.25f; |
| 354 | c[Default][3] = 1.0f; |
| 355 | c[EaseInEaseOut][0] = 0.42f; |
| 356 | c[EaseInEaseOut][1] = 0.0f; |
| 357 | c[EaseInEaseOut][2] = 0.58f; |
| 358 | c[EaseInEaseOut][3] = 1.0f; |
| 359 | c[EaseIn][0] = 0.42f; |
| 360 | c[EaseIn][1] = 0.0f; |
| 361 | c[EaseIn][2] = 1.0f; |
| 362 | c[EaseIn][3] = 1.0f; |
| 363 | c[EaseOut][0] = 0.0f; |
| 364 | c[EaseOut][1] = 0.0f; |
| 365 | c[EaseOut][2] = 0.58f; |
| 366 | c[EaseOut][3] = 1.0f; |
| 367 | c[EaseOutBounce][0] = 0.0f; |
| 368 | c[EaseOutBounce][1] = 0.0f; |
| 369 | c[EaseOutBounce][2] = 0.0f; |
| 370 | c[EaseOutBounce][3] = 1.25; |
| 371 | c[Linear][0] = 0.0; |
| 372 | c[Linear][1] = 0.0; |
| 373 | c[Linear][2] = 1.0; |
| 374 | c[Linear][3] = 1.0; |
| 375 | int i; |
| 376 | for (i = 0; i < TIMING_NUM; i++) { |
| 377 | float _c1x = c[i][0]; |
| 378 | float _c1y = c[i][1]; |
| 379 | float _c2x = c[i][2]; |
| 380 | float _c2y = c[i][3]; |
| 381 | _coefficientsX[i][0] = _c0x; |
| 382 | _coefficientsX[i][1] = -3.0f * _c0x + 3.0f * _c1x; |
| 383 | _coefficientsX[i][2] = 3.0f * _c0x - 6.0f * _c1x + 3.0f * _c2x; |
| 384 | _coefficientsX[i][3] = -_c0x + 3.0f * _c1x - 3.0f * _c2x + _c3x; |
| 385 | _coefficientsY[i][0] = _c0y; |
| 386 | _coefficientsY[i][1] = -3.0f * _c0y + 3.0f * _c1y; |
| 387 | _coefficientsY[i][2] = 3.0f * _c0y - 6.0f * _c1y + 3.0f * _c2y; |
| 388 | _coefficientsY[i][3] = -_c0y + 3.0f * _c1y - 3.0f * _c2y + _c3y; |
| 389 | } |
| 390 | } |
| 391 |
| 392 | if (x == 0.0 || x == 1.0) { |
| 393 | return x; |
| 394 | } |
| 395 | float t = calcParameterUsingXAndCoefficientsForX(x, _coefficientsX[type]); |
| 396 | float y = evaluateAtParameterWithCoefficients(t, _coefficientsY[type]); |
| 397 | return y; |
| 398 | } |
| 399 |
| 400 | void set_y_offset_objects(float a) { |
| 401 | y_offset = a; |
| 402 | } |
| 403 |
| 404 | void setup_shaders() { |
| 405 | const char *vshader = |
| 406 | "uniform mat4 u_MvpMatrix;" |
| 407 | "attribute vec4 a_Position;" |
| 408 | "void main(){" |
| 409 | " gl_Position = u_MvpMatrix * a_Position;" |
| 410 | "}"; |
| 411 |
| 412 | const char *fshader = |
| 413 | "precision lowp float;" |
| 414 | "uniform vec4 u_Color;" |
| 415 | "uniform float u_Alpha;" |
| 416 | "void main() {" |
| 417 | " gl_FragColor = u_Color;" |
| 418 | " gl_FragColor.w*=u_Alpha;" |
| 419 | "}"; |
| 420 |
| 421 | color_program = get_color_program(build_program(vshader, (GLint)strlen(vshader), fshader, (GLint)strlen(fshader))); |
| 422 |
| 423 | const char *vshader_texture = |
| 424 | "uniform mat4 u_MvpMatrix;" |
| 425 | "attribute vec4 a_Position;" |
| 426 | "attribute vec2 a_TextureCoordinates;" |
| 427 | "varying vec2 v_TextureCoordinates;" |
| 428 | "void main(){" |
| 429 | " v_TextureCoordinates = a_TextureCoordinates;" |
| 430 | " gl_Position = u_MvpMatrix * a_Position;" |
| 431 | "}"; |
| 432 |
| 433 | const char *fshader_texture = |
| 434 | "precision lowp float;" |
| 435 | "uniform sampler2D u_TextureUnit;" |
| 436 | "varying vec2 v_TextureCoordinates;" |
| 437 | "uniform float u_Alpha;" |
| 438 | "void main(){" |
| 439 | " gl_FragColor = texture2D(u_TextureUnit, v_TextureCoordinates);" |
| 440 | " gl_FragColor.w *= u_Alpha;" |
| 441 | "}"; |
| 442 |
| 443 | texture_program = get_texture_program(build_program(vshader_texture, (GLint)strlen(vshader_texture), fshader_texture, (GLint)strlen(fshader_texture))); |
| 444 |
| 445 | const char *vshader_texture_blue = |
| 446 | "uniform mat4 u_MvpMatrix;" |
| 447 | "attribute vec4 a_Position;" |
| 448 | "attribute vec2 a_TextureCoordinates;" |
| 449 | "varying vec2 v_TextureCoordinates;" |
| 450 | "void main(){" |
| 451 | " v_TextureCoordinates = a_TextureCoordinates;" |
| 452 | " gl_Position = u_MvpMatrix * a_Position;" |
| 453 | "}"; |
| 454 |
| 455 | const char *fshader_texture_blue = |
| 456 | "precision lowp float;" |
| 457 | "uniform sampler2D u_TextureUnit;" |
| 458 | "varying vec2 v_TextureCoordinates;" |
| 459 | "uniform float u_Alpha;" |
| 460 | "void main(){" |
| 461 | " gl_FragColor = texture2D(u_TextureUnit, v_TextureCoordinates);" |
| 462 | " float p = u_Alpha*gl_FragColor.w;" |
| 463 | " gl_FragColor = vec4(0,0.6,0.898,p);" |
| 464 | "}"; |
| 465 |
| 466 | texture_program_blue = get_texture_program(build_program(vshader_texture_blue, (GLint)strlen(vshader_texture_blue), fshader_texture_blue, (GLint)strlen(fshader_texture_blue))); |
| 467 |
| 468 | const char *vshader_texture_red = |
| 469 | "uniform mat4 u_MvpMatrix;" |
| 470 | "attribute vec4 a_Position;" |
| 471 | "attribute vec2 a_TextureCoordinates;" |
| 472 | "varying vec2 v_TextureCoordinates;" |
| 473 | "void main(){" |
| 474 | " v_TextureCoordinates = a_TextureCoordinates;" |
| 475 | " gl_Position = u_MvpMatrix * a_Position;" |
| 476 | "}"; |
| 477 |
| 478 | const char *fshader_texture_red = |
| 479 | "precision lowp float;" |
| 480 | "uniform sampler2D u_TextureUnit;" |
| 481 | "varying vec2 v_TextureCoordinates;" |
| 482 | "uniform float u_Alpha;" |
| 483 | "void main(){" |
| 484 | " gl_FragColor = texture2D(u_TextureUnit, v_TextureCoordinates);" |
| 485 | " float p = gl_FragColor.w*u_Alpha;" |
| 486 | " gl_FragColor = vec4(210./255.,57./255.,41./255.,p);" |
| 487 | "}"; |
| 488 |
| 489 | texture_program_red = get_texture_program(build_program(vshader_texture_red, (GLint)strlen(vshader_texture_red), fshader_texture_red, (GLint)strlen(fshader_texture_red))); |
| 490 |
| 491 | vshader = |
| 492 | "uniform mat4 u_MvpMatrix;" |
| 493 | "attribute vec4 a_Position;" |
| 494 | "attribute vec2 a_TextureCoordinates;" |
| 495 | "varying vec2 v_TextureCoordinates;" |
| 496 | "void main(){" |
| 497 | " v_TextureCoordinates = a_TextureCoordinates;" |
| 498 | " gl_Position = u_MvpMatrix * a_Position;" |
| 499 | "}"; |
| 500 |
| 501 | fshader = |
| 502 | "precision lowp float;" |
| 503 | "uniform sampler2D u_TextureUnit;" |
| 504 | "varying vec2 v_TextureCoordinates;" |
| 505 | "uniform float u_Alpha;" |
| 506 | "void main(){" |
| 507 | " gl_FragColor = texture2D(u_TextureUnit, v_TextureCoordinates);" |
| 508 | " float p = u_Alpha*gl_FragColor.w;" |
| 509 | " gl_FragColor = vec4(246./255., 73./255., 55./255., p);" |
| 510 | "}"; |
| 511 |
| 512 | texture_program_light_red = get_texture_program(build_program(vshader, (GLint)strlen(vshader), fshader, (GLint)strlen(fshader))); |
| 513 |
| 514 | vshader = |
| 515 | "uniform mat4 u_MvpMatrix;" |
| 516 | "attribute vec4 a_Position;" |
| 517 | "attribute vec2 a_TextureCoordinates;" |
| 518 | "varying vec2 v_TextureCoordinates;" |
| 519 | "void main(){" |
| 520 | " v_TextureCoordinates = a_TextureCoordinates;" |
| 521 | " gl_Position = u_MvpMatrix * a_Position;" |
| 522 | "}"; |
| 523 |
| 524 | fshader = |
| 525 | "precision lowp float;" |
| 526 | "uniform sampler2D u_TextureUnit;" |
| 527 | "varying vec2 v_TextureCoordinates;" |
| 528 | "uniform float u_Alpha;" |
| 529 | "void main(){" |
| 530 | " gl_FragColor = texture2D(u_TextureUnit, v_TextureCoordinates);" |
| 531 | " float p = u_Alpha*gl_FragColor.w;" |
| 532 | " gl_FragColor = vec4(42./255.,180./255.,247./255.,p);" |
| 533 | "}"; |
| 534 |
| 535 | texture_program_light_blue = get_texture_program(build_program(vshader, (GLint)strlen(vshader), fshader, (GLint)strlen(fshader))); |
| 536 |
| 537 | vshader = |
| 538 | "uniform mat4 u_MvpMatrix;" |
| 539 | "attribute vec4 a_Position;" |
| 540 | "attribute vec2 a_TextureCoordinates;" |
| 541 | "varying vec2 v_TextureCoordinates;" |
| 542 | "void main(){" |
| 543 | " v_TextureCoordinates = a_TextureCoordinates;" |
| 544 | " gl_Position = u_MvpMatrix * a_Position;" |
| 545 | "}"; |
| 546 |
| 547 | fshader = |
| 548 | "precision lowp float;" |
| 549 | "uniform sampler2D u_TextureUnit;" |
| 550 | "varying vec2 v_TextureCoordinates;" |
| 551 | "uniform float u_Alpha;" |
| 552 | "void main(){" |
| 553 | " gl_FragColor = texture2D(u_TextureUnit, v_TextureCoordinates);" |
| 554 | " gl_FragColor *= u_Alpha;" |
| 555 | "}"; |
| 556 |
| 557 | texture_program_one = get_texture_program(build_program(vshader, (GLint)strlen(vshader), fshader, (GLint)strlen(fshader))); |
| 558 | } |
| 559 |
| 560 | CPoint CPointMake(float x, float y) { |
| 561 | CPoint p = {x, y}; |
| 562 | return p; |
| 563 | } |
| 564 |
| 565 | CSize CSizeMake(float width, float height) { |
| 566 | CSize s = {width, height}; |
| 567 | return s; |
| 568 | } |
| 569 |
| 570 | float D2R(float a) { |
| 571 | return (float)(a * M_PI / 180.0); |
| 572 | } |
| 573 |
| 574 | float R2D(float a) { |
| 575 | return (float)(a * 180.0 / M_PI); |
| 576 | } |
| 577 |
| 578 | xyz xyzMake(float x, float y, float z) { |
| 579 | xyz result; |
| 580 | result.x = x; |
| 581 | result.y = y; |
| 582 | result.z = z; |
| 583 | return result; |
| 584 | } |
| 585 |
| 586 | LayerParams default_layer_params() { |
| 587 | LayerParams params; |
| 588 | params.anchor.x = params.anchor.y = params.anchor.z = 0; |
| 589 | params.position.x = params.position.y = params.position.z = 0; |
| 590 | params.rotation = 0; |
| 591 | params.scale.x = params.scale.y = params.scale.z = 1.0f; |
| 592 | return params; |
| 593 | } |
| 594 |
| 595 | Params default_params() { |
| 596 | Params params; |
| 597 | params.anchor.x = params.anchor.y = params.anchor.z = 0.0f; |
| 598 | params.position.x = params.position.y = params.position.z = 0.0f; |
| 599 | params.rotation = 0; |
| 600 | params.scale.x = params.scale.y = params.scale.z = 1.0f; |
| 601 | params.alpha = 1.0f; |
| 602 | params.var_params.side_length = 0; |
| 603 | params.var_params.start_angle = 0; |
| 604 | params.var_params.end_angle = 0; |
| 605 | params.var_params.angle = 0; |
| 606 | params.var_params.size = CSizeMake(0, 0); |
| 607 | params.var_params.radius = 0; |
| 608 | params.var_params.width = 0; |
| 609 | params.const_params.is_star = 0; |
| 610 | params.layer_params = default_layer_params(); |
| 611 | return params; |
| 612 | } |
| 613 |
| 614 | void mat4x4_translate_independed(mat4x4 m, float x, float y, float z) { |
| 615 | mat4x4 tr; |
| 616 | mat4x4_identity(tr); |
| 617 | mat4x4_translate_in_place(tr, x, y, z); |
| 618 | mat4x4 m_dup; |
| 619 | mat4x4_dup(m_dup, m); |
| 620 | mat4x4_mul(m, tr, m_dup); |
| 621 | } |
| 622 |
| 623 | static inline void mvp_matrix(mat4x4 model_view_projection_matrix, Params params, mat4x4 view_projection_matrix) { |
| 624 | mat4x4 model_matrix; |
| 625 | mat4x4_identity(model_matrix); |
| 626 | mat4x4 id; |
| 627 | mat4x4_identity(id); |
| 628 | mat4x4_translate(model_matrix, -params.anchor.x, -params.anchor.y, params.anchor.z); |
| 629 | mat4x4 scaled; |
| 630 | mat4x4_identity(scaled); |
| 631 | mat4x4_scale_aniso(scaled, scaled, params.scale.x, -params.scale.y, params.scale.z); |
| 632 | mat4x4 tmp; |
| 633 | mat4x4_dup(tmp, model_matrix); |
| 634 | mat4x4_mul(model_matrix, scaled, tmp); |
| 635 | mat4x4 rotate; |
| 636 | mat4x4_dup(rotate, id); |
| 637 | mat4x4_rotate_Z2(rotate, id, deg_to_radf(-params.rotation)); |
| 638 | mat4x4_dup(tmp, model_matrix); |
| 639 | mat4x4_mul(model_matrix, rotate, tmp); |
| 640 | mat4x4_translate_independed(model_matrix, params.position.x, -params.position.y, params.position.z); |
| 641 | mat4x4 model_matrix3; |
| 642 | mat4x4_identity(model_matrix3); |
| 643 | mat4x4 mm; |
| 644 | mat4x4_mul(mm, model_matrix3, view_projection_matrix); |
| 645 | mat4x4_mul(model_view_projection_matrix, mm, model_matrix); |
| 646 | mat4x4_translate_independed(model_view_projection_matrix, 0, -y_offset / view_projection_matrix[3][3], 0); |
| 647 | } |
| 648 |
| 649 | void draw_shape(const Shape* shape, mat4x4 view_projection_matrix) { |
| 650 | if (shape->params.alpha > 0 && (fabs(shape->params.scale.x) > 0 && fabs(shape->params.scale.y) > 0 && fabs(shape->params.scale.z) > 0)) { |
| 651 | mat4x4 model_view_projection_matrix; |
| 652 | mvp_matrix(model_view_projection_matrix, shape->params, view_projection_matrix); |
| 653 | glUseProgram(color_program.program); |
| 654 | glUniformMatrix4fv(color_program.u_mvp_matrix_location, 1, GL_FALSE, (GLfloat *) model_view_projection_matrix); |
| 655 | if (shape->params.rotation == 5.0f) { |
| 656 | glUniform4fv(color_program.u_color_location, 1, shape->color); |
| 657 | } else if (shape->params.rotation == 10.0f) { |
| 658 | vec4 col = {0, 1, 0, 1}; |
| 659 | glUniform4fv(color_program.u_color_location, 1, col); |
| 660 | } else { |
| 661 | glUniform4fv(color_program.u_color_location, 1, shape->color); |
| 662 | } |
| 663 | glUniform1f(color_program.u_alpha_loaction, shape->params.alpha); |
| 664 | glVertexAttribPointer(color_program.a_position_location, 2, GL_FLOAT, GL_FALSE, sizeof(CPoint), &shape->data[0].x); |
| 665 | glEnableVertexAttribArray(color_program.a_position_location); |
| 666 | glDrawArrays(shape->params.const_params.triangle_mode, 0, shape->num_points); |
| 667 | } |
| 668 | } |
| 669 |
| 670 | void draw_textured_shape(const TexturedShape* shape, mat4x4 view_projection_matrix, texture_program_type program_type) { |
| 671 | if (shape->params.alpha > 0 && (fabs(shape->params.scale.x) > 0 && fabs(shape->params.scale.y) > 0 && fabs(shape->params.scale.z) > 0)) { |
| 672 | mat4x4 model_view_projection_matrix; |
| 673 | mvp_matrix(model_view_projection_matrix, shape->params, view_projection_matrix); |
| 674 | if (shape->params.const_params.is_star == 1) { |
| 675 | vec4 pos; |
| 676 | vec4 vertex = {0, 0, 0, 1}; |
| 677 | mat4x4_mul_vec4(pos, model_view_projection_matrix, vertex); |
| 678 | vec4 p_NDC = {pos[0] / pos[3], pos[1] / pos[3], pos[2] / pos[3], pos[3] / pos[3]}; |
| 679 | vec4 p_window = {p_NDC[0] * width, -p_NDC[1] * height, 0, 0}; |
| 680 | int d = 160; |
| 681 | if (fabs(p_window[0]) > d || p_window[1] > y_offset_absolute * 2 + d || p_window[1] < y_offset_absolute * 2 - d) { |
| 682 | return; |
| 683 | } |
| 684 | } |
| 685 | if (program_type == RED) { |
| 686 | texture_program_temp = &texture_program_red; |
| 687 | } else if (program_type == BLUE) { |
| 688 | texture_program_temp = &texture_program_blue; |
| 689 | } else if (program_type == LIGHT_RED) { |
| 690 | texture_program_temp = &texture_program_light_red; |
| 691 | } else if (program_type == LIGHT_BLUE) { |
| 692 | texture_program_temp = &texture_program_light_blue; |
| 693 | } else if (program_type == NORMAL_ONE) { |
| 694 | texture_program_temp = &texture_program_one; |
| 695 | } else { |
| 696 | texture_program_temp = &texture_program; |
| 697 | } |
| 698 |
| 699 |
| 700 | glUseProgram(texture_program_temp->program); |
| 701 |
| 702 | glActiveTexture(GL_TEXTURE0); |
| 703 | glBindTexture(GL_TEXTURE_2D, shape->texture); |
| 704 | glUniformMatrix4fv(texture_program_temp->u_mvp_matrix_location, 1, GL_FALSE, (GLfloat *) model_view_projection_matrix); |
| 705 | glUniform1i(texture_program_temp->u_texture_unit_location, 0); |
| 706 | glUniform1f(texture_program_temp->u_alpha_loaction, shape->params.alpha); |
| 707 |
| 708 | glBindBuffer(GL_ARRAY_BUFFER, shape->buffer); |
| 709 | glVertexAttribPointer(texture_program_temp->a_position_location, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(GL_FLOAT), BUFFER_OFFSET(0)); |
| 710 | glVertexAttribPointer(texture_program_temp->a_texture_coordinates_location, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(GL_FLOAT), BUFFER_OFFSET(2 * sizeof(GL_FLOAT))); |
| 711 | glEnableVertexAttribArray(texture_program_temp->a_position_location); |
| 712 | glEnableVertexAttribArray(texture_program_temp->a_texture_coordinates_location); |
| 713 | glDrawArrays(shape->params.const_params.triangle_mode, 0, shape->num_points); |
| 714 | glBindBuffer(GL_ARRAY_BUFFER, 0); |
| 715 | } |
| 716 | } |
| 717 |
| 718 | static inline int size_of_rounded_rectangle_in_vertices(int round_count) { |
| 719 | return 4*(2+round_count)+2; |
| 720 | } |
| 721 |
| 722 | static inline void gen_rounded_rectangle(CPoint* out, CSize size, float radius, int round_count) { |
| 723 | int offset = 0; |
| 724 | out[offset++] = CPointMake(0, 0); |
| 725 | float k = (float) (M_PI / 2 / (round_count + 1)); |
| 726 | int i = 0; |
| 727 | int n = 0; |
| 728 | for (i = (round_count + 2) * n; i <= round_count + 1 + (round_count + 1) * n; i++) { |
| 729 | out[offset++] = CPointMake(size.width / 2 - radius + cosf(i * k) * radius, size.height / 2 - radius + sinf(i * k) * radius); |
| 730 | } |
| 731 | n++; |
| 732 | for (i = (round_count + 1) * n; i <= round_count + 1 + (round_count + 1) * n; i++) { |
| 733 | out[offset++] = CPointMake(-size.width / 2 + radius + cosf(i * k) * radius, size.height / 2 - radius + sinf(i * k) * radius); |
| 734 | } |
| 735 | n++; |
| 736 | for (i = (round_count + 1) * n; i <= round_count + 1 + (round_count + 1) * n; i++) { |
| 737 | out[offset++] = CPointMake(-size.width / 2 + radius + cosf(i * k) * radius, -size.height / 2 + radius + sinf(i * k) * radius); |
| 738 | } |
| 739 | n++; |
| 740 | for (i = (round_count + 1) * n; i <= round_count + 1 + (round_count + 1) * n; i++) { |
| 741 | out[offset++] = CPointMake(size.width / 2 - radius + cosf(i * k) * radius, -size.height / 2 + radius + sinf(i * k) * radius); |
| 742 | } |
| 743 | out[offset] = CPointMake(size.width / 2, size.height / 2 - radius); |
| 744 | } |
| 745 |
| 746 | Shape create_rounded_rectangle(CSize size, float radius, int round_count, const vec4 color) { |
| 747 | int real_vertex_count = size_of_rounded_rectangle_in_vertices(round_count); |
| 748 |
| 749 | Params params = default_params(); |
| 750 | params.const_params.datasize = sizeof(CPoint) * real_vertex_count * 2; |
| 751 | params.const_params.round_count = round_count; |
| 752 | params.const_params.triangle_mode = GL_TRIANGLE_FAN; |
| 753 |
| 754 | params.var_params.size = size; |
| 755 | params.var_params.radius = radius; |
| 756 | CPoint *data = malloc(params.const_params.datasize); |
| 757 | gen_rounded_rectangle(data, params.var_params.size, params.var_params.radius, params.const_params.round_count); |
| 758 | return (Shape) {{color[0], color[1], color[2], color[3]}, data, create_vbo(params.const_params.datasize, data, GL_DYNAMIC_DRAW), real_vertex_count, params}; |
| 759 | } |
| 760 |
| 761 | void change_rounded_rectangle(Shape* shape, CSize size, float radius) { |
| 762 | if ((*shape).params.var_params.size.width != size.width || (*shape).params.var_params.size.height != size.height || (*shape).params.var_params.radius != radius) { |
| 763 | (*shape).params.var_params.size.width = size.width; |
| 764 | (*shape).params.var_params.size.height = size.height; |
| 765 | (*shape).params.var_params.radius = radius; |
| 766 | gen_rounded_rectangle((*shape).data, (*shape).params.var_params.size, (*shape).params.var_params.radius, (*shape).params.const_params.round_count); |
| 767 | glBindBuffer(GL_ARRAY_BUFFER, shape->buffer); |
| 768 | glBufferSubData(GL_ARRAY_BUFFER, 0, shape->params.const_params.datasize, shape->data); |
| 769 | glBindBuffer(GL_ARRAY_BUFFER, 0); |
| 770 | } |
| 771 | } |
| 772 |
| 773 | static inline int size_of_segmented_square_in_vertices() { |
| 774 | return 7; |
| 775 | } |
| 776 |
| 777 | static inline CPoint square_point(float angle, float radius) { |
| 778 | CPoint p = {0.0f, 0.0f}; |
| 779 | if (angle <= M_PI / 2 * 0.5f || angle > M_PI / 2 * 3.5f) { |
| 780 | p = CPointMake(radius, radius * sinf(angle) / cosf(angle)); |
| 781 | } else if (angle <= M_PI / 2 * 1.5) { |
| 782 | p = CPointMake(radius * cosf(angle) / sinf(angle), radius); |
| 783 | } else if (angle <= M_PI / 2 * 2.5) { |
| 784 | p = CPointMake(-radius, -radius * sinf(angle) / cosf(angle)); |
| 785 | } else if (angle <= (float) (M_PI / 2 * 3.5)) { |
| 786 | p = CPointMake(-radius * cosf(angle) / sinf(angle), -radius); |
| 787 | } |
| 788 | return p; |
| 789 | } |
| 790 |
| 791 | static inline CPoint square_texture_point(CPoint p, float side_length) { |
| 792 | return CPointMake((-p.x / side_length * 0.5f + 0.5f), -p.y / side_length * 0.5f + 0.5f); |
| 793 | } |
| 794 |
| 795 | static inline void gen_segmented_square(CPoint* out, float side_length, float start_angle, float end_angle) { |
| 796 | CPoint p; |
| 797 | float radius = side_length; |
| 798 | int offset = 0; |
| 799 | float k = 1; |
| 800 | float da = D2R(-2.6f * 2) * k; |
| 801 | p = CPointMake(sinf(start_angle + end_angle) * 6 * k, -cosf(start_angle + end_angle) * 6 * k); |
| 802 | out[offset++] = p; |
| 803 | out[offset++] = square_texture_point(p, side_length); |
| 804 | p = square_point(start_angle + da, radius); |
| 805 | out[offset++] = p; |
| 806 | out[offset++] = square_texture_point(p, side_length); |
| 807 | int q = 0; |
| 808 | int i; |
| 809 | for (i = (int) start_angle; i < floorf(R2D(start_angle + end_angle + da)); i++) { |
| 810 | if ((i + 45) % 90 == 0) { |
| 811 | p = square_point(D2R(i), radius); |
| 812 | out[offset++] = p; |
| 813 | out[offset++] = square_texture_point(p, side_length); |
| 814 | q++; |
| 815 | } |
| 816 | } |
| 817 | p = square_point(start_angle + end_angle + da, radius); |
| 818 | out[offset++] = p; |
| 819 | out[offset++] = square_texture_point(p, side_length); |
| 820 | for (i = 0; i < 4 - q; i++) { |
| 821 | p = square_point(start_angle + end_angle + da, radius); |
| 822 | out[offset++] = p; |
| 823 | out[offset++] = square_texture_point(p, side_length); |
| 824 | } |
| 825 | } |
| 826 |
| 827 | TexturedShape create_segmented_square(float side_length, float start_angle, float end_angle, GLuint texture) { |
| 828 | int real_vertex_count = size_of_segmented_square_in_vertices(); |
| 829 | Params params = default_params(); |
| 830 | params.const_params.datasize = sizeof(CPoint) * real_vertex_count * 2 * 2; |
| 831 | params.const_params.triangle_mode = GL_TRIANGLE_FAN; |
| 832 | CPoint *data = malloc(params.const_params.datasize); |
| 833 | gen_segmented_square(data, side_length, start_angle, end_angle); |
| 834 | return (TexturedShape) {texture, data, create_vbo(params.const_params.datasize, data, GL_DYNAMIC_DRAW), real_vertex_count, params}; |
| 835 | } |
| 836 |
| 837 | void change_segmented_square(TexturedShape* shape, float side_length, float start_angle, float end_angle) { |
| 838 | if ((*shape).params.var_params.side_length != side_length || (*shape).params.var_params.start_angle != start_angle || (*shape).params.var_params.end_angle != end_angle) { |
| 839 | (*shape).params.var_params.side_length = side_length; |
| 840 | (*shape).params.var_params.start_angle = start_angle; |
| 841 | (*shape).params.var_params.end_angle = end_angle; |
| 842 | gen_segmented_square((*shape).data, side_length, start_angle, end_angle); |
| 843 | glBindBuffer(GL_ARRAY_BUFFER, shape->buffer); |
| 844 | glBufferSubData(GL_ARRAY_BUFFER, 0, shape->params.const_params.datasize, shape->data); |
| 845 | glBindBuffer(GL_ARRAY_BUFFER, 0); |
| 846 | } |
| 847 | } |
| 848 |
| 849 | static inline void gen_rectangle(CPoint* out, CSize size) { |
| 850 | out[0] = CPointMake(-size.width / 2, -size.height / 2); |
| 851 | out[1] = CPointMake(size.width / 2, -size.height / 2); |
| 852 | out[2] = CPointMake(-size.width / 2, size.height / 2); |
| 853 | out[3] = CPointMake(size.width / 2, size.height / 2); |
| 854 | } |
| 855 |
| 856 | Shape create_rectangle(CSize size, const vec4 color) { |
| 857 | int real_vertex_count = 4; |
| 858 | Params params = default_params(); |
| 859 | params.const_params.datasize = sizeof(CPoint) * real_vertex_count; |
| 860 | params.const_params.triangle_mode = GL_TRIANGLE_STRIP; |
| 861 | CPoint *data = malloc(params.const_params.datasize); |
| 862 | gen_rectangle(data, size); |
| 863 | return (Shape) {{color[0], color[1], color[2], color[3]}, data, create_vbo(params.const_params.datasize, data, GL_DYNAMIC_DRAW), real_vertex_count, params}; |
| 864 | } |
| 865 |
| 866 | static inline CPoint rectangle_texture_point(CPoint p, CSize size) { |
| 867 | return CPointMake(1 - (-p.x / size.width + 0.5f), p.y / size.height + 0.5f); |
| 868 | } |
| 869 |
| 870 | static inline void gen_textured_rectangle(CPoint* out, CSize size) { |
| 871 | out[0] = CPointMake(-size.width / 2, -size.height / 2); |
| 872 | out[1] = rectangle_texture_point(CPointMake(-size.width / 2, -size.height / 2), size); |
| 873 | out[2] = CPointMake(size.width / 2, -size.height / 2); |
| 874 | out[3] = rectangle_texture_point(CPointMake(size.width / 2, -size.height / 2), size); |
| 875 | out[4] = CPointMake(-size.width / 2, size.height / 2); |
| 876 | out[5] = rectangle_texture_point(CPointMake(-size.width / 2, size.height / 2), size); |
| 877 | out[6] = CPointMake(size.width / 2, size.height / 2); |
| 878 | out[7] = rectangle_texture_point(CPointMake(size.width / 2, size.height / 2), size); |
| 879 | } |
| 880 |
| 881 | TexturedShape create_textured_rectangle(CSize size, GLuint texture) { |
| 882 | int real_vertex_count = 4; |
| 883 | Params params = default_params(); |
| 884 | params.const_params.datasize = sizeof(CPoint) * real_vertex_count * 2; |
| 885 | params.const_params.triangle_mode = GL_TRIANGLE_STRIP; |
| 886 | CPoint *data = malloc(params.const_params.datasize); |
| 887 | gen_textured_rectangle(data, size); |
| 888 | return (TexturedShape) {texture, data, create_vbo(params.const_params.datasize, data, GL_STATIC_DRAW), real_vertex_count, params}; |
| 889 | } |
| 890 |
| 891 | static inline void gen_ribbon(CPoint* out, float length) { |
| 892 | out[0] = CPointMake(-MAXf(length - 5.5f, 0), -5.5f); |
| 893 | out[1] = CPointMake(0, -5.5f); |
| 894 | out[2] = CPointMake(-MAXf(length, 0), 5.5f); |
| 895 | out[3] = CPointMake(0, 5.5f); |
| 896 | } |
| 897 |
| 898 | Shape create_ribbon(float length, const vec4 color) { |
| 899 | int real_vertex_count = 4; |
| 900 | Params params=default_params(); |
| 901 | params.const_params.datasize = sizeof(CPoint) * real_vertex_count; |
| 902 | params.const_params.triangle_mode = GL_TRIANGLE_STRIP; |
| 903 | params.var_params.side_length = length; |
| 904 | CPoint *data = malloc(params.const_params.datasize); |
| 905 | gen_ribbon(data, length); |
| 906 | return (Shape) {{color[0], color[1], color[2], color[3]}, data, create_vbo(params.const_params.datasize, data, GL_DYNAMIC_DRAW), real_vertex_count, params}; |
| 907 | } |
| 908 |
| 909 | void change_ribbon(Shape* shape, float length) { |
| 910 | if ((*shape).params.var_params.side_length != length) { |
| 911 | (*shape).params.var_params.side_length = length; |
| 912 | gen_ribbon((*shape).data, length); |
| 913 | glBindBuffer(GL_ARRAY_BUFFER, shape->buffer); |
| 914 | glBufferSubData(GL_ARRAY_BUFFER, 0, shape->params.const_params.datasize, shape->data); |
| 915 | glBindBuffer(GL_ARRAY_BUFFER, 0); |
| 916 | } |
| 917 | } |
| 918 |
| 919 | static inline int size_of_segmented_circle_in_vertices(int num_points) { |
| 920 | return 1 + (num_points + 1); |
| 921 | } |
| 922 |
| 923 | static inline void gen_circle(CPoint* out, float radius, int vertex_count) { |
| 924 | int offset = 0; |
| 925 | out[offset++] = CPointMake(0, 0); |
| 926 | int i; |
| 927 | for (i = 0; i <= vertex_count; i++) { |
| 928 | out[offset++] = CPointMake(radius * (cosf(2 * (float) M_PI * (i / (float) vertex_count))), radius * sinf(2 * (float) M_PI * (i / (float) vertex_count))); |
| 929 | } |
| 930 | } |
| 931 |
| 932 | Shape create_circle(float radius, int vertex_count, const vec4 color) { |
| 933 | int real_vertex_count = size_of_segmented_circle_in_vertices(vertex_count); |
| 934 | Params params = default_params(); |
| 935 | params.const_params.datasize = sizeof(CPoint) * real_vertex_count; |
| 936 | params.const_params.triangle_mode = GL_TRIANGLE_FAN; |
| 937 | params.const_params.round_count = vertex_count; |
| 938 | CPoint *data = (CPoint *) malloc(params.const_params.datasize); |
| 939 | gen_circle(data, radius, vertex_count); |
| 940 | return (Shape) {{color[0], color[1], color[2], color[3]}, data, create_vbo(params.const_params.datasize, data, GL_STATIC_DRAW), real_vertex_count, params}; |
| 941 | } |
| 942 |
| 943 | int size_of_infinity_in_vertices(int segment_count) { |
| 944 | return (segment_count + 1) * 2; |
| 945 | } |
| 946 |
| 947 | static inline void gen_infinity(CPoint* out, float width, float angle, int segment_count) { |
| 948 | CPoint path[13]; |
| 949 | path[0] = CPointMake(53, 23); |
| 950 | path[1] = CPointMake(49, 31); |
| 951 | path[2] = CPointMake(39, 47); |
| 952 | path[3] = CPointMake(22, 47); |
| 953 | path[4] = CPointMake(6, 47); |
| 954 | path[5] = CPointMake(0, 31); |
| 955 | path[6] = CPointMake(0, 23); |
| 956 | path[7] = CPointMake(0, 16); |
| 957 | path[8] = CPointMake(5, 0); |
| 958 | path[9] = CPointMake(23, 0); |
| 959 | path[10] = CPointMake(39, 0); |
| 960 | path[11] = CPointMake(48, 15); |
| 961 | path[12] = CPointMake(52, 21); |
| 962 | int offset = 0; |
| 963 | int seg; |
| 964 | for (seg = 0; seg <= segment_count; seg++) { |
| 965 | float tt = ((float) seg / (float) segment_count) * angle; |
| 966 | int q = 4; |
| 967 | float tstep = 1.f / q; |
| 968 | int n = (int) floor(tt / tstep); |
| 969 | CPoint a = path[0 + 3 * n];; |
| 970 | CPoint p1 = path[1 + 3 * n]; |
| 971 | CPoint p2 = path[2 + 3 * n]; |
| 972 | CPoint b = path[3 + 3 * n]; |
| 973 | float t = (tt - tstep * n) * q; |
| 974 | float nt = 1.0f - t; |
| 975 |
| 976 | vec2 p = {a.x * nt * nt * nt + 3.0f * p1.x * nt * nt * t + 3.0f * p2.x * nt * t * t + b.x * t * t * t, |
| 977 | a.y * nt * nt * nt + 3.0f * p1.y * nt * nt * t + 3.0f * p2.y * nt * t * t + b.y * t * t * t}; |
| 978 | vec2 tangent = {-3.0f * a.x * nt * nt + 3.0f * p1.x * (1.0f - 4.0f * t + 3.0f * t * t) + 3.0f * p2.x * (2.0f * t - 3.0f * t * t) + 3.0f * b.x * t * t, |
| 979 | -3.0f * a.y * nt * nt + 3.0f * p1.y * (1.0f - 4.0f * t + 3.0f * t * t) + 3.0f * p2.y * (2.0f * t - 3.0f * t * t) + 3.0f * b.y * t * t}; |
| 980 |
| 981 | vec2 tan_norm = {-tangent[1], tangent[0]}; |
| 982 | vec2 norm; |
| 983 | vec2_norm(norm, tan_norm); |
| 984 |
| 985 | vec2 v; |
| 986 | vec2 norm_scaled; |
| 987 | vec2_scale(norm_scaled, norm, +width / 2.f); |
| 988 | vec2_add(v, p, norm_scaled); |
| 989 |
| 990 | out[offset] = CPointMake(v[0], v[1]); |
| 991 | offset++; |
| 992 |
| 993 | vec2_scale(norm_scaled, norm, -width / 2.f); |
| 994 | vec2_add(v, p, norm_scaled); |
| 995 |
| 996 | out[offset] = CPointMake(v[0], v[1]); |
| 997 | offset++; |
| 998 | } |
| 999 | } |
| 1000 |
| 1001 | Shape create_infinity(float width, float angle, int segment_count, const vec4 color) { |
| 1002 | int real_vertex_count = size_of_infinity_in_vertices(segment_count); |
| 1003 | Params params = default_params(); |
| 1004 | params.const_params.datasize = sizeof(CPoint) * real_vertex_count; |
| 1005 | params.const_params.triangle_mode = GL_TRIANGLE_STRIP; |
| 1006 | params.const_params.round_count = segment_count; |
| 1007 | params.var_params.width = width; |
| 1008 | params.var_params.angle = angle; |
| 1009 | CPoint *data = malloc(params.const_params.datasize); |
| 1010 | gen_infinity(data, width, angle, segment_count); |
| 1011 | return (Shape) {{color[0], color[1], color[2], color[3]}, data, create_vbo(params.const_params.datasize, data, GL_DYNAMIC_DRAW), real_vertex_count, params}; |
| 1012 | } |
| 1013 |
| 1014 | void change_infinity(Shape* shape, float angle) { |
| 1015 | if ((*shape).params.var_params.angle != angle) { |
| 1016 | (*shape).params.var_params.angle = angle; |
| 1017 | gen_infinity(shape->data, (*shape).params.var_params.width, (*shape).params.var_params.angle, (*shape).params.const_params.round_count); |
| 1018 | glBindBuffer(GL_ARRAY_BUFFER, shape->buffer); |
| 1019 | glBufferData(GL_ARRAY_BUFFER, shape->params.const_params.datasize, shape->data, GL_DYNAMIC_DRAW); |
| 1020 | glBindBuffer(GL_ARRAY_BUFFER, 0); |
| 1021 | } |
| 1022 | } |
| 1023 |
| 1024 | static inline int size_of_rounded_rectangle_stroked_in_vertices(int round_count) { |
| 1025 | return 4 * (2 + round_count) * 2 + 2; |
| 1026 | } |
| 1027 |
| 1028 | static inline void gen_rounded_rectangle_stroked(CPoint* out, CSize size, float radius, float stroke_width, int round_count) { |
| 1029 | int offset = 0; |
| 1030 | float k = (float) (M_PI / 2 / (round_count + 1)); |
| 1031 | float inner_radius = radius - stroke_width; |
| 1032 | int i = 0; |
| 1033 | int n = 0; |
| 1034 | for (i = (round_count + 2) * n; i <= round_count + 1 + (round_count + 1) * n; i++) { |
| 1035 | out[offset++] = CPointMake(size.width / 2 - radius + cosf(i * k) * radius, size.height / 2 - radius + sinf(i * k) * radius); |
| 1036 | out[offset++] = CPointMake(size.width / 2 - radius + cosf(i * k) * inner_radius, size.height / 2 - radius + sinf(i * k) * inner_radius); |
| 1037 | } |
| 1038 | n++; |
| 1039 | for (i = (round_count + 1) * n; i <= round_count + 1 + (round_count + 1) * n; i++) { |
| 1040 | out[offset++] = CPointMake(-size.width / 2 + radius + cosf(i * k) * radius, size.height / 2 - radius + sinf(i * k) * radius); |
| 1041 | out[offset++] = CPointMake(-size.width / 2 + radius + cosf(i * k) * inner_radius, size.height / 2 - radius + sinf(i * k) * inner_radius); |
| 1042 | } |
| 1043 | n++; |
| 1044 | for (i = (round_count + 1) * n; i <= round_count + 1 + (round_count + 1) * n; i++) { |
| 1045 | out[offset++] = CPointMake(-size.width / 2 + radius + cosf(i * k) * radius, -size.height / 2 + radius + sinf(i * k) * radius); |
| 1046 | out[offset++] = CPointMake(-size.width / 2 + radius + cosf(i * k) * inner_radius, -size.height / 2 + radius + sinf(i * k) * inner_radius); |
| 1047 | } |
| 1048 | n++; |
| 1049 | for (i = (round_count + 1) * n; i <= round_count + 1 + (round_count + 1) * n; i++) { |
| 1050 | out[offset++] = CPointMake(size.width / 2 - radius + cosf(i * k) * radius, -size.height / 2 + radius + sinf(i * k) * radius); |
| 1051 | out[offset++] = CPointMake(size.width / 2 - radius + cosf(i * k) * inner_radius, -size.height / 2 + radius + sinf(i * k) * inner_radius); |
| 1052 | } |
| 1053 | i = 0; |
| 1054 | out[offset++] = CPointMake(size.width / 2 - radius + cosf(i * k) * radius, size.height / 2 - radius + sinf(i * k) * radius); |
| 1055 | out[offset] = CPointMake(size.width / 2 - radius + cosf(i * k) * inner_radius, size.height / 2 - radius + sinf(i * k) * inner_radius); |
| 1056 | } |
| 1057 |
| 1058 | Shape create_rounded_rectangle_stroked(CSize size, float radius, float stroke_width, int round_count, const vec4 color) { |
| 1059 | int real_vertex_count = size_of_rounded_rectangle_stroked_in_vertices(round_count); |
| 1060 | Params params = default_params(); |
| 1061 | params.const_params.round_count = round_count; |
| 1062 | params.const_params.datasize = sizeof(CPoint) * real_vertex_count * 2; |
| 1063 | params.var_params.size = size; |
| 1064 | params.var_params.radius = radius; |
| 1065 | params.var_params.width = stroke_width; |
| 1066 | CPoint *data = (CPoint *) malloc(params.const_params.datasize); |
| 1067 | gen_rounded_rectangle_stroked(data, params.var_params.size, params.var_params.radius, params.var_params.width, params.const_params.round_count); |
| 1068 | params.const_params.triangle_mode = GL_TRIANGLE_STRIP; |
| 1069 | return (Shape) {{color[0], color[1], color[2], color[3]}, data, create_vbo(params.const_params.datasize, data, GL_DYNAMIC_DRAW), real_vertex_count, params}; |
| 1070 | } |
| 1071 |
| 1072 | void change_rounded_rectangle_stroked(Shape* shape, CSize size, float radius, __unused float stroke_width) { |
| 1073 | if ((*shape).params.var_params.size.width != size.width || (*shape).params.var_params.size.height != size.height || (*shape).params.var_params.radius != radius) { |
| 1074 | (*shape).params.var_params.size.width = size.width; |
| 1075 | (*shape).params.var_params.size.height = size.height; |
| 1076 | (*shape).params.var_params.radius = radius; |
| 1077 | gen_rounded_rectangle_stroked((*shape).data, (*shape).params.var_params.size, (*shape).params.var_params.radius, (*shape).params.var_params.width, (*shape).params.const_params.round_count); |
| 1078 | glBindBuffer(GL_ARRAY_BUFFER, shape->buffer); |
| 1079 | glBufferSubData(GL_ARRAY_BUFFER, 0, shape->params.const_params.datasize, shape->data); |
| 1080 | glBindBuffer(GL_ARRAY_BUFFER, 0); |
| 1081 | } |
| 1082 | } |
| 1083 |
| 1084 | //------------------------------ |
| 1085 |
| 1086 | float t(float start_value, float end_value, float start_time, float duration, timing_type type) { |
| 1087 | if (time > start_time + duration) { |
| 1088 | return end_value; |
| 1089 | } |
| 1090 | if (type == Linear) { |
| 1091 | return start_value + (end_value - start_value) * MINf(duration + start_time, MAXf(.0, (time - start_time))) / duration; |
| 1092 | } |
| 1093 | return start_value + (end_value - start_value) * timing(MINf(duration + start_time, MAXf(.0, (time - start_time))) / duration, type); |
| 1094 | } |
| 1095 |
| 1096 | float t_reversed(float end_value, float start_value, float start_time, float duration, timing_type type) { |
| 1097 | if (time>start_time+duration) { |
| 1098 | return end_value; |
| 1099 | } |
| 1100 | if (type == Linear) { |
| 1101 | return start_value + (end_value - start_value)*MINf(duration+start_time, MAXf(0.0f, (time - start_time))) /duration; |
| 1102 | } |
| 1103 | return start_value + (end_value - start_value) * timing(MINf(duration+start_time, MAXf(0.0f, (time - start_time))) / duration, type); |
| 1104 | } |
| 1105 |
| 1106 |
| 1107 | float t_local(float start_value, float end_value, float start_time, float duration, timing_type type) { |
| 1108 | if (type == Sin) { |
| 1109 | return start_value + (end_value - start_value) * sinf(MINf(MAXf((time_local - start_time) / duration * (float) M_PI, 0), (float) M_PI)); |
| 1110 | } |
| 1111 |
| 1112 | if (time_local > start_time + duration) { |
| 1113 | return end_value; |
| 1114 | } |
| 1115 |
| 1116 | if (type == Linear) { |
| 1117 | return start_value + (end_value - start_value) * MINf(duration + start_time, MAXf(.0, (time_local - start_time))) / duration; |
| 1118 | } |
| 1119 | return start_value + (end_value - start_value) * timing(MINf(duration + start_time, MAXf(.0, (time_local - start_time))) / duration, type); |
| 1120 | } |
| 1121 |
| 1122 | xyz star_create_position(float far) { |
| 1123 | starsFar = 1500; |
| 1124 |
| 1125 | int minR = 100; |
| 1126 | int maxR = 1000; |
| 1127 |
| 1128 | return xyzMake(signrand() * frand(minR, maxR), signrand() * frand(minR, maxR), far); |
| 1129 | } |
| 1130 |
| 1131 | xyz star_initial_position(int randZ, int forward) { |
| 1132 | starsFar = 1500; |
| 1133 |
| 1134 | int minR = 100; |
| 1135 | int maxR = 1000; |
| 1136 |
| 1137 | float z = 0; |
| 1138 | if (forward == 1) { |
| 1139 | if (randZ == 0) { |
| 1140 | z = -starsFar; |
| 1141 | } else { |
| 1142 | z = frand(0, -starsFar); |
| 1143 | } |
| 1144 | } |
| 1145 |
| 1146 | return xyzMake(signrand() * frand(minR, maxR), signrand() * frand(minR, maxR), z); |
| 1147 | } |
| 1148 |
| 1149 | void draw_stars() { |
| 1150 | float k = (float) width / (float) height; |
| 1151 |
| 1152 | set_y_offset_objects(-100 * k * 0); |
| 1153 | for (i = 0; i < starsCount; i++) { |
| 1154 | float stars_scroll_offset = MAXf(0, scroll_offset) * 2; |
| 1155 |
| 1156 | float transition_speed; |
| 1157 | if (direct == 1) { |
| 1158 | float s = 5; |
| 1159 | transition_speed = s - t(0, s, 0, duration_const + 1 + 0.8f, Linear); |
| 1160 | } else { |
| 1161 | transition_speed = t(-4, 0, 0, duration_const + 1, EaseOut); |
| 1162 | } |
| 1163 |
| 1164 | float speed = stars_scroll_offset + transition_speed; |
| 1165 | stars[i].position.z += speed; |
| 1166 |
| 1167 | if (stars[i].position.z > 0 && speed > 0) { |
| 1168 | stars[i].position = star_initial_position(0, 1); |
| 1169 | } |
| 1170 | if (stars[i].position.z < -1500 && speed < 0) { |
| 1171 | stars[i].position = star_initial_position(0, 0); |
| 1172 | } |
| 1173 |
| 1174 | float inc = scroll_offset * 100; |
| 1175 | stars[i].position.z = stars[i].position.z + inc; |
| 1176 |
| 1177 | star.params.position = stars[i].position; |
| 1178 | float s = 1 + (-stars[i].position.z) / starsFar * 5; |
| 1179 |
| 1180 | star.params.scale = xyzMake(s, s, 1); |
| 1181 | float far = starsFar; |
| 1182 | float k = 10.; |
| 1183 | star.params.alpha = (1 - (-stars[i].position.z) / far) * k; |
| 1184 | star.params.alpha = star.params.alpha * star.params.alpha / k; |
| 1185 |
| 1186 |
| 1187 | draw_textured_shape(&star, stars_matrix, NORMAL); |
| 1188 |
| 1189 | stars[i].position.z = stars[i].position.z - inc; |
| 1190 | } |
| 1191 |
| 1192 | set_y_offset_objects(offset_y); |
| 1193 | } |
| 1194 |
| 1195 | static inline void mat4x4_plain(mat4x4 M, int width, int height) { |
| 1196 | int i, j; |
| 1197 | for (i = 0; i < 4; ++i) { |
| 1198 | for (j = 0; j < 4; ++j) { |
| 1199 | M[i][j] = 0.0f; |
| 1200 | } |
| 1201 | } |
| 1202 |
| 1203 | M[0][0] = 1; |
| 1204 | M[1][1] = 1; |
| 1205 | M[2][2] = 1; |
| 1206 | M[0][0] = 1; |
| 1207 | M[1][1] = (float) width / (float) height; |
| 1208 | M[2][2] = 1; |
| 1209 | M[3][3] = (float) width / 2.0f; |
| 1210 | } |
| 1211 |
| 1212 | static inline void mat4x4_stars(mat4x4 m, float y_fov_in_degrees, float aspect, float n, float f, int width, int height) { |
| 1213 | int is_iOS = 0; |
| 1214 | if (height >= width) { |
| 1215 | float k = (float) width / (float) height; |
| 1216 | float q = !is_iOS ? 1.4f : 0.7f; |
| 1217 | m[0][0] = 1.0f / q; |
| 1218 | m[1][0] = 0.0f; |
| 1219 | m[2][0] = 0.0f; |
| 1220 | m[3][0] = 0.0f; |
| 1221 |
| 1222 | m[1][0] = 0.0f; |
| 1223 | m[1][1] = k / q; |
| 1224 | m[1][2] = 0.0f; |
| 1225 | m[1][3] = 0.0f; |
| 1226 |
| 1227 | m[2][0] = 0.0f; |
| 1228 | m[2][1] = 0.0f; |
| 1229 | m[2][2] = 1.0f; |
| 1230 | m[2][3] = -1.25f; |
| 1231 |
| 1232 | m[3][0] = 0.0f; |
| 1233 | m[3][1] = 0.0f; |
| 1234 | m[3][2] = 0.0f; |
| 1235 | m[3][3] = width * k; |
| 1236 | } else { |
| 1237 | float k = (float) height / (float) width; |
| 1238 | float q = !is_iOS ? 2.0f : 0.7f; |
| 1239 |
| 1240 | m[0][0] = 1.0f / q; |
| 1241 | m[1][0] = 0.0f; |
| 1242 | m[2][0] = 0.0f; |
| 1243 | m[3][0] = 0.0f; |
| 1244 |
| 1245 | m[1][0] = 0.0f; |
| 1246 | m[1][1] = (1.0f / k) / q; |
| 1247 | m[1][2] = 0.0f; |
| 1248 | m[1][3] = 0.0f; |
| 1249 |
| 1250 | m[2][0] = 0.0f; |
| 1251 | m[2][1] = 0.0f; |
| 1252 | m[2][2] = 1.0f; |
| 1253 | m[2][3] = -1.25f; |
| 1254 |
| 1255 | m[3][0] = 0.0f; |
| 1256 | m[3][1] = 0.0f; |
| 1257 | m[3][2] = 0.0f; |
| 1258 | m[3][3] = height * k; |
| 1259 | } |
| 1260 | mat4x4_translate_independed(m, 0, -2 * y_offset_absolute / (float) height + 4 * scale_factor / (float) height, 0); |
| 1261 | } |
| 1262 |
| 1263 | void rglNormalDraw() { |
| 1264 | glDisable(GL_DEPTH_TEST); |
| 1265 | glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
| 1266 | glColorMask(1,1,1,1); |
| 1267 | glDepthMask(0); |
| 1268 | } |
| 1269 |
| 1270 | void rglMaskDraw() { |
| 1271 | glEnable(GL_DEPTH_TEST); |
| 1272 | glDisable(GL_BLEND); |
| 1273 | glDepthMask(1); |
| 1274 | glColorMask(0, 0, 0, 0); |
| 1275 | glDepthFunc(GL_GREATER); |
| 1276 | glClearDepthf(0); |
| 1277 | glClear(GL_DEPTH_BUFFER_BIT); |
| 1278 | } |
| 1279 |
| 1280 | void rglNormalDrawThroughMask() { |
| 1281 | glColorMask(1,1,1,1); |
| 1282 | glDepthFunc(GL_LESS); |
| 1283 | glDepthMask(0); |
| 1284 | } |
| 1285 |
| 1286 | void mat4x4_scaled(mat4x4 matrix, float s) { |
| 1287 | mat4x4_identity(matrix); |
| 1288 | mat4x4_scale_aniso(matrix, matrix, s, s, s); |
| 1289 | } |
| 1290 |
| 1291 | void mat4x4_layer(mat4x4 matrix, LayerParams params, float s, float r) { |
| 1292 | float a = main_matrix[1][1]; |
| 1293 | mat4x4 model_matrix; |
| 1294 | mat4x4_identity(model_matrix); |
| 1295 | mat4x4 id; |
| 1296 | mat4x4_identity(id); |
| 1297 | float sc = main_matrix[3][3]; |
| 1298 | mat4x4_translate(model_matrix, -params.anchor.x / sc, params.anchor.y / sc * a, params.anchor.z / sc); |
| 1299 | mat4x4 scaled; |
| 1300 | mat4x4_identity(scaled); |
| 1301 | float f = 1.0f; |
| 1302 | mat4x4_scale_aniso(scaled, scaled, params.scale.x * f, params.scale.y * f, params.scale.z * f); |
| 1303 | mat4x4 tmp; |
| 1304 | mat4x4_dup(tmp, model_matrix); |
| 1305 | mat4x4_mul(model_matrix, scaled, tmp); |
| 1306 | mat4x4 rotate; |
| 1307 | mat4x4_dup(rotate, id); |
| 1308 | mat4x4_rotate_Z2(rotate, id, -deg_to_radf(params.rotation)); |
| 1309 | mat4x4_dup(tmp, model_matrix); |
| 1310 | mat4x4_mul(model_matrix, rotate, tmp); |
| 1311 | mat4x4_translate_independed(model_matrix, params.position.x / sc, -params.position.y / sc * a, params.position.z / sc); |
| 1312 |
| 1313 | mat4x4 m; |
| 1314 | mat4x4_mul(m, model_matrix, main_matrix); |
| 1315 |
| 1316 | m[1][0] /= a; |
| 1317 | m[0][1] *= a; |
| 1318 |
| 1319 | mat4x4 scale_m; |
| 1320 | mat4x4_scaled(scale_m, s); |
| 1321 | mat4x4_rotate_Z(scale_m, r); |
| 1322 | scale_m[1][0] /= a; |
| 1323 | scale_m[0][1] *= a; |
| 1324 | mat4x4_mul(matrix, scale_m, m); |
| 1325 | } |
| 1326 |
| 1327 | float bubble_dots_sinf(float a) { |
| 1328 | if (a < M_PI * 2 * anim_bubble_dots_end_period) { |
| 1329 | return sinf(a); |
| 1330 | } |
| 1331 | return 0; |
| 1332 | } |
| 1333 |
| 1334 | static void reset_ic() { |
| 1335 | anim_smile_start_time1 = time_local; |
| 1336 | anim_pencil_start_time = 0; |
| 1337 | anim_pencil_start_all_end_time = 0; |
| 1338 | anim_cam_next_time = time_local; |
| 1339 | anim_smile_stage = 0; |
| 1340 | anim_smile_blink_one = 0; |
| 1341 | anim_pencil_stage = 0; |
| 1342 | anim_bubble_dots_end_period = 4; |
| 1343 | anim_pencil_period = 1; |
| 1344 | } |
| 1345 |
| 1346 | static void draw_ic(int type) { |
| 1347 | float rotation; |
| 1348 | float beginTimeK; |
| 1349 | float commonDelay; |
| 1350 | float beginY = 250; |
| 1351 | int bounce; |
| 1352 | texture_program_type COLOR, LIGHT_COLOR; |
| 1353 | if (type == 0) { |
| 1354 | beginTimeK = 2.0f; |
| 1355 | commonDelay = duration_const * 0.5f; |
| 1356 | bounce = 1; |
| 1357 | rotation = -D2R(free_scroll_offset); |
| 1358 | cloud_scroll_offset = 0; |
| 1359 | COLOR = RED, LIGHT_COLOR = LIGHT_RED; |
| 1360 | } else { |
| 1361 | rotation = 0; |
| 1362 | beginTimeK = 2.5; |
| 1363 | commonDelay = 0; |
| 1364 | bounce = 1; |
| 1365 | COLOR = BLUE, LIGHT_COLOR = LIGHT_BLUE; |
| 1366 | } |
| 1367 | float scale; |
| 1368 | float t_y; |
| 1369 | CPoint ic_pos; |
| 1370 | float ic_layer_alpha; |
| 1371 | if (current_page == 1 && direct == 0) { |
| 1372 | ic_layer_alpha = t(1, 0, 0, duration_const * 0.25f, EaseOut); |
| 1373 | } else { |
| 1374 | ic_layer_alpha = 1; |
| 1375 | } |
| 1376 | ic_pin.params.alpha = ic_layer_alpha; |
| 1377 | ic_cam.params.alpha = ic_layer_alpha; |
| 1378 | ic_cam_lens.params.alpha = ic_layer_alpha; |
| 1379 | ic_smile.params.alpha = ic_layer_alpha; |
| 1380 | ic_smile_eye.params.alpha = ic_layer_alpha; |
| 1381 | ic_videocam.params.alpha = ic_layer_alpha; |
| 1382 | ic_bubble.params.alpha = ic_layer_alpha; |
| 1383 | ic_bubble_dot.params.alpha = ic_layer_alpha; |
| 1384 | ic_pencil.params.alpha = ic_layer_alpha; |
| 1385 |
| 1386 | if (type == 0) { |
| 1387 | ic_pos = CPointMake(-106 / 2, 61 / 2); |
| 1388 | if (current_page == 1 && direct == 0) { |
| 1389 | t_y = 0; |
| 1390 | } else { |
| 1391 | t_y = t(beginY, 0, commonDelay + duration_const * 0.2f * beginTimeK, duration_const, EaseOut); |
| 1392 | float arg = MAXf(0, time - (commonDelay + duration_const * 0.2f * beginTimeK)) * 50; |
| 1393 | float value = beginY * powf(2.71, -0.055f * arg * 2) * cosf(0.08f * arg) * 0.4f; |
| 1394 | t_y -= value * bounce; |
| 1395 | } |
| 1396 | } else { |
| 1397 | ic_pos = CPointMake(-162 / 2 + 4, +26 / 2 + 20); |
| 1398 | t_y = t(beginY, 0, commonDelay + duration_const * 0.2f * beginTimeK, duration_const, EaseOut); |
| 1399 | float value = 0; |
| 1400 | float e = 2.71; |
| 1401 | float arg = MAXf(0, time - (commonDelay + duration_const * 0.2f * beginTimeK)) * 50; |
| 1402 | value = beginY * powf(e, -0.055f * arg * 2) * cosf(0.08f * arg - (float) M_PI / 8.0f) * 0.4f; |
| 1403 | t_y -= value * bounce; |
| 1404 | } |
| 1405 |
| 1406 | if (time_local > anim_pin_start_time) { |
| 1407 | if (time_local > anim_pin_start_time + anim_pin_duration) { |
| 1408 | anim_pin_start_time = time_local + duration_const * frand(10, 20) * 2; |
| 1409 | anim_pin_duration = duration_const * frand(10, 20) * 2; |
| 1410 | } |
| 1411 | } |
| 1412 | float pinasin = 0; |
| 1413 | ic_pin_layer.position = xyzMake(ic_pos.x + cosf(time_local * 5) * 3 * pinasin + cloud_scroll_offset, ic_pos.y + sinf(time_local * 5) * 1.5f * pinasin + t_y, 0); |
| 1414 | mat4x4_layer(ic_matrix, ic_pin_layer, 1, rotation); |
| 1415 | draw_textured_shape(&ic_pin, ic_matrix, COLOR); |
| 1416 |
| 1417 | if (type == 1) { |
| 1418 | ic_videocam_layer.rotation = -30 + t_local(anim_videocam_old_angle, anim_videocam_angle, anim_videocam_start_time, anim_videocam_duration, EaseOut); |
| 1419 | t_y = t(beginY, 0, commonDelay + duration_const * 0.45f * beginTimeK, duration_const, EaseOut); |
| 1420 | float value = 0; |
| 1421 | float e = 2.71; |
| 1422 | float arg = MAXf(0, time - (commonDelay + duration_const * 0.45f * beginTimeK)) * 50; |
| 1423 | value = beginY * powf(e, -0.055f * arg * 2) * cosf(0.08f * arg) * 0.4f; |
| 1424 | t_y -= value * bounce; |
| 1425 | if (t_y <= 1 && time_local > anim_videocam_next_time) { |
| 1426 | anim_videocam_duration = duration_const * frand(1.0f, 1.5f) * 1.5f; |
| 1427 | anim_videocam_old_angle = anim_videocam_angle; |
| 1428 | anim_videocam_angle = 15 * irand(-1, 1); |
| 1429 | anim_videocam_start_time = time_local; |
| 1430 | anim_videocam_next_time = time_local + 1000000 + duration_const * frand(5, 8); |
| 1431 | } |
| 1432 | ic_videocam_layer.position = xyzMake(-68 / 2 + cloud_scroll_offset, +80 / 2 + t_y, 0); |
| 1433 | mat4x4_layer(ic_matrix, ic_videocam_layer, 1, rotation); |
| 1434 | draw_textured_shape(&ic_videocam, ic_matrix, COLOR); |
| 1435 | } |
| 1436 |
| 1437 | if (type == 0) { |
| 1438 | ic_pos = CPointMake(107 / 2, 78 / 2); |
| 1439 | if (current_page == 1 && direct == 0) { |
| 1440 | t_y = 0; |
| 1441 | } else { |
| 1442 | t_y = t(beginY, 0, commonDelay + duration_const * 0.3f * beginTimeK, duration_const, EaseOut); |
| 1443 | float value = 0; |
| 1444 | float e = 2.71; |
| 1445 | float arg = MAXf(0, time - (commonDelay + duration_const * 0.3f * beginTimeK)) * 50; |
| 1446 | value = beginY * powf(e, -0.055f * arg * 2) * cosf(0.08f * arg) * 0.4f; |
| 1447 | t_y -= value * bounce; |
| 1448 | } |
| 1449 | } else { |
| 1450 | ic_pos = CPointMake(-28 / 2, -20 / 2 + 2); |
| 1451 | t_y = t(beginY, 0, commonDelay + duration_const * 0.15f * beginTimeK, duration_const, EaseOut); |
| 1452 | float arg = MAXf(0, time - (commonDelay + duration_const * 0.15f * beginTimeK)) * 50; |
| 1453 | float value = beginY * powf(2.71, -0.055f * arg * 2) * cosf(0.08f * arg) * 0.4f; |
| 1454 | t_y -= value * bounce; |
| 1455 | } |
| 1456 |
| 1457 | if (t_y <= 1 && time_local > anim_cam_next_time) { |
| 1458 | anim_cam_duration = duration_const * frand(1.0, 1.5); |
| 1459 | anim_cam_old_angle = anim_cam_angle; |
| 1460 | anim_cam_old_position = anim_cam_position; |
| 1461 | anim_cam_start_time = time_local; |
| 1462 | anim_cam_next_time = time_local + 10000000; |
| 1463 | int r = irand(0, 1); |
| 1464 | if (r == 0) { |
| 1465 | anim_cam_position = CPointMake(-8 + 4, 0); |
| 1466 | anim_cam_angle = signrand() * 10; |
| 1467 | } else if (r == 1) { |
| 1468 | anim_cam_position = CPointMake(4, -5); |
| 1469 | anim_cam_angle = signrand() * 10; |
| 1470 | } else if (r == 2) { |
| 1471 | anim_cam_position = CPointMake(0, 0); |
| 1472 | anim_cam_angle = 0; |
| 1473 | } |
| 1474 | qShot = irand(1, 2); |
| 1475 | anim_camshot_start_time = time_local + duration_const * 0.5f; |
| 1476 | anim_camshot_duration = duration_const * .4f; |
| 1477 | } |
| 1478 |
| 1479 | ic_cam_layer.rotation = 15 + t_local(anim_cam_old_angle, anim_cam_angle, anim_cam_start_time, anim_cam_duration, EaseOut); |
| 1480 | ic_cam_layer.position = xyzMake( |
| 1481 | ic_pos.x + 0 * t_local(anim_cam_old_position.x, anim_cam_position.x, anim_cam_start_time, anim_cam_duration, EaseOut) + cloud_scroll_offset, |
| 1482 | ic_pos.y + 0 * t_local(anim_cam_old_position.y, anim_cam_position.y, anim_cam_start_time, anim_cam_duration, EaseOut) |
| 1483 | + t_y, |
| 1484 | 0); |
| 1485 |
| 1486 | mat4x4_layer(ic_matrix, ic_cam_layer, 1, rotation); |
| 1487 | draw_textured_shape(&ic_cam, ic_matrix, COLOR); |
| 1488 |
| 1489 | float lens_scale; |
| 1490 | lens_scale = 1; |
| 1491 | if (qShot >= 0 && time_local > anim_camshot_start_time) { |
| 1492 | lens_scale = t_local(1, 0, anim_camshot_start_time, anim_camshot_duration, Sin); |
| 1493 | if (time_local > anim_camshot_start_time + anim_camshot_duration) { |
| 1494 | qShot--; |
| 1495 | anim_camshot_start_time = time_local + anim_camshot_duration; |
| 1496 | } |
| 1497 | } |
| 1498 | ic_cam_lens.params.scale = xyzMake(lens_scale, lens_scale, 1); |
| 1499 | ic_cam_lens.params.position = xyzMake(0, 1.7, 0); |
| 1500 | draw_textured_shape(&ic_cam_lens, ic_matrix, COLOR); |
| 1501 |
| 1502 | if (type == 0) { |
| 1503 | ic_pos = CPointMake(70 / 2, -116 / 2); |
| 1504 | if (current_page == 1 && direct == 0) { |
| 1505 | t_y = 0; |
| 1506 | } else { |
| 1507 | t_y = t(beginY, 0, commonDelay + duration_const * .0f * beginTimeK, duration_const, EaseOut); |
| 1508 | float value = 0; |
| 1509 | float e = 2.71; |
| 1510 | float arg = MAXf(0, time - (commonDelay + duration_const * .0f * beginTimeK)) * 50; |
| 1511 | value = beginY * powf(e, -0.055f * arg * 2) * cosf(0.08f * arg) * .4f; |
| 1512 | t_y -= value * bounce; |
| 1513 | } |
| 1514 | } else { |
| 1515 | ic_pos = CPointMake(+60 / 2, 50 / 2); |
| 1516 | t_y = t(beginY, 0, commonDelay + duration_const * 0.25f * beginTimeK, duration_const, EaseOut); |
| 1517 |
| 1518 | float value = 0; |
| 1519 | float e = 2.71; |
| 1520 | float arg = MAXf(0, time - (commonDelay + duration_const * 0.25f * beginTimeK)) * 50; |
| 1521 | value = beginY * powf(e, -0.055f * arg * 2) * cosf(0.08f * arg - (float) M_PI / 8.0f) * .4f; |
| 1522 |
| 1523 | t_y -= value * bounce; |
| 1524 | } |
| 1525 | float smile_laught = 0; |
| 1526 | float anim_smile_fade_duration = duration_const * 2; |
| 1527 | float anim_smile_duration = duration_const * 2; |
| 1528 | if (anim_smile_stage == 0) { |
| 1529 | smile_laught = t_local(0, 1, anim_smile_start_time1, anim_smile_fade_duration, Linear); |
| 1530 | if (time_local > anim_smile_duration * 3 + anim_smile_start_time1) { |
| 1531 | anim_smile_stage = 1; |
| 1532 | anim_smile_start_time2 = time_local; |
| 1533 | } |
| 1534 | } |
| 1535 |
| 1536 | if (anim_smile_stage == 1) { |
| 1537 | smile_laught = t_local(1, 0, anim_smile_start_time2, anim_smile_fade_duration, Linear); |
| 1538 | if (time_local > anim_smile_duration + anim_smile_start_time2) { |
| 1539 | smile_laught = 0; |
| 1540 | anim_smile_stage = 2; |
| 1541 | anim_smile_blink_one = 1; |
| 1542 | anim_smile_blink_start_time = time_local + duration_const; |
| 1543 | } |
| 1544 | } |
| 1545 |
| 1546 | float y = 0; |
| 1547 | if (anim_smile_stage < 2) { |
| 1548 | y = sinf(time_local * (float) M_PI * 10) * 1.5f * smile_laught; |
| 1549 | } |
| 1550 |
| 1551 | ic_smile_layer.position = xyzMake(ic_pos.x + cloud_scroll_offset, y + ic_pos.y + t_y, 0); |
| 1552 | mat4x4_layer(ic_matrix, ic_smile_layer, 1, rotation); |
| 1553 | draw_textured_shape(&ic_smile, ic_matrix, COLOR); |
| 1554 |
| 1555 | if (time_local > anim_smile_blink_start_time + .1) { |
| 1556 |
| 1557 | float blink_pause = frand(3, 6); |
| 1558 | if (irand(0, 3) == 0) { |
| 1559 | blink_pause = .3; |
| 1560 | } |
| 1561 | if (anim_smile_blink_one == 1) { |
| 1562 | blink_pause = frand(3, 6); |
| 1563 | } |
| 1564 | anim_smile_blink_start_time = time_local + blink_pause; |
| 1565 |
| 1566 | anim_smile_blink_one = 0; |
| 1567 | } |
| 1568 |
| 1569 | int stop_time = 5; |
| 1570 | float eye_scale = t_local(1, 0, anim_smile_blink_start_time, 0.1f, Sin); |
| 1571 | ic_smile_eye.params.scale = xyzMake(1, eye_scale, 1); |
| 1572 | if (time > stop_time) ic_smile_eye.params.scale = xyzMake(1, 1, 1); |
| 1573 |
| 1574 | ic_smile_eye.params.position = xyzMake(-7, -4.5f, 0); |
| 1575 | draw_textured_shape(&ic_smile_eye, ic_matrix, COLOR); |
| 1576 |
| 1577 | if (anim_smile_blink_one == 1) ic_smile_eye.params.scale = xyzMake(1, 1, 1); |
| 1578 | if (time > stop_time) ic_smile_eye.params.scale = xyzMake(1, 1, 1); |
| 1579 | ic_smile_eye.params.position = xyzMake(7, -4.5f, 0); |
| 1580 | draw_textured_shape(&ic_smile_eye, ic_matrix, COLOR); |
| 1581 |
| 1582 | if (type == 0) { |
| 1583 | ic_pos = CPointMake(-60 / 2, 110 / 2); |
| 1584 | if (current_page == 1 && direct == 0) { |
| 1585 | t_y = 0; |
| 1586 | } else { |
| 1587 | t_y = t(beginY, 0, commonDelay + duration_const * .45f * beginTimeK, duration_const, EaseOut); |
| 1588 |
| 1589 | float value = 0; |
| 1590 | float e = 2.71; |
| 1591 | float arg = MAXf(0, time - (commonDelay + duration_const * .45f * beginTimeK)) * 50; |
| 1592 |
| 1593 | value = beginY * powf(e, -0.055f * arg * 2) * cosf(0.08f * arg) * .4f; |
| 1594 |
| 1595 | t_y -= value * bounce; |
| 1596 | } |
| 1597 | } else { |
| 1598 | ic_pos = CPointMake(72 / 2, -74 / 2); |
| 1599 | t_y = t(beginY, 0, commonDelay + duration_const * .0f * beginTimeK, duration_const, EaseOut); |
| 1600 | float value = 0; |
| 1601 | float e = 2.71; |
| 1602 | float arg = MAXf(0, time - (commonDelay + duration_const * .0f * beginTimeK)) * 50; |
| 1603 | value = beginY * powf(e, -0.055f * arg * 2) * cosf(0.08f * arg) * .4f; |
| 1604 | t_y -= value * bounce; |
| 1605 | } |
| 1606 | ic_bubble_layer.position = xyzMake(ic_pos.x + cloud_scroll_offset, ic_pos.y + t_y, 0); |
| 1607 | mat4x4_layer(ic_matrix, ic_bubble_layer, 1, rotation); |
| 1608 | draw_textured_shape(&ic_bubble, ic_matrix, COLOR); |
| 1609 |
| 1610 | scale = 0.7f + 0.2f * bubble_dots_sinf(time * 10); |
| 1611 | ic_bubble_dot.params.scale = xyzMake(scale, scale, scale); |
| 1612 | ic_bubble_dot.params.position = xyzMake(0 - 80.5f, -9 / 2.0f, 0); |
| 1613 | draw_textured_shape(&ic_bubble_dot, ic_matrix, LIGHT_COLOR); |
| 1614 |
| 1615 | scale = 0.7f + 0.2f * bubble_dots_sinf((float) -M_PI * 2 / 3 + time * 10); |
| 1616 | if (anim_bubble_dots_stage == 0) scale = MAXf(.7, scale); |
| 1617 | ic_bubble_dot.params.scale = xyzMake(scale, scale, scale); |
| 1618 | ic_bubble_dot.params.position = xyzMake(0, -9 / 2.0f, 0); |
| 1619 | draw_textured_shape(&ic_bubble_dot, ic_matrix, LIGHT_COLOR); |
| 1620 |
| 1621 | scale = 0.7f + 0.2f * bubble_dots_sinf((float) -M_PI * 2 / 3 * 2 + time * 10); |
| 1622 | if (anim_bubble_dots_stage == 0) scale = MAXf(.7, scale); |
| 1623 | ic_bubble_dot.params.scale = xyzMake(scale, scale, scale); |
| 1624 | ic_bubble_dot.params.position = xyzMake(0 + 80.5f, -9 / 2.0f, 0); |
| 1625 | draw_textured_shape(&ic_bubble_dot, ic_matrix, LIGHT_COLOR); |
| 1626 |
| 1627 | if (type == 0) { |
| 1628 | ic_pos = CPointMake(-88 / 2 - 15, -100 / 2 + 13); |
| 1629 | if (current_page == 1 && direct == 0) { |
| 1630 | t_y = 0; |
| 1631 | } else { |
| 1632 | t_y = t(beginY, 0, commonDelay + duration_const * .1f * beginTimeK, duration_const, EaseOut); |
| 1633 | float value = 0; |
| 1634 | float e = 2.71; |
| 1635 | float arg = MAXf(0, time - (commonDelay + duration_const * .1f * beginTimeK)) * 50; |
| 1636 | value = beginY * powf(e, -0.055f * arg * 2) * cosf(0.08f * arg) * .4f; |
| 1637 | t_y -= value * bounce; |
| 1638 | } |
| 1639 | } else { |
| 1640 | ic_pos = CPointMake(+152 / 2 - 17, +66 / 2 + 14); |
| 1641 |
| 1642 | t_y = t(beginY, 0, commonDelay + duration_const * 0.35f * beginTimeK, duration_const, EaseOut); |
| 1643 |
| 1644 | float value = 0; |
| 1645 | float e = 2.71; |
| 1646 | float arg = MAXf(0, time - (commonDelay + duration_const * 0.35f * beginTimeK)) * 50; |
| 1647 | value = beginY * powf(e, -0.055f * arg * 2) * cosf(0.08f * arg) * 0.4f; |
| 1648 |
| 1649 | t_y -= value * bounce; |
| 1650 | } |
| 1651 |
| 1652 | float pencil_x = 0; |
| 1653 | if (anim_pencil_stage == 0) { |
| 1654 | ic_pencil_layer.rotation = t_local(0, -5, anim_pencil_start_all_time, duration_const * 0.5f, EaseOut); |
| 1655 |
| 1656 | pencil_x = t_local(0, 14, anim_pencil_start_time, 1.5f * 0.85f, Linear); |
| 1657 | if (time_local > anim_pencil_start_time + 1.5 * 0.85) { |
| 1658 | anim_pencil_start_time = time_local; |
| 1659 | anim_pencil_stage = 1; |
| 1660 | } |
| 1661 | } else if (anim_pencil_stage == 1) { |
| 1662 | pencil_x = t_local(14, 0, anim_pencil_start_time, 1.5f * 0.15f, Linear); |
| 1663 | if (time_local > anim_pencil_start_time + 1.5f * 0.15f) { |
| 1664 | if (anim_pencil_period == 0) { |
| 1665 | anim_pencil_start_all_end_time = time_local; |
| 1666 | anim_pencil_start_time = time_local + duration_const * 1; |
| 1667 | anim_pencil_stage = 2; |
| 1668 | } else { |
| 1669 | anim_pencil_period--; |
| 1670 | anim_pencil_start_time = time_local; |
| 1671 | anim_pencil_stage = 0; |
| 1672 | } |
| 1673 | } |
| 1674 | } else if (anim_pencil_stage == 2) { |
| 1675 | ic_pencil_layer.rotation = t_local(-5, 0, anim_pencil_start_all_end_time, duration_const * 0.5f, EaseOut); |
| 1676 | if (time_local > anim_pencil_start_time) { |
| 1677 | anim_pencil_start_all_time = time_local; |
| 1678 | anim_pencil_start_time = time_local; |
| 1679 | anim_pencil_stage = 3; |
| 1680 | } |
| 1681 | } |
| 1682 |
| 1683 | float pencil_v = (anim_pencil_stage < 2) ? sinf((float) (time_local * 2 * M_PI * 4)) * 0.8f : 0; |
| 1684 | ic_pencil_layer.position = xyzMake(pencil_x + ic_pos.x + cloud_scroll_offset, pencil_v + ic_pos.y + t_y, 0); |
| 1685 | mat4x4_layer(ic_matrix, ic_pencil_layer, 1, rotation); |
| 1686 | draw_textured_shape(&ic_pencil, ic_matrix, COLOR); |
| 1687 | } |
| 1688 |
| 1689 | void draw_safe(int type, float alpha, float screw_alpha) { |
| 1690 | float screw_distance = 53; |
| 1691 |
| 1692 | private_screw.params.alpha = alpha * screw_alpha; |
| 1693 |
| 1694 | scale = 1; |
| 1695 | private_screw.params.scale = xyzMake(scale, scale, 1); |
| 1696 | private_screw.params.position = xyzMake(-screw_distance, -screw_distance, 0); |
| 1697 | draw_textured_shape(&private_screw, private_matrix, NORMAL_ONE); |
| 1698 |
| 1699 | private_screw.params.scale = xyzMake(scale, scale, 1); |
| 1700 | private_screw.params.position = xyzMake(screw_distance, -screw_distance, 0); |
| 1701 | draw_textured_shape(&private_screw, private_matrix, NORMAL_ONE); |
| 1702 |
| 1703 | private_screw.params.scale = xyzMake(scale, scale, 1); |
| 1704 | private_screw.params.position = xyzMake(-screw_distance, screw_distance, 0); |
| 1705 | draw_textured_shape(&private_screw, private_matrix, NORMAL_ONE); |
| 1706 |
| 1707 | private_screw.params.scale = xyzMake(scale, scale, 1); |
| 1708 | private_screw.params.position = xyzMake(screw_distance, screw_distance, 0); |
| 1709 | draw_textured_shape(&private_screw, private_matrix, NORMAL_ONE); |
| 1710 | } |
| 1711 |
| 1712 | JNIEXPORT void Java_org_telegram_messenger_Intro_onDrawFrame(JNIEnv *env, jclass class) { |
| 1713 | time_local += 0.016f; |
| 1714 |
| 1715 | if (current_page != prev_page) { |
| 1716 | reset_ic(); |
| 1717 | ms0_anim = date; |
| 1718 | fps_anim = 0; |
| 1719 | count_anim_fps = 1; |
| 1720 | } |
| 1721 |
| 1722 | float knotDelayStep = 0.075f; |
| 1723 | if (prev_page != current_page) { |
| 1724 | for (i = 0; i < 4; i++) { |
| 1725 | knot_delays[i] = (0.65f + knotDelayStep * i) * duration_const; |
| 1726 | } |
| 1727 |
| 1728 | for (i = 0; i < 10; i++) { |
| 1729 | int j1 = irand(0, 3); |
| 1730 | int j2 = irand(0, 3); |
| 1731 | float temp = knot_delays[j1]; |
| 1732 | knot_delays[j1] = knot_delays[j2]; |
| 1733 | knot_delays[j2] = temp; |
| 1734 | } |
| 1735 |
| 1736 | if (current_page == 2) { |
| 1737 | ic_pin_layer.rotation = -15; |
| 1738 | ic_cam_layer.rotation = 15; |
| 1739 | ic_smile_layer.rotation = -15; |
| 1740 | ic_bubble_layer.rotation = -15; |
| 1741 | } |
| 1742 |
| 1743 | if (current_page == 5) { |
| 1744 | ic_pin_layer.rotation = -15; |
| 1745 | ic_videocam_layer.rotation = -30; |
| 1746 | ic_cam_layer.rotation = 15; |
| 1747 | ic_smile_layer.rotation = -15; |
| 1748 | ic_bubble_layer.rotation = -15; |
| 1749 | } |
| 1750 | } |
| 1751 |
| 1752 | fps_anim++; |
| 1753 | if (count_anim_fps == 1 && date - ms0_anim >= duration_const) { |
| 1754 | count_anim_fps = 0; |
| 1755 | } |
| 1756 |
| 1757 | if (date - ms0 >= 1.0f) { |
| 1758 | ms0 = date; |
| 1759 | } |
| 1760 |
| 1761 | time = date - date0; |
| 1762 |
| 1763 | float private_back_k = .8; |
| 1764 |
| 1765 | glClearColor(1, 1, 1, 1); |
| 1766 | glClear(GL_COLOR_BUFFER_BIT); |
| 1767 |
| 1768 |
| 1769 | if (current_page == 0) { |
| 1770 | rglNormalDraw(); |
| 1771 |
| 1772 | telegram_sphere.params.alpha = 1; |
| 1773 |
| 1774 | scale = 1; |
| 1775 |
| 1776 | float alpha = 1; |
| 1777 | if (direct == 0) { |
| 1778 | alpha = t(0, 1, 0, duration_const, Linear); |
| 1779 |
| 1780 | fast_body.params.alpha = 1; |
| 1781 | fast_body.params.scale = xyzMake(scale, scale, 1); |
| 1782 | draw_textured_shape(&fast_body, main_matrix, NORMAL); |
| 1783 | } |
| 1784 |
| 1785 | telegram_sphere.params.alpha = alpha; |
| 1786 | telegram_sphere.params.scale = xyzMake(scale, scale, 1); |
| 1787 |
| 1788 | telegram_plane.params.alpha = 1; |
| 1789 |
| 1790 | float tt = MINf(0, (float) (-M_PI * 125. / 180. + time * M_PI * 2 * 1.5)); |
| 1791 |
| 1792 | float dx = sinf(tt) * 75; |
| 1793 | float dy = -sinf(tt) * 60; |
| 1794 |
| 1795 | telegram_plane.params.position = xyzMake(dx, dy, 0); |
| 1796 |
| 1797 | float scale = (cosf(tt) + 1) * 0.5f; |
| 1798 |
| 1799 | telegram_plane.params.scale = xyzMake(cosf(tt) * scale, scale, 1); |
| 1800 |
| 1801 | if (tt < D2R(125)) { |
| 1802 | glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); |
| 1803 | } |
| 1804 | } else if (current_page == 1) { |
| 1805 | rglNormalDraw(); |
| 1806 | if (direct == 1) { |
| 1807 | fast_body.params.scale = xyzMake(1, 1, 1); |
| 1808 | fast_body.params.alpha = 1; |
| 1809 | draw_textured_shape(&fast_body, main_matrix, NORMAL); |
| 1810 | } else { |
| 1811 | fast_body.params.alpha = t(0, 1, .0, duration_const, Linear);; |
| 1812 | float scale = t(.95, 1, 0, duration_const, EaseInEaseOut); |
| 1813 | fast_body.params.scale = xyzMake(scale, scale, 1.0f); |
| 1814 | draw_textured_shape(&fast_body, main_matrix, NORMAL); |
| 1815 | } |
| 1816 | } else if (current_page == 2) { |
| 1817 | rglNormalDraw(); |
| 1818 | if (direct == 1) { |
| 1819 | fast_body.params.alpha = t(1.0f, .0, .0, duration_const, Linear);; |
| 1820 | float scale = t(1, .95, 0, duration_const, EaseInEaseOut); |
| 1821 | fast_body.params.scale = xyzMake(scale, scale, 1.0f); |
| 1822 | draw_textured_shape(&fast_body, main_matrix, NORMAL); |
| 1823 | } |
| 1824 | } else if (current_page == 4) { |
| 1825 | if (direct == 1) { |
| 1826 | privateLayer.rotation = private_scroll_offset + t(-90, 0, 0, duration_const, EaseOut); |
| 1827 | } else { |
| 1828 | privateLayer.rotation = private_scroll_offset + t(90, 0, 0, duration_const * private_back_k, EaseOut); |
| 1829 | } |
| 1830 | mat4x4_layer(private_matrix, privateLayer, 1.0f, 0); |
| 1831 | } |
| 1832 |
| 1833 | rglMaskDraw(); |
| 1834 | mask1.params.position.z = cloud_extra_mask1.params.position.z = cloud_extra_mask2.params.position.z = cloud_extra_mask3.params.position.z = cloud_extra_mask4.params.position.z = 1; |
| 1835 |
| 1836 | if (current_page == 0) { |
| 1837 | if (direct == 0) { |
| 1838 | change_rounded_rectangle(&mask1, CSizeMake(r1 * 2, r1 * 2), r1); |
| 1839 | mask1.params.rotation = 0; |
| 1840 | } |
| 1841 | } else if (current_page == 1) { |
| 1842 | if (direct == 1) { |
| 1843 | change_rounded_rectangle(&mask1, CSizeMake(r1 * 2, r1 * 2), r1); |
| 1844 | mask1.params.rotation = 0; |
| 1845 | } else { |
| 1846 | float size = t(r2 * 2, r1 * 2, 0, duration_const, EaseInEaseOut); |
| 1847 | float round = t(30, r1, 0, duration_const, EaseInEaseOut); |
| 1848 | change_rounded_rectangle(&mask1, CSizeMake(size, size), round); |
| 1849 | free_scroll_offset = 0; |
| 1850 | mask1.params.rotation = t(180, 0.0f, 0, duration_const, EaseInEaseOut) + free_scroll_offset; |
| 1851 | } |
| 1852 | } else if (current_page == 2) { |
| 1853 | if (direct == 1) { |
| 1854 | float size = t(r1 * 2, r2 * 2, 0, duration_const, EaseInEaseOut); |
| 1855 | float round = t(r1, 30, 0, duration_const, EaseInEaseOut); |
| 1856 | change_rounded_rectangle(&mask1, CSizeMake(size, size), round); |
| 1857 | free_scroll_offset = scroll_offset * 5; |
| 1858 | mask1.params.rotation = t(0, 180.0f, 0, duration_const, EaseInEaseOut) + free_scroll_offset; |
| 1859 | } else { |
| 1860 | free_scroll_offset = scroll_offset * 5; |
| 1861 | float r = 316 / 4.0f; |
| 1862 | float size = t_reversed(r2 * 2, r * 2, 0, duration_const, EaseInEaseOut); |
| 1863 | float round = t_reversed(30, 20, 0, duration_const, EaseInEaseOut); |
| 1864 | change_rounded_rectangle(&mask1, CSizeMake(size, size), round); |
| 1865 | mask1.params.rotation = t_reversed(180.0f + free_scroll_offset, 180.0f + 90.0f, 0, duration_const, EaseInEaseOut); |
| 1866 | } |
| 1867 | } else if (current_page == 3) { |
| 1868 | if (direct == 1) { |
| 1869 | float r = 316 / 4.0f; |
| 1870 | float size = t(r2 * 2, r * 2, 0, duration_const, EaseInEaseOut); |
| 1871 | float round = t(30, 20, 0, duration_const, EaseInEaseOut); |
| 1872 | change_rounded_rectangle(&mask1, CSizeMake(size, size), round); |
| 1873 | mask1.params.rotation = t(180.0f + free_scroll_offset, 180.0f + 90.0f, 0, duration_const, EaseInEaseOut); |
| 1874 | } else { |
| 1875 | float r = 316 / 4.0f; |
| 1876 | float size = t_reversed(r * 2, r2 * 2, 0, duration_const, EaseOut); |
| 1877 | float round = t_reversed(20, 30, 0, duration_const, EaseOut); |
| 1878 | change_rounded_rectangle(&mask1, CSizeMake(size, size), round); |
| 1879 | mask1.params.rotation = t_reversed(180.0f + 90.0f, 180.0f + 90.0f + 90.0f, 0, duration_const, EaseOut); |
| 1880 | mask1.params.position = xyzMake(0, 0, mask1.params.position.z); |
| 1881 | } |
| 1882 | } else if (current_page == 4) { |
| 1883 | if (direct == 1) { |
| 1884 | float r = 316 / 4.0f; |
| 1885 | float size = t(r * 2, r2 * 2, 0, duration_const, EaseOut); |
| 1886 | float round = t(20, 30, 0, duration_const, EaseOut); |
| 1887 | change_rounded_rectangle(&mask1, CSizeMake(size, size), round); |
| 1888 | mask1.params.rotation = private_scroll_offset + t(180.0f + 90.0f, 180.0f + 90.0f + 90.0f, 0, duration_const, EaseOut); |
| 1889 | mask1.params.position = xyzMake(0, 0, mask1.params.position.z); |
| 1890 | } else { |
| 1891 | float k = 0; |
| 1892 | k = 1.0f * private_back_k; |
| 1893 | float scale = t_reversed(r2 * 2, 100, 0, duration_const * k, EaseOut); |
| 1894 | change_rounded_rectangle(&mask1, CSizeMake(scale, scale), t_reversed(30, 50, 0, duration_const * k, EaseOut)); |
| 1895 | mask1.params.position = xyzMake(t_reversed(0, 29 / 2, 0, duration_const * k, EaseOut), t_reversed(0, -19 / 2, 0, duration_const * k, EaseOut), mask1.params.position.z); |
| 1896 | mask1.params.rotation = private_scroll_offset + t_reversed(180.0f + 90.0f + 90.0f, 180.0f + 90.0f + 90.0f + 90.0f, 0, duration_const * k, EaseOut); |
| 1897 |
| 1898 | k = 1.0f * private_back_k; |
| 1899 | int sublayer2_radius = 33; |
| 1900 | cloud_extra_mask1.params.position = xyzMake(t_reversed(0, -122 / 2, 0, duration_const * k, EaseOut), t_reversed(0, 54 / 2 - 1, 0, duration_const * k, EaseOut), cloud_extra_mask1.params.position.z); |
| 1901 | scale = t_reversed(0, sublayer2_radius, 0, duration_const * k, EaseOut); |
| 1902 | cloud_extra_mask1.params.scale = xyzMake(scale, scale, 1); |
| 1903 | draw_shape(&cloud_extra_mask1, main_matrix); |
| 1904 |
| 1905 | k = 1.15f * private_back_k; |
| 1906 | int sublayer3_radius = 94 / 4; |
| 1907 | cloud_extra_mask2.params.position = xyzMake(t_reversed(0, -84 / 2, 0, duration_const * k, EaseOut), t_reversed(0, -29 / 2, 0, duration_const * k, EaseOut), cloud_extra_mask2.params.position.z); |
| 1908 | scale = t_reversed(0, sublayer3_radius, 0, duration_const * k, EaseOut); |
| 1909 | cloud_extra_mask2.params.scale = xyzMake(scale, scale, 1); |
| 1910 | draw_shape(&cloud_extra_mask2, main_matrix); |
| 1911 |
| 1912 | k = 1.3f * private_back_k; |
| 1913 | int sublayer4_radius = 124 / 4; |
| 1914 | cloud_extra_mask3.params.position = xyzMake(t_reversed(0, 128 / 2, 0, duration_const * k, EaseOut), t_reversed(0, 56 / 2, 0, duration_const * k, EaseOut), cloud_extra_mask3.params.position.z); |
| 1915 | scale = t_reversed(0, sublayer4_radius, 0, duration_const * k, EaseOut); |
| 1916 | cloud_extra_mask3.params.scale = xyzMake(scale, scale, 1); |
| 1917 | draw_shape(&cloud_extra_mask3, main_matrix); |
| 1918 |
| 1919 | k = 1.5f * private_back_k; |
| 1920 | int sublayer5_radius = 64; |
| 1921 | cloud_extra_mask4.params.position = xyzMake(t_reversed(0, 0, 0, duration_const * k, EaseOut), t_reversed(0, 50, 0, duration_const * k, EaseOut), cloud_extra_mask4.params.position.z); |
| 1922 | scale = t_reversed(0, sublayer5_radius, 0, duration_const * k, EaseOut); |
| 1923 | cloud_extra_mask4.params.scale = xyzMake(scale, scale, 1); |
| 1924 | draw_shape(&cloud_extra_mask4, main_matrix); |
| 1925 | } |
| 1926 | } else if (current_page == 5) { |
| 1927 | float k = 0.8f; |
| 1928 | float scale = t(r2 * 2, 100, 0, duration_const * k, EaseOut); |
| 1929 | change_rounded_rectangle(&mask1, CSizeMake(scale, scale), t(30, 50, 0, duration_const * k, EaseOut)); |
| 1930 | mask1.params.position = xyzMake(t(0, 29 / 2, 0, duration_const * k, EaseOut), t(0, -19 / 2, 0, duration_const * k, EaseOut), mask1.params.position.z); |
| 1931 | mask1.params.rotation = t(180.0f + 90.0f + 90.0f, 180.0f + 90.0f + 90.0f + 90.0f, 0, duration_const * k, EaseOut); |
| 1932 |
| 1933 | k = 1.0f; |
| 1934 | int sublayer2_radius = 33; |
| 1935 | cloud_extra_mask1.params.position = xyzMake(t(0, -122 / 2, 0, duration_const * k, EaseOut), t(0, 54 / 2 - 1, 0, duration_const * k, EaseOut), cloud_extra_mask1.params.position.z); |
| 1936 | scale = t(0, sublayer2_radius, 0, duration_const * k, EaseOut); |
| 1937 | cloud_extra_mask1.params.scale = xyzMake(scale, scale, 1); |
| 1938 | draw_shape(&cloud_extra_mask1, main_matrix); |
| 1939 |
| 1940 |
| 1941 | k = 1.15; |
| 1942 | int sublayer3_radius = 94 / 4; |
| 1943 | cloud_extra_mask2.params.position = xyzMake(t(0, -84 / 2, 0, duration_const * k, EaseOut), t(0, -29 / 2, 0, duration_const * k, EaseOut), cloud_extra_mask2.params.position.z); |
| 1944 | scale = t(0, sublayer3_radius, 0, duration_const * k, EaseOut); |
| 1945 | cloud_extra_mask2.params.scale = xyzMake(scale, scale, 1); |
| 1946 | draw_shape(&cloud_extra_mask2, main_matrix); |
| 1947 |
| 1948 |
| 1949 | k = 1.3; |
| 1950 | int sublayer4_radius = 124 / 4; |
| 1951 | cloud_extra_mask3.params.position = xyzMake(t(0, 128 / 2, 0, duration_const * k, EaseOut), t(0, 56 / 2, 0, duration_const * k, EaseOut), cloud_extra_mask3.params.position.z); |
| 1952 | scale = t(0, sublayer4_radius, 0, duration_const * k, EaseOut); |
| 1953 | cloud_extra_mask3.params.scale = xyzMake(scale, scale, 1); |
| 1954 | draw_shape(&cloud_extra_mask3, main_matrix); |
| 1955 |
| 1956 |
| 1957 | k = 1.5f; |
| 1958 | int sublayer5_radius = 64; |
| 1959 | cloud_extra_mask4.params.position = xyzMake(t(0, 0, 0, duration_const * k, EaseOut), t(0, 50, 0, duration_const * k, EaseOut), cloud_extra_mask4.params.position.z); |
| 1960 | scale = t(0, sublayer5_radius, 0, duration_const * k, EaseOut); |
| 1961 | cloud_extra_mask4.params.scale = xyzMake(scale, scale, 1); |
| 1962 | draw_shape(&cloud_extra_mask4, main_matrix); |
| 1963 |
| 1964 | } |
| 1965 | draw_shape(&mask1, main_matrix); |
| 1966 |
| 1967 | int rr = 30; |
| 1968 | int seg = 15; |
| 1969 | int ang = 180; |
| 1970 | rglNormalDrawThroughMask(); |
| 1971 | if (current_page == 0) { |
| 1972 | if (direct == 0) { |
| 1973 | glEnable(GL_BLEND); |
| 1974 | glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); |
| 1975 |
| 1976 | change_segmented_square(&spiral, r1, D2R(rr + seg), D2R(speedometer_scroll_offset + calculated_speedometer_sin + t(-seg + ang, 0, 0, duration_const, EaseOut))); |
| 1977 |
| 1978 | spiral.params.scale = xyzMake(1, 1, 1); |
| 1979 | spiral.params.rotation = t(180.0f, 0, 0, duration_const, EaseOut); |
| 1980 | spiral.params.alpha = t(1, 0, 0, duration_const, Linear); |
| 1981 | draw_textured_shape(&spiral, main_matrix, NORMAL_ONE); |
| 1982 |
| 1983 | fast_arrow.params.alpha = fast_arrow_shadow.params.alpha = t(1, 0, 0, duration_const, Linear); |
| 1984 | fast_arrow.params.rotation = fast_arrow_shadow.params.rotation = t(rr, rr - 180 - 160, 0, duration_const, EaseOut) + speedometer_scroll_offset + calculated_speedometer_sin; |
| 1985 | draw_textured_shape(&fast_arrow_shadow, main_matrix, NORMAL_ONE); |
| 1986 | draw_textured_shape(&fast_arrow, main_matrix, NORMAL_ONE); |
| 1987 | } |
| 1988 | } else if (current_page == 1) { |
| 1989 | glEnable(GL_BLEND); |
| 1990 | glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); |
| 1991 |
| 1992 | speedometer_scroll_offset = scroll_offset * 25; |
| 1993 | calculated_speedometer_sin = 0; |
| 1994 |
| 1995 | if (direct == 1) { |
| 1996 |
| 1997 | float value = 0; |
| 1998 | float e = 2.71; |
| 1999 |
| 2000 | float arg = time * 50; |
| 2001 |
| 2002 | value = 180 - 180 * powf(e, -0.055f * arg * 2) * cosf(0.08f * arg * 3); |
| 2003 |
| 2004 | float ta = t(0, 180.0f, 0, duration_const, EaseOut); |
| 2005 |
| 2006 | change_segmented_square(&spiral, r1, D2R(rr + seg), D2R(-seg + value + speedometer_scroll_offset)); |
| 2007 |
| 2008 | spiral.params.scale = xyzMake(1, 1, 1); |
| 2009 | spiral.params.rotation = ta; |
| 2010 | spiral.params.alpha = t(0, 1, 0, duration_const, Linear); |
| 2011 | draw_textured_shape(&spiral, main_matrix, NORMAL_ONE); |
| 2012 |
| 2013 | fast_arrow.params.alpha = fast_arrow_shadow.params.alpha = t(0, 1, 0, duration_const, Linear); |
| 2014 | fast_arrow.params.rotation = fast_arrow_shadow.params.rotation = -330 + value + ta + speedometer_scroll_offset; |
| 2015 | draw_textured_shape(&fast_arrow_shadow, main_matrix, NORMAL_ONE); |
| 2016 | draw_textured_shape(&fast_arrow, main_matrix, NORMAL_ONE); |
| 2017 |
| 2018 | } else { |
| 2019 | spiral.params.alpha = fast_arrow.params.alpha = fast_arrow_shadow.params.alpha = 1; |
| 2020 |
| 2021 | float value = 0; |
| 2022 | float e = 2.71; |
| 2023 |
| 2024 | float arg = time * 50; |
| 2025 |
| 2026 | float dangle = 90; |
| 2027 | value = 180 - 90 - (180 - 90) * powf(e, -0.055f * arg * 2) * cosf(0.08f * arg * 3); |
| 2028 | value *= -1; |
| 2029 |
| 2030 | change_segmented_square(&spiral, r1, D2R(rr + seg), D2R(speedometer_scroll_offset + value + calculated_speedometer_sin + t(360, 360 - dangle - seg, 0, duration_const, EaseInEaseOut))); |
| 2031 |
| 2032 | float scale = t(1.18, 1, 0, duration_const, EaseInEaseOut); |
| 2033 | spiral.params.scale = xyzMake(scale, scale, 1); |
| 2034 | spiral.params.rotation = t(360, 180, 0, duration_const, EaseInEaseOut); |
| 2035 | draw_textured_shape(&spiral, main_matrix, NORMAL); |
| 2036 |
| 2037 | fast_arrow.params.rotation = fast_arrow_shadow.params.rotation = speedometer_scroll_offset + value + calculated_speedometer_sin + t(rr + 360 + 6, rr + 360 - 180 - dangle, 0, duration_const, EaseInEaseOut); |
| 2038 | draw_textured_shape(&fast_arrow_shadow, main_matrix, NORMAL); |
| 2039 | draw_textured_shape(&fast_arrow, main_matrix, NORMAL); |
| 2040 |
| 2041 | glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
| 2042 | free_bg.params.alpha = t(1, 0, 0, duration_const, Linear); |
| 2043 | draw_shape(&free_bg, main_matrix); |
| 2044 |
| 2045 | draw_ic(0); |
| 2046 | } |
| 2047 | } else if (current_page == 2) { |
| 2048 |
| 2049 | glEnable(GL_BLEND); |
| 2050 | glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); |
| 2051 |
| 2052 | if (direct == 1) { |
| 2053 | spiral.params.alpha = fast_arrow.params.alpha = fast_arrow_shadow.params.alpha = 1; |
| 2054 |
| 2055 | change_segmented_square(&spiral, r1, D2R(rr + seg + speedometer_scroll_offset), D2R(t(-seg + ang, 360, 0, duration_const, EaseInEaseOut))); |
| 2056 |
| 2057 | float scale = t(1, 1.18, 0, duration_const, EaseInEaseOut); |
| 2058 | spiral.params.scale = xyzMake(scale, scale, 1); |
| 2059 | spiral.params.rotation = t(180, 360, 0, duration_const, EaseInEaseOut); |
| 2060 | draw_textured_shape(&spiral, main_matrix, NORMAL); |
| 2061 |
| 2062 | fast_arrow.params.rotation = fast_arrow_shadow.params.rotation = speedometer_scroll_offset + t(rr, rr + 360 + 6, 0, duration_const, EaseInEaseOut); |
| 2063 | draw_textured_shape(&fast_arrow_shadow, main_matrix, NORMAL); |
| 2064 | draw_textured_shape(&fast_arrow, main_matrix, NORMAL); |
| 2065 |
| 2066 | glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
| 2067 | free_bg.params.alpha = t(0, 1, 0, duration_const, Linear); |
| 2068 | draw_shape(&free_bg, main_matrix); |
| 2069 |
| 2070 | draw_ic(0); |
| 2071 | } else { |
| 2072 | glDisable(GL_BLEND); |
| 2073 | free_bg.params.alpha = 1; |
| 2074 | draw_shape(&free_bg, main_matrix); |
| 2075 |
| 2076 | glEnable(GL_BLEND); |
| 2077 | glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
| 2078 | draw_ic(0); |
| 2079 |
| 2080 | powerful_bg.params.alpha = t_reversed(0, 1, 0, duration_const, Linear); |
| 2081 | draw_shape(&powerful_bg, main_matrix); |
| 2082 | } |
| 2083 | ribbon1.params.rotation = 0; |
| 2084 | ribbon2.params.rotation = 90; |
| 2085 | ribbon3.params.rotation = 180; |
| 2086 | ribbon4.params.rotation = 270; |
| 2087 | } else if (current_page == 3) { |
| 2088 | if (direct == 1) { |
| 2089 | glDisable(GL_BLEND); |
| 2090 | free_bg.params.alpha = 1; |
| 2091 | draw_shape(&free_bg, main_matrix); |
| 2092 |
| 2093 | glEnable(GL_BLEND); |
| 2094 | glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
| 2095 | powerful_bg.params.alpha = t(0, 1, 0, duration_const, Linear); |
| 2096 | draw_shape(&powerful_bg, main_matrix); |
| 2097 |
| 2098 | draw_stars(); |
| 2099 |
| 2100 | } else { |
| 2101 | glDisable(GL_BLEND); |
| 2102 | private_bg.params.alpha = 1; |
| 2103 | draw_shape(&private_bg, main_matrix); |
| 2104 |
| 2105 | float a = t(0, 1.0f, 0, duration_const, EaseOut); |
| 2106 |
| 2107 | glEnable(GL_BLEND); |
| 2108 | glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
| 2109 | powerful_bg.params.rotation = 0; |
| 2110 | powerful_bg.params.alpha = a; |
| 2111 | draw_shape(&powerful_bg, main_matrix); |
| 2112 |
| 2113 | draw_stars(); |
| 2114 | } |
| 2115 | } else if (current_page == 4) { |
| 2116 | if (direct == 1) { |
| 2117 |
| 2118 | glDisable(GL_BLEND); |
| 2119 | powerful_bg.params.alpha = 1; |
| 2120 | draw_shape(&powerful_bg, main_matrix); |
| 2121 |
| 2122 | float a = t(0, 1.0f, 0, duration_const, EaseOut); |
| 2123 |
| 2124 | glEnable(GL_BLEND); |
| 2125 | glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
| 2126 | private_bg.params.rotation = t(45, 0, 0, duration_const, EaseOut); |
| 2127 | private_bg.params.alpha = a; |
| 2128 | draw_shape(&private_bg, main_matrix); |
| 2129 |
| 2130 | } else { |
| 2131 | glDisable(GL_BLEND); |
| 2132 | cloud_bg.params.alpha = 1; |
| 2133 | draw_shape(&cloud_bg, main_matrix); |
| 2134 |
| 2135 | float a = t(0, 1.0f, 0, duration_const * private_back_k, EaseOut); |
| 2136 |
| 2137 | glEnable(GL_BLEND); |
| 2138 | glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
| 2139 | private_bg.params.alpha = a; |
| 2140 | draw_shape(&private_bg, main_matrix); |
| 2141 | } |
| 2142 | } else if (current_page == 5) { |
| 2143 | glDisable(GL_BLEND); |
| 2144 | private_bg.params.alpha = 1.0f; |
| 2145 | draw_shape(&private_bg, main_matrix); |
| 2146 | float a = t(0, 1.0f, 0, duration_const, EaseOut); |
| 2147 |
| 2148 | glEnable(GL_BLEND); |
| 2149 | glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
| 2150 | cloud_bg.params.alpha = a; |
| 2151 | draw_shape(&cloud_bg, main_matrix); |
| 2152 | if (scroll_offset > 0) { |
| 2153 | cloud_scroll_offset = -scroll_offset * 40; |
| 2154 | } else { |
| 2155 | cloud_scroll_offset = -scroll_offset * 15; |
| 2156 | } |
| 2157 | draw_ic(1); |
| 2158 | } |
| 2159 |
| 2160 | if (current_page == 0) { |
| 2161 | rglNormalDraw(); |
| 2162 | if (direct == 0) { |
| 2163 | telegram_sphere.params.alpha = t(0, 1, 0, duration_const * 0.8f, Linear); |
| 2164 | scale = 1; |
| 2165 |
| 2166 | telegram_sphere.params.scale = xyzMake(scale, scale, 1); |
| 2167 | draw_textured_shape(&telegram_sphere, main_matrix, NORMAL); |
| 2168 |
| 2169 | float tt = MINf(0, (float) (-M_PI * 125.0f / 180.0f + time * M_PI * 2 * 1.5f)); |
| 2170 | float dx = sinf(tt) * 75; |
| 2171 | float dy = -sinf(tt) * 60; |
| 2172 | telegram_plane.params.position = xyzMake(dx, dy, 0); |
| 2173 | float scale = (cosf(tt) + 1) * 0.5f; |
| 2174 | telegram_plane.params.scale = xyzMake(cosf(tt) * scale, scale, 1); |
| 2175 |
| 2176 | if (tt < D2R(125)) { |
| 2177 | glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); |
| 2178 | draw_textured_shape(&telegram_plane, main_matrix, NORMAL_ONE); |
| 2179 | } |
| 2180 | } |
| 2181 | } else if (current_page == 1) { |
| 2182 | rglNormalDraw(); |
| 2183 | if (direct == 1) { |
| 2184 | telegram_sphere.params.alpha = t(1, 0, 0, duration_const, Linear); |
| 2185 | draw_textured_shape(&telegram_sphere, main_matrix, NORMAL); |
| 2186 |
| 2187 | double tt = time * M_PI * 2 * 1.5f; |
| 2188 |
| 2189 | float dx = (float) sin(tt) * 75; |
| 2190 | float dy = (float) -sin(tt) * 60; |
| 2191 |
| 2192 | telegram_plane.params.position = xyzMake(dx, dy, 0); |
| 2193 |
| 2194 | float scale = (float) (cos(tt) + 1) * 0.5f; |
| 2195 |
| 2196 | telegram_plane.params.scale = xyzMake((float) cos(tt) * scale, scale, 1); |
| 2197 |
| 2198 | if (tt < D2R(125)) { |
| 2199 | glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); |
| 2200 | draw_textured_shape(&telegram_plane, main_matrix, NORMAL_ONE); |
| 2201 | } |
| 2202 | } |
| 2203 | } else if (current_page == 2) { |
| 2204 | rglNormalDraw(); |
| 2205 |
| 2206 | float dribbon = 87; |
| 2207 |
| 2208 | if (direct == 1) { |
| 2209 | glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); |
| 2210 |
| 2211 | ribbonLayer.rotation = scroll_offset * 5 + t(180, 360, 0, duration_const, EaseInEaseOut); |
| 2212 | mat4x4_layer(ribbons_layer, ribbonLayer, 1.0f, 0); |
| 2213 |
| 2214 | float scale; |
| 2215 | float dur = duration_const * 0.5f; |
| 2216 |
| 2217 | free_knot1.params.position = xyzMake(5, -5 - 9, 0); |
| 2218 | scale = t(0, 1, knot_delays[0], dur, EaseOut); |
| 2219 | free_knot1.params.scale = xyzMake(scale, scale, 1); |
| 2220 | draw_textured_shape(&free_knot1, ribbons_layer, NORMAL_ONE); |
| 2221 |
| 2222 | free_knot2.params.position = xyzMake(-5, -5 - 9, 0); |
| 2223 | scale = t(0, 1, knot_delays[1], dur, EaseOut); |
| 2224 | free_knot2.params.scale = xyzMake(-scale, scale, 1); |
| 2225 | draw_textured_shape(&free_knot2, ribbons_layer, NORMAL_ONE); |
| 2226 |
| 2227 | free_knot3.params.position = xyzMake(-5, 5 - 9, 0); |
| 2228 | scale = t(0, 1, knot_delays[2], dur, EaseOut); |
| 2229 | free_knot3.params.scale = xyzMake(-scale, scale, 1); |
| 2230 | draw_textured_shape(&free_knot3, ribbons_layer, NORMAL_ONE); |
| 2231 |
| 2232 | free_knot3.params.position = xyzMake(5, 5 - 9, 0); |
| 2233 | scale = t(0, 1, knot_delays[3], dur, EaseOut); |
| 2234 | free_knot3.params.scale = xyzMake(scale, scale, 1); |
| 2235 | draw_textured_shape(&free_knot3, ribbons_layer, NORMAL_ONE); |
| 2236 |
| 2237 |
| 2238 | glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
| 2239 | ribbon1.params.alpha = ribbon2.params.alpha = ribbon3.params.alpha = ribbon4.params.alpha = t(0, 1, 0, dur, EaseInEaseOut); |
| 2240 |
| 2241 | int ribbon_k = time > duration_const ? 1 : 0; |
| 2242 |
| 2243 | change_ribbon(&ribbon1, ribbonLength - 8.0f * ribbon_k - free_scroll_offset / 5.0f * (30 - 8 * ribbon_k)); |
| 2244 | ribbon1.params.position.x = scroll_offset * 30 * 0 + t(-dribbon, 0, 0, duration_const, EaseInEaseOut); |
| 2245 | draw_shape(&ribbon1, ribbons_layer); |
| 2246 |
| 2247 | change_ribbon(&ribbon2, ribbonLength - 10.0f * ribbon_k - free_scroll_offset / 5.0f * (22 - 10 * ribbon_k)); |
| 2248 | ribbon2.params.position.y = scroll_offset * 15 + t(-9 - dribbon, -9, 0, duration_const, EaseInEaseOut); |
| 2249 | draw_shape(&ribbon2, ribbons_layer); |
| 2250 |
| 2251 | ribbon3.params.position.x = t(dribbon, 0, 0, duration_const, EaseInEaseOut);; |
| 2252 | draw_shape(&ribbon3, ribbons_layer); |
| 2253 |
| 2254 | ribbon4.params.position.y = t(-9 + dribbon, -9, 0, duration_const, EaseInEaseOut);; |
| 2255 | draw_shape(&ribbon4, ribbons_layer); |
| 2256 |
| 2257 | ribbonLayer.anchor.y = 0; |
| 2258 | ribbonLayer.position.y = 0; |
| 2259 |
| 2260 | change_ribbon(&ribbon1, ribbonLength); |
| 2261 | change_ribbon(&ribbon2, ribbonLength); |
| 2262 | change_ribbon(&ribbon3, ribbonLength); |
| 2263 | change_ribbon(&ribbon4, ribbonLength); |
| 2264 | } else { |
| 2265 | glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); |
| 2266 |
| 2267 | float scale = t(1, 2, 0, duration_const, EaseIn); |
| 2268 | powerful_mask.params.scale = xyzMake(scale, scale, 1); |
| 2269 | draw_textured_shape(&powerful_mask, main_matrix, NORMAL_ONE); |
| 2270 |
| 2271 |
| 2272 | ribbonLayer.rotation = free_scroll_offset + t_reversed(360, 360 + (45 + 30), 0, duration_const, EaseOut); |
| 2273 | ribbonLayer.position.y = t_reversed(0, -8, 0, duration_const * 0.8f, EaseOut); |
| 2274 | ribbonLayer.anchor.y = t_reversed(0, -9, 0, duration_const * 0.8f, EaseOut); |
| 2275 | mat4x4_layer(ribbons_layer, ribbonLayer, 1.0f, 0); |
| 2276 |
| 2277 |
| 2278 | float dur = duration_const * 0.5f; |
| 2279 |
| 2280 | free_knot1.params.position = xyzMake(11 / 2, -11 / 2 - 9, 0); |
| 2281 | scale = t(0, 1, knot_delays[0], dur, EaseOut); |
| 2282 | free_knot1.params.scale = xyzMake(scale, scale, 1); |
| 2283 | draw_textured_shape(&free_knot1, ribbons_layer, NORMAL_ONE); |
| 2284 |
| 2285 | free_knot2.params.position = xyzMake(-11 / 2, -11 / 2 - 9, 0); |
| 2286 | scale = t(0, 1, knot_delays[1], dur, EaseOut); |
| 2287 | free_knot2.params.scale = xyzMake(-scale, scale, 1); |
| 2288 | draw_textured_shape(&free_knot2, ribbons_layer, NORMAL_ONE); |
| 2289 |
| 2290 | free_knot3.params.position = xyzMake(-11 / 2, 11 / 2 - 9, 0); |
| 2291 | scale = t(0, 1, knot_delays[2], dur, EaseOut); |
| 2292 | free_knot3.params.scale = xyzMake(-scale, scale, 1); |
| 2293 | draw_textured_shape(&free_knot3, ribbons_layer, NORMAL_ONE); |
| 2294 |
| 2295 | free_knot3.params.position = xyzMake(11 / 2, 11 / 2 - 9, 0); |
| 2296 | scale = t(0, 1, knot_delays[3], dur, EaseOut); |
| 2297 | free_knot3.params.scale = xyzMake(scale, scale, 1); |
| 2298 | draw_textured_shape(&free_knot3, ribbons_layer, NORMAL_ONE); |
| 2299 |
| 2300 | float a1 = -25; |
| 2301 | ribbon1.params.rotation = t_reversed(0, a1, 0, duration_const, EaseOut); |
| 2302 | ribbon3.params.rotation = t_reversed(180, 180 + a1, 0, duration_const, EaseOut); |
| 2303 |
| 2304 | float a2 = 0; |
| 2305 | ribbon2.params.rotation = t_reversed(90, 90 + a2, 0, duration_const, EaseOut); |
| 2306 | ribbon4.params.rotation = t_reversed(270, 270 + a2, 0, duration_const, EaseOut); |
| 2307 |
| 2308 | float k = .9; |
| 2309 | ribbon2.params.alpha = ribbon4.params.alpha = t_reversed(1, 0, duration_const * 0.5f, duration_const * 0.1f, Linear); |
| 2310 |
| 2311 | int ribbon_k = 0; |
| 2312 | change_ribbon(&ribbon1, t_reversed(ribbonLength - 8.0f * ribbon_k, 0, 0, duration_const * 0.9f, Linear) - free_scroll_offset / 5.0f * (30 - 8 * ribbon_k)); |
| 2313 | ribbon1.params.position.x = 0; |
| 2314 | draw_shape(&ribbon1, ribbons_layer); |
| 2315 |
| 2316 | change_ribbon(&ribbon2, t_reversed(ribbonLength - 10.0f * ribbon_k, 0, 0, duration_const * k, Linear) - free_scroll_offset / 5.0f * (22 - 10 * ribbon_k)); |
| 2317 | ribbon2.params.position.y = scroll_offset * 15 + -9; |
| 2318 | draw_shape(&ribbon2, ribbons_layer); |
| 2319 |
| 2320 | change_ribbon(&ribbon3, t_reversed(ribbonLength, 0, 0, duration_const * 0.9f, Linear)); |
| 2321 | draw_shape(&ribbon3, ribbons_layer); |
| 2322 |
| 2323 | change_ribbon(&ribbon4, t_reversed(ribbonLength, 0, duration_const * 0.6f * 0, duration_const * k, Linear)); |
| 2324 | draw_shape(&ribbon4, ribbons_layer); |
| 2325 |
| 2326 | float infinityDurK = 1.3; |
| 2327 |
| 2328 | rglMaskDraw(); |
| 2329 |
| 2330 | change_infinity(&infinity, t_reversed(0, 0.99, 0, duration_const * infinityDurK, EaseOut)); |
| 2331 |
| 2332 | float rot1 = t(0, -50, duration_const * 0.5f, duration_const * 0.8f, EaseOut); |
| 2333 | float rot2 = t(0, -30, duration_const * 0.8f, duration_const, EaseOut); |
| 2334 | infinity.params.rotation = rot1; |
| 2335 |
| 2336 | infinity.params.position.z = 1; |
| 2337 | infinity.params.position.y = -6; |
| 2338 | infinity.params.anchor = xyzMake(52.75, 23.5f, 0); |
| 2339 |
| 2340 | float infinity_scale = 1.025; |
| 2341 | infinity.params.scale = xyzMake(infinity_scale, infinity_scale, 1); |
| 2342 | draw_shape(&infinity, main_matrix); |
| 2343 | infinity.params.scale = xyzMake(-infinity_scale, -infinity_scale, 1); |
| 2344 | draw_shape(&infinity, main_matrix); |
| 2345 | rglNormalDrawThroughMask(); |
| 2346 | glEnable(GL_BLEND); |
| 2347 | glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); |
| 2348 | powerful_infinity_white.params.rotation = rot1 + rot2; |
| 2349 | powerful_infinity_white.params.alpha = 1; |
| 2350 | powerful_infinity_white.params.position.y = -6; |
| 2351 | draw_textured_shape(&powerful_infinity_white, main_matrix, NORMAL_ONE); |
| 2352 | } |
| 2353 | } else if (current_page == 3) { |
| 2354 | if (direct == 1) { |
| 2355 | ribbon1.params.position.x = 0; |
| 2356 | ribbon2.params.position.y = -9; |
| 2357 | ribbon3.params.position.x = 0; |
| 2358 | ribbon4.params.position.y = -9; |
| 2359 | rglNormalDraw(); |
| 2360 | glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); |
| 2361 | float scale = t(2, 1, 0, duration_const, EaseOut); |
| 2362 | powerful_mask.params.scale = xyzMake(scale, scale, 1); |
| 2363 | draw_textured_shape(&powerful_mask, main_matrix, NORMAL_ONE); |
| 2364 | glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
| 2365 | ribbonLayer.rotation = free_scroll_offset + t(360, 360 + (45 + 30), 0, duration_const * 0.8f, EaseOut); |
| 2366 | ribbonLayer.position.y = t(0, -8, 0, duration_const * 0.8f, EaseOut); |
| 2367 | ribbonLayer.anchor.y = t(0, -9, 0, duration_const * 0.8f, EaseOut); |
| 2368 | mat4x4_layer(ribbons_layer, ribbonLayer, 1.0f, 0); |
| 2369 |
| 2370 | float a1 = -25; |
| 2371 | ribbon1.params.rotation = t(0, a1, 0, duration_const, EaseOut); |
| 2372 | ribbon3.params.rotation = t(180, 180 + a1, 0, duration_const, EaseOut); |
| 2373 |
| 2374 | float a2 = 0; |
| 2375 | ribbon2.params.rotation = t(90, 90 + a2, 0, duration_const, EaseOut); |
| 2376 | ribbon4.params.rotation = t(270, 270 + a2, 0, duration_const, EaseOut); |
| 2377 |
| 2378 | float k = .5; |
| 2379 | ribbon2.params.alpha = ribbon4.params.alpha = t(1, 0, duration_const * k * 0.5f, duration_const * k * 0.1f, Linear); |
| 2380 |
| 2381 | int ribbon_k = time > duration_const ? 1 : 0; |
| 2382 |
| 2383 | change_ribbon(&ribbon1, t(ribbonLength - 8.0f * ribbon_k - free_scroll_offset / 5.0f * (30 - 8 * ribbon_k), 0, 0, duration_const * 0.9f, Linear)); |
| 2384 | draw_shape(&ribbon1, ribbons_layer); |
| 2385 |
| 2386 | change_ribbon(&ribbon2, t(ribbonLength - 10.0f * ribbon_k - free_scroll_offset / 5.0f * (22 - 10 * ribbon_k), 0, 0, duration_const * k, Linear)); |
| 2387 | draw_shape(&ribbon2, ribbons_layer); |
| 2388 |
| 2389 | change_ribbon(&ribbon3, t(ribbonLength, 0, 0, duration_const * 0.9f, Linear)); |
| 2390 | draw_shape(&ribbon3, ribbons_layer); |
| 2391 |
| 2392 | change_ribbon(&ribbon4, t(ribbonLength, 0, 0, duration_const * k, Linear)); |
| 2393 | draw_shape(&ribbon4, ribbons_layer); |
| 2394 |
| 2395 | float infinityDurK = 1.1f; |
| 2396 | if (time < duration_const * infinityDurK - 0.025f) { |
| 2397 | rglMaskDraw(); |
| 2398 |
| 2399 | change_infinity(&infinity, t(0, 0.99f, 0, duration_const * infinityDurK, Linear)); |
| 2400 |
| 2401 | infinity.params.rotation = 0; |
| 2402 |
| 2403 | infinity.params.position.z = 1; |
| 2404 | infinity.params.position.y = -6; |
| 2405 | infinity.params.anchor = xyzMake(52.75, 23.5f, 0); |
| 2406 |
| 2407 | float infinity_scale = 1.025f; |
| 2408 | infinity.params.scale = xyzMake(infinity_scale, infinity_scale, 1); |
| 2409 | draw_shape(&infinity, main_matrix); |
| 2410 |
| 2411 | infinity.params.scale = xyzMake(-infinity_scale, -infinity_scale, 1); |
| 2412 | draw_shape(&infinity, main_matrix); |
| 2413 |
| 2414 | rglNormalDrawThroughMask(); |
| 2415 | glEnable(GL_BLEND); |
| 2416 | glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); |
| 2417 |
| 2418 | powerful_infinity_white.params.rotation = 0; |
| 2419 | powerful_infinity_white.params.alpha = 1; |
| 2420 | powerful_infinity_white.params.position.y = -6; |
| 2421 |
| 2422 | draw_textured_shape(&powerful_infinity_white, main_matrix, NORMAL_ONE); |
| 2423 | } else { |
| 2424 | rglNormalDraw(); |
| 2425 |
| 2426 | glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); |
| 2427 | powerful_infinity.params.position.y = -6; |
| 2428 | powerful_infinity.params.alpha = 1; |
| 2429 | draw_textured_shape(&powerful_infinity, main_matrix, NORMAL_ONE); |
| 2430 | } |
| 2431 | } else { |
| 2432 | rglNormalDraw(); |
| 2433 | glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); |
| 2434 |
| 2435 | float scale = t(2, 1, 0, duration_const, EaseOut); |
| 2436 | powerful_mask.params.scale = xyzMake(scale, scale, 1); |
| 2437 | draw_textured_shape(&powerful_mask, main_matrix, NORMAL_ONE); |
| 2438 |
| 2439 | glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
| 2440 | scale = t(1, 2, 0, duration_const, EaseOut); |
| 2441 | private_stroke.params.scale = xyzMake(scale, scale, 1); |
| 2442 | private_stroke.params.rotation = t(0, -90, 0, duration_const, EaseOut); |
| 2443 | private_stroke.params.alpha = t(1, 0, 0, duration_const, Linear); |
| 2444 | private_stroke.params.position = xyzMake(0, t(0, -6, 0, duration_const, EaseOut), 0); |
| 2445 | scale = t_reversed(63 * 2.0f, 63 * 2, 0, duration_const, EaseOut); |
| 2446 | change_rounded_rectangle_stroked(&private_stroke, CSizeMake(scale, scale), scale / 2.0f, 9); |
| 2447 | draw_shape(&private_stroke, main_matrix); |
| 2448 |
| 2449 | float infinityDurK = 1.1; |
| 2450 | if (time < duration_const * infinityDurK - 0.025f) { |
| 2451 | rglMaskDraw(); |
| 2452 |
| 2453 | change_infinity(&infinity, t(0, 0.99, 0, duration_const * infinityDurK, Linear)); |
| 2454 |
| 2455 | infinity.params.rotation = 0; |
| 2456 |
| 2457 | infinity.params.position.z = 1; |
| 2458 | infinity.params.position.y = -6; |
| 2459 | infinity.params.anchor = xyzMake(52.75, 23.5f, 0); |
| 2460 |
| 2461 | float infinity_scale = 1.025; |
| 2462 | infinity.params.scale = xyzMake(infinity_scale, infinity_scale, 1); |
| 2463 | draw_shape(&infinity, main_matrix); |
| 2464 |
| 2465 | infinity.params.scale = xyzMake(-infinity_scale, -infinity_scale, 1); |
| 2466 | draw_shape(&infinity, main_matrix); |
| 2467 |
| 2468 |
| 2469 | rglNormalDrawThroughMask(); |
| 2470 | glEnable(GL_BLEND); |
| 2471 | glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); |
| 2472 |
| 2473 | powerful_infinity_white.params.rotation = 0; |
| 2474 | powerful_infinity_white.params.alpha = 1; |
| 2475 | powerful_infinity_white.params.position.y = -6; |
| 2476 |
| 2477 | draw_textured_shape(&powerful_infinity_white, main_matrix, NORMAL_ONE); |
| 2478 | } else { |
| 2479 | rglNormalDraw(); |
| 2480 |
| 2481 | glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); |
| 2482 | powerful_infinity.params.position.y = -6; |
| 2483 | powerful_infinity.params.alpha = 1; |
| 2484 | draw_textured_shape(&powerful_infinity, main_matrix, NORMAL_ONE); |
| 2485 | } |
| 2486 | } |
| 2487 | } else if (current_page == 4) { |
| 2488 | private_stroke.params.scale = xyzMake(1, 1, 1); |
| 2489 |
| 2490 | private_scroll_offset = scroll_offset * 5; |
| 2491 |
| 2492 | rglNormalDraw(); |
| 2493 | glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); |
| 2494 |
| 2495 | scale = t(1, 2, 0, duration_const, EaseOut); |
| 2496 | if (scale < 1.5) { |
| 2497 | powerful_mask.params.scale = xyzMake(scale, scale, 1); |
| 2498 | } |
| 2499 |
| 2500 | if (direct == 1) { |
| 2501 | privateLayer.rotation = private_scroll_offset + t(-90, 0, 0, duration_const, EaseOut); |
| 2502 | } else { |
| 2503 | privateLayer.rotation = private_scroll_offset + t(90, 0, 0, duration_const * private_back_k, EaseOut); |
| 2504 | } |
| 2505 |
| 2506 | mat4x4_layer(private_matrix, privateLayer, 1, 0); |
| 2507 |
| 2508 | if (direct == 1) { |
| 2509 | glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); |
| 2510 | powerful_infinity.params.position.y = -6; |
| 2511 | powerful_infinity.params.alpha = t(1, 0, 0, duration_const * 0.25f, EaseIn); |
| 2512 | draw_textured_shape(&powerful_infinity, main_matrix, NORMAL_ONE); |
| 2513 | } |
| 2514 |
| 2515 | glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
| 2516 |
| 2517 | if (direct == 1) { |
| 2518 | glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); |
| 2519 | scale = t(0.5f, 1.0f, 0, duration_const, EaseOut); |
| 2520 | private_door.params.scale = xyzMake(scale, scale, 1); |
| 2521 | private_door.params.alpha = t(.0, 1.0f, 0, duration_const, EaseOut); |
| 2522 | draw_textured_shape(&private_door, main_matrix, NORMAL_ONE); |
| 2523 |
| 2524 | glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
| 2525 | private_stroke.params.rotation = private_scroll_offset; |
| 2526 | private_stroke.params.alpha = 1; |
| 2527 | private_stroke.params.position = xyzMake(0, 0, 0); |
| 2528 | scale = t(63, 63 * 2, 0, duration_const, EaseOut); |
| 2529 | change_rounded_rectangle_stroked(&private_stroke, CSizeMake(scale, scale), scale / 2.0f, 9); |
| 2530 | draw_shape(&private_stroke, main_matrix); |
| 2531 |
| 2532 | glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); |
| 2533 | float k = .0; |
| 2534 | scale = t(0.5f, 1.0f, duration_const * k, duration_const, EaseOut); |
| 2535 | private_keyhole_body.params.rotation = private_scroll_offset; |
| 2536 | private_keyhole_body.params.scale = xyzMake(scale, scale, 1); |
| 2537 | private_keyhole_body.params.alpha = t(.0, 1.0f, duration_const * k, duration_const, EaseOut); |
| 2538 | draw_safe(0, 1, t(0, 1, 0, duration_const, Linear)); |
| 2539 | } else { |
| 2540 | glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); |
| 2541 | scale = t(0.5f, 1.0f, 0, duration_const * private_back_k, EaseOut); |
| 2542 | private_door.params.scale = xyzMake(scale, scale, 1); |
| 2543 | private_door.params.alpha = t(.0, 1.0f, 0, duration_const * private_back_k, EaseOut); |
| 2544 | draw_textured_shape(&private_door, main_matrix, NORMAL_ONE); |
| 2545 |
| 2546 | glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
| 2547 | private_stroke.params.rotation = private_scroll_offset; |
| 2548 | private_stroke.params.alpha = t(0, 1, 0, duration_const * 0.25f, Linear); |
| 2549 | private_stroke.params.position = xyzMake(0, 0, 0); |
| 2550 | scale = t(63, 63 * 2, 0, duration_const * private_back_k, EaseOut); |
| 2551 | change_rounded_rectangle_stroked(&private_stroke, CSizeMake(scale, scale), scale / 2.0f, 9); |
| 2552 | draw_shape(&private_stroke, main_matrix); |
| 2553 |
| 2554 | glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); |
| 2555 | scale = t(00.5f, 1.0, 0, duration_const * private_back_k, EaseOut); |
| 2556 | private_keyhole_body.params.rotation = private_scroll_offset; |
| 2557 | private_keyhole_body.params.scale = xyzMake(scale, scale, 1); |
| 2558 | private_keyhole_body.params.alpha = t(.0, 1.0f, 0, duration_const * private_back_k, EaseOut); |
| 2559 |
| 2560 | if (time < duration_const * .4) { |
| 2561 | cloud_cover.params.position.y = t_reversed(118 / 2 + 50, 118 / 2, duration_const * 0.8f * private_back_k, duration_const * private_back_k, EaseOut); |
| 2562 | draw_shape(&cloud_cover, main_matrix); |
| 2563 | } |
| 2564 |
| 2565 | draw_safe(0, t(0, 1, duration_const * private_back_k * 0.0f, duration_const * private_back_k, Linear), t(0, 1, 0, duration_const, Linear)); |
| 2566 | } |
| 2567 | } else if (current_page == 5) { |
| 2568 | float private_fade_k = 0.5f; |
| 2569 |
| 2570 | rglNormalDraw(); |
| 2571 |
| 2572 | glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); |
| 2573 | scale = 1; |
| 2574 | private_door.params.scale = xyzMake(scale, scale, 1); |
| 2575 | private_door.params.alpha = t(1, 0, 0, duration_const * private_fade_k * 0.5f, EaseOut); |
| 2576 | draw_textured_shape(&private_door, main_matrix, NORMAL_ONE); |
| 2577 |
| 2578 | glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
| 2579 | private_stroke.params.rotation = private_scroll_offset; |
| 2580 | private_stroke.params.alpha = t(1, 0, 0, duration_const * private_fade_k * 0.5f, EaseOut); |
| 2581 | scale = t(244 / 2, r2 * 2, 0, duration_const, EaseOut); |
| 2582 | change_rounded_rectangle_stroked(&private_stroke, CSizeMake(scale, scale), scale / 2.0f, 9); |
| 2583 | draw_shape(&private_stroke, main_matrix); |
| 2584 |
| 2585 | glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); |
| 2586 | scale = 1; |
| 2587 | private_keyhole_body.params.rotation = private_scroll_offset; |
| 2588 | private_keyhole_body.params.scale = xyzMake(scale, scale, 1); |
| 2589 | private_keyhole_body.params.alpha = t(1.0, 0.0, 0, duration_const * private_fade_k * 0.5f, EaseOut); |
| 2590 | privateLayer.rotation = private_scroll_offset; |
| 2591 | mat4x4_layer(private_matrix, privateLayer, t(1, 0.9f, 0, duration_const * private_fade_k, EaseOut), 0); |
| 2592 | cloud_cover.params.position.y = t(118 / 2 + 50, 118 / 2, 0, duration_const, EaseOut); |
| 2593 | draw_shape(&cloud_cover, main_matrix); |
| 2594 | } |
| 2595 |
| 2596 | prev_page = current_page; |
| 2597 | } |
| 2598 |
| 2599 | JNIEXPORT void Java_org_telegram_messenger_Intro_setScrollOffset(JNIEnv *env, jclass class, float a_offset) { |
| 2600 | scroll_offset = a_offset; |
| 2601 | } |
| 2602 |
| 2603 | JNIEXPORT void Java_org_telegram_messenger_Intro_setPage(JNIEnv *env, jclass class, int page) { |
| 2604 | if (current_page == page) { |
| 2605 | return; |
| 2606 | } else { |
| 2607 | prev_page = current_page; |
| 2608 | current_page = page; |
| 2609 | direct = current_page > prev_page ? 1 : 0; |
| 2610 | date0 = date; |
| 2611 | time = 0; |
| 2612 | } |
| 2613 | } |
| 2614 |
| 2615 | JNIEXPORT void Java_org_telegram_messenger_Intro_setDate(JNIEnv *env, jclass class, float a) { |
| 2616 | date = a; |
| 2617 | } |
| 2618 |
| 2619 | JNIEXPORT void Java_org_telegram_messenger_Intro_setIcTextures(JNIEnv *env, jclass class, GLuint a_ic_bubble_dot, GLuint a_ic_bubble, GLuint a_ic_cam_lens, GLuint a_ic_cam, GLuint a_ic_pencil, GLuint a_ic_pin, GLuint a_ic_smile_eye, GLuint a_ic_smile, GLuint a_ic_videocam) { |
| 2620 | ic_bubble_dot_texture = a_ic_bubble_dot; |
| 2621 | ic_bubble_texture = a_ic_bubble; |
| 2622 | ic_cam_lens_texture = a_ic_cam_lens; |
| 2623 | ic_cam_texture = a_ic_cam; |
| 2624 | ic_pencil_texture = a_ic_pencil; |
| 2625 | ic_pin_texture = a_ic_pin; |
| 2626 | ic_smile_eye_texture = a_ic_smile_eye; |
| 2627 | ic_smile_texture = a_ic_smile; |
| 2628 | ic_videocam_texture = a_ic_videocam; |
| 2629 | } |
| 2630 |
| 2631 | JNIEXPORT void Java_org_telegram_messenger_Intro_setTelegramTextures(JNIEnv *env, jclass class, GLuint a_telegram_sphere, GLuint a_telegram_plane) { |
| 2632 | telegram_sphere_texture = a_telegram_sphere; |
| 2633 | telegram_plane_texture = a_telegram_plane; |
| 2634 | } |
| 2635 |
| 2636 | JNIEXPORT void Java_org_telegram_messenger_Intro_setFastTextures(JNIEnv *env, jclass class, GLuint a_fast_body, GLuint a_fast_spiral, GLuint a_fast_arrow, GLuint a_fast_arrow_shadow) { |
| 2637 | fast_spiral_texture = a_fast_spiral; |
| 2638 | fast_body_texture = a_fast_body; |
| 2639 | fast_arrow_shadow_texture = a_fast_arrow_shadow; |
| 2640 | fast_arrow_texture = a_fast_arrow; |
| 2641 | } |
| 2642 |
| 2643 | JNIEXPORT void Java_org_telegram_messenger_Intro_setFreeTextures(JNIEnv *env, jclass class, GLuint a_knot_up, GLuint a_knot_down) { |
| 2644 | free_knot_up_texture = a_knot_up; |
| 2645 | free_knot_down_texture = a_knot_down; |
| 2646 | } |
| 2647 |
| 2648 | JNIEXPORT void Java_org_telegram_messenger_Intro_setPowerfulTextures(JNIEnv *env, jclass class, GLuint a_powerful_mask, GLuint a_powerful_star, GLuint a_powerful_infinity, GLuint a_powerful_infinity_white) { |
| 2649 | powerful_mask_texture = a_powerful_mask; |
| 2650 | powerful_star_texture = a_powerful_star; |
| 2651 | powerful_infinity_texture = a_powerful_infinity; |
| 2652 | powerful_infinity_white_texture = a_powerful_infinity_white; |
| 2653 | } |
| 2654 |
| 2655 | JNIEXPORT void Java_org_telegram_messenger_Intro_setPrivateTextures(JNIEnv *env, jclass class, GLuint a_private_door, GLuint a_private_screw) { |
| 2656 | private_door_texture = a_private_door; |
| 2657 | private_screw_texture = a_private_screw; |
| 2658 | } |
| 2659 |
| 2660 | JNIEXPORT void Java_org_telegram_messenger_Intro_onSurfaceCreated(JNIEnv *env, jclass class) { |
| 2661 |
| 2662 | ms0 = 0; |
| 2663 | date = 1; |
| 2664 | date0 = 0; |
| 2665 | direct = 0; |
| 2666 | i = 0; |
| 2667 | current_page = 0; |
| 2668 | prev_page = 0; |
| 2669 | time = 0; |
| 2670 | time_local = 0; |
| 2671 | offset_y = 0; |
| 2672 | ribbonLength = 86.5f; |
| 2673 | starsFar = 500; |
| 2674 | scroll_offset = 0; |
| 2675 | calculated_speedometer_sin = 0; |
| 2676 | ms0_anim = 0; |
| 2677 | fps_anim = 0; |
| 2678 | count_anim_fps = 0; |
| 2679 | speedometer_scroll_offset = 0; |
| 2680 | free_scroll_offset = 0; |
| 2681 | private_scroll_offset = 0; |
| 2682 | anim_pencil_start_time = 0; |
| 2683 | anim_pencil_start_all_time = 0; |
| 2684 | anim_pencil_start_all_end_time = 0; |
| 2685 | anim_pencil_stage = 0; |
| 2686 | anim_bubble_dots_stage = 0; |
| 2687 | anim_bubble_dots_end_period = 0; |
| 2688 | anim_videocam_start_time = 0; |
| 2689 | anim_videocam_next_time = 0; |
| 2690 | anim_videocam_duration = 0; |
| 2691 | anim_videocam_angle = 0; |
| 2692 | anim_videocam_old_angle = 0; |
| 2693 | anim_cam_start_time = 0; |
| 2694 | anim_cam_next_time = 0; |
| 2695 | anim_cam_duration = 0; |
| 2696 | anim_cam_angle = 0; |
| 2697 | anim_cam_old_angle = 0; |
| 2698 | qShot = 0; |
| 2699 | anim_camshot_start_time = 0; |
| 2700 | anim_camshot_duration = 0; |
| 2701 | anim_smile_start_time1 = 0; |
| 2702 | anim_smile_start_time2 = 0; |
| 2703 | anim_smile_blink_start_time = 0; |
| 2704 | anim_smile_blink_one = 0; |
| 2705 | anim_smile_stage = 0; |
| 2706 | scale = 0; |
| 2707 | anim_pin_start_time = 0; |
| 2708 | anim_pin_duration = 0; |
| 2709 | anim_pencil_period = 0; |
| 2710 | cloud_scroll_offset = 0; |
| 2711 |
| 2712 | setup_shaders(); |
| 2713 |
| 2714 | vec4 start_button_col = {44 / 255.0f, 165 / 255.0f, 224 / 255.0f, 1.0f}; |
| 2715 | start_button = create_rounded_rectangle(CSizeMake(172, 44), 2, 3, start_button_col); |
| 2716 | start_button.params.anchor.y = -22; |
| 2717 |
| 2718 | mask1 = create_rounded_rectangle(CSizeMake(60, 60), 0, 16, black_color); |
| 2719 |
| 2720 | telegram_sphere = create_textured_rectangle(CSizeMake(148, 148), telegram_sphere_texture); |
| 2721 | telegram_plane = create_textured_rectangle(CSizeMake(82, 74), telegram_plane_texture); |
| 2722 | telegram_plane.params.anchor = xyzMake(6, -5, 0); |
| 2723 |
| 2724 | fast_body = create_textured_rectangle(CSizeMake(148, 148), fast_body_texture); |
| 2725 |
| 2726 | fast_arrow_shadow = create_textured_rectangle(CSizeMake(164 / 2, 44 / 2), fast_arrow_shadow_texture); |
| 2727 | fast_arrow_shadow.params.position.x = -1; |
| 2728 | fast_arrow_shadow.params.position.y = 2; |
| 2729 |
| 2730 | fast_arrow = create_textured_rectangle(CSizeMake(164 / 2, 44 / 2), fast_arrow_texture); |
| 2731 | fast_arrow.params.anchor.x = fast_arrow_shadow.params.anchor.x = -19; |
| 2732 |
| 2733 | int ang = 180; |
| 2734 | spiral = create_segmented_square(r1, D2R(35 + 1), D2R(35 + 1 - 10 + ang), fast_spiral_texture); |
| 2735 |
| 2736 | vec4 free_bg_color = {246 / 255.0f, 73 / 255.0f, 55 / 255.0f, 1}; |
| 2737 | free_bg = create_rectangle(CSizeMake(160 * 2, 160 * 2), free_bg_color); |
| 2738 |
| 2739 | free_knot1 = create_textured_rectangle(CSizeMake(138 / 3, 138 / 3), free_knot_up_texture); |
| 2740 | free_knot1.params.anchor.x = -23 + 10; |
| 2741 | free_knot1.params.anchor.y = 23 - 10; |
| 2742 |
| 2743 | free_knot2 = create_textured_rectangle(CSizeMake(138 / 3, 138 / 3), free_knot_up_texture); |
| 2744 | free_knot2.params.anchor.x = -23 + 10; |
| 2745 | free_knot2.params.anchor.y = 23 - 10; |
| 2746 |
| 2747 | free_knot3 = create_textured_rectangle(CSizeMake(150 / 3, 150 / 3), free_knot_down_texture); |
| 2748 | free_knot3.params.anchor.x = -100 / 4.0f + 20 / 2.0f; |
| 2749 | free_knot3.params.anchor.y = -100 / 4.0f + 20 / 2.0f; |
| 2750 |
| 2751 | free_knot4 = create_textured_rectangle(CSizeMake(150 / 3, 150 / 3), free_knot_down_texture); |
| 2752 | free_knot4.params.anchor.x = -100 / 4.0f + 20 / 2.0f; |
| 2753 | free_knot4.params.anchor.y = -100 / 4.0f + 20 / 2.0f; |
| 2754 |
| 2755 |
| 2756 | ribbonLayer = default_layer_params(); |
| 2757 |
| 2758 | ribbon1 = create_ribbon(ribbonLength, white_color); |
| 2759 | ribbon1.params.layer_params = ribbonLayer; |
| 2760 |
| 2761 | ribbon2 = create_ribbon(ribbonLength, white_color); |
| 2762 | ribbon2.params.rotation = 90; |
| 2763 | ribbon2.params.layer_params = ribbonLayer; |
| 2764 |
| 2765 | ribbon3 = create_ribbon(ribbonLength, white_color); |
| 2766 | ribbon3.params.rotation = 180; |
| 2767 | ribbon3.params.layer_params = ribbonLayer; |
| 2768 |
| 2769 | ribbon4 = create_ribbon(ribbonLength, white_color); |
| 2770 | ribbon4.params.rotation = 270; |
| 2771 | ribbon4.params.layer_params = ribbonLayer; |
| 2772 |
| 2773 | ribbon1.params.position.y = ribbon2.params.position.y = ribbon3.params.position.y = ribbon4.params.position.y = -9; |
| 2774 |
| 2775 |
| 2776 | ic_bubble_dot = create_textured_rectangle(CSizeMake(18 / 3, 18 / 3), ic_bubble_dot_texture); |
| 2777 | ic_bubble = create_textured_rectangle(CSizeMake(102 / 3, 102 / 3), ic_bubble_texture); |
| 2778 | ic_cam_lens = create_textured_rectangle(CSizeMake(36 / 3, 36 / 3), ic_cam_lens_texture); |
| 2779 | ic_cam = create_textured_rectangle(CSizeMake(108 / 3, 96 / 3), ic_cam_texture); |
| 2780 | ic_pencil = create_textured_rectangle(CSizeMake(86 / 3, 86 / 3), ic_pencil_texture); |
| 2781 | ic_pin = create_textured_rectangle(CSizeMake(90 / 3, 120 / 3), ic_pin_texture); |
| 2782 | ic_smile_eye = create_textured_rectangle(CSizeMake(18 / 3, 18 / 3), ic_smile_eye_texture); |
| 2783 | ic_smile = create_textured_rectangle(CSizeMake(120 / 3, 120 / 3), ic_smile_texture); |
| 2784 | ic_videocam = create_textured_rectangle(CSizeMake(144 / 3, 84 / 3), ic_videocam_texture); |
| 2785 |
| 2786 | ic_pin_layer = ic_cam_layer = ic_videocam_layer = ic_smile_layer = ic_bubble_layer = ic_pencil_layer = default_layer_params(); |
| 2787 |
| 2788 | ic_pin_layer.anchor = xyzMake(0, 50 / 2, 0); |
| 2789 | ic_pencil_layer.anchor = xyzMake(-30 / 2, 30 / 2, 0); |
| 2790 |
| 2791 | infinity = create_infinity(11.7, .0, 32, white_color); |
| 2792 |
| 2793 | vec4 powerful_bg_color = {47 / 255.f, 90 / 255.f, 131 / 255.f, 1}; |
| 2794 | powerful_bg = create_rectangle(CSizeMake(200, 200), powerful_bg_color); |
| 2795 | powerful_mask = create_textured_rectangle(CSizeMake(200, 200), powerful_mask_texture); |
| 2796 |
| 2797 | powerful_infinity = create_textured_rectangle(CSizeMake(366 / 3, 180 / 3), powerful_infinity_texture); |
| 2798 | powerful_infinity_white = create_textured_rectangle(CSizeMake(366 / 3, 180 / 3), powerful_infinity_white_texture); |
| 2799 |
| 2800 | float star_radius = 5.25; |
| 2801 | star = create_textured_rectangle(CSizeMake(star_radius, star_radius), powerful_star_texture); |
| 2802 | star.params.const_params.is_star = 1; |
| 2803 | for (i = 0; i < starsCount; i++) { |
| 2804 | stars[i] = default_params(); |
| 2805 | stars[i].position = star_create_position(-(i * 1500.0f) / starsCount); |
| 2806 | } |
| 2807 |
| 2808 | privateLayer = default_layer_params(); |
| 2809 |
| 2810 | vec4 private_bg_color = {200 / 255.f, 207 / 255.f, 212 / 255.f, 1}; |
| 2811 | private_bg = create_rectangle(CSizeMake(240, 240), private_bg_color); |
| 2812 |
| 2813 | private_door = create_textured_rectangle(CSizeMake(408 / 3, 408 / 3), private_door_texture); |
| 2814 | private_keyhole_body = create_textured_rectangle(CSizeMake(216 / 3, 216 / 3), private_keyhole_body_texture); |
| 2815 | private_screw = create_textured_rectangle(CSizeMake(30 / 3, 30 / 3), private_screw_texture); |
| 2816 | private_stroke = create_rounded_rectangle_stroked(CSizeMake(244 / 2, 244 / 2), 21, 9, 16, white_color); |
| 2817 |
| 2818 | int cloud_polygons_count = 64; |
| 2819 | cloud_extra_mask1 = create_circle(1, cloud_polygons_count, black_color); |
| 2820 | cloud_extra_mask2 = create_circle(1, cloud_polygons_count, black_color); |
| 2821 | cloud_extra_mask3 = create_circle(1, cloud_polygons_count, black_color); |
| 2822 | cloud_extra_mask4 = create_circle(1, cloud_polygons_count, black_color); |
| 2823 |
| 2824 | cloud_cover = create_rectangle(CSizeMake(240, 100), white_color); |
| 2825 | cloud_cover.params.anchor.y = -50; |
| 2826 |
| 2827 | vec4 cloud_color = {42 / 255.0f, 180 / 255.0f, 247 / 255.0f, 1}; |
| 2828 | cloud_bg = create_rectangle(CSizeMake(160 * 2, 160 * 2), cloud_color); |
| 2829 | } |
| 2830 |
| 2831 | JNIEXPORT void Java_org_telegram_messenger_Intro_onSurfaceChanged(JNIEnv *env, jclass class, int a_width_px, int a_height_px, float a_scale_factor, int a1) { |
| 2832 | glViewport(0, 0, a_width_px, a_height_px); |
| 2833 | width = (int) (a_width_px / a_scale_factor); |
| 2834 | height = (int) (a_height_px / a_scale_factor); |
| 2835 | scale_factor = a_scale_factor; |
| 2836 | mat4x4_plain(main_matrix, (int)((float)a_width_px / a_scale_factor), (int)((float)a_height_px / a_scale_factor)); |
| 2837 | offset_y = a1*main_matrix[1][1]; |
| 2838 | set_y_offset_objects(offset_y); |
| 2839 | y_offset_absolute = a1; |
| 2840 | mat4x4_stars(stars_matrix, 45, 1, -1000, 0, (int)((float)a_width_px / a_scale_factor), (int)((float)a_height_px / a_scale_factor)); |
| 2841 | } |