Replace GL4ES_LIBNAME with RENDERER

This commit is contained in:
doregon committed 2021-08-07 01:28:55 -04:00
1 parent 4e58132e81
commit dc674c10c5
4 files changed
+51 -51

No files matched your search

+24 -24
View File
@@ -59,9 +59,9 @@ static int pfd[2];
static pthread_t logger;
const char *javaHome;
const char *gl4esLibname;
const char *renderer;
NSString *javaHome_pre;
NSString *gl4esLibname_pre;
NSString *renderer_pre;
void init_loadCustomJvmFlags() {
NSString *jvmargs = getPreference(@"java_args");
@@ -135,8 +135,8 @@ void init_checkPlist() {
setPreference(@"java_home", @"");
}
if (!getPreference(@"gl4es_libname")) {
setPreference(@"gl4es_libname", @"");
if (!getPreference(@"renderer")) {
setPreference(@"renderer", @"");
}
if (!getPreference(@"option_warn")) {
@@ -248,23 +248,23 @@ int launchJVM(int argc, char *argv[]) {
}
}
gl4esLibname_pre = getPreference(@"gl4es_libname");
gl4esLibname = [gl4esLibname_pre cStringUsingEncoding:NSUTF8StringEncoding];
if ([gl4esLibname_pre length] == 0) {
gl4esLibname_pre = @"libgl4es_114.dylib";
setPreference(@"gl4es_libname", gl4esLibname_pre);
gl4esLibname = [gl4esLibname_pre cStringUsingEncoding:NSUTF8StringEncoding];
setenv("GL4ES_LIBNAME", gl4esLibname, 1);
debug("[Pre-init] GL4ES_LIBNAME environment variable was not set. Defaulting to %s for future use.\n", gl4esLibname);
renderer_pre = getPreference(@"renderer");
renderer = [renderer_pre cStringUsingEncoding:NSUTF8StringEncoding];
if ([renderer_pre length] == 0) {
renderer_pre = @"libgl4es_114.dylib";
setPreference(@"renderer", renderer_pre);
renderer = [renderer_pre cStringUsingEncoding:NSUTF8StringEncoding];
setenv("RENDERER", renderer, 1);
debug("[Pre-init] RENDERER environment variable was not set. Defaulting to %s for future use.\n", renderer);
} else {
if(![gl4esLibname_pre isEqualToString:@"libgl4es_114.dylib"] && ![gl4esLibname_pre isEqualToString:@"libgl4es_115.dylib"]) {
debug("[Pre-Init] Failed to locate %s. Restoring default value for GL4ES_LIBNAME.", gl4esLibname);
gl4esLibname_pre = @"libgl4es_114.dylib";
setPreference(@"gl4es_libname", gl4esLibname_pre);
gl4esLibname = [gl4esLibname_pre cStringUsingEncoding:NSUTF8StringEncoding];
setenv("GL4ES_LIBNAME", gl4esLibname, 1);
if(![renderer_pre isEqualToString:@"libgl4es_114.dylib"] && ![renderer_pre isEqualToString:@"libgl4es_115.dylib"]) {
debug("[Pre-Init] Failed to locate %s. Restoring default value for RENDERER.", renderer);
renderer_pre = @"libgl4es_114.dylib";
setPreference(@"renderer", renderer_pre);
renderer = [renderer_pre cStringUsingEncoding:NSUTF8StringEncoding];
setenv("RENDERER", renderer, 1);
} else {
debug("[Pre-Init] Restored preference: GL4ES_LIBNAME is set to %s\n", gl4esLibname);
debug("[Pre-Init] Restored preference: RENDERER is set to %s\n", renderer);
}
}
@@ -296,14 +296,14 @@ int launchJVM(int argc, char *argv[]) {
if (!started) {
char *frameworkPath = calloc(1, 2048);
char *javaPath = calloc(1, 2048);
char *gl4esPath = calloc(1, 2048);
char *rendererPath = calloc(1, 2048);
char *userDir = calloc(1, 2048);
char *userHome = calloc(1, 2048);
snprintf(frameworkPath, 2048, "-Djava.library.path=%s/Frameworks", getenv("BUNDLE_PATH"));
snprintf(javaPath, 2048, "%s/bin/java", javaHome);
snprintf(userDir, 2048, "-Duser.dir=%s/Documents/minecraft", getenv("HOME"));
snprintf(userHome, 2048, "-Duser.home=%s/Documents", getenv("HOME"));
snprintf(gl4esPath, 2048, "-Dorg.lwjgl.opengl.libname=%s", gl4esLibname);
snprintf(rendererPath, 2048, "-Dorg.lwjgl.opengl.libname=%s", renderer);
chdir(userDir);
@@ -313,11 +313,11 @@ int launchJVM(int argc, char *argv[]) {
margv[margc++] = frameworkPath;
margv[margc++] = userDir;
margv[margc++] = userHome;
margv[margc++] = gl4esPath;
margv[margc++] = rendererPath;
margv[margc++] = "-Dorg.lwjgl.system.allocator=system";
} else {
setenv("GL4ES_LIBNAME", gl4esLibname, 1);
debug("[Pre-init] GL4ES_LIBNAME has been set to %s", getenv("GL4ES_LIBNAME"));
setenv("RENDERER", renderer, 1);
debug("[Pre-init] GL4ES_LIBNAME has been set to %s", getenv("RENDERER"));
}
// Load java
+1 -1
View File
@@ -20,7 +20,7 @@ void loadPreferences() {
prefDict[@"default_ctrl"] = @"default.json";
prefDict[@"java_args"] = @"";
prefDict[@"java_home"] = @"";
prefDict[@"gl4es_libname"] = @"";
prefDict[@"renderer"] = @"";
prefDict[@"option_warn"] = @YES;
prefDict[@"local_warn"] = @YES;
[prefDict writeToFile:prefPath atomically:YES];
+24 -24
View File
@@ -6,7 +6,7 @@
#define BTNSCALE 0
#define JARGS 1
#define GL4ES 2
#define REND 2
#define JHOME 3
@interface LauncherPreferencesViewController () {
@@ -18,7 +18,7 @@
@implementation LauncherPreferencesViewController
UITextField* gl4esTextField;
UITextField* rendTextField;
UITextField* jargsTextField;
UITextField* jhomeTextField;
UITextField* versionTextField;
@@ -82,21 +82,21 @@ UITextField* versionTextField;
jargsTextField.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
[scrollView addSubview:jargsTextField];
UILabel *gl4esTextView = [[UILabel alloc] initWithFrame:CGRectMake(4.0, 94.0, 0.0, 0.0)];
gl4esTextView.text = @"GL4ES dylib";
gl4esTextView.numberOfLines = 0;
[gl4esTextView sizeToFit];
[scrollView addSubview:gl4esTextView];
UILabel *rendTextView = [[UILabel alloc] initWithFrame:CGRectMake(4.0, 94.0, 0.0, 0.0)];
rendTextView.text = @"Renderer";
rendTextView.numberOfLines = 0;
[rendTextView sizeToFit];
[scrollView addSubview:rendTextView];
gl4esTextField = [[UITextField alloc] initWithFrame:CGRectMake(buttonSizeSlider.frame.origin.x + 3, 94.0, width - jargsTextView.bounds.size.width - 8.0, 30)];
[gl4esTextField addTarget:versionTextField action:@selector(resignFirstResponder) forControlEvents:UIControlEventEditingDidEndOnExit];
gl4esTextField.tag = 101;
gl4esTextField.delegate = self;
gl4esTextField.placeholder = @"Override version...";
gl4esTextField.text = (NSString *) getPreference(@"gl4es_libname");
gl4esTextField.contentVerticalAlignment = UIControlContentVerticalAlignmentTop;
gl4esTextField.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
[scrollView addSubview:gl4esTextField];
rendTextField = [[UITextField alloc] initWithFrame:CGRectMake(buttonSizeSlider.frame.origin.x + 3, 94.0, width - jargsTextView.bounds.size.width - 8.0, 30)];
[rendTextField addTarget:versionTextField action:@selector(resignFirstResponder) forControlEvents:UIControlEventEditingDidEndOnExit];
rendTextField.tag = 101;
rendTextField.delegate = self;
rendTextField.placeholder = @"Override renderer...";
rendTextField.text = (NSString *) getPreference(@"renderer");
rendTextField.contentVerticalAlignment = UIControlContentVerticalAlignmentTop;
rendTextField.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
[scrollView addSubview:rendTextField];
UILabel *jhomeTextView = [[UILabel alloc] initWithFrame:CGRectMake(4.0, 134.0, 0.0, 0.0)];
jhomeTextView.text = @"Java home";
@@ -129,8 +129,8 @@ UITextField* versionTextField;
handler:^(__kindof UIAction * _Nonnull action) {[self helpAlertOpt:BTNSCALE];}];
UIAction *option2 = [UIAction actionWithTitle:@"Java arguments" image:nil identifier:nil
handler:^(__kindof UIAction * _Nonnull action) {[self helpAlertOpt:JARGS];}];
UIAction *option3 = [UIAction actionWithTitle:@"GL4ES dylib" image:nil identifier:nil
handler:^(__kindof UIAction * _Nonnull action) {[self helpAlertOpt:GL4ES];}];
UIAction *option3 = [UIAction actionWithTitle:@"Renderer" image:nil identifier:nil
handler:^(__kindof UIAction * _Nonnull action) {[self helpAlertOpt:REND];}];
UIAction *option4 = [UIAction actionWithTitle:@"Java home" image:nil identifier:nil
handler:^(__kindof UIAction * _Nonnull action) {[self helpAlertOpt:JHOME];}];
UIMenu *menu = [UIMenu menuWithTitle:@"Help menu" image:nil identifier:nil
@@ -148,7 +148,7 @@ UITextField* versionTextField;
if (textField.tag == 100) {
setPreference(@"java_args", jargsTextField.text);
} else if (textField.tag == 101) {
setPreference(@"gl4es_libname", gl4esTextField.text);
setPreference(@"renderer", rendTextField.text);
} else if (textField.tag == 102) {
setPreference(@"java_home", jhomeTextField.text);
if (![jhomeTextField.text containsString:@"java-8-openjdk"]) {
@@ -167,13 +167,13 @@ UITextField* versionTextField;
UIAlertController *helpAlert = [UIAlertController alertControllerWithTitle:@"Needing help with these preferences?" message:nil preferredStyle:UIAlertControllerStyleActionSheet];
UIAlertAction *btnscale = [UIAlertAction actionWithTitle:@"Button scale" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {[self helpAlertOpt:BTNSCALE];}];
UIAlertAction *jargs = [UIAlertAction actionWithTitle:@"Java arguments" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {[self helpAlertOpt:JARGS];}];
UIAlertAction *gl4eslib = [UIAlertAction actionWithTitle:@"GL4ES dylib" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {[self helpAlertOpt:GL4ES];}];
UIAlertAction *renderer = [UIAlertAction actionWithTitle:@"rend dylib" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {[self helpAlertOpt:REND];}];
UIAlertAction *jhome = [UIAlertAction actionWithTitle:@"Java home" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {[self helpAlertOpt:JHOME];}];
UIAlertAction *cancel = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:nil];
[self presentViewController:helpAlert animated:YES completion:nil];
[helpAlert addAction:btnscale];
[helpAlert addAction:jargs];
[helpAlert addAction:gl4eslib];
[helpAlert addAction:renderer];
[helpAlert addAction:jhome];
[helpAlert addAction:cancel];
}
@@ -188,9 +188,9 @@ UITextField* versionTextField;
} else if(setting == JARGS) {
title = @"Java arguments";
message = @"This option allows you to edit arguments that can be passed to Minecraft. Not all arguments work with PojavLauncher, so be aware. This option also requires a restart of the launcher to take effect.";
} else if(setting == GL4ES) {
title = @"GL4ES dylib";
message = @"This option allows you to change the gl4es version in use. Typing 'libgl4es_115.dylib' may fix sheep and banner colors on 1.16 and allow 1.17 to be played, but will also not work with older versions. This option also requires a restart of the launcher to take effect.";
} else if(setting == REND) {
title = @"Renderer";
message = @"This option allows you to change the renderer in use. Typing 'libgl4es_115.dylib' may fix sheep and banner colors on 1.16 and allow 1.17 to be played, but will also not work with older versions. This option also requires a restart of the launcher to take effect.";
} else if(setting == JHOME) {
title = @"Java home";
message = @"This option allows you to change the Java executable directory. Typing '/usr/lib/jvm/java-16-openjdk' may allow you to play 1.17, however older versions and most versions of modded Minecraft, as well as the mod installer, will not work. This option also requires a restart of the launcher to take effect.";
+2 -2
View File
@@ -193,7 +193,7 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_glfw_GLFW_nativeEglMakeCurrent(JNIEnv*
debug("First frame error: %x", eglGetError());
#endif
if (success == EGL_TRUE) {
GL4ES_HANDLE = dlopen(getenv("GL4ES_LIBNAME"), RTLD_GLOBAL);
GL4ES_HANDLE = dlopen(getenv("RENDERER"), RTLD_GLOBAL);
debug("libGL=%p", GL4ES_HANDLE);
gl4esInitialize_func *gl4esInitialize = (gl4esInitialize_func*) dlsym(GL4ES_HANDLE, "initialize_gl4es");
@@ -202,7 +202,7 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_glfw_GLFW_nativeEglMakeCurrent(JNIEnv*
// gl4esSwapBuffers = (gl4esSwapBuffers_func*) dlsym(GL4ES_HANDLE, "gl4es_SwapBuffers_currentContext");
gl4esInitialize();
debug("GL4ES init success");
debug("Renderer init success");
}
// idk this should convert or just `return success;`...