├── .gitignore ├── .gitmodules ├── LICENSE ├── README.md ├── examples ├── android_triangle │ ├── README.md │ ├── android_triangle.iml │ ├── app │ │ ├── app.iml │ │ ├── build.gradle │ │ ├── build │ │ │ └── generated │ │ │ │ └── source │ │ │ │ └── buildConfig │ │ │ │ └── debug │ │ │ │ └── com │ │ │ │ └── example │ │ │ │ └── native_activity │ │ │ │ └── BuildConfig.java │ │ └── src │ │ │ └── main │ │ │ └── cpp │ │ │ └── CMakeLists.txt │ ├── build.gradle │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── gradlew │ ├── gradlew.bat │ ├── local.properties │ ├── native-activity.iml │ ├── screenshot.png │ └── settings.gradle ├── androidstudio.png ├── assets │ ├── data.txt │ ├── icons │ │ └── data.txt │ ├── simple.frag │ └── simple.vert ├── build_android.sh ├── build_ios.sh ├── ios_triangle │ ├── Info.plist │ ├── example │ │ ├── CMakeLists.txt │ │ └── cmake │ │ │ └── GLFMAppTarget.cmake │ ├── ios_triangle.xcodeproj │ │ ├── project.pbxproj │ │ ├── project.xcworkspace │ │ │ ├── contents.xcworkspacedata │ │ │ ├── xcshareddata │ │ │ │ └── IDEWorkspaceChecks.plist │ │ │ └── xcuserdata │ │ │ │ └── andre.vonhouck.xcuserdatad │ │ │ │ ├── UserInterfaceState.xcuserstate │ │ │ │ └── WorkspaceSettings.xcsettings │ │ └── xcuserdata │ │ │ └── andre.vonhouck.xcuserdatad │ │ │ ├── xcdebugger │ │ │ └── Breakpoints_v2.xcbkptlist │ │ │ └── xcschemes │ │ │ └── xcschememanagement.plist │ └── src │ │ ├── @m..@s..@s..@sUsers@sandre.vonhouck@s.nimble@spkgs@sopengl-@hhead@sopengl.nim.c │ │ ├── @mmain.nim.c │ │ ├── file_compat.h │ │ ├── glfm.h │ │ ├── glfm_platform.h │ │ ├── glfm_platform_ios.m │ │ ├── nimbase.h │ │ ├── stdlib_io.nim.c │ │ └── stdlib_system.nim.c ├── main.nim ├── screenshot.png └── xcode.png ├── glfm.nimble ├── nim.cfg └── src └── glfm.nim /.gitignore: -------------------------------------------------------------------------------- 1 | # ignore files with no extention: 2 | * 3 | !*/ 4 | !*.* 5 | 6 | # normal ignores: 7 | .* 8 | *.exe 9 | *.js 10 | nimcache 11 | glfm 12 | 13 | examples/android_triangle/app/app.iml 14 | examples/android_triangle/app/build/ 15 | examples/ios_triangle/build/ -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "glfm"] 2 | path = glfm 3 | url = git@github.com:brackeen/glfm.git 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright niv and contributors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without modification, are 4 | permitted provided that the following conditions are met: 5 | 6 | 1. Redistributions of source code must retain the above copyright notice, this list of 7 | conditions and the following disclaimer. 8 | 9 | 2. Redistributions in binary form must reproduce the above copyright notice, this list 10 | of conditions and the following disclaimer in the documentation and/or other materials 11 | provided with the distribution. 12 | 13 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, 14 | INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 15 | FOR A PARTICULAR PURPOSE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # GLFM 2 | 3 | Wrapper of [GLFM](https://github.com/brackeen/glfm) (OpenGL ES and input for iOS and Android) library for Nim. 4 | 5 | [GLFM](https://github.com/brackeen/glfm) very simple and is very simmilar to the [GLFW](https://github.com/glfw/glfw) wrapper for desktop apps. 6 | Together with [GLFM](https://github.com/brackeen/glfm) + [GLFW](https://github.com/glfw/glfw) you can writes app for almost any platform. 7 | 8 | ![example of what both apps look like](examples/screenshot.png) 9 | 10 | Compiling Nim for mobile platforms is not simple. It requires having XCode and Android Studio which have very many steps and settings they perform. 11 | 12 | In this repo I have included two projects for XCode and Android Studio which you should be able to just open and hit compile. 13 | 14 | # Compiling for iOS: 15 | 16 | Tested with: 17 | * MacOS Majave Version 10.14.6 18 | * XCode Version 10.3 (10G8) 19 | * Nim Compiler Version 0.20.99 [MacOSX: amd64] 20 | 21 | ```cp examples``` 22 | 23 | Compile everything for iOS: 24 | 25 | ```nim c -c --os:android main.nim``` 26 | 27 | (Yes saying android when compilng for iOS is very odd but its as close to mobile as you get) 28 | 29 | Now copy the generated C files into the iOS project folder 30 | 31 | ```cp ~/.cache/nim/main_d/* ios_triangle/example/src/; cp ios_triangle/example/src/main.nim.c ios_triangle/example/src/main.c``` 32 | 33 | Then you go to XCode and hit compile: 34 | 35 | ![android stuido](examples/xcode.png) 36 | 37 | # Compiling for Android 38 | 39 | Tested with: 40 | * MacOS Majave Version 10.14.6 41 | * XCode Version 10.3 (10G8) 42 | * Android Studio 3.4.2 43 | * Nim Compiler Version 0.20.99 [MacOSX: amd64] 44 | 45 | Go to the examples folder 46 | 47 | ```cp examples``` 48 | 49 | Compile everything for android running arm processor: 50 | 51 | ```nim c -c --cpu:arm --os:android main.nim``` 52 | 53 | Now copy the generated C files into the Android project folder 54 | 55 | ```cp ~/.cache/nim/main_d/* android_triangle/app/src/main/cpp/; cp android_triangle/app/src/main/cpp/main.nim.c android_triangle/app/src/main/cpp/main.c``` 56 | 57 | Then you go to Android Studio and hit compile: 58 | 59 | ![android stuido](examples/androidstudio.png) 60 | -------------------------------------------------------------------------------- /examples/android_triangle/README.md: -------------------------------------------------------------------------------- 1 | Native Activity 2 | =============== 3 | Native Activity is an Android sample that initializes a GLES 2.0 context and reads accelerometer data from C code using [Native Activity](http://developer.android.com/reference/android/app/NativeActivity.html). 4 | 5 | This sample uses the new [Android Studio CMake plugin](http://tools.android.com/tech-docs/external-c-builds) with C++ support. 6 | 7 | Pre-requisites 8 | -------------- 9 | - Android Studio 2.2+ with [NDK](https://developer.android.com/ndk/) bundle. 10 | 11 | Getting Started 12 | --------------- 13 | 1. [Download Android Studio](http://developer.android.com/sdk/index.html) 14 | 1. Launch Android Studio. 15 | 1. Open the sample directory. 16 | 1. Open *File/Project Structure...* 17 | - Click *Download* or *Select NDK location*. 18 | 1. Click *Tools/Android/Sync Project with Gradle Files*. 19 | 1. Click *Run/Run 'app'*. 20 | 21 | Screenshots 22 | ----------- 23 | ![screenshot](screenshot.png) 24 | 25 | Support 26 | ------- 27 | If you've found an error in these samples, please [file an issue](https://github.com/googlesamples/android-ndk/issues/new). 28 | 29 | Patches are encouraged, and may be submitted by [forking this project](https://github.com/googlesamples/android-ndk/fork) and 30 | submitting a pull request through GitHub. Please see [CONTRIBUTING.md](../CONTRIBUTING.md) for more details. 31 | 32 | - [Stack Overflow](http://stackoverflow.com/questions/tagged/android-ndk) 33 | - [Google+ Community](https://plus.google.com/communities/105153134372062985968) 34 | - [Android Tools Feedbacks](http://tools.android.com/feedback) 35 | 36 | License 37 | ------- 38 | Copyright 2015 Google, Inc. 39 | 40 | Licensed to the Apache Software Foundation (ASF) under one or more contributor 41 | license agreements. See the NOTICE file distributed with this work for 42 | additional information regarding copyright ownership. The ASF licenses this 43 | file to you under the Apache License, Version 2.0 (the "License"); you may not 44 | use this file except in compliance with the License. You may obtain a copy of 45 | the License at 46 | 47 | http://www.apache.org/licenses/LICENSE-2.0 48 | 49 | Unless required by applicable law or agreed to in writing, software 50 | distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 51 | WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 52 | License for the specific language governing permissions and limitations under 53 | the License. 54 | -------------------------------------------------------------------------------- /examples/android_triangle/android_triangle.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /examples/android_triangle/app/app.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 9 | 10 | 11 | 13 | 14 | 15 | 16 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | -------------------------------------------------------------------------------- /examples/android_triangle/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 28 5 | 6 | defaultConfig { 7 | applicationId = 'com.example.native_activity' 8 | minSdkVersion 14 9 | targetSdkVersion 28 10 | externalNativeBuild { 11 | cmake { 12 | arguments '-DANDROID_STL=c++_static' 13 | } 14 | } 15 | } 16 | buildTypes { 17 | release { 18 | minifyEnabled false 19 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 20 | 'proguard-rules.pro' 21 | } 22 | } 23 | externalNativeBuild { 24 | cmake { 25 | version '3.10.2' 26 | path 'src/main/cpp/CMakeLists.txt' 27 | } 28 | } 29 | } 30 | 31 | dependencies { 32 | implementation fileTree(dir: 'libs', include: ['*.jar']) 33 | implementation 'androidx.appcompat:appcompat:1.0.2' 34 | implementation 'androidx.constraintlayout:constraintlayout:1.1.3' 35 | } 36 | -------------------------------------------------------------------------------- /examples/android_triangle/app/build/generated/source/buildConfig/debug/com/example/native_activity/BuildConfig.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Automatically generated file. DO NOT MODIFY 3 | */ 4 | package com.example.native_activity; 5 | 6 | public final class BuildConfig { 7 | public static final boolean DEBUG = Boolean.parseBoolean("true"); 8 | public static final String APPLICATION_ID = "com.example.native_activity"; 9 | public static final String BUILD_TYPE = "debug"; 10 | public static final String FLAVOR = ""; 11 | public static final int VERSION_CODE = 1; 12 | public static final String VERSION_NAME = "1.0"; 13 | } 14 | -------------------------------------------------------------------------------- /examples/android_triangle/app/src/main/cpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) The Android Open Source Project 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compli ance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | cmake_minimum_required(VERSION 3.4.1) 18 | 19 | # build native_app_glue as a static lib 20 | set(${CMAKE_C_FLAGS}, "${CMAKE_C_FLAGS}") 21 | add_library(native_app_glue STATIC 22 | ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c) 23 | 24 | # now build app's shared lib 25 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11 -Wall -Werror") 26 | 27 | # Export ANativeActivity_onCreate(), 28 | # Refer to: https://github.com/android-ndk/ndk/issues/381. 29 | set(CMAKE_SHARED_LINKER_FLAGS 30 | "${CMAKE_SHARED_LINKER_FLAGS} -v -u ANativeActivity_onCreate") 31 | 32 | add_library(native-activity SHARED 33 | "@m..@s..@s..@sUsers@sandre.vonhouck@s.nimble@spkgs@sopengl-@hhead@sopengl.nim.c" 34 | @mmain.nim.c 35 | glfm_platform_android.c 36 | 37 | #stdlib_allocators.nim.c 38 | #stdlib_assertions.nim.c 39 | stdlib_io.nim.c 40 | #stdlib_os.nim.c 41 | #stdlib_pathnorm.nim.c 42 | #stdlib_strutils.nim.c 43 | stdlib_system.nim.c 44 | #stdlib_times.nim.c 45 | ) 46 | 47 | target_include_directories(native-activity PRIVATE 48 | ${ANDROID_NDK}/sources/android/native_app_glue) 49 | 50 | # add lib dependencies 51 | target_link_libraries(native-activity 52 | android 53 | native_app_glue 54 | EGL 55 | GLESv2 56 | log 57 | ) 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /examples/android_triangle/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | buildscript { 3 | repositories { 4 | google() 5 | jcenter() 6 | } 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:3.4.2' 9 | } 10 | } 11 | 12 | allprojects { 13 | repositories { 14 | google() 15 | jcenter() 16 | } 17 | } 18 | 19 | task clean(type: Delete) { 20 | delete rootProject.buildDir 21 | } 22 | -------------------------------------------------------------------------------- /examples/android_triangle/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | android.enableJetifier=true 13 | android.useAndroidX=true 14 | org.gradle.jvmargs=-Xmx1536m 15 | 16 | # When configured, Gradle will run in incubating parallel mode. 17 | # This option should only be used with decoupled projects. More details, visit 18 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 19 | # org.gradle.parallel=true 20 | 21 | -------------------------------------------------------------------------------- /examples/android_triangle/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/treeform/glfm/cbc90095ec2b6959e0ed5113f603ccd1d4ba6935/examples/android_triangle/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /examples/android_triangle/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Sun Sep 15 14:23:42 PDT 2019 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip 7 | -------------------------------------------------------------------------------- /examples/android_triangle/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # For Cygwin, ensure paths are in UNIX format before anything is touched. 46 | if $cygwin ; then 47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 48 | fi 49 | 50 | # Attempt to set APP_HOME 51 | # Resolve links: $0 may be a link 52 | PRG="$0" 53 | # Need this for relative symlinks. 54 | while [ -h "$PRG" ] ; do 55 | ls=`ls -ld "$PRG"` 56 | link=`expr "$ls" : '.*-> \(.*\)$'` 57 | if expr "$link" : '/.*' > /dev/null; then 58 | PRG="$link" 59 | else 60 | PRG=`dirname "$PRG"`"/$link" 61 | fi 62 | done 63 | SAVED="`pwd`" 64 | cd "`dirname \"$PRG\"`/" >&- 65 | APP_HOME="`pwd -P`" 66 | cd "$SAVED" >&- 67 | 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69 | 70 | # Determine the Java command to use to start the JVM. 71 | if [ -n "$JAVA_HOME" ] ; then 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73 | # IBM's JDK on AIX uses strange locations for the executables 74 | JAVACMD="$JAVA_HOME/jre/sh/java" 75 | else 76 | JAVACMD="$JAVA_HOME/bin/java" 77 | fi 78 | if [ ! -x "$JAVACMD" ] ; then 79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80 | 81 | Please set the JAVA_HOME variable in your environment to match the 82 | location of your Java installation." 83 | fi 84 | else 85 | JAVACMD="java" 86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87 | 88 | Please set the JAVA_HOME variable in your environment to match the 89 | location of your Java installation." 90 | fi 91 | 92 | # Increase the maximum file descriptors if we can. 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 94 | MAX_FD_LIMIT=`ulimit -H -n` 95 | if [ $? -eq 0 ] ; then 96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97 | MAX_FD="$MAX_FD_LIMIT" 98 | fi 99 | ulimit -n $MAX_FD 100 | if [ $? -ne 0 ] ; then 101 | warn "Could not set maximum file descriptor limit: $MAX_FD" 102 | fi 103 | else 104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105 | fi 106 | fi 107 | 108 | # For Darwin, add options to specify how the application appears in the dock 109 | if $darwin; then 110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111 | fi 112 | 113 | # For Cygwin, switch paths to Windows format before running java 114 | if $cygwin ; then 115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 158 | function splitJvmOpts() { 159 | JVM_OPTS=("$@") 160 | } 161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 163 | 164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 165 | -------------------------------------------------------------------------------- /examples/android_triangle/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /examples/android_triangle/local.properties: -------------------------------------------------------------------------------- 1 | ## This file must *NOT* be checked into Version Control Systems, 2 | # as it contains information specific to your local configuration. 3 | # 4 | # Location of the SDK. This is only used by Gradle. 5 | # For customization when using a Version Control System, please read the 6 | # header note. 7 | #Sat Sep 14 14:44:36 PDT 2019 8 | ndk.dir=/Users/andre.vonhouck/Library/Android/sdk/ndk-bundle 9 | sdk.dir=/Users/andre.vonhouck/Library/Android/sdk 10 | -------------------------------------------------------------------------------- /examples/android_triangle/native-activity.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /examples/android_triangle/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/treeform/glfm/cbc90095ec2b6959e0ed5113f603ccd1d4ba6935/examples/android_triangle/screenshot.png -------------------------------------------------------------------------------- /examples/android_triangle/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | 3 | -------------------------------------------------------------------------------- /examples/androidstudio.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/treeform/glfm/cbc90095ec2b6959e0ed5113f603ccd1d4ba6935/examples/androidstudio.png -------------------------------------------------------------------------------- /examples/assets/data.txt: -------------------------------------------------------------------------------- 1 | this is data.txt 2 | jlkljk 3 | lk 4 | klj 5 | -------------------------------------------------------------------------------- /examples/assets/icons/data.txt: -------------------------------------------------------------------------------- 1 | * ICONS got here ******************************** -------------------------------------------------------------------------------- /examples/assets/simple.frag: -------------------------------------------------------------------------------- 1 | varying lowp vec3 v_color; 2 | 3 | void main() { 4 | gl_FragColor = vec4(v_color, 1.0); 5 | } 6 | -------------------------------------------------------------------------------- /examples/assets/simple.vert: -------------------------------------------------------------------------------- 1 | attribute highp vec3 a_position; 2 | attribute lowp vec3 a_color; 3 | 4 | varying lowp vec3 v_color; 5 | 6 | void main() { 7 | gl_Position = vec4(a_position, 1.0); 8 | v_color = a_color; 9 | } 10 | -------------------------------------------------------------------------------- /examples/build_android.sh: -------------------------------------------------------------------------------- 1 | # force a build clean every time 2 | rm ~/.cache/nim/main_d/* 3 | rm android_triangle/app/src/main/cpp/* 4 | 5 | /p/Nim/bin/nim c -f --cpu:arm --os:android -c -d:androidNDK --noMain:on main.nim 6 | 7 | cp android_triangle/CMakeLists.txt android_triangle/app/src/main/cpp/ 8 | 9 | cp ~/.cache/nim/main_d/*.c android_triangle/app/src/main/cpp/ 10 | cp nimbase.h android_triangle/app/src/main/cpp/ 11 | cp file_compat.h android_triangle/app/src/main/cpp/ 12 | cp ../glfm/include/glfm.h android_triangle/app/src/main/cpp/ 13 | cp ../glfm/src/glfm_platform.h android_triangle/app/src/main/cpp/ 14 | cp ../glfm/src/glfm_platform_android.c android_triangle/app/src/main/cpp/ 15 | cp -r assets/* android_triangle/app/src/main/assets 16 | 17 | -------------------------------------------------------------------------------- /examples/build_ios.sh: -------------------------------------------------------------------------------- 1 | # force a build clean every time 2 | rm ~/.cache/nim/main_d/* 3 | rm ios_triangle/src/* 4 | 5 | # build it for iOS 6 | /p/Nim/bin/nim c -f --os:ios -c --noMain:on main.nim 7 | 8 | # copy all support files into the ios project 9 | cp ~/.cache/nim/main_d/*.c ios_triangle/src/ 10 | cp nimbase.h ios_triangle/src/ 11 | cp file_compat.h ios_triangle/src/ 12 | cp ../glfm/include/glfm.h ios_triangle/src/ 13 | cp ../glfm/src/glfm_platform.h ios_triangle/src/ 14 | cp ../glfm/src/glfm_platform_ios.m ios_triangle/src/ 15 | cp -r assets/* ios_triangle/ -------------------------------------------------------------------------------- /examples/ios_triangle/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIRequiredDeviceCapabilities 26 | 27 | armv7 28 | opengles-2 29 | 30 | UIStatusBarHidden 31 | 32 | UISupportedInterfaceOrientations 33 | 34 | UIInterfaceOrientationPortrait 35 | UIInterfaceOrientationLandscapeLeft 36 | UIInterfaceOrientationLandscapeRight 37 | 38 | UISupportedInterfaceOrientations~ipad 39 | 40 | UIInterfaceOrientationPortrait 41 | UIInterfaceOrientationPortraitUpsideDown 42 | UIInterfaceOrientationLandscapeLeft 43 | UIInterfaceOrientationLandscapeRight 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /examples/ios_triangle/example/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.6.0) # Might run on earlier versions. Probably requires 3.4 or 3.5 2 | 3 | link_libraries(glfm) 4 | list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake") 5 | 6 | # Common 7 | set(GLFM_APP_ORGANIZATION_IDENTIFIER "com.brackeen") 8 | set(GLFM_APP_VERSION "1.0") 9 | set(GLFM_APP_VERSION_ITERATION 1) 10 | set(GLFM_APP_ASSETS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/assets) 11 | 12 | # Main example 13 | set(GLFM_APP_TARGET_NAME glfm_example) 14 | set(GLFM_APP_SRC src/main.c src/file_compat.h) 15 | include(GLFMAppTarget) 16 | 17 | # Test pattern 18 | set(GLFM_APP_TARGET_NAME glfm_test_pattern) 19 | set(GLFM_APP_SRC src/test_pattern.c src/file_compat.h) 20 | include(GLFMAppTarget) 21 | set_property(TARGET glfm_test_pattern PROPERTY C_STANDARD 99) 22 | -------------------------------------------------------------------------------- /examples/ios_triangle/example/cmake/GLFMAppTarget.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # GLFM_APP_TARGET_NAME - App name 3 | # GLFM_APP_ORGANIZATION_IDENTIFIER - Reverse domain name, like "com.example" 4 | # GLFM_APP_VERSION - Version string, like "1.0" 5 | # GLFM_APP_VERSION_ITERATION - Version code (integer) 6 | # GLFM_APP_ASSETS_DIR - Assets directory 7 | # GLFM_APP_SRC - Source files 8 | 9 | file(GLOB GLFM_APP_ASSETS ${GLFM_APP_ASSETS_DIR}/*) 10 | source_group("src" FILES ${GLFM_APP_SRC}) 11 | 12 | if (CMAKE_SYSTEM_NAME MATCHES "Emscripten") 13 | # HACK: Make modifications to shell_minimal.html to take up the entire browser window 14 | file(READ ${EMSCRIPTEN_ROOT_PATH}/src/shell_minimal.html EMSCRIPTEN_SHELL_HTML) 15 | string(FIND "${EMSCRIPTEN_SHELL_HTML}" "