Frustum - problem with z dimension
Okay. So after 6 hours of tinkering with my code, trying different approaches and googling for solutions, I found this page:

http://www.glprogramming.com/red/chapter03.html

There is a short C listing which put me on the right track to solve this.

What I did wrong was that I should have set the frustum to something like this:

GLdouble x0 = -(1366/768);
GLdouble x1 = 1366/768;
glFrustum(x0, x1, -1, 1, 1, 100);
// the last two values aren't critical, as long as they are positive


But before that, I should have set the glViewport properly, before setting up the frustum:

glViewport(0, 0, 1366, 768);


I didn't do it and that's why my code produced such weird results.

Now I can create a unit cube with following vertices:

0.0, 1.0, 0.0
1.0, 1.0, 0.0
1.0, 0.0, 0.0
0.0, 0.0, 0.0
0.0, 1.0, 1.0
1.0, 1.0, 1.0
1.0, 0.0, 1.0
0.0, 0.0, 1.0


And it will display properly as a cube of size 1 in every direction.