4k intro sample code written with Nim programming language. This sample is written for MS Windows.
Nim use C compiler in Visual Studio as backend. Crinkler works as linker and compress your code and data. Output executable file from crinkler decompress code at runtime.
csrc
directory that uses OpenGL.GL
in somewhere and download glext.h
and wglext.h
to it.KHR
in same place and download khrplatform.h
to it.Make sure parent directories of nim
and crinker
are in PATH
environment variable and you can run them from command prompt.
LIB
environment variable to the directory containing *.lib
files to use Windows API.
set lib=c:\Program Files (x86)\Windows Kits\8.1\Lib\winv6.3\um\x86
LIB
environment variable. Otherwise crinkler doesn't recognize it.Build
git clone https://github.com/demotomohiro/nim-4k-intro-sample.git
cd nim-4k-intro-sample\src
Release build:
nim c -d:danger minimum.nim
Debug build:
nim c minimum.nim
Make sure parent directories of nim
and crinker
are in PATH
environment variable and you can run them from command prompt.
INCLUDE
environment variable to the directory containing OpenGL Extension Header Files(GL/glext.h
, GL/wglext.h
and KHR/khrplatform.h
).
set INCLUDE=c:\path\to\include;%INCLUDE%
git clone https://github.com/demotomohiro/nim-4k-intro-sample.git
cd nim-4k-intro-sample\csrc
minimum_build.bat
*_build.bat
files builds each samples.src
directory so that you can see whether Nim code can be compiled as small as CIt downloads and reads the OpenGL Registry XML file and generates a OpenGL wrapper optimized for 4k-intro.
It imports OpenGL 1.0 and 1.1 functions with header pragma.
Like Official OpenGL interface, it uses undocumented 'dynlib' feature and Nim generate a procedure that load only OpenGL extension functions used in user code. So loadExtensions()
must be called after the creation of an OpenGL context and before any OpenGL extension procs are used.
It only generates procedures and enums in OpenGL core profile.
Following code build openGL4kGen and generate OpenGL wrapper.
cd nim-4k-intro-sample\tools\openGL4kGen
nim c -d:ssl openGL4kGen.nim
openGL4kGen.exe > ..\..\src\openGL4k2.nim
If you want to use OpenGL with Nim not for 4k-intro, use one of them:
Official OpenGL interface
All OpenGL functions and constants are hard coded.
It uses undocumented Nim feature that allow only load OpenGL functions used in your code.
Don't forget to call loadExtensions
after initialized OpenGL context and before calling any OpenGL functions.
glad GL/GLES/EGL/GLX/WGL Loader-Generator based on the official specs written in Python lanuage. You can specify OpenGL API version or which extension to be generated. It doesn't use undocumented Nim feature and it loads all OpenGL functions in your specified OpenGL version.
Nim Game Library NimGL (Nim Game Library) is a collection of bindings for popular libraries, mostly used in computer graphics. A library of libraries.