VaKeR CYBER ARMY
Logo of a company Server : Apache/2.4.41 (Ubuntu)
System : Linux absol.cf 5.4.0-198-generic #218-Ubuntu SMP Fri Sep 27 20:18:53 UTC 2024 x86_64
User : www-data ( 33)
PHP Version : 7.4.33
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Directory :  /usr/share/emscripten/tests/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //usr/share/emscripten/tests/sdl_canvas_palette.c
#include <stdio.h>
#include <SDL/SDL.h>
#include <emscripten.h>

int main() {
  SDL_Init(SDL_INIT_VIDEO);
  SDL_Surface *screen = SDL_SetVideoMode(600, 400, 8, SDL_HWSURFACE | SDL_HWPALETTE);

  //initialize sdl palette
  //with red green and blue
  //colors
  SDL_Color pal[3];
  pal[0].r = 255;
  pal[0].g = 0;
  pal[0].b = 0;
  pal[0].unused = 0;

  pal[1].r = 0;
  pal[1].g = 255;
  pal[1].b = 0;
  pal[1].unused = 0;

  pal[2].r = 0;
  pal[2].g = 0;
  pal[2].b = 255;
  pal[2].unused = 0;

  SDL_SetColors(screen, pal, 0, 3);

  SDL_FillRect(screen, NULL, 0);

  {
    SDL_Rect rect = { 300, 0, 300, 200 };
    SDL_FillRect(screen, &rect, 1);
  }

  {
    SDL_Rect rect = { 0, 200, 600, 200 };
    SDL_FillRect(screen, &rect, 2);
  }

  //changing green color
  //to yellow
  pal[1].r = 255;
  SDL_SetColors(screen, &pal[1], 1, 1);

  {
    SDL_Rect rect = { 300, 200, 300, 200 };
    SDL_FillRect(screen, &rect, 1);
  }

  printf("you should see red, blue and yellow rectangles\n");

  SDL_Quit();

  return 0;
}


VaKeR 2022