Introducing SDL_Chomik: Graphics with Chomik + SDL2


SDL_Chomik is an extension of the Chomik programming language that integrates the SDL2 graphics library.
It inherits all of Chomik’s features while adding the ability to create windows, display images, and interact with graphics — all in Chomik’s unique style.
Quickstart: Your First SDL_Chomik Program
<create new image "chomik.png">;
let sdl loop body = value code
{
<show image <the created image index> 0 0>;
};
<sdl loop>;
Run with:
sdl_chomik hello.sdl_chomik
This will:
Load the included
chomik.png
(public domain, found in the Chomik source repo underimage/
).Open an 800×600 graphics window.
Display the hamster image in the top-left corner.
That’s all it takes to get graphics on the screen with SDL_Chomik.
The Smallest Possible Program
The most minimal valid SDL_Chomik program is:
<sdl loop>;
The sdl loop
is a predefined code in SDL_Chomik.
This program opens an 800×600 graphics window and runs the main loop — but displays nothing unless you define what happens in each iteration.
Even a completely blank file will open and close a window instantly, because without a main loop execution, SDL_Chomik quits immediately.
How the Main Loop Works
<sdl loop>
depends on a predefined code variable called sdl loop body
.
Although sdl loop body
is predefined, you can assign your own code to it.
If you do, <sdl loop>
will execute it every iteration of the main loop.
Example:let sdl loop body = value code
{
<print "Hello world">;
};
<sdl loop>;
If run with sdl_chomik
, this will print "Hello world"
repeatedly to the terminal — not the graphics window.
Displaying Images
To show graphics, you first need an image file.
Use the included chomik.png
from the Chomik source repository’s image
folder.
Load it with:<create new image "chomik.png">;
create
is a built-in family of variables in Chomik. SDL_Chomik extends it with create new image
, which loads an image file.
When called, it sets the predefined integer variable the created image index
to the ID of the loaded image.
You can store this ID in your own variable, but for now we’ll use it directly.
Putting It Together
<create new image "chomik.png">;
let sdl loop body = value code
{
<show image <the created image index> 0 0>;
};
<sdl loop>;
Here’s what happens:
The image is loaded.
We assign a custom
sdl loop body
that draws the image at(0,0)
every frame.<sdl loop>
runs forever (until you close the window), callingsdl loop body
each frame.
By the way, “chomik” means “hamster” in Polish. 🐹
Subscribe to my newsletter
Read articles from Pawel Biernacki directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Pawel Biernacki
Pawel Biernacki
I was born in 1973, in Cracow, Poland. I am a software engineer.