├── .gitignore ├── LICENSE ├── README.md ├── USAGE.md ├── android_gl_server ├── AndroidManifest.xml ├── jni │ ├── Android.mk │ ├── Application.mk │ └── glstreaming_jni.cpp ├── libs │ ├── armeabi-v7a │ │ ├── gdb.setup │ │ └── gdbserver │ ├── armeabi │ │ ├── gdb.setup │ │ └── gdbserver │ └── x86 │ │ ├── gdb.setup │ │ └── gdbserver ├── project.properties ├── res │ ├── layout │ │ ├── config.xml │ │ └── main.xml │ ├── menu │ │ └── main.xml │ └── values │ │ └── strings.xml └── src │ └── com │ └── kdt │ └── glstreamserver │ ├── GLStreamingActivity.java │ ├── GLStreamingJNIWrapper.java │ └── GLStreamingView.java ├── common ├── fastlog.h ├── fifo.c ├── fifo.h ├── gls_command.h ├── server.c ├── server.h └── utils.h ├── contributors.txt ├── gl_client ├── Android.mk ├── Makefile ├── clientegl.c ├── clientgles.c ├── glclient.c ├── glclient.h ├── include │ ├── EGL │ │ ├── egl.h │ │ ├── eglext.h │ │ └── eglplatform.h │ ├── GLES2 │ │ ├── gl2.h │ │ └── gl2platform.h │ └── KHR │ │ └── khrplatform.h ├── samples │ ├── Makefile │ ├── glsutil.c │ ├── glsutil.h │ ├── model1.h │ ├── sample1.c │ ├── sample2 │ ├── sample2.c │ └── texture1.bmp └── todo_add.txt ├── gl_server ├── Android.mk ├── Makefile ├── glcontrol.c ├── glcontrol.h ├── glserver.c ├── glserver.h ├── main.c ├── main.h ├── serveregl.c └── servergles.c └── www ├── GLStreaming.png ├── Screenshot_2020-05-19-09-42-24.png └── gl-streaming_small.png /.gitignore: -------------------------------------------------------------------------------- 1 | # Object files 2 | *.o 3 | *.ko 4 | 5 | # Libraries 6 | *.lib 7 | *.a 8 | 9 | # Shared objects (inc. Windows DLLs) 10 | *.dll 11 | *.so 12 | *.so.* 13 | *.dylib 14 | 15 | # Executables 16 | *.exe 17 | *.out 18 | *.app 19 | 20 | # Android app generated files 21 | android_gl_server/*.s 22 | android_gl_server/bin 23 | android_gl_server/gen 24 | # Adding below remove even .so and .jar library! 25 | # android_gl_server/libs 26 | android_gl_server/obj 27 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013, Shodruky Rhyammer 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | Redistributions in binary form must reproduce the above copyright notice, this 11 | list of conditions and the following disclaimer in the documentation and/or 12 | other materials provided with the distribution. 13 | 14 | Neither the name of the copyright holders nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 19 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 22 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 25 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # gl-streaming 2 | 3 | 4 | ![GLStreaming](https://github.com/khanhduytran0/gl-streaming/raw/master/www/GLStreaming.png) 5 | 6 | Streaming opengl commands over network 7 | 8 | A fast, simple, lightweight and low latency framework suitable for embedded systems. 9 | 10 | > - Original image 11 | > ![gl-streaming summary](https://raw.github.com/shodruky-rhyammer/gl-streaming/master/www/gl-streaming_small.png) 12 | 13 | * gl_client : client framework and sample program 14 | 15 | The client system may not need to have any GPU. Even without GPU, opengl programs can be run on any system ! 16 | 17 | (X Server is now required by client). 18 | 19 | Some codes are from @mittorn fork for base methods, @tinmaniac for base Android port and do my attempt on implement all stub methods to run on GL4ES. 20 | 21 | * gl_server : server framework 22 | 23 | gl_server is optimized for Android for now. Therefore, the client system can use opengl es 2.0. 24 | 25 | * android_gl_server : Android demo port app. 26 | 27 | ## Demo Video (RPi original video) 28 | 29 | [Demo Video1](https://youtu.be/6S-Epb6m6mI) 30 | 31 | [Demo Video2](https://youtu.be/y0eRwrwetcA) 32 | 33 | ## Demo Video (Android port) 34 | 35 | [Demo Video](https://youtu.be/uwM9uxLHH1M) 36 | 37 | ## TODO implement 38 | - [x] glGetActiveUniform 39 | - [x] glGetError 40 | - [x] glGetIntegerv 41 | - [x] glGetFloatv 42 | - [x] glReadPixels (experimental) 43 | - [x] glGetProgramiv 44 | - [x] glGetShaderiv 45 | - [x] glGetString 46 | - [x] glTexSubImage2D 47 | 48 | ## Current status 49 | - `es2_info`, `es2gears` and `es2tri` will work. 50 | - GL4ES apps/games may work but in blank textures (will see in `glxdemo` and `glxheads`). 51 | 52 | ## Notes 53 | - Current minimum SDK level is set to 21 (Android 5) but it may work on older Android devices by some modifies. 54 | - Default port of server: 18145, client: 18146. 55 | 56 | ## Known issue (Android) 57 | - Some old devices: put app to background will make app lost EGL context (not show anything). 58 | 59 | ## Quick start 60 | - See [USAGE.md](USAGE.md) for more instruction. 61 | 62 | ### Server 63 | - Build android_gl_server use Android Studio or other similar to. 64 | - Install android_gl_server apk to Android device or AVD. 65 | - Run it. 66 | 67 | ### Client 68 | - copy the gl_client directory to any computer. 69 | 70 | ``cd gl_client`` 71 | 72 | ``make`` 73 | 74 | ``./sample1 -s 192.168.0.2:18145 -c 192.168.0.3:18146 -j /dev/input/js0`` 75 | 76 | ``./sample2 -s 192.168.0.2:18145 -c 192.168.0.3:18146 -j /dev/input/js0`` 77 | 78 | (Usage: ./sampleX [-c my_ip_address:port] [-s server_ip_address:port] [-j joystick_device]) 79 | 80 | ## License 81 | 82 | BSD 3-Clause license (except other's source code) 83 | 84 | about sample2 camel model: 85 | original model from http://opengameart.org/content/camel 86 | License:CC0 author: noway, sandsound 87 | (Thanks for sharing!) 88 | 89 | ## Bookmarks 90 | - [Parallella](http://www.parallella.org/) 91 | - [Raspberry Pi](http://www.raspberrypi.org/) 92 | 93 | ## Special Thanks 94 | 95 | Thank you very much for your interest and advices. 96 | 97 | - noway @opengameart.org / 98 | - sandsound @opengameart.org / 99 | - GClements @OpenGL forum / 100 | - The Little Body @OpenGL forum / 101 | - Stephen A @OpenGL forum / 102 | - over9000 @Parallella forum / 103 | - LamsonNguyen @Parallella forum / 104 | - Gravis @Parallella forum / 105 | - svartalf @Parallella forum / 106 | - Raspberry Pi Foundation / 107 | - Adapteva / 108 | 109 | (c) Shodruky Rhyammer 110 | 111 | since Oct 21, 2013 112 | -------------------------------------------------------------------------------- /USAGE.md: -------------------------------------------------------------------------------- 1 | # Setup streaming environment 2 | ## Server setup 3 | - Build Server app using Android Studio with NDK installed. 4 | - Install server APK. 5 | 6 | ## Client setup 7 | ``` 8 | cd /path/to/android-gl-streaming/gl_client 9 | 10 | # Make the client 11 | make 12 | 13 | # Install gl-streaming client 14 | make install 15 | 16 | # Copy GL4ES into (optional) 17 | cp /path/to/gl4es/lib/libGL.so.1 /usr/local/lib/gl-streaming 18 | 19 | # Override system libGLESv2.so.2, libEGL.so.1 and libGL.so.1 20 | export LD_LIBRARY_PATH=/usr/local/lib/gl-streaming:$LD_LIBRARY_PATH 21 | ``` 22 | 23 | # Launch streaming! 24 | ## Launch server 25 | - Do as title: Launch server. 26 | - Enter server port and client address, or leave empty for default values. 27 | 28 | ## Launch client 29 | - Test: run `es2_info, es2gears, es2tri, glxinfo, glxgears, glxdemo or glxheads` 30 | - Run an program requires OpenGL or OpenGL ES (many: Xvfb, x-window-manager, etc...). 31 | 32 | # Variables on compile 33 | ## Sever 34 | ### • GL_DEBUG 35 | - Enable debug log write to `/sdard/mthr_log.txt`. 36 | - Disabled by default. 37 | 38 | ## Client 39 | ### USE_X11 40 | - Enable support for X11 apps. 41 | - Enabled by default. 42 | - Sample side doesn't use X11 so not enabled. 43 | 44 | ### • GLS_USE_SRVSIZE 45 | - Use server window size instead of X Window size. 46 | - Disabled by default. 47 | - This is enabled if USE_X11 is not enabled. 48 | - May useful for fixing draw size bugs. 49 | 50 | ### • GLS_EMULATE_VBO 51 | - Try to emulate client arrays with VBO. 52 | - Enabled by default. 53 | - This is experimental, disable may make: 54 | + `es2tri` or some programs show blank screen. 55 | + `glxheads` show a rotating triange around surface instead of middle. 56 | + `glxgears` jump to invalid address and segmentation fault. 57 | 58 | # Environment variable on launch 59 | ## Server 60 | - Nothing yet. 61 | 62 | ## Client 63 | ### • GLS_DEBUG 64 | - Log executing/flushing command to the console. Disabled by default. 65 | - 0: Disable command logging (default). 66 | - 1: Enable command logging. 67 | 68 | ### • GLS_SERVER_ADDR 69 | - Set server IP address and port. 70 | - Default value: `127.0.0.1:18145`. 71 | 72 | -------------------------------------------------------------------------------- /android_gl_server/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 14 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /android_gl_server/jni/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | HERE_PATH := $(LOCAL_PATH) 3 | 4 | include $(HERE_PATH)/../../gl_server/Android.mk 5 | # include $(HERE_PATH)/../../gl_client/Android.mk 6 | 7 | LOCAL_PATH := $(HERE_PATH) 8 | include $(CLEAR_VARS) 9 | LOCAL_MODULE := glstreamserver 10 | LOCAL_LDLIBS := -lEGL -lGLESv2 -llog -landroid 11 | LOCAL_SRC_FILES := glstreaming_jni.cpp 12 | LOCAL_STATIC_LIBRARIES := libgl_server 13 | LOCAL_CFLAGS += -DGLS_SERVER 14 | ifeq ($(TARGET_ARCH_ABI),x86) 15 | LOCAL_CFLAGS += -ffast-math -mtune=atom -mssse3 -mfpmath=sse 16 | endif 17 | include $(BUILD_SHARED_LIBRARY) 18 | 19 | -------------------------------------------------------------------------------- /android_gl_server/jni/Application.mk: -------------------------------------------------------------------------------- 1 | NDK_TOOLCHAIN_VERSION := 4.9 2 | APP_STL := gnustl_static 3 | APP_PLATFORM := android-21 4 | APP_ABI := all 5 | # arm64-v8a 6 | -------------------------------------------------------------------------------- /android_gl_server/jni/glstreaming_jni.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include "main.h" 7 | #include "utils.h" 8 | 9 | bool need_init_glstream = true; 10 | 11 | extern "C" 12 | { 13 | JNIEXPORT void JNICALL Java_com_kdt_glstreamserver_GLStreamingJNIWrapper_initServer(JNIEnv* env, jobject thiz, jint serverPort, jstring clientAddr, jint clientPort) 14 | { 15 | var_server_port = serverPort; 16 | jstrclient_addr = clientAddr; 17 | var_client_port = clientPort; 18 | 19 | var_client_addr = env->GetStringUTFChars(jstrclient_addr, 0); 20 | /* 21 | var_path_shadercache = "/sdcard/games/.minecraft/shader_cache"; 22 | var_file_fragment_shader = "/sdcard/games/.minecraft/shader_cache/fragment_shader.glsl"; 23 | var_file_vertex_shader = "/sdcard/games/.minecraft/shader_cache/vertex_shader.glsl"; 24 | */ 25 | } 26 | 27 | JNIEXPORT void JNICALL Java_com_kdt_glstreamserver_GLStreamingJNIWrapper_setSurface(JNIEnv* env, jobject thiz, jobject surface) { 28 | glsurfaceview_window = ANativeWindow_fromSurface(env, surface); 29 | assert (glsurfaceview_window != NULL); 30 | } 31 | 32 | JNIEXPORT void JNICALL Java_com_kdt_glstreamserver_GLStreamingJNIWrapper_setGLSize(JNIEnv* env, jobject thiz, jint width, jint height) 33 | { 34 | // glmain_jnienv = env; 35 | 36 | glsurfaceview_width = width; 37 | glsurfaceview_height = height; 38 | } 39 | 40 | JNIEXPORT void JNICALL Java_com_kdt_glstreamserver_GLStreamingJNIWrapper_startServer(JNIEnv* env, jobject thiz) 41 | { 42 | /* 43 | glsurfaceview_width = 1280; 44 | glsurfaceview_height = 720; 45 | */ 46 | init_android_main(); 47 | env->ReleaseStringUTFChars(jstrclient_addr, var_client_addr); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /android_gl_server/libs/armeabi-v7a/gdb.setup: -------------------------------------------------------------------------------- 1 | set solib-search-path ./obj/local/armeabi-v7a 2 | directory /data/data/com.aide.ui/no_backup/ndksupport-1710240001/android-ndk-aide/platforms/android-21/arch-arm/usr/include jni/../../gl_server jni/../../gl_server/../common /data/data/com.aide.ui/no_backup/ndksupport-1710240001/android-ndk-aide/sources/cxx-stl/gnu-libstdc++/4.9/include /data/data/com.aide.ui/no_backup/ndksupport-1710240001/android-ndk-aide/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/include /data/data/com.aide.ui/no_backup/ndksupport-1710240001/android-ndk-aide/sources/cxx-stl/gnu-libstdc++/4.9/include/backward 3 | -------------------------------------------------------------------------------- /android_gl_server/libs/armeabi-v7a/gdbserver: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanhduytran0/android-gl-streaming/b4895522e210f38a4b5ddc93f34ff05e4533e47a/android_gl_server/libs/armeabi-v7a/gdbserver -------------------------------------------------------------------------------- /android_gl_server/libs/armeabi/gdb.setup: -------------------------------------------------------------------------------- 1 | set solib-search-path ./obj/local/armeabi 2 | directory /data/data/com.aide.ui/no_backup/ndksupport-1710240001/android-ndk-aide/platforms/android-21/arch-arm/usr/include jni/../../gl_server jni/../../gl_server/../common /data/data/com.aide.ui/no_backup/ndksupport-1710240001/android-ndk-aide/sources/cxx-stl/gnu-libstdc++/4.9/include /data/data/com.aide.ui/no_backup/ndksupport-1710240001/android-ndk-aide/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi/include /data/data/com.aide.ui/no_backup/ndksupport-1710240001/android-ndk-aide/sources/cxx-stl/gnu-libstdc++/4.9/include/backward 3 | -------------------------------------------------------------------------------- /android_gl_server/libs/armeabi/gdbserver: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanhduytran0/android-gl-streaming/b4895522e210f38a4b5ddc93f34ff05e4533e47a/android_gl_server/libs/armeabi/gdbserver -------------------------------------------------------------------------------- /android_gl_server/libs/x86/gdb.setup: -------------------------------------------------------------------------------- 1 | set solib-search-path ./obj/local/x86 2 | directory /data/data/com.aide.ui/no_backup/ndksupport-1710240001/android-ndk-aide/platforms/android-21/arch-x86/usr/include jni/../../gl_server jni/../../gl_server/../common /data/data/com.aide.ui/no_backup/ndksupport-1710240001/android-ndk-aide/sources/cxx-stl/gnu-libstdc++/4.9/include /data/data/com.aide.ui/no_backup/ndksupport-1710240001/android-ndk-aide/sources/cxx-stl/gnu-libstdc++/4.9/libs/x86/include /data/data/com.aide.ui/no_backup/ndksupport-1710240001/android-ndk-aide/sources/cxx-stl/gnu-libstdc++/4.9/include/backward 3 | -------------------------------------------------------------------------------- /android_gl_server/libs/x86/gdbserver: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanhduytran0/android-gl-streaming/b4895522e210f38a4b5ddc93f34ff05e4533e47a/android_gl_server/libs/x86/gdbserver -------------------------------------------------------------------------------- /android_gl_server/project.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system use, 7 | # "build.properties", and override values to adapt the script to your 8 | # project structure. 9 | 10 | # Project target. 11 | target=android-29 12 | -------------------------------------------------------------------------------- /android_gl_server/res/layout/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 12 | 13 | 19 | 20 | 24 | 25 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /android_gl_server/res/layout/main.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 11 | 12 | 19 | 20 | 25 | 26 |