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