Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix build for the demo app #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.yalantis.glatademo

import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import androidx.appcompat.app.AppCompatActivity
import com.yalantis.glata.core.FpsStabilizer
import com.yalantis.glata.util.initSurface
import com.yalantis.glatademo.scene.TestScene
Expand Down
44 changes: 22 additions & 22 deletions glatademo/src/main/java/com/yalantis/glatademo/scene/TestScene.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ class TestScene(sp: SceneParams = SceneParams()) : Scene(sp) {
override fun onSurfaceChanged(rp: RendererParams, width: Int, height: Int) {
super.onSurfaceChanged(rp, width, height)
if (width > height) {
sp.camera.setVerticalSizeInUnits(3.2f)
sceneParams.camera.setVerticalSizeInUnits(3.2f)
} else {
sp.camera.setHorizontalSizeInUnits(3.2f)
sceneParams.camera.setHorizontalSizeInUnits(3.2f)
}
sp.camera.setPivot(Align.CENTER)
sp.camera.setProjectionMatrix()
sceneParams.camera.setPivot(Align.CENTER)
sceneParams.camera.setProjectionMatrix()
}

override fun onDrawFrame(rp: RendererParams) {
Expand All @@ -47,14 +47,14 @@ class TestScene(sp: SceneParams = SceneParams()) : Scene(sp) {
private fun createTopRow(rp: RendererParams) {
val rowHeight = 0.6f
val rect1 = Rectangle.builder().flipTextureHorizontally().flipTextureVertically().build()
rect1.mp.textureId = rp.managers.textureManager.add(Texture(rp, "ava_2").apply { isRepeating = true })
rect1.modelParams.textureId = rp.managers.textureManager.add(Texture(rp, "ava_2").apply { isRepeating = true })
rect1.animation = ScalingAnimation(0.8f, 1f, 1000f).apply {
isInfinite = true
interpolator = AccelerateDecelerateInterpolator()
}
rect1.mp.setShader(Shaders.DEFAULT_TEXTURE_SHADER)
rect1.mp.transform.position.x = -1.1f
rect1.mp.transform.position.y = rowHeight
rect1.modelParams.setShader(Shaders.DEFAULT_TEXTURE_SHADER)
rect1.modelParams.transform.position.x = -1.1f
rect1.modelParams.transform.position.y = rowHeight
children.add(rect1)

val rect2 = Rectangle(1f, 1f, 3f, 3f)
Expand All @@ -63,16 +63,16 @@ class TestScene(sp: SceneParams = SceneParams()) : Scene(sp) {
isInfinite = true
returnToInitialAfterFinished = true
}
rect2.mp.textureId = rect1.mp.textureId
rect2.mp.setShader(Shaders.DEFAULT_TEXTURE_SHADER)
rect2.mp.transform.position.y = rowHeight
rect2.modelParams.textureId = rect1.modelParams.textureId
rect2.modelParams.setShader(Shaders.DEFAULT_TEXTURE_SHADER)
rect2.modelParams.transform.position.y = rowHeight
children.add(rect2)

val rect3 = Rectangle.builder().setHasTexture().build()
rect3.animation = AxisRotationAnimation(90f)
rect3.mp.setShader(Shaders.DEFAULT_TEXTURE_SHADER)
rect3.mp.transform.position.x = 1.1f
rect3.mp.transform.position.y = rowHeight
rect3.modelParams.setShader(Shaders.DEFAULT_TEXTURE_SHADER)
rect3.modelParams.transform.position.x = 1.1f
rect3.modelParams.transform.position.y = rowHeight
children.add(rect3)
}

Expand All @@ -83,35 +83,35 @@ class TestScene(sp: SceneParams = SceneParams()) : Scene(sp) {
.setGradientColor(Color(1f, 0f, 0f, 1f), Color(0f, 1f, 0f, 1f),
Color(0f, 0f, 1f, 1f), Color(0.6f, 0.6f, 0.6f, 1f))
.build()
rect1.mp.setShader(Shaders.DEFAULT_COLOR_SHADER)
rect1.modelParams.setShader(Shaders.DEFAULT_COLOR_SHADER)
rect1.animation = ScalingAnimation(0.8f, 1f, 1000f).apply {
isInfinite = true
interpolator = AccelerateDecelerateInterpolator()
}
rect1.mp.transform.position.x = -1.1f
rect1.mp.transform.position.y = rowHeight
rect1.modelParams.transform.position.x = -1.1f
rect1.modelParams.transform.position.y = rowHeight
children.add(rect1)

val rect2 = Rectangle.builder()
.setVerticalGradientColor(Color(1f, 0f, 0f, 1f), Color(0f, 1f, 0f, 1f))
.build()
rect2.mp.setShader(Shaders.DEFAULT_COLOR_SHADER)
rect2.modelParams.setShader(Shaders.DEFAULT_COLOR_SHADER)
rect2.animation = AxisMovementAnimation(Axis.Y, 0f, -1.1f, 1000f)
.apply {
isInfinite = true
returnToInitialAfterFinished = true
}
rect2.mp.transform.position.y = rowHeight
rect2.modelParams.transform.position.y = rowHeight
children.add(rect2)

val rect3 = Rectangle.builder()
.setSize(0.85f, 0.85f)
.setHorizontalGradientColor(Color(1f, 0f, 0f, 1f), Color(0f, 1f, 0f, 1f))
.build()
rect3.mp.setShader(Shaders.DEFAULT_COLOR_SHADER)
rect3.modelParams.setShader(Shaders.DEFAULT_COLOR_SHADER)
rect3.animation = AxisRotationAnimation(90f)
rect3.mp.transform.position.x = 1.1f
rect3.mp.transform.position.y = rowHeight
rect3.modelParams.transform.position.x = 1.1f
rect3.modelParams.transform.position.y = rowHeight
children.add(rect3)
}
}