~spiral/fantasy_console

2edc810f07c26769186d373fbe7817c0ee3f381b — spiral a month ago 00cb581 main
fix: don't load a new texture every time we update the screen
1 files changed, 14 insertions(+), 10 deletions(-)

M lib/raylib_main.c
M lib/raylib_main.c => lib/raylib_main.c +14 -10
@@ 8,6 8,8 @@ const int gameScreenHeight = 224;

unsigned char IMAGE_CODE_DATA[229376];

Texture texture;

void raylib_init(void) {
    const int windowWidth = 800;
    const int windowHeight = 450;


@@ 20,9 22,16 @@ void raylib_init(void) {
    SetTargetFPS(60);                   // Set our game to run at 60 frames-per-second

    // initialize display
    BeginDrawing();
    ClearBackground(BLACK);
    EndDrawing();
    Image image = { 0 };
    image.width = 256;
    image.height = 224;
    image.format = 7;
    image.data = IMAGE_CODE_DATA;
    image.mipmaps = 1;

    texture = LoadTextureFromImage(image);

    raylib_update_image();
}

void raylib_teardown(void) {


@@ 30,14 39,9 @@ void raylib_teardown(void) {
}

void raylib_update_image(void) {
    Image image = { 0 };
    image.width = 256;
    image.height = 224;
    image.format = 7;
    image.data = IMAGE_CODE_DATA;
    image.mipmaps = 1;
    // this immediately updates the texture after we load it, but oh well...
    UpdateTexture(texture, IMAGE_CODE_DATA);

    Texture texture = LoadTextureFromImage(image);
    // Update
    //----------------------------------------------------------------------------------
    // Compute required framebuffer scaling