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