Войти в систему

Home
    - Создать дневник
    - Написать в дневник
       - Подробный режим

LJ.Rossia.org
    - Новости сайта
    - Общие настройки
    - Sitemap
    - Оплата
    - ljr-fif

Редактировать...
    - Настройки
    - Список друзей
    - Дневник
    - Картинки
    - Пароль
    - Вид дневника

Сообщества

Настроить S2

Помощь
    - Забыли пароль?
    - FAQ
    - Тех. поддержка



Пишет nancygold ([info]nancygold)
@ 2024-05-24 00:51:00

Previous Entry  Add to memories!  Tell a Friend!  Next Entry
Настроение: amused

ChatGPT translation
Stumbled upon the following DirectX 5 example
http://archive.gamedev.net/archive/reference/articles/article589.html

It does some obscure shit. In particular, it inits palette to random colors

    // clear all the palette entries to RGB 0,0,0
    memset(color_palette,0,256*sizeof(PALETTEENTRY));
    
    // set all of the flags to the correct value
    for (index=0; index<256; index++)
    {
        // create the GRAY/RED/GREEN/BLUE palette, 64 shades of each
        if ((index / 64)==0)
        {
            color_palette[index].peRed = index*4;
            color_palette[index].peGreen = index*4;
            color_palette[index].peBlue = index*4;
        } // end if
        else
        if ((index / 64)==1)
            color_palette[index].peRed = (index%64)*4;
        else
        if ((index / 64)==2) 
            color_palette[index].peGreen = (index%64)*4;
        else
        if ((index / 64)==3)
            color_palette[index].peBlue = (index%64)*4;

        // set the no collapse flag
        color_palette[index].peFlags = PC_NOCOLLAPSE;

    } // end for index



So I asked ChatGPT to convert it to SDL2.
And it decided to be smart....
    for (int i = 0; i < MAX_COLORS; i++)
    {
        Set_Pal_Entry(i, (i % 64) * 4, ((i / 64) % 4) * 64, ((i / 64) % 4) * 64);
    }


That was in fact the single broken part of it.
Outside of the need to "#define SDL_MAIN_HANDLED" to suppress SDL from doing `#define main SDL_main /*happy debugging retards!*/`

Anyway, the code is basically Etch A Sketch


(Читать комментарии)

Добавить комментарий:

Как:
Identity URL: 
имя пользователя:    
Вы должны предварительно войти в LiveJournal.com
 
E-mail для ответов: 
Вы сможете оставлять комментарии, даже если не введете e-mail.
Но вы не сможете получать уведомления об ответах на ваши комментарии!
Внимание: на указанный адрес будет выслано подтверждение.
Имя пользователя:
Пароль:
Тема:
HTML нельзя использовать в теме сообщения
Сообщение:



Обратите внимание! Этот пользователь включил опцию сохранения IP-адресов пишущих комментарии к его дневнику.