Skip to content

Commit

Permalink
Merge branch 'main' into fix/282-stars-flicker
Browse files Browse the repository at this point in the history
# Conflicts:
#	app/src/main/java/com/github/lookupgroup27/lookup/model/map/stars/StarsLoader.kt
  • Loading branch information
AdrienBousquieEPFL committed Dec 18, 2024
2 parents 50c4e83 + 2976954 commit 575fde2
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class MapRenderer(
textureManager = TextureManager(context)

// Initialize the SkyBox
skyBoxTextureHandle = textureManager.loadTexture(R.drawable.skybox_texture)
skyBoxTextureHandle = textureManager.loadTexture(R.drawable.skybox)
skyBox = SkyBox(context)

// Initialize the objects in the scene
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ import com.github.lookupgroup27.lookup.util.opengl.ShaderProgram
/**
* Renderer for creating circular 2D objects in an OpenGL environment.
*
* @param segments Number of segments used to approximate the circle (default is 32)
* @param segments Number of segments used to approximate the circle (default is DEFAULT_SEGMENTS)
* @param radius Radius of the circle (default is 1.0f)
* @param color Color of the circle as an integer (RGBA)
* @param color Color of the circle in RGBA format (range 0-255) (default is white)
*/
open class CircleRenderer(
private val context: Context,
private val segments: Int = DEFAULT_SEGMENTS,
private val radius: Float = 1.0f,
private val color: FloatArray = floatArrayOf(1.0f, 1.0f, 1.0f, 1.0f)
private val color: IntArray = intArrayOf(255, 255, 255, 255)
) {
/** Buffer for storing vertex positions. */
private val vertexBuffer = VertexBuffer()
Expand Down Expand Up @@ -54,22 +54,12 @@ open class CircleRenderer(
}

// Add indices to the index buffer
for (index in geometryData.indices) {
indexBuffer.addIndex(index)
}

// Convert float color to integer color for buffer
val colorInt =
((color[3] * 255).toInt() shl
24 or
(color[0] * 255).toInt() shl
16 or
(color[1] * 255).toInt() shl
8 or
(color[2] * 255).toInt())
for (index in geometryData.indices) indexBuffer.addIndex(index)

// Apply a single color for all vertices
repeat(geometryData.vertices.size / 3) { colorBuffer.addColor(colorInt) }
repeat(geometryData.vertices.size / 3) {
colorBuffer.addColor(color[3], color[0], color[1], color[2])
}
}

/** Initializes shaders for rendering the circle. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import com.github.lookupgroup27.lookup.model.map.Camera
*
* @param context The Android context for resource management
* @param position The x, y, z coordinates of the star
* @param color The color of the star, specified as an RGBA float array
* @param color The color of the star, specified as an RGBA array (range 0-255) (default is white)
* @param size The size of the star (scale factor for its radius)
* @param segments The number of segments used to approximate the circle (default is 32)
*/
class Star(
val context: Context,
val position: FloatArray,
val color: FloatArray,
val color: IntArray = intArrayOf(255, 255, 255, 255),
val size: Float = 0.5f,
val segments: Int = CircleRenderer.DEFAULT_SEGMENTS
) : Object() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class ColorBuffer {
*/
fun addColor(a: Int, r: Int, g: Int, b: Int) {
val color =
((a and 0xFF) shl 24) or ((r and 0xFF) shl 16) or ((g and 0xFF) shl 8) or (b and 0xFF)
((a and 0xFF) shl 24) or ((b and 0xFF) shl 16) or ((g and 0xFF) shl 8) or (r and 0xFF)
colorBuffer?.put(color)
}

Expand All @@ -66,7 +66,7 @@ class ColorBuffer {
COLORS_PER_VERTEX,
GLES20.GL_UNSIGNED_BYTE,
true, // Normalize the values to [0, 1]
COLORS_PER_VERTEX * Int.SIZE_BYTES,
0,
colorBuffer)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package com.github.lookupgroup27.lookup.model.map.stars
package com.github.lookupgroup27.lookup.model.loader

import android.content.Context
import com.github.lookupgroup27.lookup.model.map.renderables.Star
import com.github.lookupgroup27.lookup.model.map.stars.StarDataRepository

/**
* Converts star data into renderable objects for OpenGL rendering.
Expand Down
Binary file removed app/src/main/res/drawable/image1.webp
Binary file not shown.
Binary file removed app/src/main/res/drawable/image2.jpg
Binary file not shown.
Binary file added app/src/main/res/drawable/skybox.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed app/src/main/res/drawable/skybox_texture.jpg
Binary file not shown.

0 comments on commit 575fde2

Please sign in to comment.