mirror of
https://github.com/geode-sdk/android-launcher.git
synced 2026-10-21 16:32:39 +00:00
proper refresh rate selection
This commit is contained in:
2 files changed
+15
-7
No files matched your search
@@ -363,7 +363,13 @@ class GeometryDashActivity : AppCompatActivity(), Cocos2dxHelper.Cocos2dxHelperL
|
|||||||
}
|
}
|
||||||
|
|
||||||
glSurfaceView.initView()
|
glSurfaceView.initView()
|
||||||
glSurfaceView.setCocos2dxRenderer(Cocos2dxRenderer())
|
|
||||||
|
val renderer = Cocos2dxRenderer(glSurfaceView)
|
||||||
|
glSurfaceView.setCocos2dxRenderer(renderer)
|
||||||
|
|
||||||
|
if (forceRefreshRate) {
|
||||||
|
renderer.setFrameRate = true
|
||||||
|
}
|
||||||
|
|
||||||
editText.inputType = 145
|
editText.inputType = 145
|
||||||
glSurfaceView.cocos2dxEditText = editText
|
glSurfaceView.cocos2dxEditText = editText
|
||||||
@@ -417,10 +423,6 @@ class GeometryDashActivity : AppCompatActivity(), Cocos2dxHelper.Cocos2dxHelperL
|
|||||||
mIsRunning = true
|
mIsRunning = true
|
||||||
// Cocos2dxHelper.onResume()
|
// Cocos2dxHelper.onResume()
|
||||||
mGLSurfaceView?.onResume()
|
mGLSurfaceView?.onResume()
|
||||||
|
|
||||||
if (forceRefreshRate && Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
|
||||||
mGLSurfaceView?.updateRefreshRate()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun pauseGame() {
|
private fun pauseGame() {
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
package org.cocos2dx.lib
|
package org.cocos2dx.lib
|
||||||
|
|
||||||
import android.opengl.GLSurfaceView
|
import android.opengl.GLSurfaceView
|
||||||
|
import android.os.Build
|
||||||
import javax.microedition.khronos.egl.EGLConfig
|
import javax.microedition.khronos.egl.EGLConfig
|
||||||
import javax.microedition.khronos.opengles.GL10
|
import javax.microedition.khronos.opengles.GL10
|
||||||
|
|
||||||
@Suppress("unused", "KotlinJniMissingFunction")
|
@Suppress("unused", "KotlinJniMissingFunction")
|
||||||
class Cocos2dxRenderer : GLSurfaceView.Renderer {
|
class Cocos2dxRenderer(private var handler: Cocos2dxGLSurfaceView) : GLSurfaceView.Renderer {
|
||||||
companion object {
|
companion object {
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun setAnimationInterval(@Suppress("UNUSED_PARAMETER") animationInterval: Double) {
|
fun setAnimationInterval(@Suppress("UNUSED_PARAMETER") animationInterval: Double) {
|
||||||
@@ -60,6 +61,7 @@ class Cocos2dxRenderer : GLSurfaceView.Renderer {
|
|||||||
private var screenWidth = 0
|
private var screenWidth = 0
|
||||||
private var screenHeight = 0
|
private var screenHeight = 0
|
||||||
var sendResizeEvents = false
|
var sendResizeEvents = false
|
||||||
|
var setFrameRate = false
|
||||||
|
|
||||||
fun setScreenWidthAndHeight(surfaceWidth: Int, surfaceHeight: Int) {
|
fun setScreenWidthAndHeight(surfaceWidth: Int, surfaceHeight: Int) {
|
||||||
screenWidth = surfaceWidth
|
screenWidth = surfaceWidth
|
||||||
@@ -71,7 +73,11 @@ class Cocos2dxRenderer : GLSurfaceView.Renderer {
|
|||||||
lastTickInNanoSeconds = System.nanoTime()
|
lastTickInNanoSeconds = System.nanoTime()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onSurfaceChanged(gl10: GL10?, width: Int, height: Int) {}
|
override fun onSurfaceChanged(gl10: GL10?, width: Int, height: Int) {
|
||||||
|
if (setFrameRate && Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||||
|
handler.updateRefreshRate()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun onDrawFrame(gl: GL10?) {
|
override fun onDrawFrame(gl: GL10?) {
|
||||||
nativeRender()
|
nativeRender()
|
||||||
|
|||||||
Reference in new issue
Block a user