Skip to content

Commit

Permalink
removed un-needed conus codes
Browse files Browse the repository at this point in the history
  • Loading branch information
U-METAL103\103 authored and U-METAL103\103 committed May 1, 2024
1 parent cf68444 commit bd1968b
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 112 deletions.
1 change: 0 additions & 1 deletion app/src/main/java/joshuatee/wx/radar/NexradRenderData.kt
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,4 @@ class NexradRenderData(val context: Context) {
val warningBuffers = mutableMapOf<PolygonWarningType, OglBuffers>()
//elys mod
val userPointsBuffers = OglBuffers(PolygonType.USERPOINTS, zoomToHideMiscFeatures)
val conusRadarBuffers = OglBuffers()
}
45 changes: 0 additions & 45 deletions app/src/main/java/joshuatee/wx/radar/NexradRenderUtilities.kt
Original file line number Diff line number Diff line change
Expand Up @@ -312,45 +312,6 @@ internal object NexradRenderUtilities {
}
}

/*
//elys mod - keeping this for now.
fun generate4326Projection(inBuff: ByteBuffer, outBuff: ByteBuffer, pn: ProjectionNumbers, count: Int) {
val pnXFloat = pn.xFloat
val pnYFloat = pn.yFloat
val pnXCenter = pn.xCenter
val pnYCenter = pn.yCenter
val pnScaleFloat = pn.scaleFloat
if (count * 4 <= outBuff.limit()) {
for (iCount in 0 until count step 2) {
outBuff.putFloat(iCount * 4, (-((inBuff.getFloat(iCount * 4 + 4) - pnYFloat) * pnScaleFloat) + pnXCenter.toFloat()))
outBuff.putFloat(iCount * 4 + 4, -(-((inBuff.getFloat(iCount * 4) - pnXFloat) * pnScaleFloat) + pnYCenter.toFloat()))
}
}
}
*/

//elys mods
fun genConus(buffers: OglBuffers, pn: ProjectionNumbers, x: Double, y: Double) {
buffers.setToPositionZero()
val pixYD: Float
val pixXD = (-((y - pn.yDbl) * pn.oneDegreeScaleFactor) + pn.xCenter).toFloat()
var ixCount = 0
val test1 = M_180_DIV_PI * log(tan(M_PI_DIV_4 + x * M_PI_DIV_360), E).toFloat()
val test2 = M_180_DIV_PI * log(tan(M_PI_DIV_4 + pn.xDbl * M_PI_DIV_360), E).toFloat()
val len = 1 //buffers.lenInit * 2.0f
val triangleAmount = 1 //buffers.triangleCount
pixYD = -((test1 - test2) * pn.oneDegreeScaleFactorFloat) + pn.yCenter.toFloat()
(0 until triangleAmount).forEach {
buffers.putFloat(pixXD + len * cos((it * TWICE_PI / triangleAmount).toDouble()).toFloat())
buffers.putFloat(-pixYD + len * sin((it * TWICE_PI / triangleAmount).toDouble()).toFloat())
buffers.putFloat(pixXD + len * cos(((it + 1) * TWICE_PI / triangleAmount).toDouble()).toFloat())
buffers.putFloat(-pixYD + len * sin(((it + 1) * TWICE_PI / triangleAmount).toDouble()).toFloat())
buffers.putIndex(ixCount.toShort())
buffers.putIndex((ixCount + 1).toShort())
ixCount += 2
}
}

