-
-
Save jim1987s/3fd724d737a97f04654b2c94ed03ff63 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static String vendor; | |
private static String renderer; | |
private static GLContext glContext; | |
public static GL gl; | |
private static GLDrawable glDrawable; | |
private static final int getParams() { | |
int var0 = 0; | |
vendor = gl.glGetString(7936); | |
renderer = gl.glGetString(7937); | |
System.out.println(renderer); | |
String var1 = vendor.toLowerCase(); | |
if (var1.contains("microsoft")) { | |
var0 |= 1; | |
} | |
if (var1.contains("brian paul") || var1.contains("mesa")) { | |
var0 |= 1; | |
} | |
String version = gl.glGetString(7938); | |
String[] var3 = version.split("[. ]"); | |
if (var3.length >= 2) { | |
try { | |
int var4 = Integer.parseInt(var3[0]); | |
int var5 = Integer.parseInt(var3[1]); | |
anInt1812 = var4 * 10 + var5; | |
} catch (NumberFormatException var11) { | |
var0 |= 4; | |
} | |
} else { | |
var0 |= 4; | |
} | |
if (anInt1812 < 12) { | |
var0 |= 2; | |
} | |
if (!gl.isExtensionAvailable("GL_ARB_multitexture")) { | |
var0 |= 8; | |
} | |
if (!gl.isExtensionAvailable("GL_ARB_texture_env_combine")) { | |
var0 |= 32; | |
} | |
int[] params = new int[1]; | |
gl.glGetIntegerv(34018, params, 0); | |
maxTextureUnits = params[0]; | |
gl.glGetIntegerv(34929, params, 0); | |
maxTextureCoords = params[0]; | |
gl.glGetIntegerv(34930, params, 0); | |
maxTextureImageUnits = params[0]; | |
if (maxTextureUnits < 2 || maxTextureCoords < 2 || maxTextureImageUnits < 2) { | |
var0 |= 16; | |
} | |
if (var0 != 0) { | |
return var0; | |
} else { | |
isBigEndianOrder = ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN; | |
isBufferAnObject = gl.isExtensionAvailable("GL_ARB_vertex_buffer_object"); | |
aBoolean1809 = gl.isExtensionAvailable("GL_ARB_multisample"); | |
cubemapSupported = gl.isExtensionAvailable("GL_ARB_texture_cube_map"); | |
aBoolean1818 = gl.isExtensionAvailable("GL_ARB_vertex_program"); | |
allows3DTextureMapping = gl.isExtensionAvailable("GL_EXT_texture3D"); | |
RSString var13 = method1820(renderer).toLowerCase(); | |
if (var13.indexOf(Constants.aClass94_1819) != -1) { | |
int var6 = 0; | |
RSString[] var7 = var13.method1565(32, 47).method1567(32); | |
for (RSString var9 : var7) { | |
if (var9.getLength() >= 4 && var9.substring(0, 4).method1543()) { | |
var6 = var9.substring(0, 4).stringToBase10(); | |
break; | |
} | |
} | |
if (var6 >= 7000 && var6 <= 7999) { | |
isBufferAnObject = false; | |
} | |
if (var6 >= 7000 && var6 <= 9250) { | |
allows3DTextureMapping = false; | |
} | |
aBoolean1817 = isBufferAnObject; | |
} | |
if (isBufferAnObject) { | |
try { | |
int[] var14 = new int[1]; | |
gl.glGenBuffersARB(1, var14, 0); | |
} catch (Throwable var10) { | |
return -4; | |
} | |
} | |
return 0; | |
} | |
} | |
private static final void method1857() { | |
int[] var0 = new int[1]; | |
gl.glGenTextures(1, var0, 0); | |
lightsTextureHandle = var0[0]; | |
gl.glBindTexture(GL_TEXTURE_2D, lightsTextureHandle); | |
gl.glTexImage2D(GL_TEXTURE_2D, 0, 4, 1, 1, 0, 6408, 5121, IntBuffer.wrap(new int[]{-1})); | |
SceneLighting.initializeLights(); | |
OpenGLEffects.initializeEffects(); | |
} | |
private static final void initialize() { | |
//System.out.println("method1829 toolkit"); | |
projectionUpdated = false; | |
combineRGBMode = 0; | |
combineAlphaMode = 0; | |
texture = -1; | |
gl.glDisable(3553); | |
gl.glTexEnvi(8960, 8704, 0x8570); | |
gl.glTexEnvi(8960, 0x8571, 8448); | |
gl.glTexEnvi(8960, 0x8572, 8448); | |
gl.glEnable(2896); | |
gl.glEnable(2912); | |
gl.glEnable(2929); | |
lightingEnabled = true; | |
depthTestEnabled = true; | |
fogEnabled = true; | |
normalsEnabled = true; | |
OpenGLEffects.resetState(); | |
gl.glActiveTexture(0x84c1); | |
gl.glTexEnvi(8960, 8704, 0x8570); | |
gl.glTexEnvi(8960, 0x8571, 8448); | |
gl.glTexEnvi(8960, 0x8572, 8448); | |
gl.glActiveTexture(0x84c0); | |
gl.setSwapInterval(0); | |
gl.glClearColor(0.0F, 0.0F, 0.0F, 0.0F); | |
gl.glShadeModel(7425); | |
gl.glClearDepth(1.0D); | |
gl.glDepthFunc(515); | |
enableDepthBuffer(); | |
gl.glMatrixMode(5890); | |
gl.glLoadIdentity(); | |
gl.glPolygonMode(1028, 6914); | |
gl.glEnable(2884); | |
gl.glCullFace(1029); | |
gl.glEnable(3042); | |
gl.glBlendFunc(770, 771); | |
gl.glEnable(3008); | |
gl.glAlphaFunc(516, 0.0F); | |
gl.glEnableClientState(0x8074); | |
gl.glEnableClientState(0x8075); | |
gl.glEnableClientState(0x8076); | |
gl.glEnableClientState(0x8078); | |
gl.glMatrixMode(5888); | |
gl.glLoadIdentity(); | |
AtmosphereManager.setup(); | |
SceneLighting.method1275(); | |
} | |
static final void close() { | |
if (gl != null) { | |
try { | |
Class101.method1609(); | |
} catch (Throwable var4) { | |
; | |
} | |
gl = null; | |
} | |
if (glContext != null) { | |
MemoryManager.dropCycle(); | |
try { | |
if (GLContext.getCurrent() == glContext) { | |
glContext.release(); | |
} | |
} catch (Throwable var3) { | |
; | |
} | |
try { | |
glContext.destroy(); | |
} catch (Throwable var2) { | |
; | |
} | |
glContext = null; | |
} | |
if (glDrawable != null) { | |
try { | |
glDrawable.setRealized(false); | |
} catch (Throwable var1) { | |
; | |
} | |
glDrawable = null; | |
} | |
SceneLighting.method1273(); | |
openGLEnabled = false; | |
} | |
static final int startToolkit(Canvas canvas, int samples) { | |
try { | |
if (!canvas.isDisplayable()) { | |
return -1; | |
} else { | |
GLCapabilities glCapabilities = new GLCapabilities(); | |
samples = 4; | |
//MSAA / AA / Anti-aliasing setting | |
if (samples > 0) { | |
glCapabilities.setSampleBuffers(true); | |
glCapabilities.setNumSamples(samples); | |
} | |
GLDrawableFactory glDrawableFac = GLDrawableFactory.getFactory(); | |
glDrawable = glDrawableFac.getGLDrawable(canvas, glCapabilities, null); | |
glDrawable.setRealized(true); | |
int tries = 0; | |
while (true) { | |
glContext = glDrawable.createContext(null); | |
try { | |
int context = glContext.makeCurrent(); | |
if (context != 0) { | |
break; | |
} | |
} catch (Exception e) { | |
e.printStackTrace(); | |
} | |
if (tries++ > 5) { | |
return -2; | |
} | |
TimeUtil.sleepWrapper(1000L); | |
} | |
gl = glContext.getGL(); | |
new GLU(); | |
openGLEnabled = true; | |
canvasWidth = canvas.getSize().width; | |
canvasHeight = canvas.getSize().height; | |
int params = getParams(); | |
if (params != 0) { | |
close(); | |
return params; | |
} else { | |
method1857(); | |
initialize(); | |
gl.glClear(16384); | |
tries = 0; | |
while (true) { | |
try { | |
glDrawable.swapBuffers(); | |
break; | |
} catch (Exception e) { | |
e.printStackTrace(); | |
if (tries++ > 5) { | |
close(); | |
return -3; | |
} | |
TimeUtil.sleepWrapper(100L); | |
} | |
} | |
gl.glClear(16384); | |
return 0; | |
} | |
} | |
} catch (Throwable e) { | |
e.printStackTrace(); | |
close(); | |
return -5; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment