Skip to content

Commit

Permalink
fix gradle build on linux
Browse files Browse the repository at this point in the history
  • Loading branch information
glKarin committed Apr 16, 2024
1 parent 36605f3 commit c8196c1
Show file tree
Hide file tree
Showing 202 changed files with 850 additions and 767 deletions.
Binary file modified Q3E/src/main/assets/pak/darkmod/glprogs.pk4
Binary file not shown.
Binary file modified Q3E/src/main/assets/pak/glslprogs.pk4
Binary file not shown.
6 changes: 3 additions & 3 deletions Q3E/src/main/java/com/n0n3m4/q3e/Q3EGameHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public void InitGlobalEnv()
private String FindDLL(String fs_game)
{
String DLLPath = Q3EUtils.q3ei.datadir + File.separator + fs_game + File.separator; // /sdcard/diii4a/<fs_game>
String Suffix = "game" + Q3EJNI.ARCH + ".so"; // gameaarch64.so(64) / gamearm.so(32)
String Suffix = "game" + Q3EGlobals.ARCH + ".so"; // gameaarch64.so(64) / gamearm.so(32)
String[] guess = {
Suffix,
"lib" + Suffix,
Expand Down Expand Up @@ -252,8 +252,8 @@ public void ExtractTDMGLSLShaderSource()
try
{
final String destname = Q3EUtils.q3ei.datadir + "/darkmod";
File versionFile = new File(destname + "/glprogs/idtech4amm.version");
if(!versionFile.isFile())
File versionFile = new File(destname + "/glslprogs/idtech4amm.version");
if(!versionFile.isFile() || !versionFile.canRead())
{
Log.i(Q3EGlobals.CONST_Q3E_LOG_TAG, "The Dark Mod GLSL shader source file version not exists.");
overwrite = true;
Expand Down
58 changes: 58 additions & 0 deletions Q3E/src/main/java/com/n0n3m4/q3e/Q3EGlobals.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package com.n0n3m4.q3e;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

public final class Q3EGlobals
{
public static final String CONST_PACKAGE_NAME = "com.karin.idTech4Amm";
Expand Down Expand Up @@ -252,5 +256,59 @@ public final class Q3EGlobals

public static final String IDTECH4AMM_PAK_SUFFIX = ".zipak";


public static boolean IS_NEON = false; // only armv7-a 32. arm64 always support, but using hard
public static boolean IS_64 = false;
public static boolean SYSTEM_64 = false;
public static String ARCH = "";
private static boolean _is_detected = false;

private static boolean GetCpuInfo()
{
if (_is_detected)
return true;
IS_64 = Q3EJNI.Is64();
ARCH = IS_64 ? "aarch64" : "arm";
BufferedReader br = null;
try
{
br = new BufferedReader(new FileReader("/proc/cpuinfo"));
String l;
while ((l = br.readLine()) != null)
{
if ((l.contains("Features")) && (l.contains("neon")))
{
IS_NEON = true;
}
if (l.contains("Processor") && (l.contains("AArch64")))
{
SYSTEM_64 = true;
IS_NEON = true;
}

}
_is_detected = true;
} catch (Exception e)
{
e.printStackTrace();
_is_detected = false;
} finally
{
try
{
if (br != null)
br.close();
} catch (IOException ioe)
{
ioe.printStackTrace();
}
}
return _is_detected;
}

static {
GetCpuInfo();
}

private Q3EGlobals() {}
}
54 changes: 0 additions & 54 deletions Q3E/src/main/java/com/n0n3m4/q3e/Q3EJNI.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@

import android.view.Surface;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

public class Q3EJNI {
public static native void setCallbackObject(Object obj);

Expand Down Expand Up @@ -57,58 +53,8 @@ public static native void init(
public static native void OnResume();
public static native void SetSurface(Surface view);

public static boolean IS_NEON = false; // only armv7-a 32. arm64 always support, but using hard
public static boolean IS_64 = false;
public static boolean SYSTEM_64 = false;
public static String ARCH = "";
private static boolean _is_detected = false;

private static boolean GetCpuInfo()
{
if (_is_detected)
return true;
IS_64 = Is64();
ARCH = IS_64 ? "aarch64" : "arm";
BufferedReader br = null;
try
{
br = new BufferedReader(new FileReader("/proc/cpuinfo"));
String l;
while ((l = br.readLine()) != null)
{
if ((l.contains("Features")) && (l.contains("neon")))
{
IS_NEON = true;
}
if (l.contains("Processor") && (l.contains("AArch64")))
{
SYSTEM_64 = true;
IS_NEON = true;
}

}
_is_detected = true;
} catch (Exception e)
{
e.printStackTrace();
_is_detected = false;
} finally
{
try
{
if (br != null)
br.close();
} catch (IOException ioe)
{
ioe.printStackTrace();
}
}
return _is_detected;
}

static {
System.loadLibrary("q3eloader");
GetCpuInfo();
}
}

12 changes: 4 additions & 8 deletions Q3E/src/main/java/com/n0n3m4/q3e/onscreen/Slider.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.content.Context;
import android.graphics.Bitmap;
import android.util.Log;
import android.view.View;

import com.n0n3m4.q3e.Q3EGlobals;
Expand Down Expand Up @@ -188,7 +189,7 @@ public boolean onTouchEvent(int x, int y, int act)
{
startx = x;
starty = y;
if(IsClickable())
if(style == Q3EGlobals.ONSCRREN_SLIDER_STYLE_LEFT_RIGHT_SPLIT_CLICK || style == Q3EGlobals.ONSCRREN_SLIDER_STYLE_DOWN_RIGHT_SPLIT_CLICK)
{
int key = KeyInPosition(x, y);
if(key > 0)
Expand Down Expand Up @@ -260,15 +261,15 @@ else if (x - startx > SLIDE_DIST)
@Override
public boolean isInside(int x, int y)
{
if (IsClickable())
if (style == Q3EGlobals.ONSCRREN_SLIDER_STYLE_LEFT_RIGHT || style == Q3EGlobals.ONSCRREN_SLIDER_STYLE_LEFT_RIGHT_SPLIT_CLICK)
return ((2 * Math.abs(cx - x) < width) && (2 * Math.abs(cy - y) < height));
else
return ((2 * Math.abs(cx - x) < width) && (2 * Math.abs(cy - y) < height)) && (!((y > cy) && (x > cx)));
}

private int KeyInPosition(int x, int y)
{
if (IsClickable())
if (style == Q3EGlobals.ONSCRREN_SLIDER_STYLE_LEFT_RIGHT || style == Q3EGlobals.ONSCRREN_SLIDER_STYLE_LEFT_RIGHT_SPLIT_CLICK)
{
int deltaX = x - cx;
int slide_dist_2 = SLIDE_DIST / 2;
Expand Down Expand Up @@ -317,9 +318,4 @@ public void SetPosition(int x, int y)
cx = x;
cy = y;
}

public boolean IsClickable()
{
return style == Q3EGlobals.ONSCRREN_SLIDER_STYLE_LEFT_RIGHT_SPLIT_CLICK || style == Q3EGlobals.ONSCRREN_SLIDER_STYLE_DOWN_RIGHT_SPLIT_CLICK;
}
}
2 changes: 2 additions & 0 deletions Q3E/src/main/jni/deplibs/libpng/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1080,11 +1080,13 @@ if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL)

if(PNG_SHARED)
# Create a symlink for libpng.dll.a => libpng16.dll.a on Cygwin
if(NOT ANDROID) #k
if(NOT WIN32 OR CYGWIN OR MINGW)
create_symlink(libpng${CMAKE_SHARED_LIBRARY_SUFFIX} TARGET png_shared)
install(FILES $<TARGET_LINKER_FILE_DIR:png_shared>/libpng${CMAKE_SHARED_LIBRARY_SUFFIX}
DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
endif()
endif()

if(PNG_STATIC)
Expand Down
6 changes: 2 additions & 4 deletions Q3E/src/main/jni/tdm/glprogs/HeatHazeWithMaskAndDepth.fs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ or (at your option) any later version. For details, see LICENSE.TXT.
Project: The Dark Mod (http://www.thedarkmod.com/)
******************************************************************************/
#version 320 es

precision mediump float;
#version 300 es
// !!ARBfp1.0

in vec4 var_tc0;
Expand Down Expand Up @@ -56,7 +54,7 @@ void main() {
localNormal = texture(u_texture1, var_tc1.xy); //TEX localNormal, fragment.texcoord[1], texture[1], 2D;
// localNormal.x = localNormal.a; //MOV localNormal.x, localNormal.a;
localNormal = (localNormal) * (scaleTwo) + (subOne); //MAD localNormal, localNormal, scaleTwo, subOne;
localNormal.z = sqrt(max(0.0, 1.0-localNormal.x*localNormal.x-localNormal.y*localNormal.y));
localNormal.z = sqrt(max(0, 1-localNormal.x*localNormal.x-localNormal.y*localNormal.y));
localNormal = (localNormal) * (mask); //MUL localNormal, localNormal, mask;

// calculate the screen texcoord in the 0.0 to 1.0 range
Expand Down
4 changes: 1 addition & 3 deletions Q3E/src/main/jni/tdm/glprogs/HeatHazeWithMaskAndDepth.vs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ or (at your option) any later version. For details, see LICENSE.TXT.
Project: The Dark Mod (http://www.thedarkmod.com/)
******************************************************************************/
#version 320 es

precision mediump float;
#version 300 es
// !!ARBvp1.0

#pragma tdm_include "tdm_transform.glsl"
Expand Down
6 changes: 2 additions & 4 deletions Q3E/src/main/jni/tdm/glprogs/ambientEnvironment.fs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ or (at your option) any later version. For details, see LICENSE.TXT.
Project: The Dark Mod (http://www.thedarkmod.com/)
******************************************************************************/
#version 320 es

precision mediump float;
#version 300 es
// !!ARBfp1.0

in vec4 var_tc0;
Expand Down Expand Up @@ -99,7 +97,7 @@ void main() {
//-----------------------------------------
// Calculate fresnel reflectance.
//-----------------------------------------
fresnelFactor.x = clamp((1.0) - (R0.x), 0.0, 1.0); //SUB_SAT fresnelFactor.x, 1, R0.x;
fresnelFactor.x = clamp((1) - (R0.x), 0.0, 1.0); //SUB_SAT fresnelFactor.x, 1, R0.x;
fresnelFactor.x = (fresnelFactor.x) * (fresnelFactor.x); //MUL fresnelFactor.x, fresnelFactor.x, fresnelFactor.x;
fresnelFactor.x = (fresnelFactor.x) * (fresnelFactor.x); //MUL fresnelFactor.x, fresnelFactor.x, fresnelFactor.x;
//-----------------------------------------
Expand Down
4 changes: 1 addition & 3 deletions Q3E/src/main/jni/tdm/glprogs/ambientEnvironment.vs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ or (at your option) any later version. For details, see LICENSE.TXT.
Project: The Dark Mod (http://www.thedarkmod.com/)
******************************************************************************/
#version 320 es

precision mediump float;
#version 300 es
// !!ARBvp1.0 OPTION ARB_position_invariant ;

#pragma tdm_include "tdm_transform.glsl"
Expand Down
4 changes: 1 addition & 3 deletions Q3E/src/main/jni/tdm/glprogs/blend.fs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ or (at your option) any later version. For details, see LICENSE.TXT.
Project: The Dark Mod (http://www.thedarkmod.com/)
******************************************************************************/
#version 320 es

precision mediump float;
#version 300 es

uniform sampler2D u_texture0;
uniform sampler2D u_texture1;
Expand Down
4 changes: 1 addition & 3 deletions Q3E/src/main/jni/tdm/glprogs/blend.vs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ or (at your option) any later version. For details, see LICENSE.TXT.
Project: The Dark Mod (http://www.thedarkmod.com/)
******************************************************************************/
#version 320 es

precision mediump float;
#version 300 es

#pragma tdm_include "tdm_transform.glsl"

Expand Down
4 changes: 1 addition & 3 deletions Q3E/src/main/jni/tdm/glprogs/bloom_apply.frag.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ or (at your option) any later version. For details, see LICENSE.TXT.
Project: The Dark Mod (http://www.thedarkmod.com/)
******************************************************************************/
#version 320 es

precision mediump float;
#version 300 es

in vec2 var_TexCoord;
out vec4 draw_Color;
Expand Down
4 changes: 1 addition & 3 deletions Q3E/src/main/jni/tdm/glprogs/bloom_downsample.frag.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ or (at your option) any later version. For details, see LICENSE.TXT.
Project: The Dark Mod (http://www.thedarkmod.com/)
******************************************************************************/
#version 320 es

precision mediump float;
#version 300 es
#pragma tdm_define "BLOOM_BRIGHTPASS"

/**
Expand Down
4 changes: 1 addition & 3 deletions Q3E/src/main/jni/tdm/glprogs/bloom_upsample.frag.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ or (at your option) any later version. For details, see LICENSE.TXT.
Project: The Dark Mod (http://www.thedarkmod.com/)
******************************************************************************/
#version 320 es

precision mediump float;
#version 300 es

/**
* This is the upsampling portion of the "dual filtering" blur as suggested in the Siggraph 2015 talk
Expand Down
12 changes: 5 additions & 7 deletions Q3E/src/main/jni/tdm/glprogs/bumpyEnvironment.fs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ or (at your option) any later version. For details, see LICENSE.TXT.
Project: The Dark Mod (http://www.thedarkmod.com/)
******************************************************************************/
#version 320 es

precision mediump float;
#version 300 es

uniform sampler2D u_normalTexture;
uniform samplerCube u_texture0;
Expand All @@ -33,8 +31,8 @@ void main() {

// load the filtered normal map, then normalize to full scale,
vec3 localNormal = texture(u_normalTexture, var_texCoord).rgb;
localNormal = localNormal * vec3(2) - vec3(1);
localNormal.z = sqrt(max(0.0, 1.0 - localNormal.x * localNormal.x - localNormal.y * localNormal.y));
localNormal = localNormal * 2 - vec3(1);
localNormal.z = sqrt(max(0, 1 - localNormal.x * localNormal.x - localNormal.y * localNormal.y));
localNormal = normalize(localNormal);

// transform the surface normal by the local tangent space
Expand All @@ -43,13 +41,13 @@ void main() {
// calculate reflection vector
vec3 globalEye = normalize(var_toEyeWorld);
float dotEN = dot(globalEye, globalNormal);
vec3 globalReflect = 2.0 * (dotEN * globalNormal) - globalEye;
vec3 globalReflect = 2 * (dotEN * globalNormal) - globalEye;

// read the environment map with the reflection vector
vec3 reflectedColor = texture(u_texture0, globalReflect).rgb;

// calculate fresnel reflectance.
float q = 1.0 - dotEN;
float q = 1 - dotEN;
float fresnel = 3.0 * q * q * q * q;
reflectedColor *= (fresnel + 0.4);

Expand Down
10 changes: 4 additions & 6 deletions Q3E/src/main/jni/tdm/glprogs/bumpyEnvironment.vs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ or (at your option) any later version. For details, see LICENSE.TXT.
Project: The Dark Mod (http://www.thedarkmod.com/)
******************************************************************************/
#version 320 es

precision mediump float;
#version 300 es

#pragma tdm_include "tdm_transform.glsl"

Expand All @@ -37,9 +35,9 @@ void main() {
var_toEyeWorld = mat3(u_modelMatrix) * vec3(u_viewOriginLocal - attr_Position);

mat3 matTangentToLocal = mat3(
clamp(attr_Tangent, vec3(-1.0), vec3(1.0)),
clamp(attr_Bitangent, vec3(-1.0), vec3(1.0)),
clamp(attr_Normal, vec3(-1.0), vec3(1.0))
clamp(attr_Tangent, -1, 1),
clamp(attr_Bitangent, -1, 1),
clamp(attr_Normal, -1, 1)
);
var_TangentToWorldMatrix = mat3(u_modelMatrix) * matTangentToLocal;

Expand Down
Loading

0 comments on commit c8196c1

Please sign in to comment.