mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-12-06 02:40:23 -08:00
New OpenGL version selection for SDL
This commit is contained in:
parent
03544dda46
commit
7a1d126fcd
3 changed files with 29 additions and 13 deletions
|
|
@ -8,7 +8,7 @@ import mindustry.graphics.g3d.PlanetGrid.*;
|
||||||
import mindustry.maps.generators.*;
|
import mindustry.maps.generators.*;
|
||||||
|
|
||||||
public class MeshBuilder{
|
public class MeshBuilder{
|
||||||
private static final boolean gl30 = Core.gl30 != null;
|
private static final boolean packNormals = Core.gl30 != null && (Core.app.isMobile() || Core.graphics.getGLVersion().atLeast(3, 3));
|
||||||
private static volatile float[] tmpHeights = new float[14580]; //highest amount of corners in vanilla
|
private static volatile float[] tmpHeights = new float[14580]; //highest amount of corners in vanilla
|
||||||
|
|
||||||
/** Note that the resulting icosphere does not have normals or a color. */
|
/** Note that the resulting icosphere does not have normals or a color. */
|
||||||
|
|
@ -110,7 +110,7 @@ public class MeshBuilder{
|
||||||
int position = 0;
|
int position = 0;
|
||||||
|
|
||||||
short[] shorts = indexed ? new short[12] : null;
|
short[] shorts = indexed ? new short[12] : null;
|
||||||
float[] floats = new float[3 + (gl30 ? 1 : 3) + 1 + (emit ? 1 : 0)];
|
float[] floats = new float[3 + (packNormals ? 1 : 3) + 1 + (emit ? 1 : 0)];
|
||||||
Vec3 nor = new Vec3();
|
Vec3 nor = new Vec3();
|
||||||
|
|
||||||
Color tmpCol = new Color();
|
Color tmpCol = new Color();
|
||||||
|
|
@ -199,7 +199,7 @@ public class MeshBuilder{
|
||||||
|
|
||||||
if(normal){
|
if(normal){
|
||||||
//only GL30 supports GL_INT_2_10_10_10_REV
|
//only GL30 supports GL_INT_2_10_10_10_REV
|
||||||
attributes.add(gl30 ? VertexAttribute.packedNormal : VertexAttribute.normal);
|
attributes.add(packNormals ? VertexAttribute.packedNormal : VertexAttribute.normal);
|
||||||
}
|
}
|
||||||
|
|
||||||
attributes.add(VertexAttribute.color);
|
attributes.add(VertexAttribute.color);
|
||||||
|
|
@ -262,7 +262,7 @@ public class MeshBuilder{
|
||||||
floats[1] = y;
|
floats[1] = y;
|
||||||
floats[2] = z;
|
floats[2] = z;
|
||||||
|
|
||||||
if(gl30){
|
if(packNormals){
|
||||||
floats[3] = packNormals(normal.x, normal.y, normal.z);
|
floats[3] = packNormals(normal.x, normal.y, normal.z);
|
||||||
|
|
||||||
floats[4] = color;
|
floats[4] = color;
|
||||||
|
|
|
||||||
|
|
@ -47,13 +47,20 @@ public class DesktopLauncher extends ClientLauncher{
|
||||||
new SdlApplication(new DesktopLauncher(arg), new SdlConfig(){{
|
new SdlApplication(new DesktopLauncher(arg), new SdlConfig(){{
|
||||||
title = "Mindustry";
|
title = "Mindustry";
|
||||||
maximized = true;
|
maximized = true;
|
||||||
|
coreProfile = true;
|
||||||
width = 900;
|
width = 900;
|
||||||
height = 700;
|
height = 700;
|
||||||
gl30Minor = 2;
|
|
||||||
|
|
||||||
//on Windows, Intel drivers might be buggy with OpenGL 3.x, so disable it. See https://github.com/Anuken/Mindustry/issues/11041
|
//on Windows, Intel drivers might be buggy with OpenGL 3.x, so only use 2.0. See https://github.com/Anuken/Mindustry/issues/11041
|
||||||
if(!GpuDetect.isIntel){
|
if(GpuDetect.isIntel){
|
||||||
gl30 = true;
|
coreProfile = false;
|
||||||
|
glVersions = new int[][]{{2, 0}};
|
||||||
|
}else if(OS.isMac){
|
||||||
|
//MacOS supports 4.1 at most
|
||||||
|
glVersions = new int[][]{{4, 1}, {3, 2}, {2, 0}};
|
||||||
|
}else{
|
||||||
|
//try essentially every OpenGL version
|
||||||
|
glVersions = new int[][]{{4, 6}, {4, 1}, {3, 3}, {3, 2}, {3, 1}, {2, 0}};
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int i = 0; i < arg.length; i++){
|
for(int i = 0; i < arg.length; i++){
|
||||||
|
|
@ -62,11 +69,20 @@ public class DesktopLauncher extends ClientLauncher{
|
||||||
switch(name){
|
switch(name){
|
||||||
case "width" -> width = Strings.parseInt(arg[i + 1], width);
|
case "width" -> width = Strings.parseInt(arg[i + 1], width);
|
||||||
case "height" -> height = Strings.parseInt(arg[i + 1], height);
|
case "height" -> height = Strings.parseInt(arg[i + 1], height);
|
||||||
case "glMajor" -> gl30Major = Strings.parseInt(arg[i + 1], gl30Major);
|
case "gl" -> {
|
||||||
case "glMinor" -> gl30Minor = Strings.parseInt(arg[i + 1], gl30Minor);
|
String str = arg[i + 1];
|
||||||
case "gl3" -> gl30 = true;
|
if(str.contains(".")){
|
||||||
case "gl2" -> gl30 = false;
|
String[] split = str.split("\\.");
|
||||||
|
if(split.length == 2 && Strings.canParsePositiveInt(split[0]) && Strings.canParsePositiveInt(split[1])){
|
||||||
|
glVersions = new int[][]{{Strings.parseInt(split[0]), Strings.parseInt(split[1])}};
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
Log.err("Invalid GL version format string: '@'. GL version must be of the form <major>.<minor>", str);
|
||||||
|
}
|
||||||
case "coreGl" -> coreProfile = true;
|
case "coreGl" -> coreProfile = true;
|
||||||
|
case "compatibilityGl" -> coreProfile = false;
|
||||||
case "antialias" -> samples = 16;
|
case "antialias" -> samples = 16;
|
||||||
case "debug" -> Log.level = LogLevel.debug;
|
case "debug" -> Log.level = LogLevel.debug;
|
||||||
case "maximized" -> maximized = Boolean.parseBoolean(arg[i + 1]);
|
case "maximized" -> maximized = Boolean.parseBoolean(arg[i + 1]);
|
||||||
|
|
|
||||||
|
|
@ -26,4 +26,4 @@ org.gradle.caching=true
|
||||||
org.gradle.internal.http.socketTimeout=100000
|
org.gradle.internal.http.socketTimeout=100000
|
||||||
org.gradle.internal.http.connectionTimeout=100000
|
org.gradle.internal.http.connectionTimeout=100000
|
||||||
android.enableR8.fullMode=false
|
android.enableR8.fullMode=false
|
||||||
archash=f4edc7709d
|
archash=bf0cbe10da
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue