Skip to content

Instantly share code, notes, and snippets.

@eterps
Created September 11, 2018 13:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eterps/8ceb26298cebb1715a3062508234900b to your computer and use it in GitHub Desktop.
Save eterps/8ceb26298cebb1715a3062508234900b to your computer and use it in GitHub Desktop.
#!/bin/bash
set -e
cat >fpstest.obn <<EOS
MODULE fpstest;
(*draw dots and print the number of displayed frames per second*)
IMPORT Input, Out, XYplane;
VAR
n, t, x, y: INTEGER;
BEGIN
XYplane.Open;
n := -1;
t := Input.Time();
REPEAT
INC(n);
IF Input.Time() - t >= Input.TimeUnit THEN
Out.String("fps: ");
Out.Int(n, 0);
Out.Ln;
n := 0;
t := Input.Time()
END;
x := Input.Time() MOD XYplane.W;
y := Input.Time() MOD XYplane.H;
XYplane.Dot(x, y, XYplane.draw)
UNTIL XYplane.Key() = "q"
END fpstest.
EOS
## Current parameters:
# obnc -V fpstest.obn
# Compiling module fpstest:
#
# /usr/local/bin/obnc-compile -e fpstest.obn
# cc -c -o .obnc/fpstest.o .obnc/fpstest.c
#
# Linking modules:
# cc -o fpstest /usr/local/lib/obnc/OBNC.o /usr/local/lib/obnc/XYplane.o /usr/local/lib/obnc/Out.o /usr/local/lib/obnc/Input.o .obnc/fpstest.o -lgc -lm -lSDL -lSDL
## Changes that make focus possible:
/usr/local/bin/obnc-compile -e fpstest.obn
sed -i -e '/main/i#include <SDL/SDL.h>' .obnc/fpstest.c
cc -c -o .obnc/fpstest.o .obnc/fpstest.c
cc -o fpstest /usr/local/lib/obnc/OBNC.o /usr/local/lib/obnc/XYplane.o /usr/local/lib/obnc/Out.o /usr/local/lib/obnc/Input.o .obnc/fpstest.o -lgc -lm -lSDL -lSDLmain -framework Cocoa
./fpstest
## Conclusion
# Compilation phase needs: #include <SDL/SDL.h> in main program
# Linking phase parameters needs: -lSDLmain -framework Cocoa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment