4k intro sample code written with Nim programming language. This sample is written for MS Windows.
- Nim
- Works in version 1.2.0
Current sample requires devel version. You can download it fromnim-lang/nightlies
- Visual Studio 2015
- Crinkler
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.
- winlean4k
- with
- Used in openGL4kGen
- OpenGL Extension Header Files
- Optional. This header file is used when building samples in
csrc
directory that uses OpenGL. - Create the directory
GL
in somewhere and downloadglext.h
andwglext.h
to it. - Create the directory
KHR
in same place and downloadkhrplatform.h
to it.
- Optional. This header file is used when building samples in
Make sure parent directories of nim
and crinker
are in PATH
environment variable and you can run them from command prompt.
-
Set
LIB
environment variable to the directory containing*.lib
files to use Windows API.- For example:
set lib=c:\Program Files (x86)\Windows Kits\8.1\Lib\winv6.3\um\x86
- Do not use double quote in
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.
- Run VS2015 x86 Native Tools command prompt
- Set
INCLUDE
environment variable to the directory containing OpenGL Extension Header Files(GL/glext.h
,GL/wglext.h
andKHR/khrplatform.h
).- For example:
set INCLUDE=c:\path\to\include;%INCLUDE%
- Build
git clone https://github.com/demotomohiro/nim-4k-intro-sample.git cd nim-4k-intro-sample\csrc minimum_build.bat
- Each
*_build.bat
files builds each samples.
- Each
- csrc
- C language code same to source code in
src
directory so that you can see whether Nim code can be compiled as small as C
- C language code same to source code in
- shaders
- GLSL shader langage code used by samples that use shader
- src
- Nim language sample code
- tools
- Tools used for making 4k intros with Nim
It 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.