├── settings.gradle ├── .gitignore ├── README.md ├── app ├── src │ └── main │ │ ├── res │ │ ├── mipmap-hdpi │ │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ │ └── ic_launcher.png │ │ └── values │ │ │ └── strings.xml │ │ ├── cpp │ │ ├── imGui │ │ │ ├── Crossplatform.h │ │ │ ├── imgui_impl_android_gl2.h │ │ │ ├── imconfig.h │ │ │ ├── ArgDefines.h │ │ │ ├── imgui_impl_android_gl2.cpp │ │ │ ├── stb_rect_pack.h │ │ │ └── FmtConversion.h │ │ ├── CMakeLists.txt │ │ ├── gles3jni.h │ │ ├── RendererES2.cpp │ │ ├── RendererES3.cpp │ │ ├── gles3jni.cpp │ │ ├── gl3stub.c │ │ └── gl3stub.h │ │ ├── java │ │ └── com │ │ │ └── android │ │ │ └── gles3jni │ │ │ ├── GLES3JNILib.java │ │ │ ├── GLES3JNIActivity.java │ │ │ └── GLES3JNIView.java │ │ └── AndroidManifest.xml ├── build.gradle └── app.iml ├── local.properties ├── gles3jni.iml ├── gradlew.bat ├── gradlew └── LICENSE /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .gradle/ 2 | .idea/ 3 | .google/ 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ImGUIAndroid 2 | ImGui Sample on Android GLESv3.0 3 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/braviel/ImGUIAndroid/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/braviel/ImGUIAndroid/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/braviel/ImGUIAndroid/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/braviel/ImGUIAndroid/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/cpp/imGui/Crossplatform.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 Qualcomm Technologies, Inc. 2 | // Some functions to convert between formats. 3 | 4 | #ifndef _ACG_CROSSPLATFORM_H_ 5 | #define _ACG_CROSSPLATFORM_H_ 6 | 7 | #define LINUX defined(__linux__) 8 | #define OSX defined(__APPLE__) 9 | #define LINUX_OR_OSX OSX || LINUX 10 | 11 | #endif // _CROSSPLATFORM_H_ 12 | 13 | -------------------------------------------------------------------------------- /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 | #Fri Apr 27 15:04:48 ICT 2018 8 | ndk.dir=/Users/nghiahoang/Library/Android/sdk/ndk-bundle 9 | sdk.dir=/Users/nghiahoang/Library/Android/sdk 10 | -------------------------------------------------------------------------------- /gles3jni.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | def platformVersion = 24 // openGLES 3.2 min api level 4 | // def platformVersion = 18 //openGLES 3 min api level 5 | // def platformVersion = 12 //openGLES 2 min api level 6 | 7 | android { 8 | compileSdkVersion 25 9 | 10 | defaultConfig { 11 | applicationId 'com.android.gles3jni' 12 | minSdkVersion "${platformVersion}" 13 | targetSdkVersion 25 14 | externalNativeBuild { 15 | cmake { 16 | arguments '-DANDROID_STL=c++_static' 17 | } 18 | } 19 | } 20 | buildTypes { 21 | release { 22 | minifyEnabled = false 23 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 24 | 'proguard-rules.pro' 25 | } 26 | } 27 | externalNativeBuild { 28 | cmake { 29 | path 'src/main/cpp/CMakeLists.txt' 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 19 | 20 | 21 | 22 | GLES3JNI 23 | 24 | 25 | -------------------------------------------------------------------------------- /app/src/main/java/com/android/gles3jni/GLES3JNILib.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 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 compliance 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 | package com.android.gles3jni; 18 | 19 | // Wrapper for native library 20 | 21 | public class GLES3JNILib { 22 | 23 | static { 24 | System.loadLibrary("gles3jni"); 25 | } 26 | 27 | public static native void init(); 28 | public static native void resize(int width, int height); 29 | public static native void step(); 30 | } 31 | -------------------------------------------------------------------------------- /app/src/main/java/com/android/gles3jni/GLES3JNIActivity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 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 compliance 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 | package com.android.gles3jni; 18 | 19 | import android.app.Activity; 20 | import android.os.Bundle; 21 | import android.util.Log; 22 | import android.view.WindowManager; 23 | 24 | import java.io.File; 25 | 26 | public class GLES3JNIActivity extends Activity { 27 | 28 | GLES3JNIView mView; 29 | 30 | @Override protected void onCreate(Bundle icicle) { 31 | super.onCreate(icicle); 32 | mView = new GLES3JNIView(getApplication()); 33 | setContentView(mView); 34 | } 35 | 36 | @Override protected void onPause() { 37 | super.onPause(); 38 | mView.onPause(); 39 | } 40 | 41 | @Override protected void onResume() { 42 | super.onResume(); 43 | mView.onResume(); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 19 | 20 | 25 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /app/src/main/cpp/imGui/imgui_impl_android_gl2.h: -------------------------------------------------------------------------------- 1 | // ImGui GLFW binding with OpenGL3 + shaders 2 | // In this binding, ImTextureID is used to store an OpenGL 'GLuint' texture identifier. Read the FAQ about ImTextureID in imgui.cpp. 3 | 4 | // You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this. 5 | // If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown(). 6 | // If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp. 7 | // https://github.com/ocornut/imgui 8 | 9 | //struct GLFWwindow; 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | IMGUI_API bool ImGui_ImplAndroidGL3_Init(); 16 | IMGUI_API void ImGui_ImplAndroidGL3_Shutdown(); 17 | IMGUI_API void ImGui_ImplAndroidGL3_NewFrame(float time, ImVec2 mousePos, bool down); 18 | 19 | // Use if you want to reset your rendering device without losing ImGui state. 20 | IMGUI_API void ImGui_ImplAndroidGL3_InvalidateDeviceObjects(); 21 | IMGUI_API bool ImGui_ImplAndroidGL3_CreateDeviceObjects(); 22 | 23 | // GLFW callbacks (installed by default if you enable 'install_callbacks' during initialization) 24 | // Provided here if you want to chain callbacks. 25 | // You can also handle inputs yourself and use those as a reference. 26 | IMGUI_API void ImGui_ImplAndroidGL3_MouseButtonCallback(int button, int action, int mods); 27 | //IMGUI_API void ImGui_ImplGlfwGL3_ScrollCallback(GLFWwindow* window, double xoffset, double yoffset); 28 | //IMGUI_API void ImGui_ImplGlfwGL3_KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods); 29 | //IMGUI_API void ImGui_ImplGlfwGL3_CharCallback(GLFWwindow* window, unsigned int c); 30 | -------------------------------------------------------------------------------- /app/src/main/java/com/android/gles3jni/GLES3JNIView.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 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 compliance 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 | package com.android.gles3jni; 18 | 19 | import android.content.Context; 20 | import android.graphics.PixelFormat; 21 | import android.opengl.GLSurfaceView; 22 | import android.util.AttributeSet; 23 | import android.util.Log; 24 | import android.view.KeyEvent; 25 | import android.view.MotionEvent; 26 | 27 | import javax.microedition.khronos.egl.EGL10; 28 | import javax.microedition.khronos.egl.EGLConfig; 29 | import javax.microedition.khronos.egl.EGLContext; 30 | import javax.microedition.khronos.egl.EGLDisplay; 31 | import javax.microedition.khronos.opengles.GL10; 32 | 33 | class GLES3JNIView extends GLSurfaceView { 34 | private static final String TAG = "GLES3JNI"; 35 | private static final boolean DEBUG = true; 36 | 37 | public GLES3JNIView(Context context) { 38 | super(context); 39 | // Pick an EGLConfig with RGB8 color, 16-bit depth, no stencil, 40 | // supporting OpenGL ES 2.0 or later backwards-compatible versions. 41 | setEGLConfigChooser(8, 8, 8, 0, 16, 0); 42 | setEGLContextClientVersion(3); 43 | setRenderer(new Renderer()); 44 | } 45 | 46 | private static class Renderer implements GLSurfaceView.Renderer { 47 | public void onDrawFrame(GL10 gl) { 48 | GLES3JNILib.step(); 49 | } 50 | 51 | public void onSurfaceChanged(GL10 gl, int width, int height) { 52 | GLES3JNILib.resize(width, height); 53 | } 54 | 55 | public void onSurfaceCreated(GL10 gl, EGLConfig config) { 56 | GLES3JNILib.init(); 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /app/src/main/cpp/imGui/imconfig.h: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // USER IMPLEMENTATION 3 | // This file contains compile-time options for ImGui. 4 | // Other options (memory allocation overrides, callbacks, etc.) can be set at runtime via the ImGuiIO structure - ImGui::GetIO(). 5 | //----------------------------------------------------------------------------- 6 | 7 | #pragma once 8 | 9 | //---- Define assertion handler. Defaults to calling assert(). 10 | //#define IM_ASSERT(_EXPR) MyAssert(_EXPR) 11 | 12 | //---- Define attributes of all API symbols declarations, e.g. for DLL under Windows. 13 | //#define IMGUI_API __declspec( dllexport ) 14 | //#define IMGUI_API __declspec( dllimport ) 15 | 16 | //---- Include imgui_user.h at the end of imgui.h 17 | //#define IMGUI_INCLUDE_IMGUI_USER_H 18 | 19 | //---- Don't implement default handlers for Windows (so as not to link with OpenClipboard() and others Win32 functions) 20 | //#define IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCS 21 | //#define IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCS 22 | 23 | //---- Don't implement help and test window functionality (ShowUserGuide()/ShowStyleEditor()/ShowTestWindow() methods will be empty) 24 | //#define IMGUI_DISABLE_TEST_WINDOWS 25 | 26 | //---- Don't define obsolete functions names 27 | //#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS 28 | 29 | //---- Implement STB libraries in a namespace to avoid conflicts 30 | //#define IMGUI_STB_NAMESPACE ImGuiStb 31 | 32 | //---- Define constructor and implicit cast operators to convert back<>forth from your math types and ImVec2/ImVec4. 33 | /* 34 | #define IM_VEC2_CLASS_EXTRA \ 35 | ImVec2(const MyVec2& f) { x = f.x; y = f.y; } \ 36 | operator MyVec2() const { return MyVec2(x,y); } 37 | 38 | #define IM_VEC4_CLASS_EXTRA \ 39 | ImVec4(const MyVec4& f) { x = f.x; y = f.y; z = f.z; w = f.w; } \ 40 | operator MyVec4() const { return MyVec4(x,y,z,w); } 41 | */ 42 | 43 | //---- Tip: You can add extra functions within the ImGui:: namespace, here or in your own headers files. 44 | //---- e.g. create variants of the ImGui::Value() helper for your low-level math types, or your own widgets/helpers. 45 | /* 46 | namespace ImGui 47 | { 48 | void Value(const char* prefix, const MyMatrix44& v, const char* float_format = NULL); 49 | } 50 | */ 51 | 52 | -------------------------------------------------------------------------------- /app/src/main/cpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.4.1) 2 | # set targetPlatform, will be passed in from gradle when this sample is completed 3 | # openGL Supportability 4 | # platform status 5 | # (0 12) ES2/ES3 not supported 6 | # [12, 18) ES2 only; for ES3, app do dynamic load/detection 7 | # this applies to the situations that: 8 | # - minimum API is set to less than 18. In this case 9 | # there is no ES3 header/lib support inside NDK 10 | # - the built APK might be running on newer API phones 11 | # with dynamic loading of ES3, the same APK would still be able 12 | # to use ES3. Otherwise, app would stuck with ES2 even phone is 13 | # is newer than the minimum API level (for example, Android-27 etc). 14 | # 15 | # [18, 24) ES2 & ES3 16 | # If app is built to only support API-18 or later, 17 | # set minimum api level to 18 is good enough, NDK supprts ES3 18 | # with the right header and lib files. No need to use ES3 dynamic 19 | # detection. 20 | # [24, infinite) ES2 & ES3 & Vulkan 21 | 22 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall") 23 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fno-rtti -fno-exceptions -Wall") 24 | if (${ANDROID_PLATFORM_LEVEL} LESS 12) 25 | message(FATAL_ERROR "OpenGL 2 is not supported before API level 11 \ 26 | (currently using ${ANDROID_PLATFORM_LEVEL}).") 27 | return() 28 | elseif (${ANDROID_PLATFORM_LEVEL} LESS 18) 29 | add_definitions("-DDYNAMIC_ES3") 30 | set(GL3STUB_SRC gl3stub.c) 31 | set(OPENGL_LIB GLESv2) 32 | else () 33 | set(OPENGL_LIB GLESv3) 34 | endif (${ANDROID_PLATFORM_LEVEL} LESS 12) 35 | # 36 | # ImGui lib 37 | # 38 | add_library(imGui SHARED 39 | ./imGui/imgui.cpp 40 | ./imGui/imgui_draw.cpp 41 | ./imGui/imgui_demo.cpp 42 | ./imGui/imgui_impl_android_gl2.cpp 43 | ) 44 | target_include_directories(imGui PRIVATE 45 | ./imGui) 46 | # 47 | # native entry lib 48 | # 49 | add_library(gles3jni SHARED 50 | ${GL3STUB_SRC} 51 | gles3jni.cpp 52 | RendererES2.cpp 53 | RendererES3.cpp) 54 | target_include_directories(gles3jni PRIVATE 55 | ./imGui 56 | ) 57 | # Include libraries needed for gles3jni lib 58 | target_link_libraries(imGui 59 | android 60 | EGL 61 | GLESv3 62 | log) 63 | 64 | target_link_libraries(gles3jni 65 | imGui 66 | ${OPENGL_LIB} 67 | android 68 | EGL 69 | log 70 | m) 71 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /app/src/main/cpp/imGui/ArgDefines.h: -------------------------------------------------------------------------------- 1 | 2 | //================================================================================================================================= 3 | // Copyright (c) 2013 Qualcomm Technologies, Inc. All rights reserved. 4 | //================================================================================================================================= 5 | // Standard types 6 | 7 | #ifndef _ARGDEFINES_H_ 8 | #define _ARGDEFINES_H_ 9 | 10 | 11 | #include "Crossplatform.h" 12 | 13 | #if defined( _WIN32 ) || defined( _WIN64 ) 14 | typedef char char8; 15 | typedef char int8; 16 | typedef short int16; 17 | typedef int int32; 18 | typedef __int64 int64; 19 | typedef float float32; 20 | typedef double float64; 21 | typedef unsigned char uint8; 22 | typedef unsigned short uint16; 23 | typedef unsigned int uint32; 24 | typedef unsigned __int64 uint64; 25 | #elif defined(LINUX_OR_OSX) 26 | 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | typedef char char8; 34 | typedef char int8; 35 | typedef short int16; 36 | typedef int int32; 37 | typedef int64_t int64; 38 | typedef float float32; 39 | typedef double float64; 40 | typedef unsigned char uint8; 41 | typedef unsigned short uint16; 42 | typedef unsigned int uint32; 43 | typedef uint64_t uint64; 44 | 45 | #endif 46 | 47 | //-------------------------------------------------------------------------------------- 48 | // Common types 49 | //-------------------------------------------------------------------------------------- 50 | typedef unsigned char BYTE; 51 | 52 | typedef char CHAR; 53 | typedef char CHAR8; 54 | typedef unsigned char UCHAR; 55 | typedef unsigned char UCHAR8; 56 | 57 | typedef wchar_t WCHAR; 58 | typedef unsigned short UCHAR16; 59 | 60 | typedef signed char INT8; 61 | typedef signed short INT16; 62 | typedef signed int INT32; 63 | typedef unsigned char UINT8; 64 | typedef unsigned short UINT16; 65 | typedef unsigned int UINT32; 66 | 67 | typedef float FLOAT; 68 | typedef float FLOAT32; 69 | typedef double FLOAT64; 70 | 71 | typedef int BOOL; 72 | 73 | typedef unsigned short WORD; 74 | typedef unsigned long DWORD; 75 | 76 | #ifndef VOID 77 | #define VOID void 78 | #endif 79 | 80 | #ifndef TRUE 81 | #define TRUE 1 82 | #endif 83 | 84 | #ifndef FALSE 85 | #define FALSE 0 86 | #endif 87 | 88 | #ifndef NULL 89 | #define NULL 0 90 | #endif 91 | 92 | const UINT32 NATIVE_APP_WIDTH = 480; 93 | const UINT32 NATIVE_APP_HEIGHT = 765; 94 | 95 | #define SAFE_DELETE(p) if ((p) != NULL) delete (p); (p) = NULL; 96 | #define SAFE_FREE(p) if ((p) != NULL) free(p); (p) = NULL; 97 | 98 | 99 | 100 | #endif // _ARGDEFINES_H_ 101 | 102 | -------------------------------------------------------------------------------- /app/src/main/cpp/gles3jni.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 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 compliance 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 | #ifndef GLES3JNI_H 18 | #define GLES3JNI_H 1 19 | 20 | #include 21 | #include 22 | 23 | #if DYNAMIC_ES3 24 | #include "gl3stub.h" 25 | #else 26 | // Include the latest possible header file( GL version header ) 27 | #if __ANDROID_API__ >= 24 28 | #include 29 | #elif __ANDROID_API__ >= 21 30 | #include 31 | #else 32 | #include 33 | #endif 34 | 35 | #endif 36 | 37 | #define DEBUG 1 38 | 39 | #define LOG_TAG "GLES3JNI" 40 | #define ALOGE(...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__) 41 | #if DEBUG 42 | #define ALOGV(...) __android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__) 43 | #else 44 | #define ALOGV(...) 45 | #endif 46 | 47 | // ---------------------------------------------------------------------------- 48 | // Types, functions, and data used by both ES2 and ES3 renderers. 49 | // Defined in gles3jni.cpp. 50 | 51 | #define MAX_INSTANCES_PER_SIDE 16 52 | #define MAX_INSTANCES (MAX_INSTANCES_PER_SIDE * MAX_INSTANCES_PER_SIDE) 53 | #define TWO_PI (2.0 * M_PI) 54 | #define MAX_ROT_SPEED (0.3 * TWO_PI) 55 | 56 | // This demo uses three coordinate spaces: 57 | // - The model (a quad) is in a [-1 .. 1]^2 space 58 | // - Scene space is either 59 | // landscape: [-1 .. 1] x [-1/(2*w/h) .. 1/(2*w/h)] 60 | // portrait: [-1/(2*h/w) .. 1/(2*h/w)] x [-1 .. 1] 61 | // - Clip space in OpenGL is [-1 .. 1]^2 62 | // 63 | // Conceptually, the quads are rotated in model space, then scaled (uniformly) 64 | // and translated to place them in scene space. Scene space is then 65 | // non-uniformly scaled to clip space. In practice the transforms are combined 66 | // so vertices go directly from model to clip space. 67 | 68 | struct Vertex { 69 | GLfloat pos[2]; 70 | GLubyte rgba[4]; 71 | }; 72 | extern const Vertex QUAD[4]; 73 | 74 | // returns true if a GL error occurred 75 | extern bool checkGlError(const char* funcName); 76 | extern GLuint createShader(GLenum shaderType, const char* src); 77 | extern GLuint createProgram(const char* vtxSrc, const char* fragSrc); 78 | 79 | // ---------------------------------------------------------------------------- 80 | // Interface to the ES2 and ES3 renderers, used by JNI code. 81 | 82 | class Renderer { 83 | public: 84 | virtual ~Renderer(); 85 | void resize(int w, int h); 86 | void render(); 87 | float t[3] = { 0,0,0 }; 88 | bool b1 = false, b2 = false, b3 = false; 89 | int i = 0; 90 | protected: 91 | Renderer(); 92 | 93 | // return a pointer to a buffer of MAX_INSTANCES * sizeof(vec2). 94 | // the buffer is filled with per-instance offsets, then unmapped. 95 | virtual float* mapOffsetBuf() = 0; 96 | virtual void unmapOffsetBuf() = 0; 97 | // return a pointer to a buffer of MAX_INSTANCES * sizeof(vec4). 98 | // the buffer is filled with per-instance scale and rotation transforms. 99 | virtual float* mapTransformBuf() = 0; 100 | virtual void unmapTransformBuf() = 0; 101 | 102 | virtual void draw(unsigned int numInstances) = 0; 103 | 104 | private: 105 | void calcSceneParams(unsigned int w, unsigned int h, float* offsets); 106 | void step(); 107 | 108 | unsigned int mNumInstances; 109 | float mScale[2]; 110 | float mAngularVelocity[MAX_INSTANCES]; 111 | uint64_t mLastFrameNs; 112 | float mAngles[MAX_INSTANCES]; 113 | }; 114 | 115 | extern Renderer* createES2Renderer(); 116 | extern Renderer* createES3Renderer(); 117 | 118 | #endif // GLES3JNI_H 119 | -------------------------------------------------------------------------------- /app/src/main/cpp/RendererES2.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 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 compliance 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 | #include "gles3jni.h" 18 | #include 19 | #include "imgui.h" 20 | #include "imgui_impl_android_gl2.h" 21 | #include "imGui/imgui.h" 22 | #include "imGui/imgui_impl_android_gl2.h" 23 | 24 | static const char VERTEX_SHADER[] = 25 | "#version 100\n" 26 | "uniform mat2 scaleRot;\n" 27 | "uniform vec2 offset;\n" 28 | "attribute vec2 pos;\n" 29 | "attribute vec4 color;\n" 30 | "varying vec4 vColor;\n" 31 | "void main() {\n" 32 | " gl_Position = vec4(scaleRot*pos + offset, 0.0, 1.0);\n" 33 | " vColor = color;\n" 34 | "}\n"; 35 | 36 | static const char FRAGMENT_SHADER[] = 37 | "#version 100\n" 38 | "precision mediump float;\n" 39 | "varying vec4 vColor;\n" 40 | "void main() {\n" 41 | " gl_FragColor = vColor;\n" 42 | "}\n"; 43 | 44 | class RendererES2: public Renderer { 45 | public: 46 | RendererES2(); 47 | virtual ~RendererES2(); 48 | bool init(); 49 | 50 | private: 51 | virtual float* mapOffsetBuf(); 52 | virtual void unmapOffsetBuf(); 53 | virtual float* mapTransformBuf(); 54 | virtual void unmapTransformBuf(); 55 | virtual void draw(unsigned int numInstances); 56 | 57 | const EGLContext mEglContext; 58 | GLuint mProgram; 59 | GLuint mVB; 60 | GLint mPosAttrib; 61 | GLint mColorAttrib; 62 | GLint mScaleRotUniform; 63 | GLint mOffsetUniform; 64 | 65 | float mOffsets[2*MAX_INSTANCES]; 66 | float mScaleRot[4*MAX_INSTANCES]; // array of 2x2 column-major matrices 67 | }; 68 | 69 | Renderer* createES2Renderer() { 70 | RendererES2* renderer = new RendererES2; 71 | if (!renderer->init()) { 72 | delete renderer; 73 | return NULL; 74 | } 75 | return renderer; 76 | } 77 | 78 | RendererES2::RendererES2() 79 | : mEglContext(eglGetCurrentContext()), 80 | mProgram(0), 81 | mVB(0), 82 | mPosAttrib(-1), 83 | mColorAttrib(-1), 84 | mScaleRotUniform(-1), 85 | mOffsetUniform(-1) 86 | {} 87 | 88 | bool RendererES2::init() { 89 | mProgram = createProgram(VERTEX_SHADER, FRAGMENT_SHADER); 90 | if (!mProgram) 91 | return false; 92 | mPosAttrib = glGetAttribLocation(mProgram, "pos"); 93 | mColorAttrib = glGetAttribLocation(mProgram, "color"); 94 | mScaleRotUniform = glGetUniformLocation(mProgram, "scaleRot"); 95 | mOffsetUniform = glGetUniformLocation(mProgram, "offset"); 96 | 97 | glGenBuffers(1, &mVB); 98 | glBindBuffer(GL_ARRAY_BUFFER, mVB); 99 | glBufferData(GL_ARRAY_BUFFER, sizeof(QUAD), &QUAD[0], GL_STATIC_DRAW); 100 | 101 | ALOGV("Using OpenGL ES 2.0 renderer"); 102 | ImGui_ImplAndroidGL3_Init(); 103 | return true; 104 | } 105 | 106 | RendererES2::~RendererES2() { 107 | /* The destructor may be called after the context has already been 108 | * destroyed, in which case our objects have already been destroyed. 109 | * 110 | * If the context exists, it must be current. This only happens when we're 111 | * cleaning up after a failed init(). 112 | */ 113 | ImGui_ImplAndroidGL3_Shutdown(); 114 | if (eglGetCurrentContext() != mEglContext) 115 | return; 116 | glDeleteBuffers(1, &mVB); 117 | glDeleteProgram(mProgram); 118 | } 119 | 120 | float* RendererES2::mapOffsetBuf() { 121 | return mOffsets; 122 | } 123 | 124 | void RendererES2::unmapOffsetBuf() { 125 | } 126 | 127 | float* RendererES2::mapTransformBuf() { 128 | return mScaleRot; 129 | } 130 | 131 | void RendererES2::unmapTransformBuf() { 132 | } 133 | 134 | //float t[3] = { 0,0,0 }; 135 | //bool b1 = false, b2 = false, b3 = false; 136 | //int i = 0; 137 | 138 | void RendererES2::draw(unsigned int numInstances) { 139 | glUseProgram(mProgram); 140 | 141 | glBindBuffer(GL_ARRAY_BUFFER, mVB); 142 | glVertexAttribPointer(mPosAttrib, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), (const GLvoid*)offsetof(Vertex, pos)); 143 | glVertexAttribPointer(mColorAttrib, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(Vertex), (const GLvoid*)offsetof(Vertex, rgba)); 144 | glEnableVertexAttribArray(mPosAttrib); 145 | glEnableVertexAttribArray(mColorAttrib); 146 | 147 | for (unsigned int i = 0; i < numInstances; i++) { 148 | glUniformMatrix2fv(mScaleRotUniform, 1, GL_FALSE, mScaleRot + 4*i); 149 | glUniform2fv(mOffsetUniform, 1, mOffsets + 2*i); 150 | glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); 151 | } 152 | ImGui::Begin("Test"); 153 | ImGui::SetWindowFontScale(3.0f); 154 | ImGui::Button("button", ImVec2(300, 75)); 155 | ImGui::Button("button2", ImVec2(300, 75)); 156 | 157 | ImGui::DragFloat3("LightDir", &t[0], 0.05); 158 | 159 | ImGui::Checkbox("Show ShadowMap", &b1); 160 | ImGui::Checkbox("Linear Depth", &b2); 161 | ImGui::Checkbox("UseAutoCamera", &b3); 162 | 163 | const char* SamplePatterns[] = { "POISSON_25_25", "POISSON_32_64", "POISSON_100_100", "POISSON_64_128", "REGULAR_49_225" }; 164 | ImGui::ListBox("SamplePattern", &i, SamplePatterns, 5); 165 | ImGui::End(); 166 | ImGui::Render(); 167 | } 168 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /app/src/main/cpp/RendererES3.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 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 compliance 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 | #include "gles3jni.h" 18 | #include 19 | #include "imGui/imgui.h" 20 | #include "imGui/imgui_impl_android_gl2.h" 21 | 22 | #define STR(s) #s 23 | #define STRV(s) STR(s) 24 | 25 | #define POS_ATTRIB 0 26 | #define COLOR_ATTRIB 1 27 | #define SCALEROT_ATTRIB 2 28 | #define OFFSET_ATTRIB 3 29 | 30 | static const char VERTEX_SHADER[] = 31 | "#version 300 es\n" 32 | "layout(location = " STRV(POS_ATTRIB) ") in vec2 pos;\n" 33 | "layout(location=" STRV(COLOR_ATTRIB) ") in vec4 color;\n" 34 | "layout(location=" STRV(SCALEROT_ATTRIB) ") in vec4 scaleRot;\n" 35 | "layout(location=" STRV(OFFSET_ATTRIB) ") in vec2 offset;\n" 36 | "out vec4 vColor;\n" 37 | "void main() {\n" 38 | " mat2 sr = mat2(scaleRot.xy, scaleRot.zw);\n" 39 | " gl_Position = vec4(sr*pos + offset, 0.0, 1.0);\n" 40 | " vColor = color;\n" 41 | "}\n"; 42 | 43 | static const char FRAGMENT_SHADER[] = 44 | "#version 300 es\n" 45 | "precision mediump float;\n" 46 | "in vec4 vColor;\n" 47 | "out vec4 outColor;\n" 48 | "void main() {\n" 49 | " outColor = vColor;\n" 50 | "}\n"; 51 | 52 | class RendererES3: public Renderer { 53 | public: 54 | RendererES3(); 55 | virtual ~RendererES3(); 56 | bool init(); 57 | 58 | private: 59 | enum {VB_INSTANCE, VB_SCALEROT, VB_OFFSET, VB_COUNT}; 60 | 61 | virtual float* mapOffsetBuf(); 62 | virtual void unmapOffsetBuf(); 63 | virtual float* mapTransformBuf(); 64 | virtual void unmapTransformBuf(); 65 | virtual void draw(unsigned int numInstances); 66 | 67 | const EGLContext mEglContext; 68 | GLuint mProgram; 69 | GLuint mVB[VB_COUNT]; 70 | GLuint mVBState; 71 | }; 72 | 73 | Renderer* createES3Renderer() { 74 | RendererES3* renderer = new RendererES3; 75 | if (!renderer->init()) { 76 | delete renderer; 77 | return NULL; 78 | } 79 | return renderer; 80 | } 81 | 82 | RendererES3::RendererES3() 83 | : mEglContext(eglGetCurrentContext()), 84 | mProgram(0), 85 | mVBState(0) 86 | { 87 | for (int i = 0; i < VB_COUNT; i++) 88 | mVB[i] = 0; 89 | } 90 | 91 | bool RendererES3::init() { 92 | mProgram = createProgram(VERTEX_SHADER, FRAGMENT_SHADER); 93 | if (!mProgram) 94 | return false; 95 | 96 | glGenBuffers(VB_COUNT, mVB); 97 | glBindBuffer(GL_ARRAY_BUFFER, mVB[VB_INSTANCE]); 98 | glBufferData(GL_ARRAY_BUFFER, sizeof(QUAD), &QUAD[0], GL_STATIC_DRAW); 99 | glBindBuffer(GL_ARRAY_BUFFER, mVB[VB_SCALEROT]); 100 | glBufferData(GL_ARRAY_BUFFER, MAX_INSTANCES * 4*sizeof(float), NULL, GL_DYNAMIC_DRAW); 101 | glBindBuffer(GL_ARRAY_BUFFER, mVB[VB_OFFSET]); 102 | glBufferData(GL_ARRAY_BUFFER, MAX_INSTANCES * 2*sizeof(float), NULL, GL_STATIC_DRAW); 103 | 104 | glGenVertexArrays(1, &mVBState); 105 | glBindVertexArray(mVBState); 106 | 107 | glBindBuffer(GL_ARRAY_BUFFER, mVB[VB_INSTANCE]); 108 | glVertexAttribPointer(POS_ATTRIB, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), (const GLvoid*)offsetof(Vertex, pos)); 109 | glVertexAttribPointer(COLOR_ATTRIB, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(Vertex), (const GLvoid*)offsetof(Vertex, rgba)); 110 | glEnableVertexAttribArray(POS_ATTRIB); 111 | glEnableVertexAttribArray(COLOR_ATTRIB); 112 | 113 | glBindBuffer(GL_ARRAY_BUFFER, mVB[VB_SCALEROT]); 114 | glVertexAttribPointer(SCALEROT_ATTRIB, 4, GL_FLOAT, GL_FALSE, 4*sizeof(float), 0); 115 | glEnableVertexAttribArray(SCALEROT_ATTRIB); 116 | glVertexAttribDivisor(SCALEROT_ATTRIB, 1); 117 | 118 | glBindBuffer(GL_ARRAY_BUFFER, mVB[VB_OFFSET]); 119 | glVertexAttribPointer(OFFSET_ATTRIB, 2, GL_FLOAT, GL_FALSE, 2*sizeof(float), 0); 120 | glEnableVertexAttribArray(OFFSET_ATTRIB); 121 | glVertexAttribDivisor(OFFSET_ATTRIB, 1); 122 | 123 | ALOGV("Using OpenGL ES 3.0 renderer"); 124 | ImGui_ImplAndroidGL3_Init(); 125 | return true; 126 | } 127 | 128 | RendererES3::~RendererES3() { 129 | /* The destructor may be called after the context has already been 130 | * destroyed, in which case our objects have already been destroyed. 131 | * 132 | * If the context exists, it must be current. This only happens when we're 133 | * cleaning up after a failed init(). 134 | */ 135 | if (eglGetCurrentContext() != mEglContext) 136 | return; 137 | ImGui_ImplAndroidGL3_Shutdown(); 138 | glDeleteVertexArrays(1, &mVBState); 139 | glDeleteBuffers(VB_COUNT, mVB); 140 | glDeleteProgram(mProgram); 141 | } 142 | 143 | float* RendererES3::mapOffsetBuf() { 144 | glBindBuffer(GL_ARRAY_BUFFER, mVB[VB_OFFSET]); 145 | return (float*)glMapBufferRange(GL_ARRAY_BUFFER, 146 | 0, MAX_INSTANCES * 2*sizeof(float), 147 | GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT); 148 | } 149 | 150 | void RendererES3::unmapOffsetBuf() { 151 | glUnmapBuffer(GL_ARRAY_BUFFER); 152 | } 153 | 154 | float* RendererES3::mapTransformBuf() { 155 | glBindBuffer(GL_ARRAY_BUFFER, mVB[VB_SCALEROT]); 156 | return (float*)glMapBufferRange(GL_ARRAY_BUFFER, 157 | 0, MAX_INSTANCES * 4*sizeof(float), 158 | GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT); 159 | } 160 | 161 | void RendererES3::unmapTransformBuf() { 162 | glUnmapBuffer(GL_ARRAY_BUFFER); 163 | } 164 | //float t[3] = { 0,0,0 }; 165 | //bool b1 = false, b2 = false, b3 = false; 166 | //int i = 0; 167 | void RendererES3::draw(unsigned int numInstances) { 168 | glUseProgram(mProgram); 169 | glBindVertexArray(mVBState); 170 | glDrawArraysInstanced(GL_TRIANGLE_STRIP, 0, 4, numInstances); 171 | static float fTime = 0.0f; 172 | fTime += 0.1f; 173 | ImGui_ImplAndroidGL3_NewFrame(fTime, ImVec2(0.0f, 0.0f), false); 174 | ImGui::Begin("Test", NULL, ImVec2(800, 600)); 175 | ImGui::SetWindowFontScale(3.0f); 176 | ImGui::Button("button", ImVec2(300, 75)); 177 | ImGui::Button("button2", ImVec2(300, 75)); 178 | 179 | ImGui::DragFloat3("LightDir", &t[0], 0.05); 180 | 181 | ImGui::Checkbox("Show ShadowMap", &b1); 182 | ImGui::Checkbox("Linear Depth", &b2); 183 | ImGui::Checkbox("UseAutoCamera", &b3); 184 | 185 | const char* SamplePatterns[] = { "POISSON_25_25", "POISSON_32_64", "POISSON_100_100", "POISSON_64_128", "REGULAR_49_225" }; 186 | ImGui::ListBox("SamplePattern", &i, SamplePatterns, 5); 187 | ImGui::End(); 188 | ImGui::Render(); 189 | } 190 | -------------------------------------------------------------------------------- /app/src/main/cpp/gles3jni.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 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 compliance 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 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #include "gles3jni.h" 23 | 24 | const Vertex QUAD[4] = { 25 | // Square with diagonal < 2 so that it fits in a [-1 .. 1]^2 square 26 | // regardless of rotation. 27 | {{-0.7f, -0.7f}, {0x00, 0xFF, 0x00}}, 28 | {{ 0.7f, -0.7f}, {0x00, 0x00, 0xFF}}, 29 | {{-0.7f, 0.7f}, {0xFF, 0x00, 0x00}}, 30 | {{ 0.7f, 0.7f}, {0xFF, 0xFF, 0xFF}}, 31 | }; 32 | 33 | bool checkGlError(const char* funcName) { 34 | GLint err = glGetError(); 35 | if (err != GL_NO_ERROR) { 36 | ALOGE("GL error after %s(): 0x%08x\n", funcName, err); 37 | return true; 38 | } 39 | return false; 40 | } 41 | 42 | GLuint createShader(GLenum shaderType, const char* src) { 43 | GLuint shader = glCreateShader(shaderType); 44 | if (!shader) { 45 | checkGlError("glCreateShader"); 46 | return 0; 47 | } 48 | glShaderSource(shader, 1, &src, NULL); 49 | 50 | GLint compiled = GL_FALSE; 51 | glCompileShader(shader); 52 | glGetShaderiv(shader, GL_COMPILE_STATUS, &compiled); 53 | if (!compiled) { 54 | GLint infoLogLen = 0; 55 | glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &infoLogLen); 56 | if (infoLogLen > 0) { 57 | GLchar* infoLog = (GLchar*)malloc(infoLogLen); 58 | if (infoLog) { 59 | glGetShaderInfoLog(shader, infoLogLen, NULL, infoLog); 60 | ALOGE("Could not compile %s shader:\n%s\n", 61 | shaderType == GL_VERTEX_SHADER ? "vertex" : "fragment", 62 | infoLog); 63 | free(infoLog); 64 | } 65 | } 66 | glDeleteShader(shader); 67 | return 0; 68 | } 69 | 70 | return shader; 71 | } 72 | 73 | GLuint createProgram(const char* vtxSrc, const char* fragSrc) { 74 | GLuint vtxShader = 0; 75 | GLuint fragShader = 0; 76 | GLuint program = 0; 77 | GLint linked = GL_FALSE; 78 | 79 | vtxShader = createShader(GL_VERTEX_SHADER, vtxSrc); 80 | if (!vtxShader) 81 | goto exit; 82 | 83 | fragShader = createShader(GL_FRAGMENT_SHADER, fragSrc); 84 | if (!fragShader) 85 | goto exit; 86 | 87 | program = glCreateProgram(); 88 | if (!program) { 89 | checkGlError("glCreateProgram"); 90 | goto exit; 91 | } 92 | glAttachShader(program, vtxShader); 93 | glAttachShader(program, fragShader); 94 | 95 | glLinkProgram(program); 96 | glGetProgramiv(program, GL_LINK_STATUS, &linked); 97 | if (!linked) { 98 | ALOGE("Could not link program"); 99 | GLint infoLogLen = 0; 100 | glGetProgramiv(program, GL_INFO_LOG_LENGTH, &infoLogLen); 101 | if (infoLogLen) { 102 | GLchar* infoLog = (GLchar*)malloc(infoLogLen); 103 | if (infoLog) { 104 | glGetProgramInfoLog(program, infoLogLen, NULL, infoLog); 105 | ALOGE("Could not link program:\n%s\n", infoLog); 106 | free(infoLog); 107 | } 108 | } 109 | glDeleteProgram(program); 110 | program = 0; 111 | } 112 | 113 | exit: 114 | glDeleteShader(vtxShader); 115 | glDeleteShader(fragShader); 116 | return program; 117 | } 118 | 119 | static void printGlString(const char* name, GLenum s) { 120 | const char* v = (const char*)glGetString(s); 121 | ALOGV("GL %s: %s\n", name, v); 122 | } 123 | 124 | // ---------------------------------------------------------------------------- 125 | 126 | Renderer::Renderer() 127 | : mNumInstances(0), 128 | mLastFrameNs(0) 129 | { 130 | memset(mScale, 0, sizeof(mScale)); 131 | memset(mAngularVelocity, 0, sizeof(mAngularVelocity)); 132 | memset(mAngles, 0, sizeof(mAngles)); 133 | } 134 | 135 | Renderer::~Renderer() { 136 | } 137 | 138 | void Renderer::resize(int w, int h) { 139 | auto offsets = mapOffsetBuf(); 140 | calcSceneParams(w, h, offsets); 141 | unmapOffsetBuf(); 142 | 143 | // Auto gives a signed int :-( 144 | for (auto i = (unsigned)0; i < mNumInstances; i++) { 145 | mAngles[i] = drand48() * TWO_PI; 146 | mAngularVelocity[i] = MAX_ROT_SPEED * (2.0*drand48() - 1.0); 147 | } 148 | 149 | mLastFrameNs = 0; 150 | 151 | glViewport(0, 0, w, h); 152 | } 153 | 154 | void Renderer::calcSceneParams(unsigned int w, unsigned int h, 155 | float* offsets) { 156 | // number of cells along the larger screen dimension 157 | const float NCELLS_MAJOR = MAX_INSTANCES_PER_SIDE; 158 | // cell size in scene space 159 | const float CELL_SIZE = 2.0f / NCELLS_MAJOR; 160 | 161 | // Calculations are done in "landscape", i.e. assuming dim[0] >= dim[1]. 162 | // Only at the end are values put in the opposite order if h > w. 163 | const float dim[2] = {fmaxf(w,h), fminf(w,h)}; 164 | const float aspect[2] = {dim[0] / dim[1], dim[1] / dim[0]}; 165 | const float scene2clip[2] = {1.0f, aspect[0]}; 166 | const int ncells[2] = { 167 | static_cast(NCELLS_MAJOR), 168 | (int)floorf(NCELLS_MAJOR * aspect[1]) 169 | }; 170 | 171 | float centers[2][MAX_INSTANCES_PER_SIDE]; 172 | for (int d = 0; d < 2; d++) { 173 | auto offset = -ncells[d] / NCELLS_MAJOR; // -1.0 for d=0 174 | for (auto i = 0; i < ncells[d]; i++) { 175 | centers[d][i] = scene2clip[d] * (CELL_SIZE*(i + 0.5f) + offset); 176 | } 177 | } 178 | 179 | int major = w >= h ? 0 : 1; 180 | int minor = w >= h ? 1 : 0; 181 | // outer product of centers[0] and centers[1] 182 | for (int i = 0; i < ncells[0]; i++) { 183 | for (int j = 0; j < ncells[1]; j++) { 184 | int idx = i*ncells[1] + j; 185 | offsets[2*idx + major] = centers[0][i]; 186 | offsets[2*idx + minor] = centers[1][j]; 187 | } 188 | } 189 | 190 | mNumInstances = ncells[0] * ncells[1]; 191 | mScale[major] = 0.5f * CELL_SIZE * scene2clip[0]; 192 | mScale[minor] = 0.5f * CELL_SIZE * scene2clip[1]; 193 | } 194 | 195 | void Renderer::step() { 196 | timespec now; 197 | clock_gettime(CLOCK_MONOTONIC, &now); 198 | auto nowNs = now.tv_sec*1000000000ull + now.tv_nsec; 199 | 200 | if (mLastFrameNs > 0) { 201 | float dt = float(nowNs - mLastFrameNs) * 0.000000001f; 202 | 203 | for (unsigned int i = 0; i < mNumInstances; i++) { 204 | mAngles[i] += mAngularVelocity[i] * dt; 205 | if (mAngles[i] >= TWO_PI) { 206 | mAngles[i] -= TWO_PI; 207 | } else if (mAngles[i] <= -TWO_PI) { 208 | mAngles[i] += TWO_PI; 209 | } 210 | } 211 | 212 | float* transforms = mapTransformBuf(); 213 | for (unsigned int i = 0; i < mNumInstances; i++) { 214 | float s = sinf(mAngles[i]); 215 | float c = cosf(mAngles[i]); 216 | transforms[4*i + 0] = c * mScale[0]; 217 | transforms[4*i + 1] = s * mScale[1]; 218 | transforms[4*i + 2] = -s * mScale[0]; 219 | transforms[4*i + 3] = c * mScale[1]; 220 | } 221 | unmapTransformBuf(); 222 | } 223 | 224 | mLastFrameNs = nowNs; 225 | } 226 | 227 | void Renderer::render() { 228 | step(); 229 | 230 | glClearColor(0.2f, 0.2f, 0.3f, 1.0f); 231 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 232 | draw(mNumInstances); 233 | checkGlError("Renderer::render"); 234 | } 235 | 236 | // ---------------------------------------------------------------------------- 237 | 238 | static Renderer* g_renderer = NULL; 239 | 240 | extern "C" { 241 | JNIEXPORT void JNICALL Java_com_android_gles3jni_GLES3JNILib_init(JNIEnv* env, jobject obj); 242 | JNIEXPORT void JNICALL Java_com_android_gles3jni_GLES3JNILib_resize(JNIEnv* env, jobject obj, jint width, jint height); 243 | JNIEXPORT void JNICALL Java_com_android_gles3jni_GLES3JNILib_step(JNIEnv* env, jobject obj); 244 | }; 245 | 246 | #if !defined(DYNAMIC_ES3) 247 | static GLboolean gl3stubInit() { 248 | return GL_TRUE; 249 | } 250 | #endif 251 | 252 | JNIEXPORT void JNICALL 253 | Java_com_android_gles3jni_GLES3JNILib_init(JNIEnv* env, jobject obj) { 254 | if (g_renderer) { 255 | delete g_renderer; 256 | g_renderer = NULL; 257 | } 258 | 259 | printGlString("Version", GL_VERSION); 260 | printGlString("Vendor", GL_VENDOR); 261 | printGlString("Renderer", GL_RENDERER); 262 | printGlString("Extensions", GL_EXTENSIONS); 263 | 264 | const char* versionStr = (const char*)glGetString(GL_VERSION); 265 | if (strstr(versionStr, "OpenGL ES 3.") && gl3stubInit()) { 266 | g_renderer = createES3Renderer(); 267 | } else if (strstr(versionStr, "OpenGL ES 2.")) { 268 | g_renderer = createES2Renderer(); 269 | } else { 270 | ALOGE("Unsupported OpenGL ES version"); 271 | } 272 | } 273 | 274 | JNIEXPORT void JNICALL 275 | Java_com_android_gles3jni_GLES3JNILib_resize(JNIEnv* env, jobject obj, jint width, jint height) { 276 | if (g_renderer) { 277 | g_renderer->resize(width, height); 278 | } 279 | } 280 | 281 | JNIEXPORT void JNICALL 282 | Java_com_android_gles3jni_GLES3JNILib_step(JNIEnv* env, jobject obj) { 283 | if (g_renderer) { 284 | g_renderer->render(); 285 | } 286 | } 287 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, and 10 | distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by the copyright 13 | owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all other entities 16 | that control, are controlled by, or are under common control with that entity. 17 | For the purposes of this definition, "control" means (i) the power, direct or 18 | indirect, to cause the direction or management of such entity, whether by 19 | contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the 20 | outstanding shares, or (iii) beneficial ownership of such entity. 21 | 22 | "You" (or "Your") shall mean an individual or Legal Entity exercising 23 | permissions granted by this License. 24 | 25 | "Source" form shall mean the preferred form for making modifications, including 26 | but not limited to software source code, documentation source, and configuration 27 | files. 28 | 29 | "Object" form shall mean any form resulting from mechanical transformation or 30 | translation of a Source form, including but not limited to compiled object code, 31 | generated documentation, and conversions to other media types. 32 | 33 | "Work" shall mean the work of authorship, whether in Source or Object form, made 34 | available under the License, as indicated by a copyright notice that is included 35 | in or attached to the work (an example is provided in the Appendix below). 36 | 37 | "Derivative Works" shall mean any work, whether in Source or Object form, that 38 | is based on (or derived from) the Work and for which the editorial revisions, 39 | annotations, elaborations, or other modifications represent, as a whole, an 40 | original work of authorship. For the purposes of this License, Derivative Works 41 | shall not include works that remain separable from, or merely link (or bind by 42 | name) to the interfaces of, the Work and Derivative Works thereof. 43 | 44 | "Contribution" shall mean any work of authorship, including the original version 45 | of the Work and any modifications or additions to that Work or Derivative Works 46 | thereof, that is intentionally submitted to Licensor for inclusion in the Work 47 | by the copyright owner or by an individual or Legal Entity authorized to submit 48 | on behalf of the copyright owner. For the purposes of this definition, 49 | "submitted" means any form of electronic, verbal, or written communication sent 50 | to the Licensor or its representatives, including but not limited to 51 | communication on electronic mailing lists, source code control systems, and 52 | issue tracking systems that are managed by, or on behalf of, the Licensor for 53 | the purpose of discussing and improving the Work, but excluding communication 54 | that is conspicuously marked or otherwise designated in writing by the copyright 55 | owner as "Not a Contribution." 56 | 57 | "Contributor" shall mean Licensor and any individual or Legal Entity on behalf 58 | of whom a Contribution has been received by Licensor and subsequently 59 | incorporated within the Work. 60 | 61 | 2. Grant of Copyright License. 62 | 63 | Subject to the terms and conditions of this License, each Contributor hereby 64 | grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, 65 | irrevocable copyright license to reproduce, prepare Derivative Works of, 66 | publicly display, publicly perform, sublicense, and distribute the Work and such 67 | Derivative Works in Source or Object form. 68 | 69 | 3. Grant of Patent License. 70 | 71 | Subject to the terms and conditions of this License, each Contributor hereby 72 | grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, 73 | irrevocable (except as stated in this section) patent license to make, have 74 | made, use, offer to sell, sell, import, and otherwise transfer the Work, where 75 | such license applies only to those patent claims licensable by such Contributor 76 | that are necessarily infringed by their Contribution(s) alone or by combination 77 | of their Contribution(s) with the Work to which such Contribution(s) was 78 | submitted. If You institute patent litigation against any entity (including a 79 | cross-claim or counterclaim in a lawsuit) alleging that the Work or a 80 | Contribution incorporated within the Work constitutes direct or contributory 81 | patent infringement, then any patent licenses granted to You under this License 82 | for that Work shall terminate as of the date such litigation is filed. 83 | 84 | 4. Redistribution. 85 | 86 | You may reproduce and distribute copies of the Work or Derivative Works thereof 87 | in any medium, with or without modifications, and in Source or Object form, 88 | provided that You meet the following conditions: 89 | 90 | You must give any other recipients of the Work or Derivative Works a copy of 91 | this License; and 92 | You must cause any modified files to carry prominent notices stating that You 93 | changed the files; and 94 | You must retain, in the Source form of any Derivative Works that You distribute, 95 | all copyright, patent, trademark, and attribution notices from the Source form 96 | of the Work, excluding those notices that do not pertain to any part of the 97 | Derivative Works; and 98 | If the Work includes a "NOTICE" text file as part of its distribution, then any 99 | Derivative Works that You distribute must include a readable copy of the 100 | attribution notices contained within such NOTICE file, excluding those notices 101 | that do not pertain to any part of the Derivative Works, in at least one of the 102 | following places: within a NOTICE text file distributed as part of the 103 | Derivative Works; within the Source form or documentation, if provided along 104 | with the Derivative Works; or, within a display generated by the Derivative 105 | Works, if and wherever such third-party notices normally appear. The contents of 106 | the NOTICE file are for informational purposes only and do not modify the 107 | License. You may add Your own attribution notices within Derivative Works that 108 | You distribute, alongside or as an addendum to the NOTICE text from the Work, 109 | provided that such additional attribution notices cannot be construed as 110 | modifying the License. 111 | You may add Your own copyright statement to Your modifications and may provide 112 | additional or different license terms and conditions for use, reproduction, or 113 | distribution of Your modifications, or for any such Derivative Works as a whole, 114 | provided Your use, reproduction, and distribution of the Work otherwise complies 115 | with the conditions stated in this License. 116 | 117 | 5. Submission of Contributions. 118 | 119 | Unless You explicitly state otherwise, any Contribution intentionally submitted 120 | for inclusion in the Work by You to the Licensor shall be under the terms and 121 | conditions of this License, without any additional terms or conditions. 122 | Notwithstanding the above, nothing herein shall supersede or modify the terms of 123 | any separate license agreement you may have executed with Licensor regarding 124 | such Contributions. 125 | 126 | 6. Trademarks. 127 | 128 | This License does not grant permission to use the trade names, trademarks, 129 | service marks, or product names of the Licensor, except as required for 130 | reasonable and customary use in describing the origin of the Work and 131 | reproducing the content of the NOTICE file. 132 | 133 | 7. Disclaimer of Warranty. 134 | 135 | Unless required by applicable law or agreed to in writing, Licensor provides the 136 | Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, 137 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, 138 | including, without limitation, any warranties or conditions of TITLE, 139 | NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are 140 | solely responsible for determining the appropriateness of using or 141 | redistributing the Work and assume any risks associated with Your exercise of 142 | permissions under this License. 143 | 144 | 8. Limitation of Liability. 145 | 146 | In no event and under no legal theory, whether in tort (including negligence), 147 | contract, or otherwise, unless required by applicable law (such as deliberate 148 | and grossly negligent acts) or agreed to in writing, shall any Contributor be 149 | liable to You for damages, including any direct, indirect, special, incidental, 150 | or consequential damages of any character arising as a result of this License or 151 | out of the use or inability to use the Work (including but not limited to 152 | damages for loss of goodwill, work stoppage, computer failure or malfunction, or 153 | any and all other commercial damages or losses), even if such Contributor has 154 | been advised of the possibility of such damages. 155 | 156 | 9. Accepting Warranty or Additional Liability. 157 | 158 | While redistributing the Work or Derivative Works thereof, You may choose to 159 | offer, and charge a fee for, acceptance of support, warranty, indemnity, or 160 | other liability obligations and/or rights consistent with this License. However, 161 | in accepting such obligations, You may act only on Your own behalf and on Your 162 | sole responsibility, not on behalf of any other Contributor, and only if You 163 | agree to indemnify, defend, and hold each Contributor harmless for any liability 164 | incurred by, or claims asserted against, such Contributor by reason of your 165 | accepting any such warranty or additional liability. 166 | 167 | END OF TERMS AND CONDITIONS 168 | 169 | APPENDIX: How to apply the Apache License to your work 170 | 171 | To apply the Apache License to your work, attach the following boilerplate 172 | notice, with the fields enclosed by brackets "[]" replaced with your own 173 | identifying information. (Don't include the brackets!) The text should be 174 | enclosed in the appropriate comment syntax for the file format. We also 175 | recommend that a file or class name and description of purpose be included on 176 | the same "printed page" as the copyright notice for easier identification within 177 | third-party archives. 178 | 179 | Copyright [yyyy] [name of copyright owner] 180 | 181 | Licensed under the Apache License, Version 2.0 (the "License"); 182 | you may not use this file except in compliance with the License. 183 | You may obtain a copy of the License at 184 | 185 | http://www.apache.org/licenses/LICENSE-2.0 186 | 187 | Unless required by applicable law or agreed to in writing, software 188 | distributed under the License is distributed on an "AS IS" BASIS, 189 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 190 | See the License for the specific language governing permissions and 191 | limitations under the License. -------------------------------------------------------------------------------- /app/app.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 9 | 10 | 11 | 13 | 14 | 15 | 16 | 28 | 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 | -------------------------------------------------------------------------------- /app/src/main/cpp/imGui/imgui_impl_android_gl2.cpp: -------------------------------------------------------------------------------- 1 | // ImGui GLFW binding with OpenGL3 + shaders 2 | // In this binding, ImTextureID is used to store an OpenGL 'GLuint' texture identifier. Read the FAQ about ImTextureID in imgui.cpp. 3 | 4 | // You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this. 5 | // If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown(). 6 | // If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp. 7 | // https://github.com/ocornut/imgui 8 | 9 | #define GL_GLEXT_PROTOTYPES 10 | #include 11 | //#include 12 | //#include 13 | #include 14 | #include 15 | 16 | #include "FmtConversion.h" 17 | #include "imgui.h" 18 | #include 19 | #include 20 | #include "imgui_impl_android_gl2.h" 21 | 22 | using namespace std; 23 | #ifdef _MSC_VER 24 | #define LOGI(...) (printf(__VA_ARGS__)) 25 | #else 26 | #define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "native-activity", __VA_ARGS__)) 27 | #endif 28 | 29 | // GL3W/GLFW 30 | #ifdef _MSC_VER 31 | #include 32 | #endif 33 | 34 | #ifdef _WIN32 35 | #undef APIENTRY 36 | #define GLFW_EXPOSE_NATIVE_WIN32 37 | #define GLFW_EXPOSE_NATIVE_WGL 38 | #include 39 | #endif 40 | 41 | // Data 42 | static bool preMouseState; 43 | static double g_Time = 0.0f; 44 | static GLuint g_FontTexture = 0; 45 | static int g_ShaderHandle = 0, g_VertHandle = 0, g_FragHandle = 0; 46 | static int g_AttribLocationTex = 0, g_AttribLocationProjMtx = 0; 47 | static int g_AttribLocationPosition = 0, g_AttribLocationUV = 0, g_AttribLocationColor = 0; 48 | static unsigned int g_VboHandle = 0, g_VaoHandle = 0, g_ElementsHandle = 0; 49 | 50 | 51 | void GLError(string info) 52 | { 53 | GLenum error = glGetError(); 54 | LOGI("%s", info.c_str()); 55 | switch (error) 56 | { 57 | case GL_INVALID_ENUM: 58 | LOGI("GL_INVALID_ENUM"); 59 | break; 60 | case GL_INVALID_VALUE: 61 | LOGI("GL_INVALID_VALUE"); 62 | break; 63 | case GL_INVALID_OPERATION: 64 | LOGI("GL_INVALID_OPERATION"); 65 | break; 66 | case GL_INVALID_FRAMEBUFFER_OPERATION: 67 | LOGI("GL_INVALID_FRAMEBUFFER_OPERATION"); 68 | break; 69 | case GL_OUT_OF_MEMORY: 70 | LOGI("GL_OUT_OF_MEMORY"); 71 | break; 72 | default: 73 | LOGI("clean"); 74 | } 75 | } 76 | 77 | // This is the main rendering function that you have to implement and provide to ImGui (via setting up 'RenderDrawListsFn' in the ImGuiIO structure) 78 | // If text or lines are blurry when integrating ImGui in your engine: 79 | // - in your Render function, try translating your projection matrix by (0.5f,0.5f) or (0.375f,0.375f) 80 | void ImGui_ImplAndroidGL3_RenderDrawLists(ImDrawData* draw_data) 81 | { 82 | // Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates) 83 | ImGuiIO& io = ImGui::GetIO(); 84 | int fb_width = (int)(io.DisplaySize.x * io.DisplayFramebufferScale.x); 85 | int fb_height = (int)(io.DisplaySize.y * io.DisplayFramebufferScale.y); 86 | if (fb_width == 0 || fb_height == 0) 87 | return; 88 | draw_data->ScaleClipRects(io.DisplayFramebufferScale); 89 | 90 | // Backup GL state 91 | GLint last_program; glGetIntegerv(GL_CURRENT_PROGRAM, &last_program); 92 | GLint last_texture; glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture); 93 | GLint last_active_texture; glGetIntegerv(GL_ACTIVE_TEXTURE, &last_active_texture); 94 | GLint last_array_buffer; glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &last_array_buffer); 95 | GLint last_element_array_buffer; glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING, &last_element_array_buffer); 96 | GLint last_vertex_array; glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &last_vertex_array); 97 | GLint last_blend_src; glGetIntegerv(GL_BLEND_SRC_ALPHA, &last_blend_src); 98 | GLint last_blend_dst; glGetIntegerv(GL_BLEND_DST_ALPHA, &last_blend_dst); 99 | GLint last_blend_equation_rgb; glGetIntegerv(GL_BLEND_EQUATION_RGB, &last_blend_equation_rgb); 100 | GLint last_blend_equation_alpha; glGetIntegerv(GL_BLEND_EQUATION_ALPHA, &last_blend_equation_alpha); 101 | GLint last_viewport[4]; glGetIntegerv(GL_VIEWPORT, last_viewport); 102 | GLboolean last_enable_blend = glIsEnabled(GL_BLEND); 103 | GLboolean last_enable_cull_face = glIsEnabled(GL_CULL_FACE); 104 | GLboolean last_enable_depth_test = glIsEnabled(GL_DEPTH_TEST); 105 | GLboolean last_enable_scissor_test = glIsEnabled(GL_SCISSOR_TEST); 106 | 107 | // Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled 108 | glEnable(GL_BLEND); 109 | glBlendEquation(GL_FUNC_ADD); 110 | glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 111 | glDisable(GL_CULL_FACE); 112 | glDisable(GL_DEPTH_TEST); 113 | glEnable(GL_SCISSOR_TEST); 114 | glActiveTexture(GL_TEXTURE0); 115 | 116 | // Setup viewport, orthographic projection matrix 117 | glViewport(0, 0, (GLsizei)fb_width, (GLsizei)fb_height); 118 | const float ortho_projection[4][4] = 119 | { 120 | { 2.0f/io.DisplaySize.x, 0.0f, 0.0f, 0.0f }, 121 | { 0.0f, 2.0f/-io.DisplaySize.y, 0.0f, 0.0f }, 122 | { 0.0f, 0.0f, -1.0f, 0.0f }, 123 | {-1.0f, 1.0f, 0.0f, 1.0f }, 124 | }; 125 | glUseProgram(g_ShaderHandle); 126 | glUniform1i(g_AttribLocationTex, 0); 127 | glUniformMatrix4fv(g_AttribLocationProjMtx, 1, GL_FALSE, &ortho_projection[0][0]); 128 | glBindVertexArray(g_VaoHandle); 129 | 130 | for (int n = 0; n < draw_data->CmdListsCount; n++) 131 | { 132 | const ImDrawList* cmd_list = draw_data->CmdLists[n]; 133 | const ImDrawIdx* idx_buffer_offset = 0; 134 | 135 | glBindBuffer(GL_ARRAY_BUFFER, g_VboHandle); 136 | glBufferData(GL_ARRAY_BUFFER, (GLsizeiptr)cmd_list->VtxBuffer.size() * sizeof(ImDrawVert), (GLvoid*)&cmd_list->VtxBuffer.front(), GL_STREAM_DRAW); 137 | glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, g_ElementsHandle); 138 | glBufferData(GL_ELEMENT_ARRAY_BUFFER, (GLsizeiptr)cmd_list->IdxBuffer.size() * sizeof(ImDrawIdx), (GLvoid*)&cmd_list->IdxBuffer.front(), GL_STREAM_DRAW); 139 | 140 | for (const ImDrawCmd* pcmd = cmd_list->CmdBuffer.begin(); pcmd != cmd_list->CmdBuffer.end(); pcmd++) 141 | { 142 | if (pcmd->UserCallback) 143 | { 144 | pcmd->UserCallback(cmd_list, pcmd); 145 | } 146 | else 147 | { 148 | glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->TextureId); 149 | glScissor((int)pcmd->ClipRect.x, (int)(fb_height - pcmd->ClipRect.w), (int)(pcmd->ClipRect.z - pcmd->ClipRect.x), (int)(pcmd->ClipRect.w - pcmd->ClipRect.y)); 150 | glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, idx_buffer_offset); 151 | } 152 | idx_buffer_offset += pcmd->ElemCount; 153 | } 154 | } 155 | 156 | // Restore modified GL state 157 | glUseProgram(last_program); 158 | glActiveTexture(last_active_texture); 159 | glBindTexture(GL_TEXTURE_2D, last_texture); 160 | glBindVertexArray(last_vertex_array); 161 | glBindBuffer(GL_ARRAY_BUFFER, last_array_buffer); 162 | glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, last_element_array_buffer); 163 | glBlendEquationSeparate(last_blend_equation_rgb, last_blend_equation_alpha); 164 | glBlendFunc(last_blend_src, last_blend_dst); 165 | if (last_enable_blend) glEnable(GL_BLEND); else glDisable(GL_BLEND); 166 | if (last_enable_cull_face) glEnable(GL_CULL_FACE); else glDisable(GL_CULL_FACE); 167 | if (last_enable_depth_test) glEnable(GL_DEPTH_TEST); else glDisable(GL_DEPTH_TEST); 168 | if (last_enable_scissor_test) glEnable(GL_SCISSOR_TEST); else glDisable(GL_SCISSOR_TEST); 169 | glViewport(last_viewport[0], last_viewport[1], (GLsizei)last_viewport[2], (GLsizei)last_viewport[3]); 170 | 171 | } 172 | 173 | void ImGui_ImplAndroidGL3_MouseButtonCallback(int button, int action, int /*mods*/) 174 | { 175 | /*if (action == GLFW_PRESS && button >= 0 && button < 3) 176 | g_MousePressed[button] = true;*/ 177 | } 178 | 179 | bool ImGui_ImplAndroidGL3_CreateFontsTexture() 180 | { 181 | // Build texture atlas 182 | ImGuiIO& io = ImGui::GetIO(); 183 | unsigned char* pixels; 184 | int width, height; 185 | io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); // Load as RGBA 32-bits for OpenGL3 demo because it is more likely to be compatible with user's existing shader. 186 | 187 | // Upload texture to graphics system 188 | GLint last_texture; 189 | glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture); 190 | glGenTextures(1, &g_FontTexture); 191 | glBindTexture(GL_TEXTURE_2D, g_FontTexture); 192 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 193 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 194 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels); 195 | 196 | // Store our identifier 197 | io.Fonts->TexID = (void *)(intptr_t)g_FontTexture; 198 | 199 | // Restore state 200 | glBindTexture(GL_TEXTURE_2D, last_texture); 201 | 202 | return true; 203 | } 204 | 205 | bool ImGui_ImplAndroidGL3_CreateDeviceObjects() 206 | { 207 | GLError("ImGui_ImplAndroidGL3_CreateDeviceObjects"); 208 | // Backup GL state 209 | GLint last_texture, last_array_buffer, last_vertex_array; 210 | glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture); 211 | glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &last_array_buffer); 212 | glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &last_vertex_array); 213 | 214 | const GLchar *vertex_shader = 215 | "#version 300 es\n" 216 | "uniform mat4 ProjMtx;\n" 217 | "in vec2 Position;\n" 218 | "in vec2 UV;\n" 219 | "in vec4 Color;\n" 220 | "out vec2 Frag_UV;\n" 221 | "out vec4 Frag_Color;\n" 222 | "void main()\n" 223 | "{\n" 224 | " Frag_UV = UV;\n" 225 | " Frag_Color = Color;\n" 226 | " gl_Position = ProjMtx * vec4(Position.xy,0,1);\n" 227 | "}\n"; 228 | 229 | const GLchar* fragment_shader = 230 | "#version 300 es\n" 231 | "precision mediump float;\n" 232 | "uniform sampler2D Texture;\n" 233 | "in vec2 Frag_UV;\n" 234 | "in vec4 Frag_Color;\n" 235 | "out vec4 Out_Color;\n" 236 | "void main()\n" 237 | "{\n" 238 | " Out_Color = Frag_Color * texture( Texture, Frag_UV.st);\n" 239 | "}\n"; 240 | 241 | g_ShaderHandle = glCreateProgram(); 242 | g_VertHandle = glCreateShader(GL_VERTEX_SHADER); 243 | g_FragHandle = glCreateShader(GL_FRAGMENT_SHADER); 244 | glShaderSource(g_VertHandle, 1, &vertex_shader, 0); 245 | glShaderSource(g_FragHandle, 1, &fragment_shader, 0); 246 | GLError("glShaderSource"); 247 | 248 | //compile vs 249 | glCompileShader(g_VertHandle); 250 | GLint nCompileResult = 0; 251 | glGetShaderiv(g_VertHandle, GL_COMPILE_STATUS, &nCompileResult); 252 | GLError("glGetShaderiv"); 253 | CHAR strLog[1024]; 254 | GLint nLength; 255 | glGetShaderInfoLog(g_VertHandle, 1024, &nLength, strLog); 256 | LOGI("vs info %s", strLog); 257 | /*if (0 == nCompileResult) 258 | { 259 | CHAR strLog[1024]; 260 | GLint nLength; 261 | glGetShaderInfoLog(g_VertHandle, 1024, &nLength, strLog); 262 | LOGI("vs info %s", strLog); 263 | return FALSE; 264 | }*/ 265 | GLError("vs compile finish"); 266 | //compile fs 267 | glCompileShader(g_FragHandle); 268 | GLError("fs compile finish"); 269 | glGetShaderiv(g_FragHandle, GL_COMPILE_STATUS, &nCompileResult); 270 | glGetShaderInfoLog(g_FragHandle, 1024, &nLength, strLog); 271 | GLError("fs get"); 272 | LOGI("fs info %s", strLog); 273 | /*if (0 == nCompileResult) 274 | { 275 | CHAR strLog[1024]; 276 | GLint nLength; 277 | glGetShaderInfoLog(g_FragHandle, 1024, &nLength, strLog); 278 | LOGI("fs info %s", strLog); 279 | return FALSE; 280 | }*/ 281 | GLError("finish compile"); 282 | 283 | glAttachShader(g_ShaderHandle, g_VertHandle); 284 | glAttachShader(g_ShaderHandle, g_FragHandle); 285 | glLinkProgram(g_ShaderHandle); 286 | GLint nLinkResult = 0; 287 | glGetProgramiv(g_ShaderHandle, GL_LINK_STATUS, &nLinkResult); 288 | if (0 == nLinkResult) 289 | { 290 | CHAR strLog[1024]; 291 | GLint nLength; 292 | glGetProgramInfoLog(g_ShaderHandle, 1024, &nLength, strLog); 293 | LOGI("link: %s", strLog); 294 | return FALSE; 295 | } 296 | GLError("attach"); 297 | 298 | g_AttribLocationTex = glGetUniformLocation(g_ShaderHandle, "Texture"); 299 | g_AttribLocationProjMtx = glGetUniformLocation(g_ShaderHandle, "ProjMtx"); 300 | g_AttribLocationPosition = glGetAttribLocation(g_ShaderHandle, "Position"); 301 | g_AttribLocationUV = glGetAttribLocation(g_ShaderHandle, "UV"); 302 | g_AttribLocationColor = glGetAttribLocation(g_ShaderHandle, "Color"); 303 | GLError("before gen"); 304 | 305 | glGenBuffers(1, &g_VboHandle); 306 | glGenBuffers(1, &g_ElementsHandle); 307 | 308 | 309 | glGenVertexArrays(1, &g_VaoHandle); 310 | glBindVertexArray(g_VaoHandle); 311 | glBindBuffer(GL_ARRAY_BUFFER, g_VboHandle); 312 | glEnableVertexAttribArray(g_AttribLocationPosition); 313 | glEnableVertexAttribArray(g_AttribLocationUV); 314 | glEnableVertexAttribArray(g_AttribLocationColor); 315 | GLError("enable"); 316 | 317 | #define OFFSETOF(TYPE, ELEMENT) ((size_t)&(((TYPE *)0)->ELEMENT)) 318 | glVertexAttribPointer(g_AttribLocationPosition, 2, GL_FLOAT, GL_FALSE, sizeof(ImDrawVert), (GLvoid*)OFFSETOF(ImDrawVert, pos)); 319 | glVertexAttribPointer(g_AttribLocationUV, 2, GL_FLOAT, GL_FALSE, sizeof(ImDrawVert), (GLvoid*)OFFSETOF(ImDrawVert, uv)); 320 | glVertexAttribPointer(g_AttribLocationColor, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(ImDrawVert), (GLvoid*)OFFSETOF(ImDrawVert, col)); 321 | #undef OFFSETOF 322 | 323 | ImGui_ImplAndroidGL3_CreateFontsTexture(); 324 | 325 | // Restore modified GL state 326 | glBindTexture(GL_TEXTURE_2D, last_texture); 327 | glBindBuffer(GL_ARRAY_BUFFER, last_array_buffer); 328 | glBindVertexArray(last_vertex_array); 329 | 330 | GLError("glBindTexture"); 331 | 332 | return true; 333 | } 334 | 335 | void ImGui_ImplAndroidGL3_InvalidateDeviceObjects() 336 | { 337 | if (g_VaoHandle) glDeleteVertexArrays(1, &g_VaoHandle); 338 | if (g_VboHandle) glDeleteBuffers(1, &g_VboHandle); 339 | if (g_ElementsHandle) glDeleteBuffers(1, &g_ElementsHandle); 340 | g_VaoHandle = g_VboHandle = g_ElementsHandle = 0; 341 | 342 | glDetachShader(g_ShaderHandle, g_VertHandle); 343 | glDeleteShader(g_VertHandle); 344 | g_VertHandle = 0; 345 | 346 | glDetachShader(g_ShaderHandle, g_FragHandle); 347 | glDeleteShader(g_FragHandle); 348 | g_FragHandle = 0; 349 | 350 | glDeleteProgram(g_ShaderHandle); 351 | g_ShaderHandle = 0; 352 | 353 | if (g_FontTexture) 354 | { 355 | glDeleteTextures(1, &g_FontTexture); 356 | ImGui::GetIO().Fonts->TexID = 0; 357 | g_FontTexture = 0; 358 | } 359 | } 360 | 361 | bool ImGui_ImplAndroidGL3_Init() 362 | { 363 | LOGI("ImGui_ImplAndroidGL3_Init"); 364 | ImGuiIO& io = ImGui::GetIO(); 365 | 366 | io.RenderDrawListsFn = ImGui_ImplAndroidGL3_RenderDrawLists; // Alternatively you can set this to NULL and call ImGui::GetDrawData() after ImGui::Render() to get the same ImDrawData pointer. 367 | 368 | return true; 369 | } 370 | 371 | void ImGui_ImplAndroidGL3_Shutdown() 372 | { 373 | ImGui_ImplAndroidGL3_InvalidateDeviceObjects(); 374 | ImGui::Shutdown(); 375 | } 376 | 377 | void ImGui_ImplAndroidGL3_NewFrame(float time, ImVec2 mousePos, bool down) 378 | { 379 | if (!g_FontTexture) 380 | ImGui_ImplAndroidGL3_CreateDeviceObjects(); 381 | 382 | ImGuiIO& io = ImGui::GetIO(); 383 | 384 | // Setup display size (every frame to accommodate for window resizing) 385 | int w, h; 386 | // hnn. Werror 387 | // int display_w, display_h; 388 | //glfwGetWindowSize(g_Window, &w, &h); 389 | h = 1920; 390 | w = 1080; 391 | //glfwGetFramebufferSize(g_Window, &display_w, &display_h); 392 | io.DisplaySize = ImVec2((float)w, (float)h); 393 | //io.DisplayFramebufferScale = ImVec2(w > 0 ? ((float)display_w / w) : 0, h > 0 ? ((float)display_h / h) : 0); 394 | 395 | // Setup time step 396 | double current_time = time; 397 | io.DeltaTime = g_Time > 0.0 ? (float)(current_time - g_Time) : (float)(1.0f/60.0f); 398 | g_Time = current_time; 399 | 400 | // Setup inputs 401 | // (we already got mouse wheel, keyboard keys & characters from glfw callbacks polled in glfwPollEvents()) 402 | io.MousePos.x = 0.5f * (mousePos.x + 1) * w; 403 | io.MousePos.y = 0.5f * (1 - mousePos.y) * h; 404 | if (!down) 405 | { 406 | //io.MousePos = ImVec2(-1, -1); 407 | if (down != preMouseState) // from down to release 408 | io.MouseOFF[0] = true; 409 | else 410 | io.MouseOFF[0] = false; 411 | } 412 | else 413 | { 414 | io.MouseDrawCursor = true; 415 | if (down != preMouseState) // from release to down 416 | io.MouseON[0] = true; 417 | else 418 | io.MouseON[0] = false; 419 | } 420 | 421 | preMouseState = down; 422 | 423 | io.MouseDown[0] = down; // if a mouse press event came, always pass it as "mouse held this frame", so we don't miss click-release events that are shorter than 1 frame. 424 | //io.MouseClicked[0] = down; 425 | //// Hide OS mouse cursor if ImGui is drawing it 426 | //glfwSetInputMode(g_Window, GLFW_CURSOR, io.MouseDrawCursor ? GLFW_CURSOR_HIDDEN : GLFW_CURSOR_NORMAL); 427 | 428 | // Start the frame 429 | ImGui::NewFrame(); 430 | } 431 | -------------------------------------------------------------------------------- /app/src/main/cpp/imGui/stb_rect_pack.h: -------------------------------------------------------------------------------- 1 | // stb_rect_pack.h - v0.08 - public domain - rectangle packing 2 | // Sean Barrett 2014 3 | // 4 | // Useful for e.g. packing rectangular textures into an atlas. 5 | // Does not do rotation. 6 | // 7 | // Not necessarily the awesomest packing method, but better than 8 | // the totally naive one in stb_truetype (which is primarily what 9 | // this is meant to replace). 10 | // 11 | // Has only had a few tests run, may have issues. 12 | // 13 | // More docs to come. 14 | // 15 | // No memory allocations; uses qsort() and assert() from stdlib. 16 | // Can override those by defining STBRP_SORT and STBRP_ASSERT. 17 | // 18 | // This library currently uses the Skyline Bottom-Left algorithm. 19 | // 20 | // Please note: better rectangle packers are welcome! Please 21 | // implement them to the same API, but with a different init 22 | // function. 23 | // 24 | // Credits 25 | // 26 | // Library 27 | // Sean Barrett 28 | // Minor features 29 | // Martins Mozeiko 30 | // Bugfixes / warning fixes 31 | // Jeremy Jaussaud 32 | // 33 | // Version history: 34 | // 35 | // 0.08 (2015-09-13) really fix bug with empty rects (w=0 or h=0) 36 | // 0.07 (2015-09-13) fix bug with empty rects (w=0 or h=0) 37 | // 0.06 (2015-04-15) added STBRP_SORT to allow replacing qsort 38 | // 0.05: added STBRP_ASSERT to allow replacing assert 39 | // 0.04: fixed minor bug in STBRP_LARGE_RECTS support 40 | // 0.01: initial release 41 | // 42 | // LICENSE 43 | // 44 | // This software is in the public domain. Where that dedication is not 45 | // recognized, you are granted a perpetual, irrevocable license to copy, 46 | // distribute, and modify this file as you see fit. 47 | 48 | ////////////////////////////////////////////////////////////////////////////// 49 | // 50 | // INCLUDE SECTION 51 | // 52 | 53 | #ifndef STB_INCLUDE_STB_RECT_PACK_H 54 | #define STB_INCLUDE_STB_RECT_PACK_H 55 | 56 | #define STB_RECT_PACK_VERSION 1 57 | 58 | #ifdef STBRP_STATIC 59 | #define STBRP_DEF static 60 | #else 61 | #define STBRP_DEF extern 62 | #endif 63 | 64 | #ifdef __cplusplus 65 | extern "C" { 66 | #endif 67 | 68 | typedef struct stbrp_context stbrp_context; 69 | typedef struct stbrp_node stbrp_node; 70 | typedef struct stbrp_rect stbrp_rect; 71 | 72 | #ifdef STBRP_LARGE_RECTS 73 | typedef int stbrp_coord; 74 | #else 75 | typedef unsigned short stbrp_coord; 76 | #endif 77 | 78 | STBRP_DEF void stbrp_pack_rects (stbrp_context *context, stbrp_rect *rects, int num_rects); 79 | // Assign packed locations to rectangles. The rectangles are of type 80 | // 'stbrp_rect' defined below, stored in the array 'rects', and there 81 | // are 'num_rects' many of them. 82 | // 83 | // Rectangles which are successfully packed have the 'was_packed' flag 84 | // set to a non-zero value and 'x' and 'y' store the minimum location 85 | // on each axis (i.e. bottom-left in cartesian coordinates, top-left 86 | // if you imagine y increasing downwards). Rectangles which do not fit 87 | // have the 'was_packed' flag set to 0. 88 | // 89 | // You should not try to access the 'rects' array from another thread 90 | // while this function is running, as the function temporarily reorders 91 | // the array while it executes. 92 | // 93 | // To pack into another rectangle, you need to call stbrp_init_target 94 | // again. To continue packing into the same rectangle, you can call 95 | // this function again. Calling this multiple times with multiple rect 96 | // arrays will probably produce worse packing results than calling it 97 | // a single time with the full rectangle array, but the option is 98 | // available. 99 | 100 | struct stbrp_rect 101 | { 102 | // reserved for your use: 103 | int id; 104 | 105 | // input: 106 | stbrp_coord w, h; 107 | 108 | // output: 109 | stbrp_coord x, y; 110 | int was_packed; // non-zero if valid packing 111 | 112 | }; // 16 bytes, nominally 113 | 114 | 115 | STBRP_DEF void stbrp_init_target (stbrp_context *context, int width, int height, stbrp_node *nodes, int num_nodes); 116 | // Initialize a rectangle packer to: 117 | // pack a rectangle that is 'width' by 'height' in dimensions 118 | // using temporary storage provided by the array 'nodes', which is 'num_nodes' long 119 | // 120 | // You must call this function every time you start packing into a new target. 121 | // 122 | // There is no "shutdown" function. The 'nodes' memory must stay valid for 123 | // the following stbrp_pack_rects() call (or calls), but can be freed after 124 | // the call (or calls) finish. 125 | // 126 | // Note: to guarantee best results, either: 127 | // 1. make sure 'num_nodes' >= 'width' 128 | // or 2. call stbrp_allow_out_of_mem() defined below with 'allow_out_of_mem = 1' 129 | // 130 | // If you don't do either of the above things, widths will be quantized to multiples 131 | // of small integers to guarantee the algorithm doesn't run out of temporary storage. 132 | // 133 | // If you do #2, then the non-quantized algorithm will be used, but the algorithm 134 | // may run out of temporary storage and be unable to pack some rectangles. 135 | 136 | STBRP_DEF void stbrp_setup_allow_out_of_mem (stbrp_context *context, int allow_out_of_mem); 137 | // Optionally call this function after init but before doing any packing to 138 | // change the handling of the out-of-temp-memory scenario, described above. 139 | // If you call init again, this will be reset to the default (false). 140 | 141 | 142 | STBRP_DEF void stbrp_setup_heuristic (stbrp_context *context, int heuristic); 143 | // Optionally select which packing heuristic the library should use. Different 144 | // heuristics will produce better/worse results for different data sets. 145 | // If you call init again, this will be reset to the default. 146 | 147 | enum 148 | { 149 | STBRP_HEURISTIC_Skyline_default=0, 150 | STBRP_HEURISTIC_Skyline_BL_sortHeight = STBRP_HEURISTIC_Skyline_default, 151 | STBRP_HEURISTIC_Skyline_BF_sortHeight 152 | }; 153 | 154 | 155 | ////////////////////////////////////////////////////////////////////////////// 156 | // 157 | // the details of the following structures don't matter to you, but they must 158 | // be visible so you can handle the memory allocations for them 159 | 160 | struct stbrp_node 161 | { 162 | stbrp_coord x,y; 163 | stbrp_node *next; 164 | }; 165 | 166 | struct stbrp_context 167 | { 168 | int width; 169 | int height; 170 | int align; 171 | int init_mode; 172 | int heuristic; 173 | int num_nodes; 174 | stbrp_node *active_head; 175 | stbrp_node *free_head; 176 | stbrp_node extra[2]; // we allocate two extra nodes so optimal user-node-count is 'width' not 'width+2' 177 | }; 178 | 179 | #ifdef __cplusplus 180 | } 181 | #endif 182 | 183 | #endif 184 | 185 | ////////////////////////////////////////////////////////////////////////////// 186 | // 187 | // IMPLEMENTATION SECTION 188 | // 189 | 190 | #ifdef STB_RECT_PACK_IMPLEMENTATION 191 | #ifndef STBRP_SORT 192 | #include 193 | #define STBRP_SORT qsort 194 | #endif 195 | 196 | #ifndef STBRP_ASSERT 197 | #include 198 | #define STBRP_ASSERT assert 199 | #endif 200 | 201 | enum 202 | { 203 | STBRP__INIT_skyline = 1 204 | }; 205 | 206 | STBRP_DEF void stbrp_setup_heuristic(stbrp_context *context, int heuristic) 207 | { 208 | switch (context->init_mode) { 209 | case STBRP__INIT_skyline: 210 | STBRP_ASSERT(heuristic == STBRP_HEURISTIC_Skyline_BL_sortHeight || heuristic == STBRP_HEURISTIC_Skyline_BF_sortHeight); 211 | context->heuristic = heuristic; 212 | break; 213 | default: 214 | STBRP_ASSERT(0); 215 | } 216 | } 217 | 218 | STBRP_DEF void stbrp_setup_allow_out_of_mem(stbrp_context *context, int allow_out_of_mem) 219 | { 220 | if (allow_out_of_mem) 221 | // if it's ok to run out of memory, then don't bother aligning them; 222 | // this gives better packing, but may fail due to OOM (even though 223 | // the rectangles easily fit). @TODO a smarter approach would be to only 224 | // quantize once we've hit OOM, then we could get rid of this parameter. 225 | context->align = 1; 226 | else { 227 | // if it's not ok to run out of memory, then quantize the widths 228 | // so that num_nodes is always enough nodes. 229 | // 230 | // I.e. num_nodes * align >= width 231 | // align >= width / num_nodes 232 | // align = ceil(width/num_nodes) 233 | 234 | context->align = (context->width + context->num_nodes-1) / context->num_nodes; 235 | } 236 | } 237 | 238 | STBRP_DEF void stbrp_init_target(stbrp_context *context, int width, int height, stbrp_node *nodes, int num_nodes) 239 | { 240 | int i; 241 | #ifndef STBRP_LARGE_RECTS 242 | STBRP_ASSERT(width <= 0xffff && height <= 0xffff); 243 | #endif 244 | 245 | for (i=0; i < num_nodes-1; ++i) 246 | nodes[i].next = &nodes[i+1]; 247 | nodes[i].next = NULL; 248 | context->init_mode = STBRP__INIT_skyline; 249 | context->heuristic = STBRP_HEURISTIC_Skyline_default; 250 | context->free_head = &nodes[0]; 251 | context->active_head = &context->extra[0]; 252 | context->width = width; 253 | context->height = height; 254 | context->num_nodes = num_nodes; 255 | stbrp_setup_allow_out_of_mem(context, 0); 256 | 257 | // node 0 is the full width, node 1 is the sentinel (lets us not store width explicitly) 258 | context->extra[0].x = 0; 259 | context->extra[0].y = 0; 260 | context->extra[0].next = &context->extra[1]; 261 | context->extra[1].x = (stbrp_coord) width; 262 | #ifdef STBRP_LARGE_RECTS 263 | context->extra[1].y = (1<<30); 264 | #else 265 | context->extra[1].y = 65535; 266 | #endif 267 | context->extra[1].next = NULL; 268 | } 269 | 270 | // find minimum y position if it starts at x1 271 | static int stbrp__skyline_find_min_y(stbrp_context *, stbrp_node *first, int x0, int width, int *pwaste) 272 | { 273 | //(void)c; 274 | stbrp_node *node = first; 275 | int x1 = x0 + width; 276 | int min_y, visited_width, waste_area; 277 | STBRP_ASSERT(first->x <= x0); 278 | 279 | #if 0 280 | // skip in case we're past the node 281 | while (node->next->x <= x0) 282 | ++node; 283 | #else 284 | STBRP_ASSERT(node->next->x > x0); // we ended up handling this in the caller for efficiency 285 | #endif 286 | 287 | STBRP_ASSERT(node->x <= x0); 288 | 289 | min_y = 0; 290 | waste_area = 0; 291 | visited_width = 0; 292 | while (node->x < x1) { 293 | if (node->y > min_y) { 294 | // raise min_y higher. 295 | // we've accounted for all waste up to min_y, 296 | // but we'll now add more waste for everything we've visted 297 | waste_area += visited_width * (node->y - min_y); 298 | min_y = node->y; 299 | // the first time through, visited_width might be reduced 300 | if (node->x < x0) 301 | visited_width += node->next->x - x0; 302 | else 303 | visited_width += node->next->x - node->x; 304 | } else { 305 | // add waste area 306 | int under_width = node->next->x - node->x; 307 | if (under_width + visited_width > width) 308 | under_width = width - visited_width; 309 | waste_area += under_width * (min_y - node->y); 310 | visited_width += under_width; 311 | } 312 | node = node->next; 313 | } 314 | 315 | *pwaste = waste_area; 316 | return min_y; 317 | } 318 | 319 | typedef struct 320 | { 321 | int x,y; 322 | stbrp_node **prev_link; 323 | } stbrp__findresult; 324 | 325 | static stbrp__findresult stbrp__skyline_find_best_pos(stbrp_context *c, int width, int height) 326 | { 327 | int best_waste = (1<<30), best_x, best_y = (1 << 30); 328 | stbrp__findresult fr; 329 | stbrp_node **prev, *node, *tail, **best = NULL; 330 | 331 | // align to multiple of c->align 332 | width = (width + c->align - 1); 333 | width -= width % c->align; 334 | STBRP_ASSERT(width % c->align == 0); 335 | 336 | node = c->active_head; 337 | prev = &c->active_head; 338 | while (node->x + width <= c->width) { 339 | int y,waste; 340 | y = stbrp__skyline_find_min_y(c, node, node->x, width, &waste); 341 | if (c->heuristic == STBRP_HEURISTIC_Skyline_BL_sortHeight) { // actually just want to test BL 342 | // bottom left 343 | if (y < best_y) { 344 | best_y = y; 345 | best = prev; 346 | } 347 | } else { 348 | // best-fit 349 | if (y + height <= c->height) { 350 | // can only use it if it first vertically 351 | if (y < best_y || (y == best_y && waste < best_waste)) { 352 | best_y = y; 353 | best_waste = waste; 354 | best = prev; 355 | } 356 | } 357 | } 358 | prev = &node->next; 359 | node = node->next; 360 | } 361 | 362 | best_x = (best == NULL) ? 0 : (*best)->x; 363 | 364 | // if doing best-fit (BF), we also have to try aligning right edge to each node position 365 | // 366 | // e.g, if fitting 367 | // 368 | // ____________________ 369 | // |____________________| 370 | // 371 | // into 372 | // 373 | // | | 374 | // | ____________| 375 | // |____________| 376 | // 377 | // then right-aligned reduces waste, but bottom-left BL is always chooses left-aligned 378 | // 379 | // This makes BF take about 2x the time 380 | 381 | if (c->heuristic == STBRP_HEURISTIC_Skyline_BF_sortHeight) { 382 | tail = c->active_head; 383 | node = c->active_head; 384 | prev = &c->active_head; 385 | // find first node that's admissible 386 | while (tail->x < width) 387 | tail = tail->next; 388 | while (tail) { 389 | int xpos = tail->x - width; 390 | int y,waste; 391 | STBRP_ASSERT(xpos >= 0); 392 | // find the left position that matches this 393 | while (node->next->x <= xpos) { 394 | prev = &node->next; 395 | node = node->next; 396 | } 397 | STBRP_ASSERT(node->next->x > xpos && node->x <= xpos); 398 | y = stbrp__skyline_find_min_y(c, node, xpos, width, &waste); 399 | if (y + height < c->height) { 400 | if (y <= best_y) { 401 | if (y < best_y || waste < best_waste || (waste==best_waste && xpos < best_x)) { 402 | best_x = xpos; 403 | STBRP_ASSERT(y <= best_y); 404 | best_y = y; 405 | best_waste = waste; 406 | best = prev; 407 | } 408 | } 409 | } 410 | tail = tail->next; 411 | } 412 | } 413 | 414 | fr.prev_link = best; 415 | fr.x = best_x; 416 | fr.y = best_y; 417 | return fr; 418 | } 419 | 420 | static stbrp__findresult stbrp__skyline_pack_rectangle(stbrp_context *context, int width, int height) 421 | { 422 | // find best position according to heuristic 423 | stbrp__findresult res = stbrp__skyline_find_best_pos(context, width, height); 424 | stbrp_node *node, *cur; 425 | 426 | // bail if: 427 | // 1. it failed 428 | // 2. the best node doesn't fit (we don't always check this) 429 | // 3. we're out of memory 430 | if (res.prev_link == NULL || res.y + height > context->height || context->free_head == NULL) { 431 | res.prev_link = NULL; 432 | return res; 433 | } 434 | 435 | // on success, create new node 436 | node = context->free_head; 437 | node->x = (stbrp_coord) res.x; 438 | node->y = (stbrp_coord) (res.y + height); 439 | 440 | context->free_head = node->next; 441 | 442 | // insert the new node into the right starting point, and 443 | // let 'cur' point to the remaining nodes needing to be 444 | // stiched back in 445 | 446 | cur = *res.prev_link; 447 | if (cur->x < res.x) { 448 | // preserve the existing one, so start testing with the next one 449 | stbrp_node *next = cur->next; 450 | cur->next = node; 451 | cur = next; 452 | } else { 453 | *res.prev_link = node; 454 | } 455 | 456 | // from here, traverse cur and free the nodes, until we get to one 457 | // that shouldn't be freed 458 | while (cur->next && cur->next->x <= res.x + width) { 459 | stbrp_node *next = cur->next; 460 | // move the current node to the free list 461 | cur->next = context->free_head; 462 | context->free_head = cur; 463 | cur = next; 464 | } 465 | 466 | // stitch the list back in 467 | node->next = cur; 468 | 469 | if (cur->x < res.x + width) 470 | cur->x = (stbrp_coord) (res.x + width); 471 | 472 | #ifdef _DEBUG 473 | cur = context->active_head; 474 | while (cur->x < context->width) { 475 | STBRP_ASSERT(cur->x < cur->next->x); 476 | cur = cur->next; 477 | } 478 | STBRP_ASSERT(cur->next == NULL); 479 | 480 | { 481 | stbrp_node *L1 = NULL, *L2 = NULL; 482 | int count=0; 483 | cur = context->active_head; 484 | while (cur) { 485 | L1 = cur; 486 | cur = cur->next; 487 | ++count; 488 | } 489 | cur = context->free_head; 490 | while (cur) { 491 | L2 = cur; 492 | cur = cur->next; 493 | ++count; 494 | } 495 | STBRP_ASSERT(count == context->num_nodes+2); 496 | } 497 | #endif 498 | 499 | return res; 500 | } 501 | 502 | static int rect_height_compare(const void *a, const void *b) 503 | { 504 | stbrp_rect *p = (stbrp_rect *) a; 505 | stbrp_rect *q = (stbrp_rect *) b; 506 | if (p->h > q->h) 507 | return -1; 508 | if (p->h < q->h) 509 | return 1; 510 | return (p->w > q->w) ? -1 : (p->w < q->w); 511 | } 512 | 513 | static int rect_width_compare(const void *a, const void *b) 514 | { 515 | stbrp_rect *p = (stbrp_rect *) a; 516 | stbrp_rect *q = (stbrp_rect *) b; 517 | if (p->w > q->w) 518 | return -1; 519 | if (p->w < q->w) 520 | return 1; 521 | return (p->h > q->h) ? -1 : (p->h < q->h); 522 | } 523 | 524 | static int rect_original_order(const void *a, const void *b) 525 | { 526 | stbrp_rect *p = (stbrp_rect *) a; 527 | stbrp_rect *q = (stbrp_rect *) b; 528 | return (p->was_packed < q->was_packed) ? -1 : (p->was_packed > q->was_packed); 529 | } 530 | 531 | #ifdef STBRP_LARGE_RECTS 532 | #define STBRP__MAXVAL 0xffffffff 533 | #else 534 | #define STBRP__MAXVAL 0xffff 535 | #endif 536 | 537 | STBRP_DEF void stbrp_pack_rects(stbrp_context *context, stbrp_rect *rects, int num_rects) 538 | { 539 | int i; 540 | 541 | // we use the 'was_packed' field internally to allow sorting/unsorting 542 | for (i=0; i < num_rects; ++i) { 543 | rects[i].was_packed = i; 544 | #ifndef STBRP_LARGE_RECTS 545 | STBRP_ASSERT(rects[i].w <= 0xffff && rects[i].h <= 0xffff); 546 | #endif 547 | } 548 | 549 | // sort according to heuristic 550 | STBRP_SORT(rects, num_rects, sizeof(rects[0]), rect_height_compare); 551 | 552 | for (i=0; i < num_rects; ++i) { 553 | if (rects[i].w == 0 || rects[i].h == 0) { 554 | rects[i].x = rects[i].y = 0; // empty rect needs no space 555 | } else { 556 | stbrp__findresult fr = stbrp__skyline_pack_rectangle(context, rects[i].w, rects[i].h); 557 | if (fr.prev_link) { 558 | rects[i].x = (stbrp_coord) fr.x; 559 | rects[i].y = (stbrp_coord) fr.y; 560 | } else { 561 | rects[i].x = rects[i].y = STBRP__MAXVAL; 562 | } 563 | } 564 | } 565 | 566 | // unsort 567 | STBRP_SORT(rects, num_rects, sizeof(rects[0]), rect_original_order); 568 | 569 | // set was_packed flags 570 | for (i=0; i < num_rects; ++i) 571 | rects[i].was_packed = !(rects[i].x == STBRP__MAXVAL && rects[i].y == STBRP__MAXVAL); 572 | } 573 | #endif 574 | -------------------------------------------------------------------------------- /app/src/main/cpp/gl3stub.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 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 compliance 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 | #include 18 | #include "gl3stub.h" 19 | 20 | GLboolean gl3stubInit() { 21 | #define FIND_PROC(s) s = (void*)eglGetProcAddress(#s) 22 | FIND_PROC(glReadBuffer); 23 | FIND_PROC(glDrawRangeElements); 24 | FIND_PROC(glTexImage3D); 25 | FIND_PROC(glTexSubImage3D); 26 | FIND_PROC(glCopyTexSubImage3D); 27 | FIND_PROC(glCompressedTexImage3D); 28 | FIND_PROC(glCompressedTexSubImage3D); 29 | FIND_PROC(glGenQueries); 30 | FIND_PROC(glDeleteQueries); 31 | FIND_PROC(glIsQuery); 32 | FIND_PROC(glBeginQuery); 33 | FIND_PROC(glEndQuery); 34 | FIND_PROC(glGetQueryiv); 35 | FIND_PROC(glGetQueryObjectuiv); 36 | FIND_PROC(glUnmapBuffer); 37 | FIND_PROC(glGetBufferPointerv); 38 | FIND_PROC(glDrawBuffers); 39 | FIND_PROC(glUniformMatrix2x3fv); 40 | FIND_PROC(glUniformMatrix3x2fv); 41 | FIND_PROC(glUniformMatrix2x4fv); 42 | FIND_PROC(glUniformMatrix4x2fv); 43 | FIND_PROC(glUniformMatrix3x4fv); 44 | FIND_PROC(glUniformMatrix4x3fv); 45 | FIND_PROC(glBlitFramebuffer); 46 | FIND_PROC(glRenderbufferStorageMultisample); 47 | FIND_PROC(glFramebufferTextureLayer); 48 | FIND_PROC(glMapBufferRange); 49 | FIND_PROC(glFlushMappedBufferRange); 50 | FIND_PROC(glBindVertexArray); 51 | FIND_PROC(glDeleteVertexArrays); 52 | FIND_PROC(glGenVertexArrays); 53 | FIND_PROC(glIsVertexArray); 54 | FIND_PROC(glGetIntegeri_v); 55 | FIND_PROC(glBeginTransformFeedback); 56 | FIND_PROC(glEndTransformFeedback); 57 | FIND_PROC(glBindBufferRange); 58 | FIND_PROC(glBindBufferBase); 59 | FIND_PROC(glTransformFeedbackVaryings); 60 | FIND_PROC(glGetTransformFeedbackVarying); 61 | FIND_PROC(glVertexAttribIPointer); 62 | FIND_PROC(glGetVertexAttribIiv); 63 | FIND_PROC(glGetVertexAttribIuiv); 64 | FIND_PROC(glVertexAttribI4i); 65 | FIND_PROC(glVertexAttribI4ui); 66 | FIND_PROC(glVertexAttribI4iv); 67 | FIND_PROC(glVertexAttribI4uiv); 68 | FIND_PROC(glGetUniformuiv); 69 | FIND_PROC(glGetFragDataLocation); 70 | FIND_PROC(glUniform1ui); 71 | FIND_PROC(glUniform2ui); 72 | FIND_PROC(glUniform3ui); 73 | FIND_PROC(glUniform4ui); 74 | FIND_PROC(glUniform1uiv); 75 | FIND_PROC(glUniform2uiv); 76 | FIND_PROC(glUniform3uiv); 77 | FIND_PROC(glUniform4uiv); 78 | FIND_PROC(glClearBufferiv); 79 | FIND_PROC(glClearBufferuiv); 80 | FIND_PROC(glClearBufferfv); 81 | FIND_PROC(glClearBufferfi); 82 | FIND_PROC(glGetStringi); 83 | FIND_PROC(glCopyBufferSubData); 84 | FIND_PROC(glGetUniformIndices); 85 | FIND_PROC(glGetActiveUniformsiv); 86 | FIND_PROC(glGetUniformBlockIndex); 87 | FIND_PROC(glGetActiveUniformBlockiv); 88 | FIND_PROC(glGetActiveUniformBlockName); 89 | FIND_PROC(glUniformBlockBinding); 90 | FIND_PROC(glDrawArraysInstanced); 91 | FIND_PROC(glDrawElementsInstanced); 92 | FIND_PROC(glFenceSync); 93 | FIND_PROC(glIsSync); 94 | FIND_PROC(glDeleteSync); 95 | FIND_PROC(glClientWaitSync); 96 | FIND_PROC(glWaitSync); 97 | FIND_PROC(glGetInteger64v); 98 | FIND_PROC(glGetSynciv); 99 | FIND_PROC(glGetInteger64i_v); 100 | FIND_PROC(glGetBufferParameteri64v); 101 | FIND_PROC(glGenSamplers); 102 | FIND_PROC(glDeleteSamplers); 103 | FIND_PROC(glIsSampler); 104 | FIND_PROC(glBindSampler); 105 | FIND_PROC(glSamplerParameteri); 106 | FIND_PROC(glSamplerParameteriv); 107 | FIND_PROC(glSamplerParameterf); 108 | FIND_PROC(glSamplerParameterfv); 109 | FIND_PROC(glGetSamplerParameteriv); 110 | FIND_PROC(glGetSamplerParameterfv); 111 | FIND_PROC(glVertexAttribDivisor); 112 | FIND_PROC(glBindTransformFeedback); 113 | FIND_PROC(glDeleteTransformFeedbacks); 114 | FIND_PROC(glGenTransformFeedbacks); 115 | FIND_PROC(glIsTransformFeedback); 116 | FIND_PROC(glPauseTransformFeedback); 117 | FIND_PROC(glResumeTransformFeedback); 118 | FIND_PROC(glGetProgramBinary); 119 | FIND_PROC(glProgramBinary); 120 | FIND_PROC(glProgramParameteri); 121 | FIND_PROC(glInvalidateFramebuffer); 122 | FIND_PROC(glInvalidateSubFramebuffer); 123 | FIND_PROC(glTexStorage2D); 124 | FIND_PROC(glTexStorage3D); 125 | FIND_PROC(glGetInternalformativ); 126 | #undef FIND_PROC 127 | 128 | if (!glReadBuffer || 129 | !glDrawRangeElements || 130 | !glTexImage3D || 131 | !glTexSubImage3D || 132 | !glCopyTexSubImage3D || 133 | !glCompressedTexImage3D || 134 | !glCompressedTexSubImage3D || 135 | !glGenQueries || 136 | !glDeleteQueries || 137 | !glIsQuery || 138 | !glBeginQuery || 139 | !glEndQuery || 140 | !glGetQueryiv || 141 | !glGetQueryObjectuiv || 142 | !glUnmapBuffer || 143 | !glGetBufferPointerv || 144 | !glDrawBuffers || 145 | !glUniformMatrix2x3fv || 146 | !glUniformMatrix3x2fv || 147 | !glUniformMatrix2x4fv || 148 | !glUniformMatrix4x2fv || 149 | !glUniformMatrix3x4fv || 150 | !glUniformMatrix4x3fv || 151 | !glBlitFramebuffer || 152 | !glRenderbufferStorageMultisample || 153 | !glFramebufferTextureLayer || 154 | !glMapBufferRange || 155 | !glFlushMappedBufferRange || 156 | !glBindVertexArray || 157 | !glDeleteVertexArrays || 158 | !glGenVertexArrays || 159 | !glIsVertexArray || 160 | !glGetIntegeri_v || 161 | !glBeginTransformFeedback || 162 | !glEndTransformFeedback || 163 | !glBindBufferRange || 164 | !glBindBufferBase || 165 | !glTransformFeedbackVaryings || 166 | !glGetTransformFeedbackVarying || 167 | !glVertexAttribIPointer || 168 | !glGetVertexAttribIiv || 169 | !glGetVertexAttribIuiv || 170 | !glVertexAttribI4i || 171 | !glVertexAttribI4ui || 172 | !glVertexAttribI4iv || 173 | !glVertexAttribI4uiv || 174 | !glGetUniformuiv || 175 | !glGetFragDataLocation || 176 | !glUniform1ui || 177 | !glUniform2ui || 178 | !glUniform3ui || 179 | !glUniform4ui || 180 | !glUniform1uiv || 181 | !glUniform2uiv || 182 | !glUniform3uiv || 183 | !glUniform4uiv || 184 | !glClearBufferiv || 185 | !glClearBufferuiv || 186 | !glClearBufferfv || 187 | !glClearBufferfi || 188 | !glGetStringi || 189 | !glCopyBufferSubData || 190 | !glGetUniformIndices || 191 | !glGetActiveUniformsiv || 192 | !glGetUniformBlockIndex || 193 | !glGetActiveUniformBlockiv || 194 | !glGetActiveUniformBlockName || 195 | !glUniformBlockBinding || 196 | !glDrawArraysInstanced || 197 | !glDrawElementsInstanced || 198 | !glFenceSync || 199 | !glIsSync || 200 | !glDeleteSync || 201 | !glClientWaitSync || 202 | !glWaitSync || 203 | !glGetInteger64v || 204 | !glGetSynciv || 205 | !glGetInteger64i_v || 206 | !glGetBufferParameteri64v || 207 | !glGenSamplers || 208 | !glDeleteSamplers || 209 | !glIsSampler || 210 | !glBindSampler || 211 | !glSamplerParameteri || 212 | !glSamplerParameteriv || 213 | !glSamplerParameterf || 214 | !glSamplerParameterfv || 215 | !glGetSamplerParameteriv || 216 | !glGetSamplerParameterfv || 217 | !glVertexAttribDivisor || 218 | !glBindTransformFeedback || 219 | !glDeleteTransformFeedbacks || 220 | !glGenTransformFeedbacks || 221 | !glIsTransformFeedback || 222 | !glPauseTransformFeedback || 223 | !glResumeTransformFeedback || 224 | !glGetProgramBinary || 225 | !glProgramBinary || 226 | !glProgramParameteri || 227 | !glInvalidateFramebuffer || 228 | !glInvalidateSubFramebuffer || 229 | !glTexStorage2D || 230 | !glTexStorage3D || 231 | !glGetInternalformativ) 232 | { 233 | return GL_FALSE; 234 | } 235 | 236 | return GL_TRUE; 237 | } 238 | 239 | /* Function pointer definitions */ 240 | GL_APICALL void (* GL_APIENTRY glReadBuffer) (GLenum mode); 241 | GL_APICALL void (* GL_APIENTRY glDrawRangeElements) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid* indices); 242 | GL_APICALL void (* GL_APIENTRY glTexImage3D) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels); 243 | GL_APICALL void (* GL_APIENTRY glTexSubImage3D) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels); 244 | GL_APICALL void (* GL_APIENTRY glCopyTexSubImage3D) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); 245 | GL_APICALL void (* GL_APIENTRY glCompressedTexImage3D) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data); 246 | GL_APICALL void (* GL_APIENTRY glCompressedTexSubImage3D) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data); 247 | GL_APICALL void (* GL_APIENTRY glGenQueries) (GLsizei n, GLuint* ids); 248 | GL_APICALL void (* GL_APIENTRY glDeleteQueries) (GLsizei n, const GLuint* ids); 249 | GL_APICALL GLboolean (* GL_APIENTRY glIsQuery) (GLuint id); 250 | GL_APICALL void (* GL_APIENTRY glBeginQuery) (GLenum target, GLuint id); 251 | GL_APICALL void (* GL_APIENTRY glEndQuery) (GLenum target); 252 | GL_APICALL void (* GL_APIENTRY glGetQueryiv) (GLenum target, GLenum pname, GLint* params); 253 | GL_APICALL void (* GL_APIENTRY glGetQueryObjectuiv) (GLuint id, GLenum pname, GLuint* params); 254 | GL_APICALL GLboolean (* GL_APIENTRY glUnmapBuffer) (GLenum target); 255 | GL_APICALL void (* GL_APIENTRY glGetBufferPointerv) (GLenum target, GLenum pname, GLvoid** params); 256 | GL_APICALL void (* GL_APIENTRY glDrawBuffers) (GLsizei n, const GLenum* bufs); 257 | GL_APICALL void (* GL_APIENTRY glUniformMatrix2x3fv) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); 258 | GL_APICALL void (* GL_APIENTRY glUniformMatrix3x2fv) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); 259 | GL_APICALL void (* GL_APIENTRY glUniformMatrix2x4fv) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); 260 | GL_APICALL void (* GL_APIENTRY glUniformMatrix4x2fv) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); 261 | GL_APICALL void (* GL_APIENTRY glUniformMatrix3x4fv) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); 262 | GL_APICALL void (* GL_APIENTRY glUniformMatrix4x3fv) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); 263 | GL_APICALL void (* GL_APIENTRY glBlitFramebuffer) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); 264 | GL_APICALL void (* GL_APIENTRY glRenderbufferStorageMultisample) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); 265 | GL_APICALL void (* GL_APIENTRY glFramebufferTextureLayer) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); 266 | GL_APICALL GLvoid* (* GL_APIENTRY glMapBufferRange) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); 267 | GL_APICALL void (* GL_APIENTRY glFlushMappedBufferRange) (GLenum target, GLintptr offset, GLsizeiptr length); 268 | GL_APICALL void (* GL_APIENTRY glBindVertexArray) (GLuint array); 269 | GL_APICALL void (* GL_APIENTRY glDeleteVertexArrays) (GLsizei n, const GLuint* arrays); 270 | GL_APICALL void (* GL_APIENTRY glGenVertexArrays) (GLsizei n, GLuint* arrays); 271 | GL_APICALL GLboolean (* GL_APIENTRY glIsVertexArray) (GLuint array); 272 | GL_APICALL void (* GL_APIENTRY glGetIntegeri_v) (GLenum target, GLuint index, GLint* data); 273 | GL_APICALL void (* GL_APIENTRY glBeginTransformFeedback) (GLenum primitiveMode); 274 | GL_APICALL void (* GL_APIENTRY glEndTransformFeedback) (void); 275 | GL_APICALL void (* GL_APIENTRY glBindBufferRange) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); 276 | GL_APICALL void (* GL_APIENTRY glBindBufferBase) (GLenum target, GLuint index, GLuint buffer); 277 | GL_APICALL void (* GL_APIENTRY glTransformFeedbackVaryings) (GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode); 278 | GL_APICALL void (* GL_APIENTRY glGetTransformFeedbackVarying) (GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name); 279 | GL_APICALL void (* GL_APIENTRY glVertexAttribIPointer) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer); 280 | GL_APICALL void (* GL_APIENTRY glGetVertexAttribIiv) (GLuint index, GLenum pname, GLint* params); 281 | GL_APICALL void (* GL_APIENTRY glGetVertexAttribIuiv) (GLuint index, GLenum pname, GLuint* params); 282 | GL_APICALL void (* GL_APIENTRY glVertexAttribI4i) (GLuint index, GLint x, GLint y, GLint z, GLint w); 283 | GL_APICALL void (* GL_APIENTRY glVertexAttribI4ui) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); 284 | GL_APICALL void (* GL_APIENTRY glVertexAttribI4iv) (GLuint index, const GLint* v); 285 | GL_APICALL void (* GL_APIENTRY glVertexAttribI4uiv) (GLuint index, const GLuint* v); 286 | GL_APICALL void (* GL_APIENTRY glGetUniformuiv) (GLuint program, GLint location, GLuint* params); 287 | GL_APICALL GLint (* GL_APIENTRY glGetFragDataLocation) (GLuint program, const GLchar *name); 288 | GL_APICALL void (* GL_APIENTRY glUniform1ui) (GLint location, GLuint v0); 289 | GL_APICALL void (* GL_APIENTRY glUniform2ui) (GLint location, GLuint v0, GLuint v1); 290 | GL_APICALL void (* GL_APIENTRY glUniform3ui) (GLint location, GLuint v0, GLuint v1, GLuint v2); 291 | GL_APICALL void (* GL_APIENTRY glUniform4ui) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); 292 | GL_APICALL void (* GL_APIENTRY glUniform1uiv) (GLint location, GLsizei count, const GLuint* value); 293 | GL_APICALL void (* GL_APIENTRY glUniform2uiv) (GLint location, GLsizei count, const GLuint* value); 294 | GL_APICALL void (* GL_APIENTRY glUniform3uiv) (GLint location, GLsizei count, const GLuint* value); 295 | GL_APICALL void (* GL_APIENTRY glUniform4uiv) (GLint location, GLsizei count, const GLuint* value); 296 | GL_APICALL void (* GL_APIENTRY glClearBufferiv) (GLenum buffer, GLint drawbuffer, const GLint* value); 297 | GL_APICALL void (* GL_APIENTRY glClearBufferuiv) (GLenum buffer, GLint drawbuffer, const GLuint* value); 298 | GL_APICALL void (* GL_APIENTRY glClearBufferfv) (GLenum buffer, GLint drawbuffer, const GLfloat* value); 299 | GL_APICALL void (* GL_APIENTRY glClearBufferfi) (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); 300 | GL_APICALL const GLubyte* (* GL_APIENTRY glGetStringi) (GLenum name, GLuint index); 301 | GL_APICALL void (* GL_APIENTRY glCopyBufferSubData) (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); 302 | GL_APICALL void (* GL_APIENTRY glGetUniformIndices) (GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices); 303 | GL_APICALL void (* GL_APIENTRY glGetActiveUniformsiv) (GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params); 304 | GL_APICALL GLuint (* GL_APIENTRY glGetUniformBlockIndex) (GLuint program, const GLchar* uniformBlockName); 305 | GL_APICALL void (* GL_APIENTRY glGetActiveUniformBlockiv) (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params); 306 | GL_APICALL void (* GL_APIENTRY glGetActiveUniformBlockName) (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName); 307 | GL_APICALL void (* GL_APIENTRY glUniformBlockBinding) (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); 308 | GL_APICALL void (* GL_APIENTRY glDrawArraysInstanced) (GLenum mode, GLint first, GLsizei count, GLsizei instanceCount); 309 | GL_APICALL void (* GL_APIENTRY glDrawElementsInstanced) (GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLsizei instanceCount); 310 | GL_APICALL GLsync (* GL_APIENTRY glFenceSync) (GLenum condition, GLbitfield flags); 311 | GL_APICALL GLboolean (* GL_APIENTRY glIsSync) (GLsync sync); 312 | GL_APICALL void (* GL_APIENTRY glDeleteSync) (GLsync sync); 313 | GL_APICALL GLenum (* GL_APIENTRY glClientWaitSync) (GLsync sync, GLbitfield flags, GLuint64 timeout); 314 | GL_APICALL void (* GL_APIENTRY glWaitSync) (GLsync sync, GLbitfield flags, GLuint64 timeout); 315 | GL_APICALL void (* GL_APIENTRY glGetInteger64v) (GLenum pname, GLint64* params); 316 | GL_APICALL void (* GL_APIENTRY glGetSynciv) (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values); 317 | GL_APICALL void (* GL_APIENTRY glGetInteger64i_v) (GLenum target, GLuint index, GLint64* data); 318 | GL_APICALL void (* GL_APIENTRY glGetBufferParameteri64v) (GLenum target, GLenum pname, GLint64* params); 319 | GL_APICALL void (* GL_APIENTRY glGenSamplers) (GLsizei count, GLuint* samplers); 320 | GL_APICALL void (* GL_APIENTRY glDeleteSamplers) (GLsizei count, const GLuint* samplers); 321 | GL_APICALL GLboolean (* GL_APIENTRY glIsSampler) (GLuint sampler); 322 | GL_APICALL void (* GL_APIENTRY glBindSampler) (GLuint unit, GLuint sampler); 323 | GL_APICALL void (* GL_APIENTRY glSamplerParameteri) (GLuint sampler, GLenum pname, GLint param); 324 | GL_APICALL void (* GL_APIENTRY glSamplerParameteriv) (GLuint sampler, GLenum pname, const GLint* param); 325 | GL_APICALL void (* GL_APIENTRY glSamplerParameterf) (GLuint sampler, GLenum pname, GLfloat param); 326 | GL_APICALL void (* GL_APIENTRY glSamplerParameterfv) (GLuint sampler, GLenum pname, const GLfloat* param); 327 | GL_APICALL void (* GL_APIENTRY glGetSamplerParameteriv) (GLuint sampler, GLenum pname, GLint* params); 328 | GL_APICALL void (* GL_APIENTRY glGetSamplerParameterfv) (GLuint sampler, GLenum pname, GLfloat* params); 329 | GL_APICALL void (* GL_APIENTRY glVertexAttribDivisor) (GLuint index, GLuint divisor); 330 | GL_APICALL void (* GL_APIENTRY glBindTransformFeedback) (GLenum target, GLuint id); 331 | GL_APICALL void (* GL_APIENTRY glDeleteTransformFeedbacks) (GLsizei n, const GLuint* ids); 332 | GL_APICALL void (* GL_APIENTRY glGenTransformFeedbacks) (GLsizei n, GLuint* ids); 333 | GL_APICALL GLboolean (* GL_APIENTRY glIsTransformFeedback) (GLuint id); 334 | GL_APICALL void (* GL_APIENTRY glPauseTransformFeedback) (void); 335 | GL_APICALL void (* GL_APIENTRY glResumeTransformFeedback) (void); 336 | GL_APICALL void (* GL_APIENTRY glGetProgramBinary) (GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary); 337 | GL_APICALL void (* GL_APIENTRY glProgramBinary) (GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length); 338 | GL_APICALL void (* GL_APIENTRY glProgramParameteri) (GLuint program, GLenum pname, GLint value); 339 | GL_APICALL void (* GL_APIENTRY glInvalidateFramebuffer) (GLenum target, GLsizei numAttachments, const GLenum* attachments); 340 | GL_APICALL void (* GL_APIENTRY glInvalidateSubFramebuffer) (GLenum target, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height); 341 | GL_APICALL void (* GL_APIENTRY glTexStorage2D) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); 342 | GL_APICALL void (* GL_APIENTRY glTexStorage3D) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); 343 | GL_APICALL void (* GL_APIENTRY glGetInternalformativ) (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params); 344 | -------------------------------------------------------------------------------- /app/src/main/cpp/imGui/FmtConversion.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 Qualcomm Technologies, Inc. // Some functions to convert between formats. #ifndef _FMTCONVERSIONS_H_ #define _FMTCONVERSIONS_H_ #include "ArgDefines.h" //================================================================================================================================= /// /// Converts a fixed 16.16 int to a float32 /// /// \param The fixed 16.16 int value /// /// \return The float32 value //================================================================================================================================= inline float32 FixedToFloat( uint32 v ) { float32 v0 = (float32)(int32)v; uint32 v1 = v ? (*((uint32*)&v0) - 0x08000000) : 0; return *((float32*)&v1); } //================================================================================================================================= /// /// Converts a fixed 32.32 int to a float32 /// /// \param The fixed 32.32 int value /// /// \return The float64 value //================================================================================================================================= inline float64 FixedToFloat( uint64 v ) { float64 v0 = (float64)(int64)v; uint64 v1 = v ? (*((uint64*)&v0) - 0x08000000) : 0; return *((float64*)&v1); } //================================================================================================================================= /// /// Converts a float32 to a fixed 16.16 int /// /// \param The float32 value /// /// \return The fixed 16.16 int value //================================================================================================================================= inline uint32 FloatToFixed( float32 v ) { float32 b = v; uint32 ret; uint32 d = *((uint32*)&b) + 0x08000000; ret = (int32)(*((float32*)&d)); return ret; } //================================================================================================================================= /// /// Converts a float64 to a fixed 32.32 int /// /// \param The float64 value /// /// \return The fixed 32.32 int value //================================================================================================================================= inline uint64 FloatToFixed( float64 v ) { float64 b = v; uint64 ret; uint64 d = *((uint64*)&b) + 0x08000000; ret = (int64)(*((float64*)&d)); return ret; } //================================================================================================================================= /// /// Converts a float32 to a float16 /// /// \param The float32 value /// /// \return The float16 value //================================================================================================================================= inline uint16 FloatToHalf( float32 v ) { uint32 src = *(uint32*)(&v); uint32 sign = src >> 31; // Shifts on unsigned int types are always supposed to zero fill, is this the case for Mac, and Linux, etc. as well.. uint16 ret; // Extract mantissa uint32 mantissa = src & (1 << 23) - 1; // extract & convert exp bits int32 exp = int32( src >> 23 & 0xFF ) - 127; if( exp > 15 ) { // The largest-possible positive 2-byte-float exponent value would be 11110-01111 = 11110 = 15. exp = 15; mantissa = (1 << 23) - 1; } else if( exp < -14 ) { // handle wraparound of shifts (done mod 64 on PPC) // All float32 denormal/0 values map to float16 0 if( exp <= - 14 - 24 ) { mantissa = 0; } else { mantissa = ( mantissa | 1 << 23 ) >> (-exp - 14); } exp = -14; } // TODO: exp is a *signed* int, left shifting it could extend the signed bit, // will have to mask off the first bits where the mantissa should go. ret = (sign << 15) | ((uint16)(exp + 15) << 10) | (mantissa >> 13); return ret; } //================================================================================================================================= /// /// Converts from float64 to float32 /// /// \param The float64 value /// /// \return The float32 value in a uint32 //================================================================================================================================= inline uint32 FloatToHalf( float64 v ) { // 64bit IEEE 754 float format: 1 sign bit, 11 exp bits,52 mantissa bits uint64 src = *(uint64*)(&v); uint64 sign = src >> 63; uint32 ret; // Extract mantissa uint64 mantissa = src & ((uint64)1 << 52) - 1; // NOTE: 2047 = 11111111111 (11 'set' bits), below it functions as a mask so that the first 11bits (which we're treating as our exponent) // are retained while the remaining are set to zero. int64 exp = int64( src >> 52 & 2047 ) - 1023; if( exp > 127 ) { // largest possible (non infinity) 4-byte-float-number... exp = 127; mantissa = ((uint64)1 << 52) - 1; } else if( exp < -126 ) { // handle wraparound of shifts (done mod 64 on PPC) // All float32 denorm/0 values map to float16 0 if( exp <= - 126 - 24 ) { mantissa = 0; } else { mantissa = ( mantissa | (uint64)1 << 52 ) >> (-exp - 126); } exp = -15; } // TODO: Can't left shift *signed* integer exp as it may fill in using the sign bit which could be 1, and not 0. ret = (uint32)((sign << 31) | ((uint32)(exp + 127) << 23) | (mantissa >> 29)); return ret; } //================================================================================================================================= /// /// Takes subnormal float32 (cast as a uint32 so we can operate on it for this function) /// /// \param The subnormal float32 value /// /// \return The float32 value //================================================================================================================================= inline uint32 Float32SubnormalToNormal(uint32 i) { uint32 mantissa = i; uint32 exponent = 0; // Zero exponent // Recall that a float represents a (base 2) binary number using scientific notation, which is of the format: MANTISSA x 2^(EXPONENT-EXP_BIAS). // So to represent the "normal" version of a "subnormal" float, where the exponent==0 AND mantissa!=0 indicates "subnormal" via IEEE float 754 specification, // we just need to make the exponent non-zero while still having the overall float value represent the same number.. // We do this by subtracting // While not normalized.. while(!(mantissa&0x00800000)) { exponent -= 0x00800000; // Decrement exponent (1<<23). This is the same as subtracting 1 from the 8bit mantissa, but in the context of a uint32 instead of a uint8. mantissa <<= 1; // Left shift mantissa 1, which is multiplying by 2.. } mantissa &= ~0x00800000; // Clear first exponent bit exponent += 0x38800000; // Adjust bias ((127-14)<<23) return (mantissa | exponent); // Return finalized float including new mantissa and exponent } //================================================================================================================================= /// /// Converts a float16 to a float32 /// /// \param The float16 value /// /// \return The float32 value //================================================================================================================================= inline float32 HalfToFloat( uint16 bits ) { // This accounts for normal 2byte floats, but what about the special cases.. uint32 ret = ((bits&0x8000)<<16) | (((bits&0x7c00)+0x1C000)<<13) | ((bits&0x03FF)<<13); // When exponent is zero: we're dealing with either +/- zero (when mantissa is also zero), OR subnormal values (when mantissa is also non-zero) // However zero exponents are handled by the above logic, and it also properly handles mantissas of any values. // When exponent is 31: we're dealing with either +/- infinity (when mantissa is also zero), OR NaN (Not a Number) (when mantissa is also non-zero) // For the case when the 5-bit exponent is 31, we're converting to an 8-bit exponent, and our logic will not expand the exponent to 255 like it needs to. // If the 2byte float (masking off the sign/mantissa bits) is equal to the mask for the exponent bits... if( (bits & 0x7c00) == 0x7c00) { // Exponent==31 special case.. ret|= 0x7F800000; // Set the 8bits of the exponent for the 4 byte return value. } else if( 0 == (bits&0x7c00) && 0 != (bits&0x03FF)) // If 2byte float was a subnormal number... { // Return the normalized version of 4byte float, since operating on subnormal floating point numbers // will introduce "floating point drift" (loss of precision), after arithmetic, sooner.. ret = Float32SubnormalToNormal(ret); } return *((float32*)&ret); } // TODO: Finish making this 64bit. //================================================================================================================================= /// /// Takes subnormal float32 (cast as a uint32 so we can operate on it for this function) /// /// \param The subnormal float64 value /// /// \return The float64 value //================================================================================================================================= inline uint64 Float64SubnormalToNormal(uint64 input) { uint64 mantissa = input; uint64 exponent = 0; // Zero exponent const uint64 firstExpBit= ((uint64)1<<52); // Werror // const uint64 mantissaMask= firstExpBit-1; // Recall that a float represents a (base 2) binary number using scientific notation, which is of the format: MANTISSA x 2^EXPONENT. // So to represent the "normal" version of a "subnormal" float, where the exponent==0 AND mantissa!=0 indicates "subnormal" via IEEE float 754 specification // we just need to make the exponent non-zero, yet still have the overall float value represent the same number.. // We do this by subtracting // While not normalized.. while(!(mantissa&firstExpBit)) { exponent -= firstExpBit; // Decrement exponent (1<<23). This is the same as subtracting 1 from the 8bit mantissa, but in the context of a uint32 instead of a uint8. mantissa <<= 1; // Left shift mantissa 1, which is multiplying by 2.. } mantissa &= ~firstExpBit; // Clear leading 1 bit exponent += (uint64)896<<52; // Adjust bias ((1023-127)<<52) return (mantissa | exponent); // Return finalized float including new mantissa and exponent } //================================================================================================================================= /// /// Converts a float32 to a float64 /// /// \param The float32 value /// /// \return The float64 value //================================================================================================================================= inline float64 HalfToFloat( uint32 bits ) { const uint64 bits64= (uint64)bits; const uint64 exponentMask64bitFloat= (uint64)0x7FF<<52; const uint64 exponentBiasSubAdd = (uint64)896<<23; // This accounts for normal 2byte floats, but what about the special cases.. uint64 ret = ((bits64&0x80000000)<<32) | (((bits64&0x7F800000)+exponentBiasSubAdd)<<29) | ((bits64&0x7FFFFF)<<29); // When exponent is zero: we're dealing with either +/- zero (when mantissa is also zero), OR subnormal values (when mantissa is also non-zero) // However zero exponents are handled by the above logic, and it also properly handles mantissas of any values. // When exponent is 31: we're dealing with either +/- infinity (when mantissa is also zero), OR NaN (Not a Number) (when mantissa is also non-zero) // For the case when the 5-bit exponent is 31, we're converting to an 8-bit exponent, and our logic will not expand the exponent to 255 like it needs to. // If the 2byte float (masking off the sign/mantissa bits) is equal to the mask for the exponent bits... if( (bits&0x7F800000) == 0x7F800000) { // Exponent==31 special case.. ret|= exponentMask64bitFloat; // Set the 11bits of the exponent for the 8byte return value. } else if( 0 == (bits&0x7F800000) && 0 != (bits&0x7FFFFF)) // If 4byte float was a subnormal number... { // Return the normalized version of 4byte float, since operating on subnormal floating point numbers // will introduce "floating point drift" (loss of precision), after arithmetic, sooner.. ret = Float64SubnormalToNormal(ret); } return *((float64*)&ret); } //================================================================================================================================= /// /// Converts 4 floats into a GL_UNSIGNED_INT_2_10_10_10_REV /// /// \param The float16 value /// /// \return The float32 value //================================================================================================================================= inline uint32 FloatsToUint2_10_10_10( float32 a, float32 b, float32 g, float32 r) { // Clamp from 0 to 1 float32 fTempR = (r > 1.0f) ? 1.0f : (r < 0.0f) ? 0.0f : r; float32 fTempG = (g > 1.0f) ? 1.0f : (g < 0.0f) ? 0.0f : g; float32 fTempB = (b > 1.0f) ? 1.0f : (b < 0.0f) ? 0.0f : b; float32 fTempA = (a > 1.0f) ? 1.0f : (a < 0.0f) ? 0.0f : a; // Convert to unsigned integer 0 to 1023 range uint32 iR = (uint32) (fTempR * 1023.0f); uint32 iG = (uint32) (fTempG * 1023.0f); uint32 iB = (uint32) (fTempB * 1023.0f); uint32 iA = (uint32) (fTempA * 3.0f); return ((iA & 0x3) << 30) | ((iB & 0x3FF) << 20) | ((iG & 0x3FF) << 10) | (iR & 0x3FF); } //================================================================================================================================= /// /// Converts 4 floats into a GL_UNSIGNED_INT_10_10_10_2 /// /// \param The float16 value /// /// \return The float32 value //================================================================================================================================= inline uint32 FloatsToUint10_10_10_2( float32 r, float32 g, float32 b, float32 a ) { // Clamp from 0 to 1 float32 fTempR = (r > 1.0f) ? 1.0f : (r < 0.0f) ? 0.0f : r; float32 fTempG = (g > 1.0f) ? 1.0f : (g < 0.0f) ? 0.0f : g; float32 fTempB = (b > 1.0f) ? 1.0f : (b < 0.0f) ? 0.0f : b; float32 fTempA = (a > 1.0f) ? 1.0f : (a < 0.0f) ? 0.0f : a; // Convert to unsigned integer 0 to 1023 range uint32 iR = (uint32) (fTempR * 1023.0f); uint32 iG = (uint32) (fTempG * 1023.0f); uint32 iB = (uint32) (fTempB * 1023.0f); uint32 iA = (uint32) (fTempA * 3.0f); return ((iR & 0x3FF) << 22) | ((iG & 0x3FF) << 12) | ((iB & 0x3FF) << 2) | (iA & 0x3); } //================================================================================================================================= /// /// Converts 4 floats into a GL_UNSIGNED_INT_10_10_10_2 /// /// \param The float32 value /// /// \return The float64 value //================================================================================================================================= inline uint64 FloatsToUint10_10_10_2( float64 r, float64 g, float64 b, float64 a ) { // Clamp from 0 to 1 float64 fTempR = (r > 1.0f) ? 1.0f : (r < 0.0f) ? 0.0f : r; float64 fTempG = (g > 1.0f) ? 1.0f : (g < 0.0f) ? 0.0f : g; float64 fTempB = (b > 1.0f) ? 1.0f : (b < 0.0f) ? 0.0f : b; float64 fTempA = (a > 1.0f) ? 1.0f : (a < 0.0f) ? 0.0f : a; // Convert to unsigned integer 0 to 1023 range uint64 iR = (uint64) (fTempR * 1023.0f); uint64 iG = (uint64) (fTempG * 1023.0f); uint64 iB = (uint64) (fTempB * 1023.0f); uint64 iA = (uint64) (fTempA * 3.0f); return ((iR & 0x3FF) << 22) | ((iG & 0x3FF) << 12) | ((iB & 0x3FF) << 2) | (iA & 0x3); } //================================================================================================================================= /// /// Converts 3 floats into a GL_INT_10_10_10 /// /// \param The float16 value /// /// \return The float32 value //================================================================================================================================= inline uint32 FloatsToInt10_10_10( float32 r, float32 g, float32 b ) { // Clamp from -1 to 1 float32 fTempR = (r > 1.0f) ? 1.0f : (r < -1.0f) ? -1.0f : r; float32 fTempG = (g > 1.0f) ? 1.0f : (g < -1.0f) ? -1.0f : g; float32 fTempB = (b > 1.0f) ? 1.0f : (b < -1.0f) ? -1.0f : b; // Convert to signed integer -511 to +511 range int32 iR = (uint32) (fTempR * 511.0f); int32 iG = (uint32) (fTempG * 511.0f); int32 iB = (uint32) (fTempB * 511.0f); return ((iR & 0x3FF) << 22) | ((iG & 0x3FF) << 12) | ((iB & 0x3FF) << 2) | (0 & 0x3); } //================================================================================================================================= /// /// Converts a GL_UNSIGNED_INT_10_10_10_2 to 3 floats /// /// \param The float16 value /// /// \return The float32 value //================================================================================================================================= inline void Uint10_10_10_2ToFloats( int32 inVal, float32 *outVal ) { uint32 iR = (inVal >> 22) & 0x3FF; uint32 iG = (inVal >> 12) & 0x3FF; uint32 iB = (inVal >> 2) & 0x3FF; uint32 iA = (inVal & 0x3 ); outVal[0] = (float32)iR; outVal[1] = (float32)iG; outVal[2] = (float32)iB; outVal[3] = (float32)iA; } //================================================================================================================================= // Converts a GL_UNSIGNED_INT_2_10_10_10_REV to 4 floats // ABGR format // 2 - alpha // 10 - blue // 10 - green // 10 - red //================================================================================================================================= inline void Uint2_10_10_10_REV_ToFloats( int32 inVal, float32 *outVal ) { uint32 iA = (inVal >> 30) & 0x3; uint32 iB = (inVal >> 20) & 0x3FF; uint32 iG = (inVal >> 10) & 0x3FF; uint32 iR = (inVal >> 0) & 0x3FF; outVal[0] = (float32)iR; outVal[1] = (float32)iG; outVal[2] = (float32)iB; outVal[3] = (float32)iA; } //================================================================================================================================= /// /// Converts a GL_UNSIGNED_INT_10_10_10_2 to 3 normalized floats /// /// \param The float16 value /// /// \return The float32 value //================================================================================================================================= inline void Uint10_10_10_2ToFloatsN( int32 inVal, float32 *outVal ) { uint32 iR = (inVal >> 22) & 0x3FF; uint32 iG = (inVal >> 12) & 0x3FF; uint32 iB = (inVal >> 2) & 0x3FF; uint32 iA = (inVal & 0x3 ); outVal[0] = float32(iR) / 1023.0f; outVal[1] = float32(iG) / 1023.0f; outVal[2] = float32(iB) / 1023.0f; outVal[3] = float32(iA) / 3.0f; } //================================================================================================================================= // Converts a GL_UNSIGNED_INT_2_10_10_10_REV to 4 floats, normalized // ABGR format // 2 - alpha // 10 - blue // 10 - green // 10 - red //================================================================================================================================= inline void Uint2_10_10_10_REV_ToFloatsN( int32 inVal, float32 *outVal ) { uint32 iA = (inVal >> 30) & 0x3; uint32 iB = (inVal >> 20) & 0x3FF; uint32 iG = (inVal >> 10) & 0x3FF; uint32 iR = (inVal >> 0) & 0x3FF; outVal[0] = (float32)iR / 1023.0f; outVal[1] = (float32)iG / 1023.0f; outVal[2] = (float32)iB / 1023.0f; outVal[3] = (float32)iA / 3.0f; } //================================================================================================================================= /// /// Converts a GL_INT_10_10_10_2 to 3 floats /// /// \param The float16 value /// /// \return The float32 value //================================================================================================================================= inline void Int10_10_10_2ToFloats( int32 inVal, float32 *outVal ) { int32 iR = (inVal >> 22) & 0x3FF; if( iR & 0x200 ) iR |= 0xfffffc00; // handle negitive numbers int32 iG = (inVal >> 12) & 0x3FF; if( iG & 0x200 ) iG |= 0xfffffc00; // handle negitive numbers int32 iB = (inVal >> 2) & 0x3FF; if( iB & 0x200 ) iB |= 0xfffffc00; // handle negitive numbers outVal[0] = (float32)iR; outVal[1] = (float32)iG; outVal[2] = (float32)iB; } //================================================================================================================================= // Converts a GL_INT_2_10_10_10_REV to 4 floats // ABGR format // 2 - alpha // 10 - blue // 10 - green // 10 - red //================================================================================================================================= inline void Int2_10_10_10_REV_ToFloats( int32 inVal, float32 *outVal ) { int32 iR = (inVal >> 0) & 0x3FF; if (iR & 0x200) iR |= 0xfffffc00; // handle negative numbers int32 iG = (inVal >> 10) & 0x3FF; if (iG & 0x200) iG |= 0xfffffc00; // handle negative numbers int32 iB = (inVal >> 20) & 0x3FF; if (iB & 0x200) iB |= 0xfffffc00; // handle negative numbers int32 iA = (inVal >> 30) & 0x3; if (iA & 0x200) iA |= 0xfffffc00; // handle negative numbers outVal[0] = (float32)iR; outVal[1] = (float32)iG; outVal[2] = (float32)iB; outVal[3] = (float32)iA; } //================================================================================================================================= /// /// Converts a GL_INT_10_10_10_2 to 3 normalized floats /// /// \param The float16 value /// /// \return The float32 value //================================================================================================================================= inline void Int10_10_10_2ToFloatsN( int32 inVal, float32 *outVal ) { int32 iR = (inVal >> 22) & 0x3FF; if( iR & 0x200 ) iR |= 0xfffffc00; // handle negitive numbers int32 iG = (inVal >> 12) & 0x3FF; if( iG & 0x200 ) iG |= 0xfffffc00; // handle negitive numbers int32 iB = (inVal >> 2) & 0x3FF; if( iB & 0x200 ) iB |= 0xfffffc00; // handle negitive numbers outVal[0] = float32(iR) / 511.0f; outVal[1] = float32(iG) / 511.0f; outVal[2] = float32(iB) / 511.0f; } //================================================================================================================================= // Converts a GL_INT_2_10_10_10_REV to 4 floats, normalized // ABGR format // 2 - alpha // 10 - blue // 10 - green // 10 - red //================================================================================================================================= inline void Int2_10_10_10_REV_ToFloatsN( int32 inVal, float32 *outVal ) { int32 iR = (inVal >> 0) & 0x3FF; if (iR & 0x200) iR |= 0xfffffc00; // handle negative numbers int32 iG = (inVal >> 10) & 0x3FF; if (iG & 0x200) iG |= 0xfffffc00; // handle negative numbers int32 iB = (inVal >> 20) & 0x3FF; if (iB & 0x200) iB |= 0xfffffc00; // handle negative numbers int32 iA = (inVal >> 30) & 0x3; if (iA & 0x200) iA |= 0xfffffc00; // handle negative numbers outVal[0] = (float32)iR / 511.0f; outVal[1] = (float32)iG / 511.0f; outVal[2] = (float32)iB / 511.0f; outVal[3] = (float32)iA / 511.0f; } //================================================================================================================================= /// /// Converts a 3 floats in the range 0-1 to a packed short565 /// /// \param r - red value /// \param g - green value /// \param b - blue value /// /// \return The packed short 565 //================================================================================================================================= inline uint16 FloatsToShort5_6_5( float32 r, float32 g, float32 b ) { // Clamp from 0 to max float32 fTempR = (r < 0.0f) ? 0.0f : (r > 1.0f) ? 1.0f : r; float32 fTempG = (g < 0.0f) ? 0.0f : (g > 1.0f) ? 1.0f : g; float32 fTempB = (b < 0.0f) ? 0.0f : (b > 1.0f) ? 1.0f : b; // Convert to integer max range (32 to 64) uint16 iR = (uint32) (fTempR * 31.0f); uint16 iG = (uint32) (fTempG * 63.0f); uint16 iB = (uint32) (fTempB * 31.0f); return ((iR & 0x1F) << 11) | ((iG & 0x3F) << 5) | ((iB & 0x1F) << 0); } //================================================================================================================================= /// /// Converts a an uint24 to an uint32 /// /// \param val - the input uint24 value /// /// \return The uint32 value //================================================================================================================================= inline uint32 Uint24ToUint32( uint8* val ) { uint32 p0 = val[0]; uint32 p1 = val[1]; uint32 p2 = val[2]; uint32 out; out = ( ( p0 << 0 ) + ( p1 << 8 ) + ( p2 << 16 ) ) << 8; return out; } //================================================================================================================================= /// /// Converts a an uint32 to an uint24 /// /// \param inVal - The input uint32 value /// \param outVal - The output uint24 value /// /// \return void //================================================================================================================================= inline void Uint32ToUint24( uint32 inVal, uint8 *outVal ) { outVal[0] = ((int8*)&inVal)[1]; outVal[1] = ((int8*)&inVal)[2]; outVal[2] = ((int8*)&inVal)[3]; } #endif // _FMTCONVERSIONS_H_ -------------------------------------------------------------------------------- /app/src/main/cpp/gl3stub.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 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 compliance 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 | #ifndef __gl3_h_ 17 | #define __gl3_h_ 18 | 19 | /* 20 | * stub gl3.h for dynamic loading, based on: 21 | * gl3.h last updated on $Date: 2013-02-12 14:37:24 -0800 (Tue, 12 Feb 2013) $ 22 | * 23 | * Changes: 24 | * - Added #include 25 | * - Removed duplicate OpenGL ES 2.0 declarations 26 | * - Converted OpenGL ES 3.0 function prototypes to function pointer 27 | * declarations 28 | * - Added gl3stubInit() declaration 29 | */ 30 | 31 | #include 32 | #include 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | /* 39 | ** Copyright (c) 2007-2013 The Khronos Group Inc. 40 | ** 41 | ** Permission is hereby granted, free of charge, to any person obtaining a 42 | ** copy of this software and/or associated documentation files (the 43 | ** "Materials"), to deal in the Materials without restriction, including 44 | ** without limitation the rights to use, copy, modify, merge, publish, 45 | ** distribute, sublicense, and/or sell copies of the Materials, and to 46 | ** permit persons to whom the Materials are furnished to do so, subject to 47 | ** the following conditions: 48 | ** 49 | ** The above copyright notice and this permission notice shall be included 50 | ** in all copies or substantial portions of the Materials. 51 | ** 52 | ** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 53 | ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 54 | ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 55 | ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 56 | ** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 57 | ** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 58 | ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. 59 | */ 60 | 61 | /* Call this function before calling any OpenGL ES 3.0 functions. It will 62 | * return GL_TRUE if the OpenGL ES 3.0 was successfully initialized, GL_FALSE 63 | * otherwise. */ 64 | GLboolean gl3stubInit(); 65 | 66 | /*------------------------------------------------------------------------- 67 | * Data type definitions 68 | *-----------------------------------------------------------------------*/ 69 | 70 | /* OpenGL ES 3.0 */ 71 | 72 | typedef unsigned short GLhalf; 73 | #if __ANDROID_API__ <= 19 74 | typedef khronos_int64_t GLint64; 75 | typedef khronos_uint64_t GLuint64; 76 | typedef struct __GLsync *GLsync; 77 | #endif 78 | 79 | /*------------------------------------------------------------------------- 80 | * Token definitions 81 | *-----------------------------------------------------------------------*/ 82 | 83 | /* OpenGL ES core versions */ 84 | #define GL_ES_VERSION_3_0 1 85 | 86 | /* OpenGL ES 3.0 */ 87 | 88 | #define GL_READ_BUFFER 0x0C02 89 | #define GL_UNPACK_ROW_LENGTH 0x0CF2 90 | #define GL_UNPACK_SKIP_ROWS 0x0CF3 91 | #define GL_UNPACK_SKIP_PIXELS 0x0CF4 92 | #define GL_PACK_ROW_LENGTH 0x0D02 93 | #define GL_PACK_SKIP_ROWS 0x0D03 94 | #define GL_PACK_SKIP_PIXELS 0x0D04 95 | #define GL_COLOR 0x1800 96 | #define GL_DEPTH 0x1801 97 | #define GL_STENCIL 0x1802 98 | #define GL_RED 0x1903 99 | #define GL_RGB8 0x8051 100 | #define GL_RGBA8 0x8058 101 | #define GL_RGB10_A2 0x8059 102 | #define GL_TEXTURE_BINDING_3D 0x806A 103 | #define GL_UNPACK_SKIP_IMAGES 0x806D 104 | #define GL_UNPACK_IMAGE_HEIGHT 0x806E 105 | #define GL_TEXTURE_3D 0x806F 106 | #define GL_TEXTURE_WRAP_R 0x8072 107 | #define GL_MAX_3D_TEXTURE_SIZE 0x8073 108 | #define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 109 | #define GL_MAX_ELEMENTS_VERTICES 0x80E8 110 | #define GL_MAX_ELEMENTS_INDICES 0x80E9 111 | #define GL_TEXTURE_MIN_LOD 0x813A 112 | #define GL_TEXTURE_MAX_LOD 0x813B 113 | #define GL_TEXTURE_BASE_LEVEL 0x813C 114 | #define GL_TEXTURE_MAX_LEVEL 0x813D 115 | #define GL_MIN 0x8007 116 | #define GL_MAX 0x8008 117 | #define GL_DEPTH_COMPONENT24 0x81A6 118 | #define GL_MAX_TEXTURE_LOD_BIAS 0x84FD 119 | #define GL_TEXTURE_COMPARE_MODE 0x884C 120 | #define GL_TEXTURE_COMPARE_FUNC 0x884D 121 | #define GL_CURRENT_QUERY 0x8865 122 | #define GL_QUERY_RESULT 0x8866 123 | #define GL_QUERY_RESULT_AVAILABLE 0x8867 124 | #define GL_BUFFER_MAPPED 0x88BC 125 | #define GL_BUFFER_MAP_POINTER 0x88BD 126 | #define GL_STREAM_READ 0x88E1 127 | #define GL_STREAM_COPY 0x88E2 128 | #define GL_STATIC_READ 0x88E5 129 | #define GL_STATIC_COPY 0x88E6 130 | #define GL_DYNAMIC_READ 0x88E9 131 | #define GL_DYNAMIC_COPY 0x88EA 132 | #define GL_MAX_DRAW_BUFFERS 0x8824 133 | #define GL_DRAW_BUFFER0 0x8825 134 | #define GL_DRAW_BUFFER1 0x8826 135 | #define GL_DRAW_BUFFER2 0x8827 136 | #define GL_DRAW_BUFFER3 0x8828 137 | #define GL_DRAW_BUFFER4 0x8829 138 | #define GL_DRAW_BUFFER5 0x882A 139 | #define GL_DRAW_BUFFER6 0x882B 140 | #define GL_DRAW_BUFFER7 0x882C 141 | #define GL_DRAW_BUFFER8 0x882D 142 | #define GL_DRAW_BUFFER9 0x882E 143 | #define GL_DRAW_BUFFER10 0x882F 144 | #define GL_DRAW_BUFFER11 0x8830 145 | #define GL_DRAW_BUFFER12 0x8831 146 | #define GL_DRAW_BUFFER13 0x8832 147 | #define GL_DRAW_BUFFER14 0x8833 148 | #define GL_DRAW_BUFFER15 0x8834 149 | #define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49 150 | #define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A 151 | #define GL_SAMPLER_3D 0x8B5F 152 | #define GL_SAMPLER_2D_SHADOW 0x8B62 153 | #define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B 154 | #define GL_PIXEL_PACK_BUFFER 0x88EB 155 | #define GL_PIXEL_UNPACK_BUFFER 0x88EC 156 | #define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED 157 | #define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF 158 | #define GL_FLOAT_MAT2x3 0x8B65 159 | #define GL_FLOAT_MAT2x4 0x8B66 160 | #define GL_FLOAT_MAT3x2 0x8B67 161 | #define GL_FLOAT_MAT3x4 0x8B68 162 | #define GL_FLOAT_MAT4x2 0x8B69 163 | #define GL_FLOAT_MAT4x3 0x8B6A 164 | #define GL_SRGB 0x8C40 165 | #define GL_SRGB8 0x8C41 166 | #define GL_SRGB8_ALPHA8 0x8C43 167 | #define GL_COMPARE_REF_TO_TEXTURE 0x884E 168 | #define GL_MAJOR_VERSION 0x821B 169 | #define GL_MINOR_VERSION 0x821C 170 | #define GL_NUM_EXTENSIONS 0x821D 171 | #define GL_RGBA32F 0x8814 172 | #define GL_RGB32F 0x8815 173 | #define GL_RGBA16F 0x881A 174 | #define GL_RGB16F 0x881B 175 | #define GL_VERTEX_ATTRIB_ARRAY_INTEGER 0x88FD 176 | #define GL_MAX_ARRAY_TEXTURE_LAYERS 0x88FF 177 | #define GL_MIN_PROGRAM_TEXEL_OFFSET 0x8904 178 | #define GL_MAX_PROGRAM_TEXEL_OFFSET 0x8905 179 | #define GL_MAX_VARYING_COMPONENTS 0x8B4B 180 | #define GL_TEXTURE_2D_ARRAY 0x8C1A 181 | #define GL_TEXTURE_BINDING_2D_ARRAY 0x8C1D 182 | #define GL_R11F_G11F_B10F 0x8C3A 183 | #define GL_UNSIGNED_INT_10F_11F_11F_REV 0x8C3B 184 | #define GL_RGB9_E5 0x8C3D 185 | #define GL_UNSIGNED_INT_5_9_9_9_REV 0x8C3E 186 | #define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH 0x8C76 187 | #define GL_TRANSFORM_FEEDBACK_BUFFER_MODE 0x8C7F 188 | #define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS 0x8C80 189 | #define GL_TRANSFORM_FEEDBACK_VARYINGS 0x8C83 190 | #define GL_TRANSFORM_FEEDBACK_BUFFER_START 0x8C84 191 | #define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE 0x8C85 192 | #define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN 0x8C88 193 | #define GL_RASTERIZER_DISCARD 0x8C89 194 | #define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS 0x8C8A 195 | #define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS 0x8C8B 196 | #define GL_INTERLEAVED_ATTRIBS 0x8C8C 197 | #define GL_SEPARATE_ATTRIBS 0x8C8D 198 | #define GL_TRANSFORM_FEEDBACK_BUFFER 0x8C8E 199 | #define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING 0x8C8F 200 | #define GL_RGBA32UI 0x8D70 201 | #define GL_RGB32UI 0x8D71 202 | #define GL_RGBA16UI 0x8D76 203 | #define GL_RGB16UI 0x8D77 204 | #define GL_RGBA8UI 0x8D7C 205 | #define GL_RGB8UI 0x8D7D 206 | #define GL_RGBA32I 0x8D82 207 | #define GL_RGB32I 0x8D83 208 | #define GL_RGBA16I 0x8D88 209 | #define GL_RGB16I 0x8D89 210 | #define GL_RGBA8I 0x8D8E 211 | #define GL_RGB8I 0x8D8F 212 | #define GL_RED_INTEGER 0x8D94 213 | #define GL_RGB_INTEGER 0x8D98 214 | #define GL_RGBA_INTEGER 0x8D99 215 | #define GL_SAMPLER_2D_ARRAY 0x8DC1 216 | #define GL_SAMPLER_2D_ARRAY_SHADOW 0x8DC4 217 | #define GL_SAMPLER_CUBE_SHADOW 0x8DC5 218 | #define GL_UNSIGNED_INT_VEC2 0x8DC6 219 | #define GL_UNSIGNED_INT_VEC3 0x8DC7 220 | #define GL_UNSIGNED_INT_VEC4 0x8DC8 221 | #define GL_INT_SAMPLER_2D 0x8DCA 222 | #define GL_INT_SAMPLER_3D 0x8DCB 223 | #define GL_INT_SAMPLER_CUBE 0x8DCC 224 | #define GL_INT_SAMPLER_2D_ARRAY 0x8DCF 225 | #define GL_UNSIGNED_INT_SAMPLER_2D 0x8DD2 226 | #define GL_UNSIGNED_INT_SAMPLER_3D 0x8DD3 227 | #define GL_UNSIGNED_INT_SAMPLER_CUBE 0x8DD4 228 | #define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY 0x8DD7 229 | #define GL_BUFFER_ACCESS_FLAGS 0x911F 230 | #define GL_BUFFER_MAP_LENGTH 0x9120 231 | #define GL_BUFFER_MAP_OFFSET 0x9121 232 | #define GL_DEPTH_COMPONENT32F 0x8CAC 233 | #define GL_DEPTH32F_STENCIL8 0x8CAD 234 | #define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8DAD 235 | #define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210 236 | #define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211 237 | #define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE 0x8212 238 | #define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE 0x8213 239 | #define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE 0x8214 240 | #define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE 0x8215 241 | #define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE 0x8216 242 | #define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE 0x8217 243 | #define GL_FRAMEBUFFER_DEFAULT 0x8218 244 | #define GL_FRAMEBUFFER_UNDEFINED 0x8219 245 | #define GL_DEPTH_STENCIL_ATTACHMENT 0x821A 246 | #define GL_DEPTH_STENCIL 0x84F9 247 | #define GL_UNSIGNED_INT_24_8 0x84FA 248 | #define GL_DEPTH24_STENCIL8 0x88F0 249 | #define GL_UNSIGNED_NORMALIZED 0x8C17 250 | #define GL_DRAW_FRAMEBUFFER_BINDING GL_FRAMEBUFFER_BINDING 251 | #define GL_READ_FRAMEBUFFER 0x8CA8 252 | #define GL_DRAW_FRAMEBUFFER 0x8CA9 253 | #define GL_READ_FRAMEBUFFER_BINDING 0x8CAA 254 | #define GL_RENDERBUFFER_SAMPLES 0x8CAB 255 | #define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4 256 | #define GL_MAX_COLOR_ATTACHMENTS 0x8CDF 257 | #define GL_COLOR_ATTACHMENT1 0x8CE1 258 | #define GL_COLOR_ATTACHMENT2 0x8CE2 259 | #define GL_COLOR_ATTACHMENT3 0x8CE3 260 | #define GL_COLOR_ATTACHMENT4 0x8CE4 261 | #define GL_COLOR_ATTACHMENT5 0x8CE5 262 | #define GL_COLOR_ATTACHMENT6 0x8CE6 263 | #define GL_COLOR_ATTACHMENT7 0x8CE7 264 | #define GL_COLOR_ATTACHMENT8 0x8CE8 265 | #define GL_COLOR_ATTACHMENT9 0x8CE9 266 | #define GL_COLOR_ATTACHMENT10 0x8CEA 267 | #define GL_COLOR_ATTACHMENT11 0x8CEB 268 | #define GL_COLOR_ATTACHMENT12 0x8CEC 269 | #define GL_COLOR_ATTACHMENT13 0x8CED 270 | #define GL_COLOR_ATTACHMENT14 0x8CEE 271 | #define GL_COLOR_ATTACHMENT15 0x8CEF 272 | #define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56 273 | #define GL_MAX_SAMPLES 0x8D57 274 | #define GL_HALF_FLOAT 0x140B 275 | #define GL_MAP_READ_BIT 0x0001 276 | #define GL_MAP_WRITE_BIT 0x0002 277 | #define GL_MAP_INVALIDATE_RANGE_BIT 0x0004 278 | #define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008 279 | #define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010 280 | #define GL_MAP_UNSYNCHRONIZED_BIT 0x0020 281 | #define GL_RG 0x8227 282 | #define GL_RG_INTEGER 0x8228 283 | #define GL_R8 0x8229 284 | #define GL_RG8 0x822B 285 | #define GL_R16F 0x822D 286 | #define GL_R32F 0x822E 287 | #define GL_RG16F 0x822F 288 | #define GL_RG32F 0x8230 289 | #define GL_R8I 0x8231 290 | #define GL_R8UI 0x8232 291 | #define GL_R16I 0x8233 292 | #define GL_R16UI 0x8234 293 | #define GL_R32I 0x8235 294 | #define GL_R32UI 0x8236 295 | #define GL_RG8I 0x8237 296 | #define GL_RG8UI 0x8238 297 | #define GL_RG16I 0x8239 298 | #define GL_RG16UI 0x823A 299 | #define GL_RG32I 0x823B 300 | #define GL_RG32UI 0x823C 301 | #define GL_VERTEX_ARRAY_BINDING 0x85B5 302 | #define GL_R8_SNORM 0x8F94 303 | #define GL_RG8_SNORM 0x8F95 304 | #define GL_RGB8_SNORM 0x8F96 305 | #define GL_RGBA8_SNORM 0x8F97 306 | #define GL_SIGNED_NORMALIZED 0x8F9C 307 | #define GL_PRIMITIVE_RESTART_FIXED_INDEX 0x8D69 308 | #define GL_COPY_READ_BUFFER 0x8F36 309 | #define GL_COPY_WRITE_BUFFER 0x8F37 310 | #define GL_COPY_READ_BUFFER_BINDING GL_COPY_READ_BUFFER 311 | #define GL_COPY_WRITE_BUFFER_BINDING GL_COPY_WRITE_BUFFER 312 | #define GL_UNIFORM_BUFFER 0x8A11 313 | #define GL_UNIFORM_BUFFER_BINDING 0x8A28 314 | #define GL_UNIFORM_BUFFER_START 0x8A29 315 | #define GL_UNIFORM_BUFFER_SIZE 0x8A2A 316 | #define GL_MAX_VERTEX_UNIFORM_BLOCKS 0x8A2B 317 | #define GL_MAX_FRAGMENT_UNIFORM_BLOCKS 0x8A2D 318 | #define GL_MAX_COMBINED_UNIFORM_BLOCKS 0x8A2E 319 | #define GL_MAX_UNIFORM_BUFFER_BINDINGS 0x8A2F 320 | #define GL_MAX_UNIFORM_BLOCK_SIZE 0x8A30 321 | #define GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS 0x8A31 322 | #define GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS 0x8A33 323 | #define GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT 0x8A34 324 | #define GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH 0x8A35 325 | #define GL_ACTIVE_UNIFORM_BLOCKS 0x8A36 326 | #define GL_UNIFORM_TYPE 0x8A37 327 | #define GL_UNIFORM_SIZE 0x8A38 328 | #define GL_UNIFORM_NAME_LENGTH 0x8A39 329 | #define GL_UNIFORM_BLOCK_INDEX 0x8A3A 330 | #define GL_UNIFORM_OFFSET 0x8A3B 331 | #define GL_UNIFORM_ARRAY_STRIDE 0x8A3C 332 | #define GL_UNIFORM_MATRIX_STRIDE 0x8A3D 333 | #define GL_UNIFORM_IS_ROW_MAJOR 0x8A3E 334 | #define GL_UNIFORM_BLOCK_BINDING 0x8A3F 335 | #define GL_UNIFORM_BLOCK_DATA_SIZE 0x8A40 336 | #define GL_UNIFORM_BLOCK_NAME_LENGTH 0x8A41 337 | #define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS 0x8A42 338 | #define GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES 0x8A43 339 | #define GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER 0x8A44 340 | #define GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER 0x8A46 341 | #define GL_INVALID_INDEX 0xFFFFFFFFu 342 | #define GL_MAX_VERTEX_OUTPUT_COMPONENTS 0x9122 343 | #define GL_MAX_FRAGMENT_INPUT_COMPONENTS 0x9125 344 | #define GL_MAX_SERVER_WAIT_TIMEOUT 0x9111 345 | #define GL_OBJECT_TYPE 0x9112 346 | #define GL_SYNC_CONDITION 0x9113 347 | #define GL_SYNC_STATUS 0x9114 348 | #define GL_SYNC_FLAGS 0x9115 349 | #define GL_SYNC_FENCE 0x9116 350 | #define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117 351 | #define GL_UNSIGNALED 0x9118 352 | #define GL_SIGNALED 0x9119 353 | #define GL_ALREADY_SIGNALED 0x911A 354 | #define GL_TIMEOUT_EXPIRED 0x911B 355 | #define GL_CONDITION_SATISFIED 0x911C 356 | #define GL_WAIT_FAILED 0x911D 357 | #define GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001 358 | #define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFFull 359 | #define GL_VERTEX_ATTRIB_ARRAY_DIVISOR 0x88FE 360 | #define GL_ANY_SAMPLES_PASSED 0x8C2F 361 | #define GL_ANY_SAMPLES_PASSED_CONSERVATIVE 0x8D6A 362 | #define GL_SAMPLER_BINDING 0x8919 363 | #define GL_RGB10_A2UI 0x906F 364 | #define GL_TEXTURE_SWIZZLE_R 0x8E42 365 | #define GL_TEXTURE_SWIZZLE_G 0x8E43 366 | #define GL_TEXTURE_SWIZZLE_B 0x8E44 367 | #define GL_TEXTURE_SWIZZLE_A 0x8E45 368 | #define GL_GREEN 0x1904 369 | #define GL_BLUE 0x1905 370 | #define GL_INT_2_10_10_10_REV 0x8D9F 371 | #define GL_TRANSFORM_FEEDBACK 0x8E22 372 | #define GL_TRANSFORM_FEEDBACK_PAUSED 0x8E23 373 | #define GL_TRANSFORM_FEEDBACK_ACTIVE 0x8E24 374 | #define GL_TRANSFORM_FEEDBACK_BINDING 0x8E25 375 | #define GL_PROGRAM_BINARY_RETRIEVABLE_HINT 0x8257 376 | #define GL_PROGRAM_BINARY_LENGTH 0x8741 377 | #define GL_NUM_PROGRAM_BINARY_FORMATS 0x87FE 378 | #define GL_PROGRAM_BINARY_FORMATS 0x87FF 379 | #define GL_COMPRESSED_R11_EAC 0x9270 380 | #define GL_COMPRESSED_SIGNED_R11_EAC 0x9271 381 | #define GL_COMPRESSED_RG11_EAC 0x9272 382 | #define GL_COMPRESSED_SIGNED_RG11_EAC 0x9273 383 | #define GL_COMPRESSED_RGB8_ETC2 0x9274 384 | #define GL_COMPRESSED_SRGB8_ETC2 0x9275 385 | #define GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9276 386 | #define GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9277 387 | #define GL_COMPRESSED_RGBA8_ETC2_EAC 0x9278 388 | #define GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC 0x9279 389 | #define GL_TEXTURE_IMMUTABLE_FORMAT 0x912F 390 | #define GL_MAX_ELEMENT_INDEX 0x8D6B 391 | #define GL_NUM_SAMPLE_COUNTS 0x9380 392 | #define GL_TEXTURE_IMMUTABLE_LEVELS 0x82DF 393 | 394 | /*------------------------------------------------------------------------- 395 | * Entrypoint definitions 396 | *-----------------------------------------------------------------------*/ 397 | 398 | /* OpenGL ES 3.0 */ 399 | 400 | extern GL_APICALL void (* GL_APIENTRY glReadBuffer) (GLenum mode); 401 | extern GL_APICALL void (* GL_APIENTRY glDrawRangeElements) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid* indices); 402 | extern GL_APICALL void (* GL_APIENTRY glTexImage3D) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels); 403 | extern GL_APICALL void (* GL_APIENTRY glTexSubImage3D) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels); 404 | extern GL_APICALL void (* GL_APIENTRY glCopyTexSubImage3D) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); 405 | extern GL_APICALL void (* GL_APIENTRY glCompressedTexImage3D) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data); 406 | extern GL_APICALL void (* GL_APIENTRY glCompressedTexSubImage3D) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data); 407 | extern GL_APICALL void (* GL_APIENTRY glGenQueries) (GLsizei n, GLuint* ids); 408 | extern GL_APICALL void (* GL_APIENTRY glDeleteQueries) (GLsizei n, const GLuint* ids); 409 | extern GL_APICALL GLboolean (* GL_APIENTRY glIsQuery) (GLuint id); 410 | extern GL_APICALL void (* GL_APIENTRY glBeginQuery) (GLenum target, GLuint id); 411 | extern GL_APICALL void (* GL_APIENTRY glEndQuery) (GLenum target); 412 | extern GL_APICALL void (* GL_APIENTRY glGetQueryiv) (GLenum target, GLenum pname, GLint* params); 413 | extern GL_APICALL void (* GL_APIENTRY glGetQueryObjectuiv) (GLuint id, GLenum pname, GLuint* params); 414 | extern GL_APICALL GLboolean (* GL_APIENTRY glUnmapBuffer) (GLenum target); 415 | extern GL_APICALL void (* GL_APIENTRY glGetBufferPointerv) (GLenum target, GLenum pname, GLvoid** params); 416 | extern GL_APICALL void (* GL_APIENTRY glDrawBuffers) (GLsizei n, const GLenum* bufs); 417 | extern GL_APICALL void (* GL_APIENTRY glUniformMatrix2x3fv) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); 418 | extern GL_APICALL void (* GL_APIENTRY glUniformMatrix3x2fv) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); 419 | extern GL_APICALL void (* GL_APIENTRY glUniformMatrix2x4fv) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); 420 | extern GL_APICALL void (* GL_APIENTRY glUniformMatrix4x2fv) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); 421 | extern GL_APICALL void (* GL_APIENTRY glUniformMatrix3x4fv) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); 422 | extern GL_APICALL void (* GL_APIENTRY glUniformMatrix4x3fv) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); 423 | extern GL_APICALL void (* GL_APIENTRY glBlitFramebuffer) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); 424 | extern GL_APICALL void (* GL_APIENTRY glRenderbufferStorageMultisample) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); 425 | extern GL_APICALL void (* GL_APIENTRY glFramebufferTextureLayer) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); 426 | extern GL_APICALL GLvoid* (* GL_APIENTRY glMapBufferRange) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); 427 | extern GL_APICALL void (* GL_APIENTRY glFlushMappedBufferRange) (GLenum target, GLintptr offset, GLsizeiptr length); 428 | extern GL_APICALL void (* GL_APIENTRY glBindVertexArray) (GLuint array); 429 | extern GL_APICALL void (* GL_APIENTRY glDeleteVertexArrays) (GLsizei n, const GLuint* arrays); 430 | extern GL_APICALL void (* GL_APIENTRY glGenVertexArrays) (GLsizei n, GLuint* arrays); 431 | extern GL_APICALL GLboolean (* GL_APIENTRY glIsVertexArray) (GLuint array); 432 | extern GL_APICALL void (* GL_APIENTRY glGetIntegeri_v) (GLenum target, GLuint index, GLint* data); 433 | extern GL_APICALL void (* GL_APIENTRY glBeginTransformFeedback) (GLenum primitiveMode); 434 | extern GL_APICALL void (* GL_APIENTRY glEndTransformFeedback) (void); 435 | extern GL_APICALL void (* GL_APIENTRY glBindBufferRange) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); 436 | extern GL_APICALL void (* GL_APIENTRY glBindBufferBase) (GLenum target, GLuint index, GLuint buffer); 437 | extern GL_APICALL void (* GL_APIENTRY glTransformFeedbackVaryings) (GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode); 438 | extern GL_APICALL void (* GL_APIENTRY glGetTransformFeedbackVarying) (GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name); 439 | extern GL_APICALL void (* GL_APIENTRY glVertexAttribIPointer) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer); 440 | extern GL_APICALL void (* GL_APIENTRY glGetVertexAttribIiv) (GLuint index, GLenum pname, GLint* params); 441 | extern GL_APICALL void (* GL_APIENTRY glGetVertexAttribIuiv) (GLuint index, GLenum pname, GLuint* params); 442 | extern GL_APICALL void (* GL_APIENTRY glVertexAttribI4i) (GLuint index, GLint x, GLint y, GLint z, GLint w); 443 | extern GL_APICALL void (* GL_APIENTRY glVertexAttribI4ui) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); 444 | extern GL_APICALL void (* GL_APIENTRY glVertexAttribI4iv) (GLuint index, const GLint* v); 445 | extern GL_APICALL void (* GL_APIENTRY glVertexAttribI4uiv) (GLuint index, const GLuint* v); 446 | extern GL_APICALL void (* GL_APIENTRY glGetUniformuiv) (GLuint program, GLint location, GLuint* params); 447 | extern GL_APICALL GLint (* GL_APIENTRY glGetFragDataLocation) (GLuint program, const GLchar *name); 448 | extern GL_APICALL void (* GL_APIENTRY glUniform1ui) (GLint location, GLuint v0); 449 | extern GL_APICALL void (* GL_APIENTRY glUniform2ui) (GLint location, GLuint v0, GLuint v1); 450 | extern GL_APICALL void (* GL_APIENTRY glUniform3ui) (GLint location, GLuint v0, GLuint v1, GLuint v2); 451 | extern GL_APICALL void (* GL_APIENTRY glUniform4ui) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); 452 | extern GL_APICALL void (* GL_APIENTRY glUniform1uiv) (GLint location, GLsizei count, const GLuint* value); 453 | extern GL_APICALL void (* GL_APIENTRY glUniform2uiv) (GLint location, GLsizei count, const GLuint* value); 454 | extern GL_APICALL void (* GL_APIENTRY glUniform3uiv) (GLint location, GLsizei count, const GLuint* value); 455 | extern GL_APICALL void (* GL_APIENTRY glUniform4uiv) (GLint location, GLsizei count, const GLuint* value); 456 | extern GL_APICALL void (* GL_APIENTRY glClearBufferiv) (GLenum buffer, GLint drawbuffer, const GLint* value); 457 | extern GL_APICALL void (* GL_APIENTRY glClearBufferuiv) (GLenum buffer, GLint drawbuffer, const GLuint* value); 458 | extern GL_APICALL void (* GL_APIENTRY glClearBufferfv) (GLenum buffer, GLint drawbuffer, const GLfloat* value); 459 | extern GL_APICALL void (* GL_APIENTRY glClearBufferfi) (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); 460 | extern GL_APICALL const GLubyte* (* GL_APIENTRY glGetStringi) (GLenum name, GLuint index); 461 | extern GL_APICALL void (* GL_APIENTRY glCopyBufferSubData) (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); 462 | extern GL_APICALL void (* GL_APIENTRY glGetUniformIndices) (GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices); 463 | extern GL_APICALL void (* GL_APIENTRY glGetActiveUniformsiv) (GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params); 464 | extern GL_APICALL GLuint (* GL_APIENTRY glGetUniformBlockIndex) (GLuint program, const GLchar* uniformBlockName); 465 | extern GL_APICALL void (* GL_APIENTRY glGetActiveUniformBlockiv) (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params); 466 | extern GL_APICALL void (* GL_APIENTRY glGetActiveUniformBlockName) (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName); 467 | extern GL_APICALL void (* GL_APIENTRY glUniformBlockBinding) (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); 468 | extern GL_APICALL void (* GL_APIENTRY glDrawArraysInstanced) (GLenum mode, GLint first, GLsizei count, GLsizei instanceCount); 469 | extern GL_APICALL void (* GL_APIENTRY glDrawElementsInstanced) (GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLsizei instanceCount); 470 | extern GL_APICALL GLsync (* GL_APIENTRY glFenceSync) (GLenum condition, GLbitfield flags); 471 | extern GL_APICALL GLboolean (* GL_APIENTRY glIsSync) (GLsync sync); 472 | extern GL_APICALL void (* GL_APIENTRY glDeleteSync) (GLsync sync); 473 | extern GL_APICALL GLenum (* GL_APIENTRY glClientWaitSync) (GLsync sync, GLbitfield flags, GLuint64 timeout); 474 | extern GL_APICALL void (* GL_APIENTRY glWaitSync) (GLsync sync, GLbitfield flags, GLuint64 timeout); 475 | extern GL_APICALL void (* GL_APIENTRY glGetInteger64v) (GLenum pname, GLint64* params); 476 | extern GL_APICALL void (* GL_APIENTRY glGetSynciv) (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values); 477 | extern GL_APICALL void (* GL_APIENTRY glGetInteger64i_v) (GLenum target, GLuint index, GLint64* data); 478 | extern GL_APICALL void (* GL_APIENTRY glGetBufferParameteri64v) (GLenum target, GLenum pname, GLint64* params); 479 | extern GL_APICALL void (* GL_APIENTRY glGenSamplers) (GLsizei count, GLuint* samplers); 480 | extern GL_APICALL void (* GL_APIENTRY glDeleteSamplers) (GLsizei count, const GLuint* samplers); 481 | extern GL_APICALL GLboolean (* GL_APIENTRY glIsSampler) (GLuint sampler); 482 | extern GL_APICALL void (* GL_APIENTRY glBindSampler) (GLuint unit, GLuint sampler); 483 | extern GL_APICALL void (* GL_APIENTRY glSamplerParameteri) (GLuint sampler, GLenum pname, GLint param); 484 | extern GL_APICALL void (* GL_APIENTRY glSamplerParameteriv) (GLuint sampler, GLenum pname, const GLint* param); 485 | extern GL_APICALL void (* GL_APIENTRY glSamplerParameterf) (GLuint sampler, GLenum pname, GLfloat param); 486 | extern GL_APICALL void (* GL_APIENTRY glSamplerParameterfv) (GLuint sampler, GLenum pname, const GLfloat* param); 487 | extern GL_APICALL void (* GL_APIENTRY glGetSamplerParameteriv) (GLuint sampler, GLenum pname, GLint* params); 488 | extern GL_APICALL void (* GL_APIENTRY glGetSamplerParameterfv) (GLuint sampler, GLenum pname, GLfloat* params); 489 | extern GL_APICALL void (* GL_APIENTRY glVertexAttribDivisor) (GLuint index, GLuint divisor); 490 | extern GL_APICALL void (* GL_APIENTRY glBindTransformFeedback) (GLenum target, GLuint id); 491 | extern GL_APICALL void (* GL_APIENTRY glDeleteTransformFeedbacks) (GLsizei n, const GLuint* ids); 492 | extern GL_APICALL void (* GL_APIENTRY glGenTransformFeedbacks) (GLsizei n, GLuint* ids); 493 | extern GL_APICALL GLboolean (* GL_APIENTRY glIsTransformFeedback) (GLuint id); 494 | extern GL_APICALL void (* GL_APIENTRY glPauseTransformFeedback) (void); 495 | extern GL_APICALL void (* GL_APIENTRY glResumeTransformFeedback) (void); 496 | extern GL_APICALL void (* GL_APIENTRY glGetProgramBinary) (GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary); 497 | extern GL_APICALL void (* GL_APIENTRY glProgramBinary) (GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length); 498 | extern GL_APICALL void (* GL_APIENTRY glProgramParameteri) (GLuint program, GLenum pname, GLint value); 499 | extern GL_APICALL void (* GL_APIENTRY glInvalidateFramebuffer) (GLenum target, GLsizei numAttachments, const GLenum* attachments); 500 | extern GL_APICALL void (* GL_APIENTRY glInvalidateSubFramebuffer) (GLenum target, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height); 501 | extern GL_APICALL void (* GL_APIENTRY glTexStorage2D) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); 502 | extern GL_APICALL void (* GL_APIENTRY glTexStorage3D) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); 503 | extern GL_APICALL void (* GL_APIENTRY glGetInternalformativ) (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params); 504 | 505 | #ifdef __cplusplus 506 | } 507 | #endif 508 | 509 | #endif 510 | --------------------------------------------------------------------------------