Просмотр исходного кода

Rename max sprites constant

Use IZ_ prefix for constants.
master
TheoryOfNekomata 1 год назад
Родитель
Сommit
47c9784093
3 измененных файлов: 7 добавлений и 7 удалений
  1. +1
    -1
      src/packages/game/IZ_app_video.c
  2. +4
    -4
      src/packages/game/output/video/IZ_video.c
  3. +2
    -2
      src/packages/game/output/video/IZ_video.h

+ 1
- 1
src/packages/game/IZ_app_video.c Просмотреть файл

@@ -116,7 +116,7 @@ void IZ_VideoUpdate(IZ_VideoState* video_state) {
SDL_RenderClear(video_state->renderer);
u16 sprite_index;
// TODO: optimize this, cut the loop as much as possible.
for (sprite_index = 0; sprite_index < MAX_ACTIVE_SPRITES; sprite_index += 1) {
for (sprite_index = 0; sprite_index < IZ_MAX_ACTIVE_SPRITES; sprite_index += 1) {
if (!video_state->active_sprites[sprite_index].sprite.texture) {
continue;
}


+ 4
- 4
src/packages/game/output/video/IZ_video.c Просмотреть файл

@@ -66,7 +66,7 @@ IZ_ProcedureResult IZ_VideoInitializeConfig(IZ_VideoState* state, const char* c

IZ_ProcedureResult IZ_VideoInitialize(IZ_VideoState* state, void* user_data, const char* config_path, u8 argc, const char* argv[]) {
IZ_memcpy(state, sizeof(IZ_VideoState), &IZ_VIDEO_DEFAULT_STATE, sizeof(IZ_VideoState));
memset(state->active_sprites, 0, sizeof(IZ_SpriteSlot) * MAX_ACTIVE_SPRITES);
memset(state->active_sprites, 0, sizeof(IZ_SpriteSlot) * IZ_MAX_ACTIVE_SPRITES);
if (IZ_VideoInitializeConfig(state, config_path, argc, argv) < 0) {
return -2;
}
@@ -92,7 +92,7 @@ IZ_ProcedureResult IZ_VideoInitialize(IZ_VideoState* state, void* user_data, con
}

void IZ_VideoTeardown(IZ_VideoState* state) {
for (u16 i = 0; i < MAX_ACTIVE_SPRITES; i += 1) {
for (u16 i = 0; i < IZ_MAX_ACTIVE_SPRITES; i += 1) {
if (state->active_sprites[i].sprite.texture) {
SDL_DestroyTexture(state->active_sprites[i].sprite.texture);
state->active_sprites[i].sprite.texture = NULL;
@@ -110,13 +110,13 @@ u16 IZ_VideoGetNextFreeSpriteSlot(IZ_VideoState* state, IZ_VideoSpritePriority p
// 2. Check each sprite's priority and requested_at (for eviction policy)
// 3. Return that new slot. (prefer returning empty slots)
// 4. Return MAX_ACTIVE_SPRITES if there's no slot left)
for (u16 i = 0; i < MAX_ACTIVE_SPRITES; i += 1) {
for (u16 i = 0; i < IZ_MAX_ACTIVE_SPRITES; i += 1) {
if (!state->active_sprites[i].sprite.texture) {
return i;
}
}

return MAX_ACTIVE_SPRITES;
return IZ_MAX_ACTIVE_SPRITES;
}

void IZ_VideoLoadSprite(IZ_VideoState* state, IZ_VideoLoadSpriteParams params, IZ_SpriteSlot* out) {


+ 2
- 2
src/packages/game/output/video/IZ_video.h Просмотреть файл

@@ -14,7 +14,7 @@
#include "../../geometry/IZ_vector2d.h"
#include "../../input/IZ_input.h"

#define MAX_ACTIVE_SPRITES 512u
#define IZ_MAX_ACTIVE_SPRITES 512u

typedef enum {
// eyecandy, e.g. sparks
@@ -68,7 +68,7 @@ typedef struct {
u64 last_update_at;
SDL_Window* window;
SDL_Renderer* renderer;
IZ_SpriteSlot active_sprites[MAX_ACTIVE_SPRITES];
IZ_SpriteSlot active_sprites[IZ_MAX_ACTIVE_SPRITES];
} IZ_VideoState;

static const IZ_VideoState IZ_VIDEO_DEFAULT_STATE = {


Загрузка…
Отмена
Сохранить