//for single images
fun genMarker(buffers: OglBuffers, pn: ProjectionNumbers, x: Double, y: Double) {
buffers.setToPositionZero()
Expand Down Expand Up @@ -415,14 +376,8 @@ internal object NexradRenderUtilities {
buffers.putIndex(iI, (ixCount + 2).toShort())
iI += 2
ixCount += 3

}
iCount += 1
}
}





}
68 changes: 2 additions & 66 deletions app/src/main/java/joshuatee/wx/radar/OpenGLShader.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ internal object OpenGLShader {
// Program variables
var sp_SolidColor: Int = 0
var sp_loadimage: Int = 0
var sp_loadconus: Int = 0
var sp_conus: Int = 0

/* SHADER Solid
*
Expand All @@ -44,11 +42,7 @@ internal object OpenGLShader {
"void main() {" +
" gl_FragColor = vec4(v_Color,1.0);" +
"}"






//Thanks to this for point sprite shader and codes
//http://opengles2learning.blogspot.com/2011/05/applying-texture-to-point-sprite.html
//This is my modified shader :) ELY M.
Expand All @@ -67,49 +61,7 @@ internal object OpenGLShader {
"void main() {" +
" gl_FragColor = texture2D(u_texture, gl_PointCoord);" +
"}"


/*
val vs_conus = "uniform mat4 uMVPMatrix;" +
"attribute vec4 vPosition;" +
"attribute vec2 a_texCoords;" +
"varying vec2 v_texCoords;" +
"void main() {" +
" gl_Position = uMVPMatrix * vPosition;" +
" v_texCoords = a_texCoords;" +
"}"
val fs_conus = (
"precision mediump float;" +
"varying vec2 v_texCoords;" +
"uniform sampler2D u_texture;" +
"void main() {" +
" gl_FragColor = texture2D(u_texture, v_texCoords);" +
"}")
*/

val vs_conus = "uniform mat4 uMVPMatrix;" +
"attribute vec4 vPosition;" +
"attribute vec2 a_texCoords;" +
"varying vec2 v_texCoords;" +
"void main() {" +
" gl_Position = uMVPMatrix * vPosition;" +
" v_texCoords = a_texCoords;" +
"}"

val fs_conus = (
"precision mediump float;" +
"varying vec2 v_texCoords;" +
"uniform sampler2D u_texture;" +
"void main() {" +
" gl_FragColor = texture2D(u_texture, v_texCoords);" +
"}")



fun loadShader(type: Int, shaderCode: String): Int {

// create a vertex shader type (GLES20.GL_VERTEX_SHADER)
Expand All @@ -124,7 +76,6 @@ internal object OpenGLShader {
return shader
}


fun LoadImage(imagefile: String) {
val texturenames = IntArray(1)
GLES20.glGenTextures(1, texturenames, 0)
Expand All @@ -140,16 +91,12 @@ internal object OpenGLShader {
GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE.toFloat())
GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, bmp, 0)
///UtilityLog.d("wx-elys", "Loaded texture" + ":H:" + bmp.height + ":W:" + bmp.width)

try {
bmp.recycle()
} catch (e: NullPointerException) {
UtilityLog.handleException(e)
}

}


fun LoadTexture(imagefile: String): Int {
var img: Bitmap? = null
val textures = IntArray(1)
Expand All @@ -169,37 +116,31 @@ internal object OpenGLShader {
} catch (e: Exception) {
UtilityLog.handleException(e)
}

try {
img!!.recycle()
} catch (e: NullPointerException) {
UtilityLog.handleException(e)
}

return textures[0]
}

fun LoadBitmap(imagefile: String): Bitmap? {
var img: Bitmap? = null
try {
val options = BitmapFactory.Options()
options.inScaled = false
options.inPreferredConfig = Bitmap.Config.ARGB_8888
img = BitmapFactory.decodeFile(imagefile, options)

} catch (e: NullPointerException) {
UtilityLog.handleException(e)
}
return img
}

fun resizeBitmap(imagefile: String, size: Double): Bitmap {
val bitmap: Bitmap? = LoadBitmap(imagefile)
val newWidth: Double = (bitmap!!.getWidth() * (size / 100))
val newHeight: Double = (bitmap!!.getHeight() * (size / 100))
return Bitmap.createScaledBitmap(bitmap, newWidth.toInt(), newHeight.toInt(), true)
}

fun RotateBitmap(imagefile: String, d: Double): Bitmap {
//UtilityLog.d("wx-elys", "rotating bitmap: "+ imagefile + " to: "+d)
val bitmap: Bitmap? = LoadBitmap(imagefile)
Expand All @@ -208,7 +149,6 @@ internal object OpenGLShader {
matrix.postTranslate(0.0f, bitmap!!.width.toFloat())
return Bitmap.createBitmap(bitmap, 0, 0, bitmap.width, bitmap.height, matrix, true)
}

fun LoadBitmapTexture(img: Bitmap): Int {
val textures = IntArray(1)
try {
Expand All @@ -223,15 +163,11 @@ internal object OpenGLShader {
} catch (e: Exception) {
UtilityLog.handleException(e)
}

try {
img.recycle()
} catch (e: NullPointerException) {
UtilityLog.handleException(e)
}

return textures[0]
}


}

0 comments on commit bd1968b

Please sign in to comment.