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