Skip to content

Commit

Permalink
update openmw, gl4es and something
Browse files Browse the repository at this point in the history
  • Loading branch information
Sisah2 committed May 6, 2024
1 parent 718072a commit 3285ee1
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 26 deletions.
4 changes: 4 additions & 0 deletions app/src/main/java/ui/activity/GameActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ class GameActivity : SDLActivity() {
if (textureShrinkingOption == "medium") Os.setenv("LIBGL_SHRINK", "7", true)
if (textureShrinkingOption == "high") Os.setenv("LIBGL_SHRINK", "6", true)

val avoid16bits = prefs!!.getBoolean("pref_avoid16bits", true)
if (avoid16bits == true) Os.setenv("LIBGL_AVOID16BITS", "1", true)
else Os.setenv("LIBGL_AVOID16BITS", "0", true)

Os.setenv("OSG_VERTEX_BUFFER_HINT", "VBO", true)
Os.setenv("OPENMW_USER_FILE_STORAGE", Constants.USER_FILE_STORAGE + "/", true)
//Os.setenv("OSG_NOTIFY_LEVEL", "FATAL", true) //hide osg errors for now, gl4es bug.
Expand Down
63 changes: 40 additions & 23 deletions app/src/main/java/ui/activity/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -485,32 +485,49 @@ class MainActivity : AppCompatActivity() {
val orientation = this.getResources().getConfiguration().orientation
var displayWidth = 0
var displayHeight = 0

if (orientation == Configuration.ORIENTATION_PORTRAIT)
{
displayWidth = if(resolutionX == 0) dm.heightPixels else resolutionX
displayHeight = if(resolutionY == 0) dm.widthPixels else resolutionY
if( displayInCutoutArea == false && resolutionX == 0) {
val cutoutRectTop = windowManager.defaultDisplay.getCutout()!!.getBoundingRectTop()
val cutoutRectBottom = windowManager.defaultDisplay.getCutout()!!.getBoundingRectBottom()
if (cutoutRectTop != null && cutoutRectBottom != null)
val cutout = windowManager.defaultDisplay.getCutout()

if (cutout != null) {
if (orientation == Configuration.ORIENTATION_PORTRAIT)
{
displayWidth = if(resolutionX == 0) dm.heightPixels else resolutionX
displayHeight = if(resolutionY == 0) dm.widthPixels else resolutionY
if( displayInCutoutArea == false && resolutionX == 0) {
val cutoutRectTop = cutout.getBoundingRectTop()
val cutoutRectBottom = cutout.getBoundingRectBottom()
displayWidth = dm.heightPixels - maxOf(cutoutRectTop.bottom, cutoutRectBottom.bottom - cutoutRectBottom.top)
}
}
else
{
displayWidth = if(resolutionX == 0) dm.widthPixels else resolutionX
displayHeight = if(resolutionY == 0) dm.heightPixels else resolutionY
if( displayInCutoutArea == false && resolutionY == 0) {
val cutoutRectLeft = windowManager.defaultDisplay.getCutout()!!.getBoundingRectLeft()
val cutoutRectRight = windowManager.defaultDisplay.getCutout()!!.getBoundingRectRight()
if (cutoutRectLeft != null && cutoutRectRight != null)
}
}
else
{
displayWidth = if(resolutionX == 0) dm.widthPixels else resolutionX
displayHeight = if(resolutionY == 0) dm.heightPixels else resolutionY
if( displayInCutoutArea == false && resolutionY == 0) {
val cutoutRectLeft = cutout.getBoundingRectLeft()
val cutoutRectRight = cutout.getBoundingRectRight()
displayWidth = dm.widthPixels - maxOf(cutoutRectLeft.right, cutoutRectRight.right - cutoutRectRight.left)
}
}
}
}

writeSetting("Video", "resolution x", displayWidth.toString())
writeSetting("Video", "resolution y", displayHeight.toString())
writeSetting("Video", "resolution x", displayWidth.toString())
writeSetting("Video", "resolution y", displayHeight.toString())
}
else {
if (resolutionX != 0 && resolutionY != 0) {
writeSetting("Video", "resolution x", displayWidth.toString())
writeSetting("Video", "resolution y", displayHeight.toString())
}
else {
if (orientation == Configuration.ORIENTATION_PORTRAIT) {
writeSetting("Video", "resolution x", dm.heightPixels.toString())
writeSetting("Video", "resolution y", dm.widthPixels.toString())
}
else {
writeSetting("Video", "resolution x", dm.widthPixels.toString())
writeSetting("Video", "resolution y", dm.heightPixels.toString())
}
}
}

// Game Mechanics
writeSetting("Game", "toggle sneak", if(prefs.getBoolean("gs_toggle_sneak", true)) "true" else "false")
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@
<string name="btn_back">Back</string>
<string name="pref_customResolution">Custom resolution</string>
<string name="pref_display_cutout_area">Display in cutout area</string>
<string name="pref_avoid16bits">Avoid 16 bits colors</string>
<string name="mods">Mods…</string>
<string name="action_about">About</string>
<string name="about_title">About OMW</string>
Expand Down
8 changes: 7 additions & 1 deletion app/src/main/res/xml/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,13 @@

<CheckBoxPreference
android:key="pref_display_cutout_area"
android:title="@string/pref_display_cutout_area" />
android:title="@string/pref_display_cutout_area"
android:summary="Disabling should help with memory usage if software decompression is used, may increase loading times? decrease visual quality? need testing"/>

<CheckBoxPreference
android:key="pref_avoid16bits"
android:title="@string/pref_avoid16bits"
android:defaultValue="true"/>

<ListPreference
android:key="pref_textureShrinking_v2"
Expand Down
5 changes: 3 additions & 2 deletions buildscripts/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ set(MYGUI_VERSION 3.4.3)
set(MYGUI_HASH SHA256=d1d5f294670ae71f7200ed4b30859018281d8cfd45d6a38d18b97a4aba604c42)

# https://github.com/sisah2/gl4es/releases
set(GL4ES_VERSION eb87d808d643782d81f77e8013799e4bbd21dded)
set(GL4ES_VERSION 8b6c0418dabe3410fc53918b66285588cde9a7e7)
set(GL4ES_HASH SHA256=b565e717c7d192e936bda25f3cb90ad8db398af56414ec08294b6716574c1a6d)

# https://github.com/openscenegraph/OpenSceneGraph/releases
Expand All @@ -56,7 +56,7 @@ set(LIBICU_VERSION 70-1)
set(LIBICU_HASH SHA256=4013d7aff8a34bae410664bdb16554d7eda03654b22627b9284ab55a685492d4)

# https://github.com/OpenMW/openmw/commits/master
set(OPENMW_VERSION dcfb943186c8c0ec185f31b52bf10d172c674043)
set(OPENMW_VERSION 6107a99cc70066b6d62ce7d1b418576170501591)
set(OPENMW_HASH SHA256=44d044ad0a5546216fe611fe92c37065bb07e2efeeeaac4f049dae03df313186)

# End of configurable options
Expand Down Expand Up @@ -539,6 +539,7 @@ set(OSG_PATCH
patch -d <SOURCE_DIR> -p1 -t -N < ${CMAKE_SOURCE_DIR}/patches/osg/0004-IncrementalCompileOperation-wrap-some-stuff-in-atomi.patch &&
patch -d <SOURCE_DIR> -p1 -t -N < ${CMAKE_SOURCE_DIR}/patches/osg/force-add-plugins.patch &&
patch -d <SOURCE_DIR> -p1 -t -N < ${CMAKE_SOURCE_DIR}/patches/osg/dae_collada.patch &&
patch -d <SOURCE_DIR> -p1 -t -N < ${CMAKE_SOURCE_DIR}/patches/osg/mipmaps.patch &&
patch -d <SOURCE_DIR> -p1 -t -N < ${CMAKE_SOURCE_DIR}/patches/osg/0005-CullSettings-make-inheritanceMask-atomic-to-silence-.patch
)

Expand Down
29 changes: 29 additions & 0 deletions buildscripts/patches/osg/mipmaps.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
diff --git a/src/osg/Texture.cpp b/src/osg/Texture.cpp
index 2c0bd4b4e..74ba0ed07 100644
--- a/src/osg/Texture.cpp
+++ b/src/osg/Texture.cpp
@@ -2497,9 +2497,13 @@ void Texture::applyTexImage2D_load(State& state, GLenum target, const Image* ima
GLint blockSize, size;
getCompressedSize(_internalFormat, inwidth, inheight, 1, blockSize,size);

+ int size2 = size;
+ if (useHardwareMipMapGeneration)
+ size2 *= -1;
+
extensions->glCompressedTexImage2D(target, 0, _internalFormat,
inwidth, inheight,0,
- size,
+ size2,
dataPtr);
}

@@ -2619,6 +2623,9 @@ void Texture::applyTexImage2D_load(State& state, GLenum target, const Image* ima

getCompressedSize(_internalFormat, width, height, 1, blockSize,size);

+ if (k == numMipmapLevels - 1)
+ size *= -1;
+
extensions->glCompressedTexImage2D(target, k, _internalFormat,
width, height, _borderWidth,
size, dataPtr + image->getMipmapOffset(k));

0 comments on commit 3285ee1

Please sign in to comment.