Allocates memory for a procedural that is attached to a texture
| 407 | |
| 408 | // Allocates memory for a procedural that is attached to a texture |
| 409 | int AllocateProceduralForTexture(int handle) { |
| 410 | int w, h; |
| 411 | |
| 412 | if (GameTextures[handle].flags & TF_TEXTURE_64) { |
| 413 | w = h = 64; |
| 414 | } else if (GameTextures[handle].flags & TF_TEXTURE_32) { |
| 415 | w = h = 32; |
| 416 | } else { |
| 417 | w = h = 128; |
| 418 | } |
| 419 | |
| 420 | GameTextures[handle].procedural = (proc_struct *)mem_malloc(sizeof(proc_struct)); |
| 421 | ASSERT(GameTextures[handle].procedural); |
| 422 | |
| 423 | GameTextures[handle].procedural->proc1 = NULL; |
| 424 | GameTextures[handle].procedural->proc2 = NULL; |
| 425 | |
| 426 | GameTextures[handle].procedural->last_evaluation_time = 0; |
| 427 | GameTextures[handle].procedural->osc_time = 0; |
| 428 | GameTextures[handle].procedural->osc_value = 8; |
| 429 | |
| 430 | GameTextures[handle].procedural->procedural_bitmap = bm_AllocBitmap(w, h, 0); |
| 431 | ASSERT(GameTextures[handle].procedural->procedural_bitmap >= 0); |
| 432 | |
| 433 | GameTextures[handle].procedural->memory_type = PROC_MEMORY_TYPE_NONE; |
| 434 | |
| 435 | GameTextures[handle].procedural->palette = (uint16_t *)mem_malloc(256 * 2); |
| 436 | |
| 437 | GameTextures[handle].procedural->last_procedural_frame = -1; |
| 438 | GameTextures[handle].procedural->heat = 128; |
| 439 | |
| 440 | GameTextures[handle].procedural->dynamic_proc_elements = -1; |
| 441 | GameTextures[handle].procedural->static_proc_elements = NULL; |
| 442 | |
| 443 | GameTextures[handle].procedural->num_static_elements = 0; |
| 444 | |
| 445 | GameTextures[handle].procedural->light = 1; |
| 446 | GameTextures[handle].procedural->thickness = 4; |
| 447 | |
| 448 | memcpy(GameTextures[handle].procedural->palette, DefaultProcPalette, 256 * 2); |
| 449 | |
| 450 | return 1; |
| 451 | } |
| 452 | |
| 453 | // Allocates the memory needed for static elements for a procedural texture |
| 454 | void AllocateStaticProceduralsForTexture(int handle, int num_elements) { |
no test coverage detected