├── LICENSE ├── MyApplication ├── .gitignore ├── .idea │ ├── .name │ ├── compiler.xml │ ├── copyright │ │ └── profiles_settings.xml │ ├── encodings.xml │ ├── gradle.xml │ ├── misc.xml │ ├── modules.xml │ └── runConfigurations.xml ├── app │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src │ │ ├── .tags │ │ ├── androidTest │ │ └── java │ │ │ └── com │ │ │ └── example │ │ │ └── yt │ │ │ └── myapplication │ │ │ └── ApplicationTest.java │ │ ├── main │ │ ├── AndroidManifest.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── example │ │ │ │ └── yt │ │ │ │ └── myapplication │ │ │ │ └── MainActivity.java │ │ ├── jni │ │ │ ├── Android.mk │ │ │ ├── jniexports.c │ │ │ ├── nk-gl.c │ │ │ ├── nk-gl.h │ │ │ └── nuklear.h │ │ ├── libs │ │ │ ├── arm64-v8a │ │ │ │ └── libnk-gl.so │ │ │ ├── armeabi-v7a │ │ │ │ └── libnk-gl.so │ │ │ ├── armeabi │ │ │ │ └── libnk-gl.so │ │ │ ├── mips │ │ │ │ └── libnk-gl.so │ │ │ ├── mips64 │ │ │ │ └── libnk-gl.so │ │ │ ├── x86 │ │ │ │ └── libnk-gl.so │ │ │ └── x86_64 │ │ │ │ └── libnk-gl.so │ │ ├── obj │ │ │ └── local │ │ │ │ ├── arm64-v8a │ │ │ │ ├── libnk-gl.so │ │ │ │ └── objs │ │ │ │ │ └── nk-gl │ │ │ │ │ ├── jniexports.o │ │ │ │ │ └── jniexports.o.d │ │ │ │ ├── armeabi-v7a │ │ │ │ ├── libnk-gl.so │ │ │ │ └── objs │ │ │ │ │ └── nk-gl │ │ │ │ │ ├── jniexports.o │ │ │ │ │ └── jniexports.o.d │ │ │ │ ├── armeabi │ │ │ │ ├── libnk-gl.so │ │ │ │ └── objs │ │ │ │ │ └── nk-gl │ │ │ │ │ ├── jniexports.o │ │ │ │ │ └── jniexports.o.d │ │ │ │ ├── mips │ │ │ │ ├── libnk-gl.so │ │ │ │ └── objs │ │ │ │ │ └── nk-gl │ │ │ │ │ ├── jniexports.o │ │ │ │ │ └── jniexports.o.d │ │ │ │ ├── mips64 │ │ │ │ ├── libnk-gl.so │ │ │ │ └── objs │ │ │ │ │ └── nk-gl │ │ │ │ │ ├── jniexports.o │ │ │ │ │ └── jniexports.o.d │ │ │ │ ├── x86 │ │ │ │ ├── libnk-gl.so │ │ │ │ └── objs │ │ │ │ │ └── nk-gl │ │ │ │ │ ├── jniexports.o │ │ │ │ │ └── jniexports.o.d │ │ │ │ └── x86_64 │ │ │ │ ├── libnk-gl.so │ │ │ │ └── objs │ │ │ │ └── nk-gl │ │ │ │ ├── jniexports.o │ │ │ │ └── jniexports.o.d │ │ └── res │ │ │ ├── mipmap-hdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxxhdpi │ │ │ └── ic_launcher.png │ │ │ ├── values-w820dp │ │ │ └── dimens.xml │ │ │ └── values │ │ │ ├── dimens.xml │ │ │ ├── strings.xml │ │ │ └── styles.xml │ │ └── test │ │ └── java │ │ └── com │ │ └── example │ │ └── yt │ │ └── myapplication │ │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle └── README.md /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 Erik Tsarko 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /MyApplication/.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | -------------------------------------------------------------------------------- /MyApplication/.idea/.name: -------------------------------------------------------------------------------- 1 | My Application -------------------------------------------------------------------------------- /MyApplication/.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /MyApplication/.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /MyApplication/.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /MyApplication/.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 24 | 25 | -------------------------------------------------------------------------------- /MyApplication/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 19 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 46 | -------------------------------------------------------------------------------- /MyApplication/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /MyApplication/.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /MyApplication/app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /MyApplication/app/build.gradle: -------------------------------------------------------------------------------- 1 | import org.apache.tools.ant.taskdefs.condition.Os 2 | 3 | apply plugin: 'com.android.application' 4 | 5 | android { 6 | compileSdkVersion 18 7 | buildToolsVersion "23.0.1" 8 | 9 | defaultConfig { 10 | applicationId "com.example.yt.myapplication" 11 | minSdkVersion 15 12 | targetSdkVersion 15 13 | versionCode 1 14 | versionName "1.0" 15 | } 16 | buildTypes { 17 | debug { 18 | jniDebuggable = true 19 | } 20 | release { 21 | minifyEnabled false 22 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 23 | } 24 | } 25 | 26 | sourceSets.main.jni.srcDirs = [] // disable automatic ndk-build call, which ignore our Android.mk 27 | sourceSets.main.jniLibs.srcDir 'src/main/libs' 28 | 29 | task ndkBuild(type: Exec) { 30 | workingDir file('src/main') 31 | commandLine getNdkBuildCmd() 32 | } 33 | 34 | tasks.withType(JavaCompile) { 35 | compileTask -> compileTask.dependsOn ndkBuild 36 | } 37 | 38 | task cleanNative(type: Exec) { 39 | workingDir file('src/main') 40 | commandLine getNdkBuildCmd(), 'clean' 41 | } 42 | 43 | clean.dependsOn cleanNative 44 | } 45 | 46 | dependencies { 47 | compile fileTree(dir: 'libs', include: ['*.jar']) 48 | testCompile 'junit:junit:4.12' 49 | compile 'com.android.support:appcompat-v7:18.0.0' 50 | } 51 | 52 | def getNdkDir() { 53 | if (System.env.ANDROID_NDK_ROOT != null) 54 | return System.env.ANDROID_NDK_ROOT 55 | 56 | Properties properties = new Properties() 57 | properties.load(project.rootProject.file('local.properties').newDataInputStream()) 58 | def ndkdir = properties.getProperty('ndk.dir', null) 59 | if (ndkdir == null) 60 | throw new GradleException("NDK location not found. Define location with ndk.dir in the local.properties file or with an ANDROID_NDK_ROOT environment variable.") 61 | 62 | return ndkdir 63 | } 64 | 65 | def getNdkBuildCmd() { 66 | def ndkbuild = getNdkDir() + "/ndk-build" 67 | if (Os.isFamily(Os.FAMILY_WINDOWS)) 68 | ndkbuild += ".cmd" 69 | 70 | return ndkbuild 71 | } 72 | -------------------------------------------------------------------------------- /MyApplication/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /opt/bigdata/AndroidSDK/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /MyApplication/app/src/androidTest/java/com/example/yt/myapplication/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.example.yt.myapplication; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /MyApplication/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /MyApplication/app/src/main/java/com/example/yt/myapplication/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.example.yt.myapplication; 2 | 3 | import android.app.Application; 4 | import android.content.Context; 5 | import android.opengl.GLSurfaceView; 6 | import android.support.v7.app.ActionBarActivity; 7 | import android.os.Bundle; 8 | import android.view.Window; 9 | import android.view.WindowManager; 10 | 11 | import javax.microedition.khronos.egl.EGLConfig; 12 | import javax.microedition.khronos.opengles.GL10; 13 | 14 | class LibraryClass { 15 | static 16 | { 17 | System.loadLibrary("nk-gl"); 18 | } 19 | 20 | public static native void init(); 21 | public static native void resize(int width, int height); 22 | public static native void render(); 23 | } 24 | 25 | class DemoProjectRenderer implements GLSurfaceView.Renderer { 26 | 27 | @Override 28 | public void onSurfaceCreated(GL10 gl10, EGLConfig eglConfig) { 29 | LibraryClass.init(); 30 | } 31 | 32 | @Override 33 | public void onSurfaceChanged(GL10 gl10, int w, int h) { 34 | LibraryClass.resize(w, h); 35 | } 36 | 37 | @Override 38 | public void onDrawFrame(GL10 gl10) { 39 | LibraryClass.render(); 40 | } 41 | } 42 | 43 | public class MainActivity extends ActionBarActivity { 44 | 45 | private GLSurfaceView view; 46 | 47 | @Override 48 | protected void onCreate(Bundle savedInstanceState) { 49 | super.onCreate(savedInstanceState); 50 | requestWindowFeature(Window.FEATURE_NO_TITLE); 51 | 52 | view = new GLSurfaceView(getApplicationContext()); 53 | 54 | // Tell EGL to use a ES 2.0 Context 55 | view.setEGLContextClientVersion(2); 56 | 57 | // Set the renderer 58 | view.setRenderer(new DemoProjectRenderer()); 59 | 60 | setContentView(view); 61 | 62 | getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 63 | WindowManager.LayoutParams.FLAG_FULLSCREEN); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /MyApplication/app/src/main/jni/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | 3 | include $(CLEAR_VARS) 4 | 5 | LOCAL_CFLAGS := -std=c99 -D_GNU_SOURCE -D_POSIX_C_SOURCE=199309L \ 6 | -DNK_INCLUDE_FIXED_TYPES \ 7 | -DNK_INCLUDE_DEFAULT_ALLOCATOR \ 8 | -DNK_INCLUDE_STANDARD_IO \ 9 | -DNK_INCLUDE_VERTEX_BUFFER_OUTPUT \ 10 | -DNK_INCLUDE_FONT_BAKING \ 11 | -DNK_INCLUDE_DEFAULT_FONT \ 12 | -DGLES 13 | 14 | LOCAL_SRC_FILES := jniexports.c 15 | 16 | LOCAL_MODULE := libnk-gl 17 | LOCAL_LDLIBS += -llog -ldl -lEGL -lGLESv2 18 | 19 | include $(BUILD_SHARED_LIBRARY) 20 | -------------------------------------------------------------------------------- /MyApplication/app/src/main/jni/jniexports.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #define _CHECK_GL_IMPL(line) \ 11 | { \ 12 | int ret; \ 13 | while ((ret = glGetError()) != GL_NO_ERROR) \ 14 | { \ 15 | __android_log_print(ANDROID_LOG_DEBUG, "[CHECK_GL]", \ 16 | "%d: glGetError(): %#x\n", \ 17 | (line), ret); \ 18 | } \ 19 | } 20 | 21 | #define CHECK_GL _CHECK_GL_IMPL(__LINE__) 22 | 23 | static int width; 24 | static int height; 25 | 26 | static GLuint vbo, vao, ebo; 27 | static GLuint prog; 28 | static GLuint vert_shdr; 29 | static GLuint frag_shdr; 30 | static GLint attrib_pos; 31 | static GLint attrib_uv; 32 | static GLint attrib_col; 33 | static GLint uniform_tex; 34 | static GLint uniform_proj; 35 | 36 | typedef void ( *__GLXextFuncPtr)(void); 37 | 38 | #define GL_EXT(name) (pfn##name)gl_ext(#name) 39 | 40 | typedef void (*pfnglGenVertexArrays)(GLsizei, GLuint*); 41 | typedef void (*pfnglBindVertexArray)(GLuint); 42 | typedef void (*pfnglDeleteVertexArrays)(GLsizei, const GLuint*); 43 | typedef void (*pfnglGenVertexArraysOES)(GLsizei, GLuint*); 44 | typedef void (*pfnglBindVertexArrayOES)(GLuint); 45 | typedef void (*pfnglDeleteVertexArraysOES)(GLsizei, const GLuint*); 46 | 47 | static pfnglGenVertexArrays glGenVertexArrays; 48 | static pfnglBindVertexArray glBindVertexArray; 49 | static pfnglDeleteVertexArrays glDeleteVertexArrays; 50 | static pfnglGenVertexArraysOES glGenVertexArraysOES; 51 | static pfnglBindVertexArrayOES glBindVertexArrayOES; 52 | static pfnglDeleteVertexArraysOES glDeleteVertexArraysOES; 53 | 54 | struct vec2 {float x,y;}; 55 | 56 | struct vec2 57 | vec2(float x, float y) 58 | { 59 | struct vec2 ret; 60 | ret.x = x; ret.y = y; 61 | return ret; 62 | } 63 | 64 | static 65 | __GLXextFuncPtr gl_ext(const char *name) 66 | { 67 | __GLXextFuncPtr func; 68 | func = eglGetProcAddress(name); 69 | if (!func) 70 | { 71 | __android_log_print(ANDROID_LOG_INFO, "native", "%s:%d: %s %s", __FUNCTION__, __LINE__, 72 | "failed to load extension ", name); 73 | return NULL; 74 | } 75 | return func; 76 | } 77 | 78 | JNIEXPORT void JNICALL Java_com_example_yt_myapplication_LibraryClass_init(JNIEnv *env, jobject thiz) 79 | { 80 | __android_log_print(ANDROID_LOG_INFO, "native", "%s:%d", __FUNCTION__, __LINE__); 81 | 82 | glGenVertexArrays = GL_EXT(glGenVertexArraysOES); 83 | glBindVertexArray = GL_EXT(glBindVertexArrayOES); 84 | glDeleteVertexArrays = GL_EXT(glDeleteVertexArraysOES); 85 | 86 | assert(glGenVertexArrays && glBindVertexArray && glDeleteVertexArrays); 87 | 88 | GLint status; 89 | GLuint vertex_index = 0; 90 | 91 | static const GLchar *vertex_shader = 92 | "uniform mat4 ProjMtx;\n" 93 | "attribute vec2 Position;\n" 94 | "attribute vec2 TexCoord;\n" 95 | "attribute vec4 Color;\n" 96 | "varying vec4 Frag_Color;\n" 97 | "void main() {\n" 98 | " Frag_Color = Color;\n" 99 | " gl_Position = ProjMtx * vec4(Position.xy, 0, 1);\n" 100 | "}\n"; 101 | static const GLchar *fragment_shader = 102 | "precision mediump float;\n" 103 | "uniform sampler2D Texture;\n" 104 | "varying vec4 Frag_Color;\n" 105 | "void main() {\n" 106 | " gl_FragColor = Frag_Color;\n" 107 | "}\n"; 108 | 109 | prog = glCreateProgram(); CHECK_GL; 110 | vert_shdr = glCreateShader(GL_VERTEX_SHADER); 111 | frag_shdr = glCreateShader(GL_FRAGMENT_SHADER); 112 | glShaderSource(vert_shdr, 1, &vertex_shader, 0); 113 | glShaderSource(frag_shdr, 1, &fragment_shader, 0); 114 | glCompileShader(vert_shdr); 115 | glCompileShader(frag_shdr); 116 | glGetShaderiv(vert_shdr, GL_COMPILE_STATUS, &status); 117 | if (status == GL_FALSE) 118 | { 119 | GLint logSize = 0; 120 | glGetShaderiv(vert_shdr, GL_INFO_LOG_LENGTH, &logSize); 121 | GLchar *log_msg = alloca(logSize); 122 | glGetShaderInfoLog(vert_shdr, logSize, &logSize, &log_msg[0]); 123 | 124 | __android_log_print(ANDROID_LOG_INFO, "native", "failed to compile vertex shader:\n%s\n", log_msg); 125 | return; 126 | } 127 | glGetShaderiv(frag_shdr, GL_COMPILE_STATUS, &status); 128 | if (status == GL_FALSE) 129 | { 130 | GLint logSize = 0; 131 | glGetShaderiv(frag_shdr, GL_INFO_LOG_LENGTH, &logSize); 132 | GLchar *log_msg = alloca(logSize); 133 | glGetShaderInfoLog(frag_shdr, logSize, &logSize, &log_msg[0]); 134 | 135 | __android_log_print(ANDROID_LOG_INFO, "native", "failed to compile fragment shader:\n%s\n", log_msg); 136 | return; 137 | } 138 | glAttachShader(prog, vert_shdr); CHECK_GL; 139 | glAttachShader(prog, frag_shdr); CHECK_GL; 140 | 141 | /* Assign each attribute a name */ 142 | 143 | glBindAttribLocation(prog, vertex_index, "Position"); CHECK_GL; 144 | attrib_pos = vertex_index; 145 | vertex_index++; 146 | 147 | glBindAttribLocation(prog, vertex_index, "Color"); CHECK_GL; 148 | attrib_col = vertex_index; 149 | vertex_index++; 150 | 151 | glLinkProgram(prog); CHECK_GL; 152 | glGetProgramiv(prog, GL_LINK_STATUS, &status); CHECK_GL; 153 | assert(status == GL_TRUE); 154 | 155 | uniform_proj = glGetUniformLocation(prog, "ProjMtx"); CHECK_GL; 156 | assert(glGetError() == GL_NO_ERROR); 157 | assert(uniform_proj >= 0); 158 | 159 | { 160 | /* buffer setup */ 161 | glGenVertexArrays(1, &vao); CHECK_GL; 162 | glBindVertexArray(vao); CHECK_GL; 163 | 164 | glGenBuffers(1, &vbo); CHECK_GL; 165 | glBindBuffer(GL_ARRAY_BUFFER, vbo); CHECK_GL; 166 | 167 | glGenBuffers(1, &ebo); CHECK_GL; 168 | glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ebo); CHECK_GL; 169 | 170 | struct my_vertex 171 | { 172 | struct vec2 pos; 173 | unsigned int color; 174 | } vertices[] = 175 | { 176 | 177 | { vec2(30.50f, 30.50f), 0xff2d2d2d, }, 178 | { vec2(400.50f, 30.50f), 0xff2d2d2d, }, 179 | { vec2(400.50f, 450.50f), 0xff2d2d2d, }, 180 | { vec2(30.50f, 450.50f), 0xff2d2d2d, }, 181 | 182 | { vec2(130.50f, 130.50f), 0xff0000ff, }, 183 | { vec2(230.50f, 130.50f), 0xff0000ff, }, 184 | { vec2(230.50f, 230.50f), 0xff0000ff, }, 185 | { vec2(130.50f, 230.50f), 0xff0000ff, }, 186 | }; 187 | 188 | unsigned short indices[] = 189 | { 190 | 0, 1, 2, 0, 2, 3, 191 | 4, 5, 6, 4, 6, 7, 192 | }; 193 | 194 | glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, 195 | GL_STATIC_DRAW); CHECK_GL; 196 | 197 | glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices, 198 | GL_STATIC_DRAW); CHECK_GL; 199 | 200 | GLsizei vs = sizeof(struct my_vertex); 201 | size_t vp = offsetof(struct my_vertex, pos); 202 | size_t vc = offsetof(struct my_vertex, color); 203 | 204 | glEnableVertexAttribArray((GLuint)attrib_pos); CHECK_GL; 205 | glEnableVertexAttribArray((GLuint)attrib_col); CHECK_GL; 206 | 207 | glVertexAttribPointer((GLuint)attrib_pos, 2, GL_FLOAT, GL_FALSE, vs, (void*)vp); CHECK_GL; 208 | glVertexAttribPointer((GLuint)attrib_col, 4, GL_UNSIGNED_BYTE, GL_TRUE, vs, (void*)vc); CHECK_GL; 209 | } 210 | 211 | glBindVertexArray(0); 212 | glBindTexture(GL_TEXTURE_2D, 0); 213 | glBindBuffer(GL_ARRAY_BUFFER, 0); 214 | glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); 215 | } 216 | 217 | static 218 | void render(int w, int h) 219 | { 220 | GLint last_prog, last_tex; 221 | GLint last_ebo, last_vbo, last_vao; 222 | GLfloat ortho[4][4] = 223 | { 224 | { 2.0f, 0.0f, 0.0f, 0.0f }, 225 | { 0.0f, -2.0f, 0.0f, 0.0f }, 226 | { 0.0f, 0.0f, -1.0f, 0.0f }, 227 | { -1.0f, 1.0f, 0.0f, 1.0f }, 228 | }; 229 | ortho[0][0] /= (GLfloat)w; 230 | ortho[1][1] /= (GLfloat)h; 231 | 232 | /* save previous opengl state */ 233 | glGetIntegerv(GL_CURRENT_PROGRAM, &last_prog); 234 | glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_tex); 235 | glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &last_vbo); 236 | glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING, &last_ebo); 237 | #ifndef GLES 238 | glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &last_vao); 239 | #else 240 | glGetIntegerv(GL_VERTEX_ARRAY_BINDING_OES, &last_vao); 241 | #endif 242 | 243 | /* setup global state */ 244 | glEnable(GL_BLEND); 245 | glBlendEquation(GL_FUNC_ADD); 246 | glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); CHECK_GL; 247 | glDisable(GL_CULL_FACE); 248 | glDisable(GL_DEPTH_TEST); 249 | glActiveTexture(GL_TEXTURE0); 250 | 251 | /* setup program */ 252 | glUseProgram(prog); CHECK_GL; 253 | 254 | glUniformMatrix4fv(uniform_proj, 1, GL_FALSE, &ortho[0][0]); CHECK_GL; 255 | 256 | glBindVertexArray(vao); CHECK_GL; 257 | 258 | glBindBuffer(GL_ARRAY_BUFFER, vbo); CHECK_GL; 259 | glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ebo); CHECK_GL; 260 | 261 | /* 262 | * Variant 1 263 | */ 264 | glDrawElements(GL_TRIANGLES, 3, GL_UNSIGNED_SHORT, 0); CHECK_GL; 265 | glDrawElements(GL_TRIANGLES, 3, GL_UNSIGNED_SHORT, (const GLushort*)(0) + 6); CHECK_GL; 266 | 267 | /* 268 | * Variant 2 269 | */ 270 | // glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0); CHECK_GL; 271 | // glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, (const GLushort*)(0) + 6); CHECK_GL; 272 | 273 | /* 274 | * Variant 3 275 | */ 276 | // glDrawElements(GL_TRIANGLES, 12, GL_UNSIGNED_SHORT, (const GLushort*)(0)); CHECK_GL; 277 | 278 | /* restore old state */ 279 | glBindTexture(GL_TEXTURE_2D, (GLuint)last_tex); 280 | glBindBuffer(GL_ARRAY_BUFFER, (GLuint)last_vbo); 281 | glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, (GLuint)last_ebo); 282 | glBindVertexArray((GLuint)last_vao); 283 | glDisable(GL_SCISSOR_TEST); 284 | } 285 | 286 | JNIEXPORT void JNICALL Java_com_example_yt_myapplication_LibraryClass_resize(JNIEnv *env, jobject thiz, jint w, jint h) 287 | { 288 | width = w; 289 | height = h; 290 | 291 | __android_log_print(ANDROID_LOG_DEBUG, "native", "%s:%d, w:%d, h:%d", __FUNCTION__, __LINE__, width, height); 292 | 293 | glViewport(0, 0, width, height); 294 | } 295 | 296 | JNIEXPORT void JNICALL Java_com_example_yt_myapplication_LibraryClass_render(JNIEnv *env, jobject thiz) 297 | { 298 | glClearColor(1.0f, 0.5f, 0.0784f, 1.0f); 299 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 300 | 301 | render(width, height); 302 | } 303 | -------------------------------------------------------------------------------- /MyApplication/app/src/main/jni/nk-gl.c: -------------------------------------------------------------------------------- 1 | #define USE_FULL_GL 0 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #include 15 | #include 16 | #include 17 | 18 | #include 19 | 20 | 21 | 22 | static int nk_gl_device_create(struct nk_gl_device *dev); 23 | static void nk_gl_device_destroy(struct nk_gl_device *dev); 24 | static void setup_null_texture(struct nk_gl_device *dev); 25 | static __GLXextFuncPtr nk_gl_ext(const char *name); 26 | 27 | /* GL_ARB_vertex_array_object */ 28 | 29 | 30 | int nk_gl_init(struct nk_context *nk_ctx, struct nk_gl **out) 31 | { 32 | assert(nk_ctx); 33 | assert(out); 34 | 35 | *out = 0; 36 | 37 | int retval = 0; 38 | struct nk_gl *nk_gl = 0; 39 | struct nk_gl_device *nk_gl_dev = 0; 40 | 41 | nk_gl = calloc(1, sizeof(*nk_gl)); 42 | if (!nk_gl) return ENOMEM; 43 | 44 | nk_gl_dev = calloc(1, sizeof(*nk_gl_dev)); 45 | if (!nk_gl_dev) 46 | { 47 | retval = ENOMEM; 48 | goto err; 49 | } 50 | 51 | retval = nk_gl_device_create(nk_gl_dev); 52 | if (retval != 0) goto err; 53 | 54 | nk_gl->ogl = nk_gl_dev; 55 | nk_gl->ctx = nk_ctx; 56 | 57 | *out = nk_gl; 58 | 59 | return 0; 60 | 61 | err: 62 | if (nk_gl_dev) free(nk_gl_dev); 63 | if (nk_gl) free(nk_gl); 64 | 65 | return retval; 66 | } 67 | 68 | void nk_gl_shutdown(struct nk_gl **ctx) 69 | { 70 | assert(ctx); 71 | 72 | nk_gl_device_destroy((*ctx)->ogl); 73 | free(*ctx); 74 | 75 | *ctx = 0; 76 | } 77 | 78 | void nk_gl_render(struct nk_gl *nk_gl, enum nk_anti_aliasing aa, 79 | int w, int h, int max_vertex_buffer, int max_element_buffer) 80 | { 81 | struct nk_gl_device *dev = nk_gl->ogl; 82 | GLint last_prog, last_tex; 83 | GLint last_ebo, last_vbo, last_vao; 84 | GLfloat ortho[4][4] = 85 | { 86 | { 2.0f, 0.0f, 0.0f, 0.0f }, 87 | { 0.0f, -2.0f, 0.0f, 0.0f }, 88 | { 0.0f, 0.0f, -1.0f, 0.0f }, 89 | { -1.0f, 1.0f, 0.0f, 1.0f }, 90 | }; 91 | ortho[0][0] /= (GLfloat)w; 92 | ortho[1][1] /= (GLfloat)h; 93 | 94 | /* save previous opengl state */ 95 | glGetIntegerv(GL_CURRENT_PROGRAM, &last_prog); 96 | glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_tex); 97 | glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &last_vbo); 98 | glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING, &last_ebo); 99 | #ifndef GLES 100 | glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &last_vao); 101 | #else 102 | glGetIntegerv(GL_VERTEX_ARRAY_BINDING_OES, &last_vao); 103 | #endif 104 | 105 | /* setup global state */ 106 | glEnable(GL_BLEND); 107 | glBlendEquation(GL_FUNC_ADD); 108 | glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); CHECK_GL; 109 | glDisable(GL_CULL_FACE); 110 | glDisable(GL_DEPTH_TEST); 111 | // glEnable(GL_SCISSOR_TEST); 112 | glActiveTexture(GL_TEXTURE0); 113 | 114 | /* setup program */ 115 | glUseProgram(dev->prog); CHECK_GL; 116 | 117 | glUniformMatrix4fv(dev->uniform_proj, 1, GL_FALSE, &ortho[0][0]); CHECK_GL; 118 | 119 | glBindVertexArray(dev->vao); CHECK_GL; 120 | 121 | glBindBuffer(GL_ARRAY_BUFFER, dev->vbo); CHECK_GL; 122 | glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, dev->ebo); CHECK_GL; 123 | 124 | glBindTexture(GL_TEXTURE_2D, (GLuint)dev->null.texture.id); CHECK_GL; 125 | // glDrawElements(GL_TRIANGLES, 3, GL_UNSIGNED_SHORT, 0); CHECK_GL; 126 | // glDrawElements(GL_TRIANGLES, 3, GL_UNSIGNED_SHORT, (const GLushort*)(0) + 6); CHECK_GL; 127 | glDrawElements(GL_TRIANGLES, 12, GL_UNSIGNED_SHORT, (const GLushort*)(0)); CHECK_GL; 128 | 129 | /* restore old state */ 130 | glBindTexture(GL_TEXTURE_2D, (GLuint)last_tex); 131 | glBindBuffer(GL_ARRAY_BUFFER, (GLuint)last_vbo); 132 | glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, (GLuint)last_ebo); 133 | glBindVertexArray((GLuint)last_vao); 134 | glDisable(GL_SCISSOR_TEST); 135 | } 136 | 137 | static GLuint FramebufferName; 138 | 139 | void nk_gl_blit(struct nk_gl *nk_gl, struct nk_color bg, int w, int h, 140 | enum nk_anti_aliasing aa) 141 | { 142 | float background[4]; 143 | nk_color_fv(background, bg); 144 | 145 | // glBindFramebuffer(GL_FRAMEBUFFER, FramebufferName); CHECK_GL; 146 | 147 | glViewport(0, 0, w, h); CHECK_GL; 148 | glClearColor(background[0], background[1], background[2], background[3]); CHECK_GL; 149 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); CHECK_GL; 150 | nk_gl_render(nk_gl, aa, w, h, MAX_VERTEX_MEMORY, MAX_ELEMENT_MEMORY); 151 | } 152 | 153 | static 154 | void setup_framebuffer() 155 | { 156 | glGenFramebuffers(1, &FramebufferName); CHECK_GL; 157 | glBindFramebuffer(GL_FRAMEBUFFER, FramebufferName); CHECK_GL; 158 | 159 | GLuint renderedTexture; 160 | glGenTextures(1, &renderedTexture); CHECK_GL; 161 | glBindTexture(GL_TEXTURE_2D, renderedTexture); CHECK_GL; 162 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1280, 720, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0); CHECK_GL; 163 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); CHECK_GL; 164 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); CHECK_GL; 165 | 166 | // Set "renderedTexture" as our colour attachement #0 167 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, renderedTexture, 0); CHECK_GL; 168 | 169 | // Set the list of draw buffers. 170 | // GLenum DrawBuffers[1] = {GL_COLOR_ATTACHMENT0}; 171 | // glDrawBuffers(1, DrawBuffers); CHECK_GL; // "1" is the size of DrawBuffers 172 | 173 | if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) 174 | { 175 | printf("failed to configure frame buffer\n"); 176 | } 177 | 178 | glBindFramebuffer(GL_FRAMEBUFFER, 0); CHECK_GL; 179 | } 180 | 181 | static int nk_gl_device_create(struct nk_gl_device *dev) 182 | { 183 | assert(glGenVertexArrays); 184 | assert(glBindVertexArray); 185 | assert(glDeleteVertexArrays); 186 | 187 | 188 | setup_null_texture(dev); 189 | 190 | setup_framebuffer(); 191 | 192 | return 0; 193 | } 194 | 195 | static void nk_gl_device_destroy(struct nk_gl_device *dev) 196 | { 197 | glDeleteTextures(1, (GLuint*)&dev->null.texture.id); 198 | glDetachShader(dev->prog, dev->vert_shdr); 199 | glDetachShader(dev->prog, dev->frag_shdr); 200 | glDeleteShader(dev->vert_shdr); 201 | glDeleteShader(dev->frag_shdr); 202 | glDeleteProgram(dev->prog); 203 | glDeleteVertexArrays(1, &dev->vao); 204 | glDeleteBuffers(1, &dev->vbo); 205 | glDeleteBuffers(1, &dev->ebo); 206 | nk_buffer_free(&dev->cmds); 207 | } 208 | 209 | static 210 | void setup_null_texture(struct nk_gl_device *dev) 211 | { 212 | GLuint id; 213 | glGenTextures(1, &id); CHECK_GL; 214 | glBindTexture(GL_TEXTURE_2D, id); CHECK_GL; 215 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); CHECK_GL; 216 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); CHECK_GL; 217 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); CHECK_GL; 218 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); CHECK_GL; 219 | 220 | const size_t width = 4; 221 | const size_t height = 4; 222 | const size_t size = width * height * sizeof(uint32_t); 223 | 224 | uint32_t *null_texture = malloc(size); 225 | assert(null_texture); 226 | // memset(null_texture, 0xff, size); 227 | 228 | for (int y = 0; y < height; y++) 229 | { 230 | for (int x = 0; x < width; x++) 231 | { 232 | uint32_t *pixel = &null_texture[y * width + x]; 233 | // *pixel = (0xff << 24) | (0x00 << 16) | (0x00 << 8) | 0x00; 234 | *pixel = 0xffffffff; 235 | } 236 | } 237 | 238 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 239 | width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, null_texture); CHECK_GL; 240 | 241 | dev->null.texture = nk_handle_id(id); 242 | dev->null.uv = nk_vec2(0.5f, 0.5f); 243 | } 244 | 245 | #define NK_IMPLEMENTATION 246 | #include "nuklear.h" 247 | -------------------------------------------------------------------------------- /MyApplication/app/src/main/jni/nk-gl.h: -------------------------------------------------------------------------------- 1 | #ifndef NK_GL_H 2 | #define NK_GL_H 3 | 4 | #pragma once 5 | 6 | #include "nuklear.h" 7 | 8 | struct nk_gl 9 | { 10 | struct nk_gl_device *ogl; 11 | struct nk_context *ctx; 12 | }; 13 | 14 | int nk_gl_init(struct nk_context *nk_ctx, struct nk_gl **out); 15 | void nk_gl_shutdown(struct nk_gl **ctx); 16 | 17 | void nk_gl_render(struct nk_gl *nk_gl, enum nk_anti_aliasing aa, 18 | int w, int h, int max_vertex_buffer, int max_element_buffer); 19 | 20 | void nk_gl_blit(struct nk_gl *nk_gl, struct nk_color bg, int w, int h, 21 | enum nk_anti_aliasing aa); 22 | 23 | #endif /* NK_GL_H */ 24 | -------------------------------------------------------------------------------- /MyApplication/app/src/main/libs/arm64-v8a/libnk-gl.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ytsarko/nuklear-android-ndk-sample/4159ff5d3fca9c36ef647b6da39c24b6b8f1b61d/MyApplication/app/src/main/libs/arm64-v8a/libnk-gl.so -------------------------------------------------------------------------------- /MyApplication/app/src/main/libs/armeabi-v7a/libnk-gl.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ytsarko/nuklear-android-ndk-sample/4159ff5d3fca9c36ef647b6da39c24b6b8f1b61d/MyApplication/app/src/main/libs/armeabi-v7a/libnk-gl.so -------------------------------------------------------------------------------- /MyApplication/app/src/main/libs/armeabi/libnk-gl.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ytsarko/nuklear-android-ndk-sample/4159ff5d3fca9c36ef647b6da39c24b6b8f1b61d/MyApplication/app/src/main/libs/armeabi/libnk-gl.so -------------------------------------------------------------------------------- /MyApplication/app/src/main/libs/mips/libnk-gl.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ytsarko/nuklear-android-ndk-sample/4159ff5d3fca9c36ef647b6da39c24b6b8f1b61d/MyApplication/app/src/main/libs/mips/libnk-gl.so -------------------------------------------------------------------------------- /MyApplication/app/src/main/libs/mips64/libnk-gl.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ytsarko/nuklear-android-ndk-sample/4159ff5d3fca9c36ef647b6da39c24b6b8f1b61d/MyApplication/app/src/main/libs/mips64/libnk-gl.so -------------------------------------------------------------------------------- /MyApplication/app/src/main/libs/x86/libnk-gl.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ytsarko/nuklear-android-ndk-sample/4159ff5d3fca9c36ef647b6da39c24b6b8f1b61d/MyApplication/app/src/main/libs/x86/libnk-gl.so -------------------------------------------------------------------------------- /MyApplication/app/src/main/libs/x86_64/libnk-gl.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ytsarko/nuklear-android-ndk-sample/4159ff5d3fca9c36ef647b6da39c24b6b8f1b61d/MyApplication/app/src/main/libs/x86_64/libnk-gl.so -------------------------------------------------------------------------------- /MyApplication/app/src/main/obj/local/arm64-v8a/libnk-gl.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ytsarko/nuklear-android-ndk-sample/4159ff5d3fca9c36ef647b6da39c24b6b8f1b61d/MyApplication/app/src/main/obj/local/arm64-v8a/libnk-gl.so -------------------------------------------------------------------------------- /MyApplication/app/src/main/obj/local/arm64-v8a/objs/nk-gl/jniexports.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ytsarko/nuklear-android-ndk-sample/4159ff5d3fca9c36ef647b6da39c24b6b8f1b61d/MyApplication/app/src/main/obj/local/arm64-v8a/objs/nk-gl/jniexports.o -------------------------------------------------------------------------------- /MyApplication/app/src/main/obj/local/arm64-v8a/objs/nk-gl/jniexports.o.d: -------------------------------------------------------------------------------- 1 | obj/local/arm64-v8a/objs/nk-gl/jniexports.o: jni/jniexports.c 2 | -------------------------------------------------------------------------------- /MyApplication/app/src/main/obj/local/armeabi-v7a/libnk-gl.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ytsarko/nuklear-android-ndk-sample/4159ff5d3fca9c36ef647b6da39c24b6b8f1b61d/MyApplication/app/src/main/obj/local/armeabi-v7a/libnk-gl.so -------------------------------------------------------------------------------- /MyApplication/app/src/main/obj/local/armeabi-v7a/objs/nk-gl/jniexports.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ytsarko/nuklear-android-ndk-sample/4159ff5d3fca9c36ef647b6da39c24b6b8f1b61d/MyApplication/app/src/main/obj/local/armeabi-v7a/objs/nk-gl/jniexports.o -------------------------------------------------------------------------------- /MyApplication/app/src/main/obj/local/armeabi-v7a/objs/nk-gl/jniexports.o.d: -------------------------------------------------------------------------------- 1 | obj/local/armeabi-v7a/objs/nk-gl/jniexports.o: jni/jniexports.c 2 | -------------------------------------------------------------------------------- /MyApplication/app/src/main/obj/local/armeabi/libnk-gl.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ytsarko/nuklear-android-ndk-sample/4159ff5d3fca9c36ef647b6da39c24b6b8f1b61d/MyApplication/app/src/main/obj/local/armeabi/libnk-gl.so -------------------------------------------------------------------------------- /MyApplication/app/src/main/obj/local/armeabi/objs/nk-gl/jniexports.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ytsarko/nuklear-android-ndk-sample/4159ff5d3fca9c36ef647b6da39c24b6b8f1b61d/MyApplication/app/src/main/obj/local/armeabi/objs/nk-gl/jniexports.o -------------------------------------------------------------------------------- /MyApplication/app/src/main/obj/local/armeabi/objs/nk-gl/jniexports.o.d: -------------------------------------------------------------------------------- 1 | obj/local/armeabi/objs/nk-gl/jniexports.o: jni/jniexports.c 2 | -------------------------------------------------------------------------------- /MyApplication/app/src/main/obj/local/mips/libnk-gl.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ytsarko/nuklear-android-ndk-sample/4159ff5d3fca9c36ef647b6da39c24b6b8f1b61d/MyApplication/app/src/main/obj/local/mips/libnk-gl.so -------------------------------------------------------------------------------- /MyApplication/app/src/main/obj/local/mips/objs/nk-gl/jniexports.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ytsarko/nuklear-android-ndk-sample/4159ff5d3fca9c36ef647b6da39c24b6b8f1b61d/MyApplication/app/src/main/obj/local/mips/objs/nk-gl/jniexports.o -------------------------------------------------------------------------------- /MyApplication/app/src/main/obj/local/mips/objs/nk-gl/jniexports.o.d: -------------------------------------------------------------------------------- 1 | obj/local/mips/objs/nk-gl/jniexports.o: jni/jniexports.c 2 | -------------------------------------------------------------------------------- /MyApplication/app/src/main/obj/local/mips64/libnk-gl.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ytsarko/nuklear-android-ndk-sample/4159ff5d3fca9c36ef647b6da39c24b6b8f1b61d/MyApplication/app/src/main/obj/local/mips64/libnk-gl.so -------------------------------------------------------------------------------- /MyApplication/app/src/main/obj/local/mips64/objs/nk-gl/jniexports.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ytsarko/nuklear-android-ndk-sample/4159ff5d3fca9c36ef647b6da39c24b6b8f1b61d/MyApplication/app/src/main/obj/local/mips64/objs/nk-gl/jniexports.o -------------------------------------------------------------------------------- /MyApplication/app/src/main/obj/local/mips64/objs/nk-gl/jniexports.o.d: -------------------------------------------------------------------------------- 1 | obj/local/mips64/objs/nk-gl/jniexports.o: jni/jniexports.c 2 | -------------------------------------------------------------------------------- /MyApplication/app/src/main/obj/local/x86/libnk-gl.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ytsarko/nuklear-android-ndk-sample/4159ff5d3fca9c36ef647b6da39c24b6b8f1b61d/MyApplication/app/src/main/obj/local/x86/libnk-gl.so -------------------------------------------------------------------------------- /MyApplication/app/src/main/obj/local/x86/objs/nk-gl/jniexports.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ytsarko/nuklear-android-ndk-sample/4159ff5d3fca9c36ef647b6da39c24b6b8f1b61d/MyApplication/app/src/main/obj/local/x86/objs/nk-gl/jniexports.o -------------------------------------------------------------------------------- /MyApplication/app/src/main/obj/local/x86/objs/nk-gl/jniexports.o.d: -------------------------------------------------------------------------------- 1 | obj/local/x86/objs/nk-gl/jniexports.o: jni/jniexports.c 2 | -------------------------------------------------------------------------------- /MyApplication/app/src/main/obj/local/x86_64/libnk-gl.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ytsarko/nuklear-android-ndk-sample/4159ff5d3fca9c36ef647b6da39c24b6b8f1b61d/MyApplication/app/src/main/obj/local/x86_64/libnk-gl.so -------------------------------------------------------------------------------- /MyApplication/app/src/main/obj/local/x86_64/objs/nk-gl/jniexports.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ytsarko/nuklear-android-ndk-sample/4159ff5d3fca9c36ef647b6da39c24b6b8f1b61d/MyApplication/app/src/main/obj/local/x86_64/objs/nk-gl/jniexports.o -------------------------------------------------------------------------------- /MyApplication/app/src/main/obj/local/x86_64/objs/nk-gl/jniexports.o.d: -------------------------------------------------------------------------------- 1 | obj/local/x86_64/objs/nk-gl/jniexports.o: jni/jniexports.c 2 | -------------------------------------------------------------------------------- /MyApplication/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ytsarko/nuklear-android-ndk-sample/4159ff5d3fca9c36ef647b6da39c24b6b8f1b61d/MyApplication/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /MyApplication/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ytsarko/nuklear-android-ndk-sample/4159ff5d3fca9c36ef647b6da39c24b6b8f1b61d/MyApplication/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /MyApplication/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ytsarko/nuklear-android-ndk-sample/4159ff5d3fca9c36ef647b6da39c24b6b8f1b61d/MyApplication/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /MyApplication/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ytsarko/nuklear-android-ndk-sample/4159ff5d3fca9c36ef647b6da39c24b6b8f1b61d/MyApplication/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /MyApplication/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ytsarko/nuklear-android-ndk-sample/4159ff5d3fca9c36ef647b6da39c24b6b8f1b61d/MyApplication/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /MyApplication/app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /MyApplication/app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /MyApplication/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | My Application 3 | 4 | -------------------------------------------------------------------------------- /MyApplication/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /MyApplication/app/src/test/java/com/example/yt/myapplication/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.example.yt.myapplication; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * To work on unit tests, switch the Test Artifact in the Build Variants view. 9 | */ 10 | public class ExampleUnitTest { 11 | @Test 12 | public void addition_isCorrect() throws Exception { 13 | assertEquals(4, 2 + 2); 14 | } 15 | } -------------------------------------------------------------------------------- /MyApplication/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | } 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:2.1.2' 9 | 10 | // NOTE: Do not place your application dependencies here; they belong 11 | // in the individual module build.gradle files 12 | } 13 | } 14 | 15 | allprojects { 16 | repositories { 17 | jcenter() 18 | } 19 | } 20 | 21 | task clean(type: Delete) { 22 | delete rootProject.buildDir 23 | } 24 | -------------------------------------------------------------------------------- /MyApplication/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 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true 19 | 20 | android.useDeprecatedNdk=true 21 | -------------------------------------------------------------------------------- /MyApplication/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ytsarko/nuklear-android-ndk-sample/4159ff5d3fca9c36ef647b6da39c24b6b8f1b61d/MyApplication/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /MyApplication/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Tue Jun 14 09:46:43 MSK 2016 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-2.10-all.zip 7 | -------------------------------------------------------------------------------- /MyApplication/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 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /MyApplication/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 | -------------------------------------------------------------------------------- /MyApplication/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # nuklear-android-ndk-sample 2 | Simple sample how to use nuklear gui framework on Android using NDK 3 | --------------------------------------------------------------------------------