From 2ab103016e85a9d16b6be5c8d79f683820efc20f Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 17 Jun 2014 17:58:52 -0430 Subject: [PATCH] Added new shaders. Enabled accelerometer and compass support. --- assets/shaders/alphaSprite/alpha_frag.glsl | 29 ++++++++++++++++++++ assets/shaders/alphaSprite/alpha_vert.glsl | 26 ++++++++++++++++++ assets/shaders/bckg/bckg_frag.glsl | 15 ++++++++++ assets/shaders/bckg/bckg_vert.glsl | 15 ++++++++++ src/ve/ucv/ciens/ccg/nxtar/MainActivity.java | 4 +-- 5 files changed, 87 insertions(+), 2 deletions(-) create mode 100644 assets/shaders/alphaSprite/alpha_frag.glsl create mode 100644 assets/shaders/alphaSprite/alpha_vert.glsl diff --git a/assets/shaders/alphaSprite/alpha_frag.glsl b/assets/shaders/alphaSprite/alpha_frag.glsl new file mode 100644 index 0000000..9cf7003 --- /dev/null +++ b/assets/shaders/alphaSprite/alpha_frag.glsl @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2014 Miguel Angel Astor Romero + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifdef GL_ES +precision mediump float; +#endif + +uniform sampler2D u_texture; + +varying vec2 v_texCoords; + +void main(){ + vec4 texColor = texture2D(u_texture, v_texCoords); + if(texColor.a > 0.0) + texColor.a = 0.5; + gl_FragColor = texColor; +} \ No newline at end of file diff --git a/assets/shaders/alphaSprite/alpha_vert.glsl b/assets/shaders/alphaSprite/alpha_vert.glsl new file mode 100644 index 0000000..156bef0 --- /dev/null +++ b/assets/shaders/alphaSprite/alpha_vert.glsl @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2014 Miguel Angel Astor Romero + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +uniform mat4 u_projTrans; + +attribute vec4 a_position; +attribute vec2 a_texCoord0; + +varying vec2 v_texCoords; + +void main(){ + v_texCoords = a_texCoord0; + gl_Position = u_projTrans * a_position; +} \ No newline at end of file diff --git a/assets/shaders/bckg/bckg_frag.glsl b/assets/shaders/bckg/bckg_frag.glsl index 5ecaf92..b9724cd 100644 --- a/assets/shaders/bckg/bckg_frag.glsl +++ b/assets/shaders/bckg/bckg_frag.glsl @@ -1,3 +1,18 @@ +/* + * Copyright (C) 2014 Miguel Angel Astor Romero + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifdef GL_ES precision mediump float; #endif diff --git a/assets/shaders/bckg/bckg_vert.glsl b/assets/shaders/bckg/bckg_vert.glsl index 191d740..156bef0 100644 --- a/assets/shaders/bckg/bckg_vert.glsl +++ b/assets/shaders/bckg/bckg_vert.glsl @@ -1,3 +1,18 @@ +/* + * Copyright (C) 2014 Miguel Angel Astor Romero + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ uniform mat4 u_projTrans; attribute vec4 a_position; diff --git a/src/ve/ucv/ciens/ccg/nxtar/MainActivity.java b/src/ve/ucv/ciens/ccg/nxtar/MainActivity.java index aea4194..d09a469 100644 --- a/src/ve/ucv/ciens/ccg/nxtar/MainActivity.java +++ b/src/ve/ucv/ciens/ccg/nxtar/MainActivity.java @@ -231,8 +231,8 @@ public class MainActivity extends AndroidApplication implements ActionResolver, // Configure LibGDX. AndroidApplicationConfiguration cfg = new AndroidApplicationConfiguration(); - cfg.useAccelerometer = false; - cfg.useCompass = false; + cfg.useAccelerometer = true; + cfg.useCompass = true; cfg.useWakelock = true; // Launch the LibGDX core game class.