Compare commits
27
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
54598f1eee | ||
|
|
00f59fd972 | ||
|
|
568f52c541 | ||
|
|
c51b4a6afd | ||
|
|
735184ebfe | ||
|
|
20e63ce68a | ||
|
|
537581c21d | ||
|
|
a05600e597 | ||
|
|
eeb994dcde | ||
|
|
3e79b122d7 | ||
|
|
0006f955da | ||
|
|
bacb4070b2 | ||
|
|
1e6139bd87 | ||
|
|
b553a284e4 | ||
|
|
7139eb3b7e | ||
|
|
e36055079b | ||
|
|
d8a8a94008 | ||
|
|
af1a05003a | ||
|
|
3ac6a31685 | ||
|
|
4d0d91f351 | ||
|
|
892918e578 | ||
|
|
428e99d013 | ||
|
|
b3135aa735 | ||
|
|
3706d1c932 | ||
|
|
4fe9d20a3b | ||
|
|
dc479a2f03 | ||
|
|
de50fd93fe |
No files matched your search
@@ -68,6 +68,9 @@ android {
|
||||
versionCode getDateSeconds()
|
||||
versionName getVersionName()
|
||||
multiDexEnabled true //important
|
||||
ndk {
|
||||
abiFilters 'arm64-v8a', 'x86_64'
|
||||
}
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
@@ -109,6 +112,7 @@ android {
|
||||
enableSplit = false
|
||||
}
|
||||
}
|
||||
|
||||
buildToolsVersion '30.0.2'
|
||||
}
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@
|
||||
android:multiprocess="true"
|
||||
android:screenOrientation="sensorLandscape"
|
||||
android:name=".MainActivity"
|
||||
android:windowSoftInputMode="stateVisible"
|
||||
|
||||
android:configChanges="keyboardHidden|orientation|screenSize|keyboard|navigation"/>
|
||||
<provider
|
||||
android:name=".scoped.GameFolderProvider"
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,2 @@
|
||||
nameserver 8.8.8.8
|
||||
nameserver 8.8.4.4
|
||||
@@ -602,7 +602,10 @@ public class BaseMainActivity extends LoggableActivity {
|
||||
}
|
||||
if(mouseCursorIndex == -1) return false; // we cant consoom that, theres no mice!
|
||||
if(CallbackBridge.isGrabbing()) {
|
||||
if(BaseMainActivity.isAndroid8OrHigher()) minecraftGLView.requestPointerCapture();
|
||||
if(BaseMainActivity.isAndroid8OrHigher()){
|
||||
minecraftGLView.requestFocus();
|
||||
minecraftGLView.requestPointerCapture();
|
||||
}
|
||||
}
|
||||
switch(ev.getActionMasked()) {
|
||||
case MotionEvent.ACTION_HOVER_MOVE:
|
||||
@@ -628,18 +631,18 @@ public class BaseMainActivity extends LoggableActivity {
|
||||
|
||||
@Override
|
||||
public boolean dispatchKeyEvent(KeyEvent event) {
|
||||
/*
|
||||
Toast.makeText(this, event.toString(),Toast.LENGTH_LONG).show();
|
||||
Toast.makeText(this, event.getUnicodeChar() + "",Toast.LENGTH_LONG).show();
|
||||
Toast.makeText(this, event.getDevice().toString(), Toast.LENGTH_LONG).show();
|
||||
*/
|
||||
//Toast.makeText(this, event.toString(),Toast.LENGTH_SHORT).show();
|
||||
//Toast.makeText(this, event.getDevice().toString(), Toast.LENGTH_SHORT).show();
|
||||
|
||||
//Filtering useless events
|
||||
if(event.getRepeatCount() != 0
|
||||
|| event.getAction() == KeyEvent.ACTION_MULTIPLE
|
||||
|| event.getKeyCode() == KeyEvent.KEYCODE_UNKNOWN
|
||||
|| (event.getFlags() & KeyEvent.FLAG_FALLBACK) == KeyEvent.FLAG_FALLBACK) return true;
|
||||
//Toast.makeText(this, "FIRST VERIF PASSED", Toast.LENGTH_LONG).show();
|
||||
//Filtering useless events by order of probability
|
||||
if((event.getFlags() & KeyEvent.FLAG_FALLBACK) == KeyEvent.FLAG_FALLBACK) return true;
|
||||
if(event.getKeyCode() == KeyEvent.KEYCODE_UNKNOWN) return true;
|
||||
if(event.getAction() == KeyEvent.KEYCODE_VOLUME_DOWN) return false;
|
||||
if(event.getAction() == KeyEvent.KEYCODE_VOLUME_UP) return false;
|
||||
if(event.getRepeatCount() != 0) return true;
|
||||
if(event.getAction() == KeyEvent.ACTION_MULTIPLE) return true;
|
||||
|
||||
//Toast.makeText(this, "FIRST VERIF PASSED", Toast.LENGTH_SHORT).show();
|
||||
|
||||
//Sometimes, key events comes from SOME keys of the software keyboard
|
||||
//Even weirder, is is unknown why a key or another is selected to trigger a keyEvent
|
||||
@@ -648,7 +651,7 @@ public class BaseMainActivity extends LoggableActivity {
|
||||
touchCharInput.dispatchKeyEvent(event);
|
||||
return true;
|
||||
}
|
||||
//Toast.makeText(this, "SECOND VERIF PASSED", Toast.LENGTH_LONG).show();
|
||||
//Toast.makeText(this, "SECOND VERIF PASSED", Toast.LENGTH_SHORT).show();
|
||||
|
||||
|
||||
//Sometimes, key events may come from the mouse
|
||||
|
||||
@@ -15,5 +15,6 @@ public class MinecraftGLView extends TextureView
|
||||
//Fixes freeform and dex mode having transparent glass,
|
||||
//since it forces android to used the background color of the view/layout behind it.
|
||||
setOpaque(false);
|
||||
setFocusable(true);
|
||||
}
|
||||
}
|
||||
@@ -338,7 +338,7 @@ public class PojavLoginActivity extends BaseActivity
|
||||
Tools.copyAssetFile(this, "options.txt", Tools.DIR_GAME_NEW, false);
|
||||
// TODO: Remove after implement.
|
||||
Tools.copyAssetFile(this, "launcher_profiles.json", Tools.DIR_GAME_NEW, false);
|
||||
|
||||
Tools.copyAssetFile(this,"resolv.conf",Tools.DIR_DATA, true);
|
||||
AssetManager am = this.getAssets();
|
||||
|
||||
unpackComponent(am, "caciocavallo");
|
||||
|
||||
+4
-2
@@ -100,15 +100,16 @@ public class TouchCharInput extends androidx.appcompat.widget.AppCompatEditText
|
||||
* @return if the keyboard is set to be shown.
|
||||
*/
|
||||
public boolean switchKeyboardState(){
|
||||
InputMethodManager imm = (InputMethodManager) getContext().getSystemService(INPUT_METHOD_SERVICE);
|
||||
//If an hard keyboard is present, never trigger the soft one
|
||||
if(hasFocus()
|
||||
|| (getResources().getConfiguration().keyboard == Configuration.KEYBOARD_QWERTY
|
||||
&& getResources().getConfiguration().hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_YES)){
|
||||
imm.hideSoftInputFromWindow(getWindowToken(), 0);
|
||||
clear();
|
||||
disable();
|
||||
return false;
|
||||
}else{
|
||||
InputMethodManager imm = (InputMethodManager) getContext().getSystemService(INPUT_METHOD_SERVICE);
|
||||
enable();
|
||||
imm.showSoftInput(this, InputMethodManager.SHOW_IMPLICIT);
|
||||
return true;
|
||||
@@ -124,7 +125,8 @@ public class TouchCharInput extends androidx.appcompat.widget.AppCompatEditText
|
||||
public void clear(){
|
||||
isDoingInternalChanges = true;
|
||||
//Braille space, doesn't trigger keyboard auto-complete
|
||||
setText("\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800");
|
||||
//replacing directly the text without though setText avoids notifying changes
|
||||
getText().replace(0, getText().length(),"\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800");
|
||||
setSelection(5);
|
||||
}
|
||||
|
||||
|
||||
@@ -225,6 +225,7 @@ public class JREUtils {
|
||||
envMap.put("REGAL_GL_VERSION", "4.5");
|
||||
if(LOCAL_RENDERER != null) {
|
||||
envMap.put("POJAV_RENDERER", LOCAL_RENDERER);
|
||||
if(LOCAL_RENDERER.equals("opengles3_desktopgl_angle_vulkan")) envMap.put("POJAVEXEC_EGL","libEGL_angle.so"); // use ANGLE egl
|
||||
}
|
||||
envMap.put("AWTSTUB_WIDTH", Integer.toString(CallbackBridge.windowWidth > 0 ? CallbackBridge.windowWidth : CallbackBridge.physicalWidth));
|
||||
envMap.put("AWTSTUB_HEIGHT", Integer.toString(CallbackBridge.windowHeight > 0 ? CallbackBridge.windowHeight : CallbackBridge.physicalHeight));
|
||||
@@ -248,7 +249,7 @@ public class JREUtils {
|
||||
//fallback to 2 since it's the minimum for the entire app
|
||||
envMap.put("LIBGL_ES","2");
|
||||
} else if (LOCAL_RENDERER.startsWith("opengles")) {
|
||||
envMap.put("LIBGL_ES", LOCAL_RENDERER.replace("opengles", "").replace("_5", ""));
|
||||
envMap.put("LIBGL_ES", Character.toString(LOCAL_RENDERER.charAt(8)));
|
||||
} else {
|
||||
// TODO if can: other backends such as Vulkan.
|
||||
// Sure, they should provide GLES 3 support.
|
||||
@@ -346,6 +347,8 @@ public class JREUtils {
|
||||
"-Dglfwstub.windowHeight=" + CallbackBridge.windowHeight,
|
||||
"-Dglfwstub.initEgl=false",
|
||||
|
||||
"-Dext.net.resolvPath=" +new File(Tools.DIR_DATA,"resolv.conf").getAbsolutePath(),
|
||||
|
||||
"-Dnet.minecraft.clientmodname=" + Tools.APP_NAME,
|
||||
"-Dfml.earlyprogresswindow=false" //Forge 1.14+ workaround
|
||||
};
|
||||
@@ -413,6 +416,7 @@ public class JREUtils {
|
||||
case "opengles3": renderLibrary = "libgl4es_115.so"; break;
|
||||
case "vulkan_zink": renderLibrary = "libOSMesa_8.so"; break;
|
||||
case "opengles3_vgpu" : renderLibrary = "libvgpu.so"; break;
|
||||
case "opengles3_desktopgl_angle_vulkan" : renderLibrary = "libtinywrapper.so"; break;
|
||||
default:
|
||||
Log.w("RENDER_LIBRARY", "No renderer selected, defaulting to opengles2");
|
||||
renderLibrary = "libgl4es_114.so";
|
||||
|
||||
@@ -24,9 +24,21 @@ LOCAL_CONLYFLAGS := -std=c11
|
||||
LOCAL_LDLIBS := -llog
|
||||
include $(BUILD_SHARED_LIBRARY)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := angle_gles2
|
||||
LOCAL_SRC_FILES := tinywrapper/angle-gles/$(TARGET_ARCH_ABI)/libGLESv2_angle.so
|
||||
include $(PREBUILT_SHARED_LIBRARY)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := tinywrapper
|
||||
LOCAL_SHARED_LIBRARIES := angle_gles2
|
||||
LOCAL_SRC_FILES := tinywrapper/main.c tinywrapper/string_utils.c
|
||||
LOCAL_C_INCLUDES := $(LOCAL_PATH)/tinywrapper
|
||||
include $(BUILD_SHARED_LIBRARY)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
# Link GLESv2 for test
|
||||
LOCAL_LDLIBS := -ldl -llog -landroid -lEGL
|
||||
LOCAL_LDLIBS := -ldl -llog -landroid
|
||||
# -lGLESv2
|
||||
LOCAL_MODULE := pojavexec
|
||||
# LOCAL_CFLAGS += -DDEBUG
|
||||
|
||||
@@ -592,6 +592,8 @@ struct PotatoBridge {
|
||||
};
|
||||
EGLConfig config;
|
||||
struct PotatoBridge potatoBridge;
|
||||
|
||||
/* OSMesa functions */
|
||||
GLboolean (*OSMesaMakeCurrent_p) (OSMesaContext ctx, void *buffer, GLenum type,
|
||||
GLsizei width, GLsizei height);
|
||||
OSMesaContext (*OSMesaGetCurrentContext_p) (void);
|
||||
@@ -603,6 +605,24 @@ void (*glFinish_p) (void);
|
||||
void (*glClearColor_p) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
|
||||
void (*glClear_p) (GLbitfield mask);
|
||||
|
||||
/*EGL functions */
|
||||
EGLBoolean (*eglMakeCurrent_p) (EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx);
|
||||
EGLBoolean (*eglDestroyContext_p) (EGLDisplay dpy, EGLContext ctx);
|
||||
EGLBoolean (*eglDestroySurface_p) (EGLDisplay dpy, EGLSurface surface);
|
||||
EGLBoolean (*eglTerminate_p) (EGLDisplay dpy);
|
||||
EGLBoolean (*eglReleaseThread_p) (void);
|
||||
EGLContext (*eglGetCurrentContext_p) (void);
|
||||
EGLDisplay (*eglGetDisplay_p) (NativeDisplayType display);
|
||||
EGLBoolean (*eglInitialize_p) (EGLDisplay dpy, EGLint *major, EGLint *minor);
|
||||
EGLBoolean (*eglChooseConfig_p) (EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config);
|
||||
EGLBoolean (*eglGetConfigAttrib_p) (EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value);
|
||||
EGLBoolean (*eglBindAPI_p) (EGLenum api);
|
||||
EGLSurface (*eglCreateWindowSurface_p) (EGLDisplay dpy, EGLConfig config, NativeWindowType window, const EGLint *attrib_list);
|
||||
EGLBoolean (*eglSwapBuffers_p) (EGLDisplay dpy, EGLSurface draw);
|
||||
EGLint (*eglGetError_p) (void);
|
||||
EGLContext (*eglCreateContext_p) (EGLDisplay dpy, EGLConfig config, EGLContext share_list, const EGLint *attrib_list);
|
||||
EGLBoolean (*eglSwapInterval_p) (EGLDisplay dpy, EGLint interval);
|
||||
EGLSurface (*eglGetCurrentSurface_p) (EGLint readdraw);
|
||||
#define RENDERER_GL4ES 1
|
||||
#define RENDERER_VK_ZINK 2
|
||||
|
||||
@@ -620,11 +640,11 @@ void terminateEgl() {
|
||||
|
||||
switch (config_renderer) {
|
||||
case RENDERER_GL4ES: {
|
||||
eglMakeCurrent(potatoBridge.eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
||||
eglDestroySurface(potatoBridge.eglDisplay, potatoBridge.eglSurface);
|
||||
eglDestroyContext(potatoBridge.eglDisplay, potatoBridge.eglContext);
|
||||
eglTerminate(potatoBridge.eglDisplay);
|
||||
eglReleaseThread();
|
||||
eglMakeCurrent_p(potatoBridge.eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
||||
eglDestroySurface_p(potatoBridge.eglDisplay, potatoBridge.eglSurface);
|
||||
eglDestroyContext_p(potatoBridge.eglDisplay, potatoBridge.eglContext);
|
||||
eglTerminate_p(potatoBridge.eglDisplay);
|
||||
eglReleaseThread_p();
|
||||
|
||||
potatoBridge.eglContext = EGL_NO_CONTEXT;
|
||||
potatoBridge.eglDisplay = EGL_NO_DISPLAY;
|
||||
@@ -644,7 +664,7 @@ JNIEXPORT void JNICALL Java_net_kdt_pojavlaunch_utils_JREUtils_setupBridgeWindow
|
||||
JNIEXPORT jlong JNICALL Java_org_lwjgl_glfw_GLFW_nativeEglGetCurrentContext(JNIEnv* env, jclass clazz) {
|
||||
switch (config_renderer) {
|
||||
case RENDERER_GL4ES:
|
||||
return (jlong) eglGetCurrentContext();
|
||||
return (jlong) eglGetCurrentContext_p();
|
||||
|
||||
case RENDERER_VK_ZINK:
|
||||
return (jlong) OSMesaGetCurrentContext_p();
|
||||
@@ -652,7 +672,65 @@ JNIEXPORT jlong JNICALL Java_org_lwjgl_glfw_GLFW_nativeEglGetCurrentContext(JNIE
|
||||
default: return (jlong) 0;
|
||||
}
|
||||
}
|
||||
bool loadSymbols() {
|
||||
char* fileName;
|
||||
char* fileNameExt;
|
||||
switch (config_renderer) {
|
||||
case RENDERER_VK_ZINK:
|
||||
fileName = "libOSMesa_8.so";
|
||||
fileNameExt = "libOSMesa.so.8";
|
||||
break;
|
||||
case RENDERER_GL4ES:
|
||||
fileName = "libEGL.so";
|
||||
char* eglLib = getenv("POJAVEXEC_EGL");
|
||||
fileNameExt = eglLib == NULL?"":eglLib;
|
||||
break;
|
||||
}
|
||||
void* dl_handle = dlopen(fileNameExt,RTLD_NOW|RTLD_GLOBAL|RTLD_NODELETE);
|
||||
if (!dl_handle) {
|
||||
dl_handle = dlopen(fileName,RTLD_NOW|RTLD_GLOBAL|RTLD_NODELETE);
|
||||
printf("DlLoader: using default %s, due to %s\n", fileName,dlerror());
|
||||
} else {
|
||||
printf("DlLoader: using external %s\n", fileNameExt);
|
||||
}
|
||||
|
||||
if(dl_handle == NULL) {
|
||||
printf("DlLoader: unable to load: %s\n",dlerror());
|
||||
return 0;
|
||||
}
|
||||
switch(config_renderer) {
|
||||
case RENDERER_VK_ZINK:
|
||||
OSMesaMakeCurrent_p = dlsym(dl_handle,"OSMesaMakeCurrent");
|
||||
OSMesaGetCurrentContext_p = dlsym(dl_handle,"OSMesaGetCurrentContext");
|
||||
OSMesaCreateContext_p = dlsym(dl_handle, "OSMesaCreateContext");
|
||||
OSMesaDestroyContext_p = dlsym(dl_handle, "OSMesaDestroyContext");
|
||||
OSMesaPixelStore_p = dlsym(dl_handle,"OSMesaPixelStore");
|
||||
glGetString_p = dlsym(dl_handle,"glGetString");
|
||||
glClearColor_p = dlsym(dl_handle, "glClearColor");
|
||||
glClear_p = dlsym(dl_handle,"glClear");
|
||||
glFinish_p = dlsym(dl_handle,"glFinish");
|
||||
break;
|
||||
case RENDERER_GL4ES:
|
||||
eglBindAPI_p = dlsym(dl_handle,"eglBindAPI");
|
||||
eglChooseConfig_p = dlsym(dl_handle, "eglChooseConfig");
|
||||
eglCreateContext_p = dlsym(dl_handle, "eglCreateContext");
|
||||
eglCreateWindowSurface_p = dlsym(dl_handle, "eglCreateWindowSurface");
|
||||
eglDestroyContext_p = dlsym(dl_handle, "eglDestroyContext");
|
||||
eglDestroySurface_p = dlsym(dl_handle, "eglDestroySurface");
|
||||
eglGetConfigAttrib_p = dlsym(dl_handle, "eglGetConfigAttrib");
|
||||
eglGetCurrentContext_p = dlsym(dl_handle, "eglGetCurrentContext");
|
||||
eglGetDisplay_p = dlsym(dl_handle, "eglGetDisplay");
|
||||
eglGetError_p = dlsym(dl_handle, "eglGetError");
|
||||
eglInitialize_p = dlsym(dl_handle, "eglInitialize");
|
||||
eglMakeCurrent_p = dlsym(dl_handle, "eglMakeCurrent");
|
||||
eglSwapBuffers_p = dlsym(dl_handle, "eglSwapBuffers");
|
||||
eglReleaseThread_p = dlsym(dl_handle, "eglReleaseThread");
|
||||
eglSwapInterval_p = dlsym(dl_handle, "eglSwapInterval");
|
||||
eglTerminate_p = dlsym(dl_handle, "eglTerminate");
|
||||
eglGetCurrentSurface_p = dlsym(dl_handle,"eglGetCurrentSurface");
|
||||
break;
|
||||
}
|
||||
}
|
||||
JNIEXPORT jboolean JNICALL Java_org_lwjgl_glfw_GLFW_nativeEglInit(JNIEnv* env, jclass clazz) {
|
||||
ANativeWindow_acquire(potatoBridge.androidWindow);
|
||||
savedWidth = ANativeWindow_getWidth(potatoBridge.androidWindow);
|
||||
@@ -662,11 +740,11 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_glfw_GLFW_nativeEglInit(JNIEnv* env, j
|
||||
const char *renderer = getenv("POJAV_RENDERER");
|
||||
if (strncmp("opengles", renderer, 8) == 0) {
|
||||
config_renderer = RENDERER_GL4ES;
|
||||
|
||||
loadSymbols();
|
||||
if (potatoBridge.eglDisplay == NULL || potatoBridge.eglDisplay == EGL_NO_DISPLAY) {
|
||||
potatoBridge.eglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
||||
potatoBridge.eglDisplay = eglGetDisplay_p(EGL_DEFAULT_DISPLAY);
|
||||
if (potatoBridge.eglDisplay == EGL_NO_DISPLAY) {
|
||||
printf("EGLBridge: Error eglGetDefaultDisplay() failed: %p\n", eglGetError());
|
||||
printf("EGLBridge: Error eglGetDefaultDisplay() failed: %p\n", eglGetError_p());
|
||||
return JNI_FALSE;
|
||||
}
|
||||
}
|
||||
@@ -674,8 +752,8 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_glfw_GLFW_nativeEglInit(JNIEnv* env, j
|
||||
printf("EGLBridge: Initializing\n");
|
||||
// printf("EGLBridge: ANativeWindow pointer = %p\n", potatoBridge.androidWindow);
|
||||
//(*env)->ThrowNew(env,(*env)->FindClass(env,"java/lang/Exception"),"Trace exception");
|
||||
if (!eglInitialize(potatoBridge.eglDisplay, NULL, NULL)) {
|
||||
printf("EGLBridge: Error eglInitialize() failed: %s\n", eglGetError());
|
||||
if (!eglInitialize_p(potatoBridge.eglDisplay, NULL, NULL)) {
|
||||
printf("EGLBridge: Error eglInitialize() failed: %s\n", eglGetError_p());
|
||||
return JNI_FALSE;
|
||||
}
|
||||
|
||||
@@ -693,27 +771,35 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_glfw_GLFW_nativeEglInit(JNIEnv* env, j
|
||||
EGLint num_configs;
|
||||
EGLint vid;
|
||||
|
||||
if (!eglChooseConfig(potatoBridge.eglDisplay, attribs, &config, 1, &num_configs)) {
|
||||
printf("EGLBridge: Error couldn't get an EGL visual config: %s\n", eglGetError());
|
||||
if (!eglChooseConfig_p(potatoBridge.eglDisplay, attribs, &config, 1, &num_configs)) {
|
||||
printf("EGLBridge: Error couldn't get an EGL visual config: %s\n", eglGetError_p());
|
||||
return JNI_FALSE;
|
||||
}
|
||||
|
||||
assert(config);
|
||||
assert(num_configs > 0);
|
||||
|
||||
if (!eglGetConfigAttrib(potatoBridge.eglDisplay, config, EGL_NATIVE_VISUAL_ID, &vid)) {
|
||||
printf("EGLBridge: Error eglGetConfigAttrib() failed: %s\n", eglGetError());
|
||||
if (!eglGetConfigAttrib_p(potatoBridge.eglDisplay, config, EGL_NATIVE_VISUAL_ID, &vid)) {
|
||||
printf("EGLBridge: Error eglGetConfigAttrib() failed: %s\n", eglGetError_p());
|
||||
return JNI_FALSE;
|
||||
}
|
||||
|
||||
ANativeWindow_setBuffersGeometry(potatoBridge.androidWindow, 0, 0, vid);
|
||||
|
||||
eglBindAPI(EGL_OPENGL_ES_API);
|
||||
|
||||
potatoBridge.eglSurface = eglCreateWindowSurface(potatoBridge.eglDisplay, config, potatoBridge.androidWindow, NULL);
|
||||
{
|
||||
EGLBoolean bindResult;
|
||||
if (strncmp(renderer, "opengles3_desktopgl", 19) == 0) {
|
||||
printf("EGLBridge: Binding to desktop OpenGL\n");
|
||||
bindResult = eglBindAPI_p(EGL_OPENGL_API);
|
||||
} else {
|
||||
printf("EGLBridge: Binding to OpenGL ES\n");
|
||||
bindResult = eglBindAPI_p(EGL_OPENGL_ES_API);
|
||||
}
|
||||
if(!bindResult) printf("EGLBridge: bind failed: %p\n", eglGetError_p());
|
||||
}
|
||||
potatoBridge.eglSurface = eglCreateWindowSurface_p(potatoBridge.eglDisplay, config, potatoBridge.androidWindow, NULL);
|
||||
|
||||
if (!potatoBridge.eglSurface) {
|
||||
printf("EGLBridge: Error eglCreateWindowSurface failed: %p\n", eglGetError());
|
||||
printf("EGLBridge: Error eglCreateWindowSurface failed: %p\n", eglGetError_p());
|
||||
//(*env)->ThrowNew(env,(*env)->FindClass(env,"java/lang/Exception"),"Trace exception");
|
||||
return JNI_FALSE;
|
||||
}
|
||||
@@ -721,7 +807,7 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_glfw_GLFW_nativeEglInit(JNIEnv* env, j
|
||||
// sanity checks
|
||||
{
|
||||
EGLint val;
|
||||
assert(eglGetConfigAttrib(potatoBridge.eglDisplay, config, EGL_SURFACE_TYPE, &val));
|
||||
assert(eglGetConfigAttrib_p(potatoBridge.eglDisplay, config, EGL_SURFACE_TYPE, &val));
|
||||
assert(val & EGL_WINDOW_BIT);
|
||||
}
|
||||
|
||||
@@ -737,29 +823,7 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_glfw_GLFW_nativeEglInit(JNIEnv* env, j
|
||||
config_renderer = RENDERER_VK_ZINK;
|
||||
|
||||
setenv("GALLIUM_DRIVER","zink",1);
|
||||
void* dl_handle = dlopen("libOSMesa.so.8",RTLD_NOLOAD|RTLD_NOW|RTLD_GLOBAL|RTLD_NODELETE);
|
||||
if (!dl_handle) {
|
||||
dl_handle = dlopen("libOSMesa_8.so",RTLD_NOLOAD|RTLD_NOW|RTLD_GLOBAL|RTLD_NODELETE);
|
||||
printf("OSMDroid: using built-in libOSMesa_8.so\n");
|
||||
} else {
|
||||
printf("OSMDroid: using developer libOSMesa.so.8 instead of built-in\n");
|
||||
}
|
||||
|
||||
if(dl_handle == NULL) {
|
||||
printf("OSMDroid: unable to load: %s\n",dlerror());
|
||||
return JNI_FALSE;
|
||||
}
|
||||
|
||||
OSMesaMakeCurrent_p = dlsym(dl_handle,"OSMesaMakeCurrent");
|
||||
OSMesaGetCurrentContext_p = dlsym(dl_handle,"OSMesaGetCurrentContext");
|
||||
OSMesaCreateContext_p = dlsym(dl_handle, "OSMesaCreateContext");
|
||||
OSMesaDestroyContext_p = dlsym(dl_handle, "OSMesaDestroyContext");
|
||||
OSMesaPixelStore_p = dlsym(dl_handle,"OSMesaPixelStore");
|
||||
glGetString_p = dlsym(dl_handle,"glGetString");
|
||||
glClearColor_p = dlsym(dl_handle, "glClearColor");
|
||||
glClear_p = dlsym(dl_handle,"glClear");
|
||||
glFinish_p = dlsym(dl_handle,"glFinish");
|
||||
|
||||
loadSymbols();
|
||||
if(OSMesaCreateContext_p == NULL) {
|
||||
printf("OSMDroid: %s\n",dlerror());
|
||||
return JNI_FALSE;
|
||||
@@ -785,8 +849,8 @@ bool stopSwapBuffers;
|
||||
void flipFrame() {
|
||||
switch (config_renderer) {
|
||||
case RENDERER_GL4ES: {
|
||||
if (!eglSwapBuffers(potatoBridge.eglDisplay, eglGetCurrentSurface(EGL_DRAW))) {
|
||||
if (eglGetError() == EGL_BAD_SURFACE) {
|
||||
if (!eglSwapBuffers_p(potatoBridge.eglDisplay, eglGetCurrentSurface_p(EGL_DRAW))) {
|
||||
if (eglGetError_p() == EGL_BAD_SURFACE) {
|
||||
stopSwapBuffers = true;
|
||||
closeGLFWWindow();
|
||||
}
|
||||
@@ -821,7 +885,7 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_glfw_GLFW_nativeEglMakeCurrent(JNIEnv*
|
||||
|
||||
switch (config_renderer) {
|
||||
case RENDERER_GL4ES: {
|
||||
EGLContext *currCtx = eglGetCurrentContext();
|
||||
EGLContext *currCtx = eglGetCurrentContext_p();
|
||||
printf("EGLBridge: Comparing: thr=%d, this=%p, curr=%p\n", gettid(), window, currCtx);
|
||||
if (currCtx == NULL || window == 0) {
|
||||
/*if (window != 0x0 && potatoBridge.eglContextOld != NULL && potatoBridge.eglContextOld != (void *) window) {
|
||||
@@ -841,14 +905,14 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_glfw_GLFW_nativeEglMakeCurrent(JNIEnv*
|
||||
//potatoBridge.eglContextOld = (void *) window;
|
||||
// eglMakeCurrent(potatoBridge.eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
||||
printf("EGLBridge: Making current on window %p on thread %d\n", window, gettid());
|
||||
EGLBoolean success = eglMakeCurrent(
|
||||
EGLBoolean success = eglMakeCurrent_p(
|
||||
potatoBridge.eglDisplay,
|
||||
window==0 ? (EGLSurface *) 0 : potatoBridge.eglSurface,
|
||||
window==0 ? (EGLSurface *) 0 : potatoBridge.eglSurface,
|
||||
/* window==0 ? EGL_NO_CONTEXT : */ (EGLContext *) window
|
||||
);
|
||||
if (success == EGL_FALSE) {
|
||||
printf("EGLBridge: Error: eglMakeCurrent() failed: %p\n", eglGetError());
|
||||
printf("EGLBridge: Error: eglMakeCurrent() failed: %p\n", eglGetError_p());
|
||||
} else {
|
||||
printf("EGLBridge: eglMakeCurrent() succeed!\n");
|
||||
}
|
||||
@@ -904,7 +968,7 @@ Java_org_lwjgl_glfw_GLFW_nativeEglDetachOnCurrentThread(JNIEnv *env, jclass claz
|
||||
|
||||
switch (config_renderer) {
|
||||
case RENDERER_GL4ES: {
|
||||
eglMakeCurrent(potatoBridge.eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
||||
eglMakeCurrent_p(potatoBridge.eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
||||
} break;
|
||||
|
||||
case RENDERER_VK_ZINK: {
|
||||
@@ -921,7 +985,7 @@ Java_org_lwjgl_glfw_GLFW_nativeEglCreateContext(JNIEnv *env, jclass clazz, jlong
|
||||
EGL_CONTEXT_CLIENT_VERSION, atoi(getenv("LIBGL_ES")),
|
||||
EGL_NONE
|
||||
};
|
||||
EGLContext* ctx = eglCreateContext(potatoBridge.eglDisplay, config, (void*)contextSrc, ctx_attribs);
|
||||
EGLContext* ctx = eglCreateContext_p(potatoBridge.eglDisplay, config, (void*)contextSrc, ctx_attribs);
|
||||
|
||||
potatoBridge.eglContext = ctx;
|
||||
|
||||
@@ -967,7 +1031,7 @@ Java_org_lwjgl_opengl_GL_getNativeWidthHeight(JNIEnv *env, jobject thiz) {
|
||||
JNIEXPORT jboolean JNICALL Java_org_lwjgl_glfw_GLFW_nativeEglSwapInterval(JNIEnv *env, jclass clazz, jint interval) {
|
||||
switch (config_renderer) {
|
||||
case RENDERER_GL4ES: {
|
||||
return eglSwapInterval(potatoBridge.eglDisplay, interval);
|
||||
return eglSwapInterval_p(potatoBridge.eglDisplay, interval);
|
||||
} break;
|
||||
|
||||
case RENDERER_VK_ZINK: {
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,201 @@
|
||||
//#import <Foundation/Foundation.h>
|
||||
#include <stdio.h>
|
||||
#include <dlfcn.h>
|
||||
|
||||
#include "GL/gl.h"
|
||||
#include "GLES3/gl32.h"
|
||||
#include "string_utils.h"
|
||||
|
||||
#define LOOKUP_FUNC(func) \
|
||||
if (!gles_##func) { \
|
||||
gles_##func = dlsym(RTLD_NEXT, #func); \
|
||||
} if (!gles_##func) { \
|
||||
gles_##func = dlsym(RTLD_DEFAULT, #func); \
|
||||
}
|
||||
|
||||
int proxy_width, proxy_height, proxy_intformat, maxTextureSize;
|
||||
|
||||
void glBindFragDataLocationEXT(GLuint program, GLuint colorNumber, const char * name);
|
||||
|
||||
void(*gles_glGetTexLevelParameteriv)(GLenum target, GLint level, GLenum pname, GLint *params);
|
||||
void(*gles_glShaderSource)(GLuint shader, GLsizei count, const GLchar * const *string, const GLint *length);
|
||||
void(*gles_glTexImage2D)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *data);
|
||||
|
||||
void glBindFragDataLocation(GLuint program, GLuint colorNumber, const char * name) {
|
||||
glBindFragDataLocationEXT(program, colorNumber, name);
|
||||
}
|
||||
|
||||
void glClearDepth(GLdouble depth) {
|
||||
glClearDepthf(depth);
|
||||
}
|
||||
|
||||
void *glMapBuffer(GLenum target, GLenum access) {
|
||||
// Use: GL_EXT_map_buffer_range
|
||||
|
||||
GLenum access_range;
|
||||
GLint length;
|
||||
|
||||
switch (target) {
|
||||
// GL 4.2
|
||||
case GL_ATOMIC_COUNTER_BUFFER:
|
||||
|
||||
// GL 4.3
|
||||
case GL_DISPATCH_INDIRECT_BUFFER:
|
||||
case GL_SHADER_STORAGE_BUFFER :
|
||||
|
||||
// GL 4.4
|
||||
case GL_QUERY_BUFFER:
|
||||
printf("ERROR: glMapBuffer unsupported target=0x%x", target);
|
||||
break; // not supported for now
|
||||
|
||||
case GL_DRAW_INDIRECT_BUFFER:
|
||||
case GL_TEXTURE_BUFFER:
|
||||
printf("ERROR: glMapBuffer unimplemented target=0x%x", target);
|
||||
break;
|
||||
}
|
||||
|
||||
switch (access) {
|
||||
case GL_READ_ONLY:
|
||||
access_range = GL_MAP_READ_BIT;
|
||||
break;
|
||||
|
||||
case GL_WRITE_ONLY:
|
||||
access_range = GL_MAP_WRITE_BIT;
|
||||
break;
|
||||
|
||||
case GL_READ_WRITE:
|
||||
access_range = GL_MAP_READ_BIT | GL_MAP_WRITE_BIT;
|
||||
break;
|
||||
}
|
||||
|
||||
glGetBufferParameteriv(target, GL_BUFFER_SIZE, &length);
|
||||
return glMapBufferRange(target, 0, length, access_range);
|
||||
}
|
||||
|
||||
void glShaderSource(GLuint shader, GLsizei count, const GLchar * const *string, const GLint *length) {
|
||||
LOOKUP_FUNC(glShaderSource)
|
||||
|
||||
// DBG(printf("glShaderSource(%d, %d, %p, %p)\n", shader, count, string, length);)
|
||||
char *source = NULL;
|
||||
char *converted;
|
||||
|
||||
// get the size of the shader sources and than concatenate in a single string
|
||||
int l = 0;
|
||||
for (int i=0; i<count; i++) l+=(length && length[i] >= 0)?length[i]:strlen(string[i]);
|
||||
if (source) free(source);
|
||||
source = calloc(1, l+1);
|
||||
if(length) {
|
||||
for (int i=0; i<count; i++) {
|
||||
if(length[i] >= 0)
|
||||
strncat(source, string[i], length[i]);
|
||||
else
|
||||
strcat(source, string[i]);
|
||||
}
|
||||
} else {
|
||||
for (int i=0; i<count; i++)
|
||||
strcat(source, string[i]);
|
||||
}
|
||||
|
||||
char *source2 = strchr(source, '#');
|
||||
if (!source2) {
|
||||
source2 = source;
|
||||
}
|
||||
// are there #version?
|
||||
if (!strncmp(source2, "#version ", 9)) {
|
||||
converted = strdup(source2);
|
||||
if (converted[9] == '1') {
|
||||
if (converted[10] - '0' < 2) {
|
||||
// 100, 110 -> 120
|
||||
converted[10] = '2';
|
||||
} else if (converted[10] - '0' < 6) {
|
||||
// 130, 140, 150 -> 330
|
||||
converted[9] = converted[10] = '3';
|
||||
}
|
||||
}
|
||||
// remove "core", is it safe?
|
||||
if (!strncmp(&converted[13], "core", 4)) {
|
||||
strncpy(&converted[13], "\n//c", 4);
|
||||
}
|
||||
} else {
|
||||
converted = calloc(1, strlen(source) + 13);
|
||||
strcpy(converted, "#version 120\n");
|
||||
strcpy(&converted[13], strdup(source));
|
||||
}
|
||||
|
||||
int convertedLen = strlen(converted);
|
||||
|
||||
#ifdef __APPLE__
|
||||
// patch OptiFine 1.17.x
|
||||
if (FindString(converted, "\nuniform mat4 textureMatrix = mat4(1.0);")) {
|
||||
InplaceReplace(converted, &convertedLen, "\nuniform mat4 textureMatrix = mat4(1.0);", "\n#define textureMatrix mat4(1.0)");
|
||||
}
|
||||
#endif
|
||||
|
||||
// some needed exts
|
||||
const char* extensions =
|
||||
"#extension GL_EXT_blend_func_extended : enable\n"
|
||||
// For OptiFine (see patch above)
|
||||
"#extension GL_EXT_shader_non_constant_global_initializers : enable\n";
|
||||
converted = InplaceInsert(GetLine(converted, 1), extensions, converted, &convertedLen);
|
||||
|
||||
gles_glShaderSource(shader, 1, (const GLchar * const*)((converted)?(&converted):(&source)), NULL);
|
||||
|
||||
free(source);
|
||||
free(converted);
|
||||
}
|
||||
|
||||
int isProxyTexture(GLenum target) {
|
||||
switch (target) {
|
||||
case GL_PROXY_TEXTURE_1D:
|
||||
case GL_PROXY_TEXTURE_2D:
|
||||
case GL_PROXY_TEXTURE_3D:
|
||||
case GL_PROXY_TEXTURE_RECTANGLE_ARB:
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int inline nlevel(int size, int level) {
|
||||
if(size) {
|
||||
size>>=level;
|
||||
if(!size) size=1;
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
void glGetTexLevelParameteriv(GLenum target, GLint level, GLenum pname, GLint *params) {
|
||||
LOOKUP_FUNC(glGetTexLevelParameteriv)
|
||||
// NSLog("glGetTexLevelParameteriv(%x, %d, %x, %p)", target, level, pname, params);
|
||||
if (isProxyTexture(target)) {
|
||||
switch (pname) {
|
||||
case GL_TEXTURE_WIDTH:
|
||||
(*params) = nlevel(proxy_width,level);
|
||||
break;
|
||||
case GL_TEXTURE_HEIGHT:
|
||||
(*params) = nlevel(proxy_height,level);
|
||||
break;
|
||||
case GL_TEXTURE_INTERNAL_FORMAT:
|
||||
(*params) = proxy_intformat;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
gles_glGetTexLevelParameteriv(target, level, pname, params);
|
||||
}
|
||||
}
|
||||
|
||||
void glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *data) {
|
||||
LOOKUP_FUNC(glTexImage2D)
|
||||
if (isProxyTexture(target)) {
|
||||
if (!maxTextureSize) {
|
||||
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize);
|
||||
// maxTextureSize = 16384;
|
||||
// NSLog(@"Maximum texture size: %d", maxTextureSize);
|
||||
}
|
||||
proxy_width = ((width<<level)>maxTextureSize)?0:width;
|
||||
proxy_height = ((height<<level)>maxTextureSize)?0:height;
|
||||
proxy_intformat = internalformat;
|
||||
// swizzle_internalformat((GLenum *) &internalformat, format, type);
|
||||
} else {
|
||||
gles_glTexImage2D(target, level, internalformat, width, height, border, format, type, data);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,234 @@
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "string_utils.h"
|
||||
|
||||
const char* AllSeparators = " \t\n\r.,;()[]{}-<>+*/%&\\\"'^$=!:?";
|
||||
|
||||
char* ResizeIfNeeded(char* pBuffer, int *size, int addsize);
|
||||
|
||||
char* InplaceReplace(char* pBuffer, int* size, const char* S, const char* D)
|
||||
{
|
||||
int lS = strlen(S), lD = strlen(D);
|
||||
pBuffer = ResizeIfNeeded(pBuffer, size, (lD-lS)*CountString(pBuffer, S));
|
||||
char* p = pBuffer;
|
||||
while((p = strstr(p, S)))
|
||||
{
|
||||
// found an occurence of S
|
||||
// check if good to replace, strchr also found '\0' :)
|
||||
if(strchr(AllSeparators, p[lS])!=NULL && (p==pBuffer || strchr(AllSeparators, p[-1])!=NULL)) {
|
||||
// move out rest of string
|
||||
memmove(p+lD, p+lS, strlen(p)-lS+1);
|
||||
// replace
|
||||
memcpy(p, D, strlen(D));
|
||||
// next
|
||||
p+=lD;
|
||||
} else p+=lS;
|
||||
}
|
||||
|
||||
return pBuffer;
|
||||
}
|
||||
|
||||
char* InplaceInsert(char* pBuffer, const char* S, char* master, int* size)
|
||||
{
|
||||
char* m = ResizeIfNeeded(master, size, strlen(S));
|
||||
if(m!=master) {
|
||||
pBuffer += (m-master);
|
||||
master = m;
|
||||
}
|
||||
char* p = pBuffer;
|
||||
int lS = strlen(S), ll = strlen(pBuffer);
|
||||
memmove(p+lS, p, ll+1);
|
||||
memcpy(p, S, lS);
|
||||
|
||||
return master;
|
||||
}
|
||||
|
||||
char* GetLine(char* pBuffer, int num)
|
||||
{
|
||||
char *p = pBuffer;
|
||||
while(num-- && (p=strstr(p, "\n"))) p+=strlen("\n");
|
||||
return (p)?p:pBuffer;
|
||||
}
|
||||
|
||||
int CountLine(const char* pBuffer)
|
||||
{
|
||||
int n=0;
|
||||
const char* p = pBuffer;
|
||||
while((p=strstr(p, "\n"))) {
|
||||
p+=strlen("\n");
|
||||
n++;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
int GetLineFor(const char* pBuffer, const char* S)
|
||||
{
|
||||
int n=0;
|
||||
const char* p = pBuffer;
|
||||
const char* end = FindString(pBuffer, S);
|
||||
if(!end)
|
||||
return 0;
|
||||
while((p=strstr(p, "\n"))) {
|
||||
p+=strlen("\n");
|
||||
n++;
|
||||
if(p>=end)
|
||||
return n;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
int CountString(const char* pBuffer, const char* S)
|
||||
{
|
||||
const char* p = pBuffer;
|
||||
int lS = strlen(S);
|
||||
int n = 0;
|
||||
while((p = strstr(p, S)))
|
||||
{
|
||||
// found an occurence of S
|
||||
// check if good to count, strchr also found '\0' :)
|
||||
if(strchr(AllSeparators, p[lS])!=NULL && (p==pBuffer || strchr(AllSeparators, p[-1])!=NULL))
|
||||
n++;
|
||||
p+=lS;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
const char* FindString(const char* pBuffer, const char* S)
|
||||
{
|
||||
const char* p = pBuffer;
|
||||
int lS = strlen(S);
|
||||
while((p = strstr(p, S)))
|
||||
{
|
||||
// found an occurence of S
|
||||
// check if good to count, strchr also found '\0' :)
|
||||
if(strchr(AllSeparators, p[lS])!=NULL && (p==pBuffer || strchr(AllSeparators, p[-1])!=NULL))
|
||||
return p;
|
||||
p+=lS;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char* FindStringNC(char* pBuffer, const char* S)
|
||||
{
|
||||
char* p = pBuffer;
|
||||
int lS = strlen(S);
|
||||
while((p = strstr(p, S)))
|
||||
{
|
||||
// found an occurence of S
|
||||
// check if good to count, strchr also found '\0' :)
|
||||
if(strchr(AllSeparators, p[lS])!=NULL && (p==pBuffer || strchr(AllSeparators, p[-1])!=NULL))
|
||||
return p;
|
||||
p+=lS;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char* ResizeIfNeeded(char* pBuffer, int *size, int addsize) {
|
||||
char* p = pBuffer;
|
||||
int newsize = strlen(pBuffer)+addsize+1;
|
||||
if (newsize>*size) {
|
||||
newsize += 100;
|
||||
p = (char*)realloc(pBuffer, newsize);
|
||||
*size=newsize;
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
char* Append(char* pBuffer, int* size, const char* S) {
|
||||
char* p =pBuffer;
|
||||
p = ResizeIfNeeded(pBuffer, size, strlen(S));
|
||||
strcat(p, S);
|
||||
return p;
|
||||
}
|
||||
|
||||
int isBlank(char c) {
|
||||
switch(c) {
|
||||
case ' ':
|
||||
case '\t':
|
||||
case '\n':
|
||||
case '\r':
|
||||
case ':':
|
||||
case ',':
|
||||
case ';':
|
||||
case '/':
|
||||
return 1;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
char* StrNext(char *pBuffer, const char* S) {
|
||||
if(!pBuffer) return NULL;
|
||||
char *p = strstr(pBuffer, S);
|
||||
return (p)?p:(p+strlen(S));
|
||||
}
|
||||
|
||||
char* NextStr(char* pBuffer) {
|
||||
if(!pBuffer) return NULL;
|
||||
while(isBlank(*pBuffer))
|
||||
++pBuffer;
|
||||
return pBuffer;
|
||||
}
|
||||
|
||||
char* NextBlank(char* pBuffer) {
|
||||
if(!pBuffer) return NULL;
|
||||
while(!isBlank(*pBuffer))
|
||||
++pBuffer;
|
||||
return pBuffer;
|
||||
}
|
||||
|
||||
char* NextLine(char* pBuffer) {
|
||||
if(!pBuffer) return NULL;
|
||||
while(*pBuffer && *pBuffer!='\n')
|
||||
++pBuffer;
|
||||
return pBuffer;
|
||||
}
|
||||
|
||||
const char* GetNextStr(char* pBuffer) {
|
||||
static char buff[100] = {0};
|
||||
buff[0] = '\0';
|
||||
if(!pBuffer) return NULL;
|
||||
char* p1 = NextStr(pBuffer);
|
||||
if(!p1) return buff;
|
||||
char* p2 = NextBlank(p1);
|
||||
if(!p2) return buff;
|
||||
int i=0;
|
||||
while(p1!=p2 && i<99)
|
||||
buff[i++] = *(p1++);
|
||||
buff[i] = '\0';
|
||||
return buff;
|
||||
}
|
||||
|
||||
int CountStringSimple(char* pBuffer, const char* S)
|
||||
{
|
||||
char* p = pBuffer;
|
||||
int lS = strlen(S);
|
||||
int n = 0;
|
||||
while((p = strstr(p, S)))
|
||||
{
|
||||
// found an occurence of S
|
||||
n++;
|
||||
p+=lS;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
char* InplaceReplaceSimple(char* pBuffer, int* size, const char* S, const char* D)
|
||||
{
|
||||
int lS = strlen(S), lD = strlen(D);
|
||||
pBuffer = ResizeIfNeeded(pBuffer, size, (lD-lS)*CountStringSimple(pBuffer, S));
|
||||
char* p = pBuffer;
|
||||
while((p = strstr(p, S)))
|
||||
{
|
||||
// found an occurence of S
|
||||
// move out rest of string
|
||||
memmove(p+lD, p+lS, strlen(p)-lS+1);
|
||||
// replace
|
||||
memcpy(p, D, strlen(D));
|
||||
// next
|
||||
p+=lD;
|
||||
}
|
||||
|
||||
return pBuffer;
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
#ifndef _GL4ES_STRING_UTILS_H_
|
||||
#define _GL4ES_STRING_UTILS_H_
|
||||
|
||||
extern const char* AllSeparators;
|
||||
|
||||
const char* FindString(const char* pBuffer, const char* S);
|
||||
char* FindStringNC(char* pBuffer, const char* S);
|
||||
int CountString(const char* pBuffer, const char* S);
|
||||
char* ResizeIfNeeded(char* pBuffer, int *size, int addsize);
|
||||
char* InplaceReplace(char* pBuffer, int* size, const char* S, const char* D);
|
||||
char* Append(char* pBuffer, int* size, const char* S);
|
||||
char* InplaceInsert(char* pBuffer, const char* S, char* master, int* size);
|
||||
char* GetLine(char* pBuffer, int num);
|
||||
int CountLine(const char* pBuffer);
|
||||
int GetLineFor(const char* pBuffer, const char* S); // get the line number for 1st occurent of S in pBuffer
|
||||
char* StrNext(char *pBuffer, const char* S); // mostly as strstr, but go after the substring if found
|
||||
//"blank" (space, tab, cr, lf,":", ",", ";", ".", "/")
|
||||
char* NextStr(char* pBuffer); // go to next non "blank"
|
||||
char* NextBlank(char* pBuffer); // go to next "blank"
|
||||
char* NextLine(char* pBuffer); // go to next new line (crlf not included)
|
||||
|
||||
const char* GetNextStr(char* pBuffer); // get a (static) copy of next str (until next separator), can be a simple number or separator also
|
||||
|
||||
// those function don't try to be smart with separators...
|
||||
int CountStringSimple(char* pBuffer, const char* S);
|
||||
char* InplaceReplaceSimple(char* pBuffer, int* size, const char* S, const char* D);
|
||||
|
||||
|
||||
#endif // _GL4ES_STRING_UTILS_H_
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -2,6 +2,7 @@
|
||||
<androidx.drawerlayout.widget.DrawerLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_alignParentRight="true"
|
||||
@@ -47,13 +48,14 @@
|
||||
app:srcCompat="@drawable/pointer" />
|
||||
|
||||
<net.kdt.pojavlaunch.customcontrols.TouchCharInput
|
||||
android:imeOptions="flagNoFullscreen|flagNoPersonalizedLearning|actionSend"
|
||||
android:inputType="textFilter|textNoSuggestions|textImeMultiLine"
|
||||
android:background="@android:color/darker_gray"
|
||||
android:id="@+id/editTextTextPersonName2"
|
||||
android:layout_width="1dp"
|
||||
android:layout_height="1dp"
|
||||
android:ems="10" />
|
||||
android:background="@android:color/darker_gray"
|
||||
android:ems="10"
|
||||
android:imeOptions="flagNoFullscreen|flagNoExtractUi|flagNoPersonalizedLearning|actionSend"
|
||||
android:inputType="textVisiblePassword"
|
||||
tools:ignore="TouchTargetSizeCheck" />
|
||||
|
||||
</net.kdt.pojavlaunch.customcontrols.ControlLayout>
|
||||
|
||||
|
||||
@@ -1,58 +1,63 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
android:layout_height="match_parent"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/pvc_jvmArgs"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:ems="10"
|
||||
android:hint="@string/pvc_jvmArgs"
|
||||
android:inputType="textPersonName"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/pvc_customDir"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:ems="10"
|
||||
android:hint="@string/pvc_gameDirectory"
|
||||
android:inputType="textPersonName"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/pvc_jvmArgs" />
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/pvc_javaVm"
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/pvc_customDir" />
|
||||
app:layout_optimizationLevel="standard|dimensions|chains">
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/pvc_renderer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/pvc_javaVm" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
<EditText
|
||||
android:id="@+id/pvc_jvmArgs"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:ems="10"
|
||||
android:hint="@string/pvc_jvmArgs"
|
||||
android:inputType="textPersonName"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/pvc_customDir"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:ems="10"
|
||||
android:hint="@string/pvc_gameDirectory"
|
||||
android:inputType="textPersonName"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/pvc_jvmArgs" />
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/pvc_javaVm"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/pvc_customDir" />
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/pvc_renderer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/pvc_javaVm" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</ScrollView>
|
||||
@@ -13,6 +13,7 @@
|
||||
<item name="3">@string/mcl_setting_renderer_gles3_5</item>
|
||||
<item name="4">@string/mcl_setting_renderer_vulkan_zink</item>
|
||||
<item name="5">@string/mcl_setting_renderer_vgpu</item>
|
||||
<item name="6">TINYWRAPPER ANGLE VULKAN</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="renderer_values">
|
||||
@@ -21,5 +22,6 @@
|
||||
<item>opengles3</item> <!-- gl4es 1.1.5 with OpenGL ES 3 -->
|
||||
<item>vulkan_zink</item>
|
||||
<item>opengles3_vgpu</item> <!-- vgpu with OpenGL ES 3 -->
|
||||
<item>opengles3_desktopgl_angle_vulkan</item>
|
||||
</string-array>
|
||||
</resources>
|
||||
+1
-1
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip
|
||||
Reference in new issue
Block a user