An extremely simple Tsdl (SDL2) demo in OCaml

open Tsdl

type point = {x : int; y : int}

let shutdown win =
Sdl.destroy_window win;
Sdl.quit ()

let initialize () =
match Sdl.init with
| `Error err -> Sdl.log "An error occured while trying to initialize SDL: %s" err; exit 1
| `Ok () ->
match Sdl.create_window ~w:800 ~h:600 "Game" Sdl.Window.opengl with
| `Error err -> Sdl.log "An error occured while trying to create a window: %s" err; exit 1
| `Ok win -> win

let drawFromImg ~imgSurface ~win ~where =
match Sdl.get_window_surface win with
| `Error err -> Sdl.log "An error occured while trying to get the surface of the window: %s" err; exit 1
| `Ok screenSurface ->
let (srcRectW, srcRectH) = Sdl.get_surface_size imgSurface in
let (destRectW, destRectH) = Sdl.get_surface_size screenSurface in
let srcRect = Sdl.Rect.create 0 0 srcRectW srcRectH in
let destRect = Sdl.Rect.create where.x where.y destRectW destRectH in
Sdl.blit_surface imgSurface srcRect screenSurface destRect

let () =
let win = initialize () in
match Sdl.load_bmp "image.bmp" with
| `Error err -> Sdl.log "An error occured while trying to load this bitmap: %s" err; exit 1
| `Ok imgSurface ->
drawFromImg imgSurface win {x = 0; y = 0};
Sdl.update_window_surface win;
Sdl.delay 10000l;
shutdown win;
exit 0

Code in public domain :)

I am currently learning SDL2 (and OCaml too :) ) for using it with the thin OCaml binding Tsdl by Daniel Buenzli to create a 2D game.
And because there aren’t any tutorials for this binding and pretty bare bones documentation, I thought I’d share this extremely basic example, which displays a bitmap image (named image.bmp) located in the same directory as where source code file resides. Make sure the image isn’t larger than 800 * 600 ;)

P.S. : thanks to numerous people on #ocaml (Freenode IRC) for helping me even getting this to compile ;)

Posted in Uncategorized

Indian Rock Python game

As you may have noticed today I added the Indian Rock Python game page to this website.

Indian Rock Python is my first game, you can read more about it on the Indian Rock Python game page.

Posted in Uncategorized

the Jolla Phone (front and back) (blue)

the Jolla Phone (front and back) (blue)

Posted in Uncategorized

the Jolla Phone (in orange)

the Jolla Phone (in orange)

Posted in Uncategorized

Interview with Jolla [questions and answers][updated!]

I would like to do a short online interview with Jolla about how the workspace of sailors looks like. I’ll post some questions here and if Jolla wants they can answer the questions in the comments area ;) I’m sure the other fans would like something interesting to read about Jolla while they wait for the first device to launch

[UPDATE]:Jolla has replied to the questions. So you can now read the answers :)

[Question 1]: What OS do sailors (mostly) use during working hours?
[Answer 1]: GNU/Linux (I didn’t expect anything else :D ;) )

[Question 2]: If the answer to question 1 is “GNU/Linux”, what desktop environment/window manager do (most) sailors (mostly) use during working hours at Jolla?
[Answer 2]: Basically the 3 biggest Linux DE’s are about equally used within Jolla and some other DE’s/WMs are also used, but less. It looks like the market share of DE’s/WMs within Jolla pretty much reflects that of the whole Desktop Linux landscape.

[Question 3]: If the answer to question 1 is “GNU/Linux”, what distribution/distro do (most) sailors (mostly) use during working hours?
[Answer 3]: Ubuntu wins, but there are lots of Fedora users within Jolla too. And also other distros. It surprises me that Ubuntu (which is Debian (.deb) and apt-get based) wins, where as Mer and Meego (where Sailfish is based on)is RPM based and uses zypper. I’d expect to see openSUSE usage (which is both RPM-based and uses zypper, just like Mer does). But at least it shows that the Jolla guys are quite flexible and can work with both tools.

[Question 4]: What are the favourite editors/IDE’s from (most) sailors? Qt Creator? KDevelop? vim? emacs? kate?
[Answer 4]: Both Qt Creator and vim/emacs commandline editors heavily used within Jolla. This isn’t too surprising.

[Question 5]: Which programming language do (most) sailors prefer during working hours when programming QML apps for Sailfish, JavaScript of C++?
[Answer 5]: Well basically a bit of everything seems to be used inside Jolla. With C++ and QML/JavaScript clearly leading the pack.

[Question 6]: Which language is primarily spoken inside Jolla during working hours? English? Finnish?
[Answer 6]: English is the language that primarily is spoken within Jolla, which makes sense because Jolla seems to employ people from lots of different countries. Jolla was founded by Finnish people and a lot of Jolla employees are Finnish. Therefore it also makes sense that Finnish is spoken too.

Tagged with: , , , ,
Posted in Uncategorized

Opera Mobile (possibly using WebKit) spotted on Sailfish OS!

Today while watching one of the recent Jolla Sailfish UI demo/interview YouTube video’s with Marc Dillon, when he scrolled the appscreen, I spotted Opera Mobile with a blue icon between the apps! This is very interesting because it means that Opera Mobile is already ported to Sailfish OS, on the Slush event (last year 21/22 November) Jolla had already revealed that Opera Software was one of their partners.

So far Jolla didn’t show the default web browser app of the Sailfish OS, but because Opera is a Jolla Partner (or friend as they prefer to call it) and Opera Mobile is already running on Sailfish, it wouldn’t be suprising if Opera Mobile will be the default browser on Sailfish OS.

But that’s not quite the big thing: what’s even more interesting is the combination of the blue Opera Mobile icon (Opera always uses a lot of read and their app icons are always red) and Opera’s recent switch to the WebKit rendering engine.

Recently the web was quite shocked by Opera’s announcement that it was switching to WebKit and ditching it’s homegrown Presto rendering engine, which Opera has been using ever since it released it’s first web browser product. Many people asked theirselves why Opera decided to switch to WebKit. But what I had already suspected when I read the news, seems to be true: Jolla seems to have asked Opera to ditch it’s closed source Presto for the open source WebKit engine! But why would Jolla want to let Opera use WebKit instead of Presto for it’s default mobile Sailfish OS browser? Well maybe Jolla really wants it’s Sailfish OS browser to be open source!

Want the evidence? Well here it is ;):


Still not convinced, well here’s the link of the YouTube video:
Pause the video at 1:54 and you’ll see when I toke the screenshot
Also notice the blue color of the icon: the WebKit logo is also largely blue.

Posted in Uncategorized

Version 1.0 of Pythagorean Python released!: complete rewrite, more functionality

Hello everybody I’m proud to release version 1.0 of my little Python 3 script: Pythagorean Python. Version 1.0 is a complete rewrite of version 0.4 and more functionality is added. Here’s the change log:

-Rewritten (pythonic and correct design)
-Functionality to track score added (if “myscore” is given as “answer” the program will print your current score)
-Functionality to check if the OS is compatible with the script (Pythagorean Python currently only runs on Linux)

-Layout of output was changed for the sake of better readability.

-If “exit” is given as “answer” the program quits

Why this version wasn’t named version 0.5? Well it is rewritten to be pythonic and correct and tested again. I think it contains the necessary parts to be mature enough to get labeled 1.0

Planned for version 1.1 is functionality to save a high score. Planned for version 2.0 is GUI. Planned for version. Planned for version 2.1 is a built-in calculator. Planned for version 2.5 is a drawing area where the triangle is visually represented.

Posted in Uncategorized

Get every new post delivered to your Inbox.