Glk question

I’ve been doing some research on Glk and found several threads and links on this forum that explain it pretty well. One question remains, but first, I’d like to check whether I have a correct basic understanding of what Glk is for.
By turning an IF interpreter into a Glk application, you get a set of I/O functions that perform equally on different platforms, so you no longer have to worry about platform specific code and libraries to change text color, style, window size, etc. You include the Glk API calls in the C-code of your interpreter, rewrite the I/O routines to Glk and then compile with the Glk libraries on the target platform.

My question now is, can Glk also handle I/O for online playing through a webserver, like with the parchments that are available for playing online? Or is this created in another way?

You might want to look at Quixe for web deployments.

If you’re thinking about some sort of client/server implementation, that’s not been done with Glk as far as I know.

If you’re making stories with Inform 7, you can export to a ulx story file which can run in a local glk-enabled interpreter, or you can export as quixe web page, which you can deploy to your web server.

Yes. See GlkOte and RemGlk.

The answer is “yes but it may be complicated.”

Parchment doesn’t play through a web server. It’s a pure Javascript program that runs directly in the client web browser. If your interpreter is written in Javascript, you can do this quite easily.

But you’re talking about an interpreter written in C. In that case, you can get it running through a web server and RemGlk, but you’ll have to do some server setup work and probably write some scripts to glue everything together. I have done this experimentally ( but it’s not production-ready.

(The way this works: RemGlk implements the Glk API calls by collecting the turn’s output and shooting it out as a JSON data structure. The web server relays this to the player’s web browser, which catches it and feeds it to the GlkOte javascript library, which displays it in the browser window. The player’s input then runs the same route in reverse.)

Thanks for the pointers. I don’t have .ulx or .gblorb files, so Quixe will not be an option, I guess.

I checked out Glkote and Remglk and also Zarf’s examples. It looks like it will require some experimenting to get it all to work in my system. One of the comments I got on my system was that it would help acceptance if storyfiles can be played online.

What I’m actually looking for is like in the IF database. With some games there’s a “play online” button in the upper right corner. This opens a parchment and starts the game. I also noticed that the play online button only shows with Inform games. Does it uses Quixe with Glulx files? Does that mean play online is not available for other systems?

The “play online” button uses the website to convert and serve the game through Parchment. But the game itself is then entirely on the client side, running in a JavaScript interpreter.

Yes. The iplayif system could be extended to support any interpreter written in pure javascript.

Thank you all for sharing this information.

Given the fact that my IF system is currently fully self-supporting (I/O thru Windows Console or Linux Terminal window) I think that aiming for a play online button is too big a step at once.

I will start with trying to turn my system into a Glk-application so that it can use the benefits of the Glk API I/O and then work from there.

I downloaded Zarf’s demos model.c and multiwin.c and managed to build the applications. It looks pretty cool compared to a console and I want to have it (when I start the demo on windows, an empty console window opens as well, is this normal behavior?).

There’s no doubt I will run into questions, is it ok to ask them here? As I see now, questions will mainly be about integrating Glk into my existing C-code and less about IF system design. I did search the web for Glk-forums, but all I found were forums about the Mercedes GLK. Very interesting but I don’t expect much help from there :smiley:

Windows applications have a flag in the header that specifies whether they’re console applications or not: it sounds like your compiler built the executable with the flag set for console. Quite how you change this depends on which compiler you’re using.

I use the code::blocks IDE with the GNU GCC compiler and selected win32 GUI when I created this project. I looked in the project properties and saw that it was set to console, don’t know why. I changed it to win32 GUI and after a rebuild the console window didn’t show up.
Thanks for your help.

Is there an overview of the Glk functions with a description and allowed parameter values? On there’s a very detailed interface spec but I don’t see such an overview. I can get a function overview from the glk.h file but then there’s no description.

The spec is the spec. There’s an entry for each function, but they’re spread out through the document.

Perhaps it might be useful to add an index with the name and parameter list of function that has the link to the proper part(s) of the document for each function?

I made an MS-Word document with a 3-column table: (no parameter list), , <reference to section in spec 0.7.4.>

The reference is just a section number, not a link.