전체상품목록 바로가기

본문 바로가기


Anaglyph 3d Video Player For Android -

private fun generateTexture(): Int // ... generate GL_TEXTURE_EXTERNAL_OES texture

// Assuming side-by-side: left half = left eye, right half = right eye vec2 leftCoord = vec2(vTexCoord.x * 0.5, vTexCoord.y); vec2 rightCoord = vec2(vTexCoord.x * 0.5 + 0.5, vTexCoord.y);

override fun onDrawFrame(gl: GL10?) surfaceTexture.updateTexImage() GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT) GLES20.glUseProgram(program) drawQuad() anaglyph 3d video player for android

// Anaglyph fragment shader – Dubois optimized matrix precision mediump float; uniform sampler2D uTexture; // frame from video varying vec2 vTexCoord; void main() vec4 color = texture2D(uTexture, vTexCoord);

vec4 left = texture2D(uTexture, leftCoord); vec4 right = texture2D(uTexture, rightCoord); private fun generateTexture(): Int //

fun getSurfaceTexture(): SurfaceTexture = surfaceTexture

override fun onSurfaceChanged(gl: GL10?, width: Int, height: Int) GLES20.glViewport(0, 0, width, height) config: EGLConfig?) program = createProgram(vertexShader

For or full‑frame interlaced – adjust coordinate sampling. 4. Android Renderer Class (Kotlin) class AnaglyphRenderer : GLSurfaceView.Renderer private var textureId = 0 private var program = 0 private lateinit var surfaceTexture: SurfaceTexture private var videoWidth = 0 private var videoHeight = 0 override fun onSurfaceCreated(gl: GL10?, config: EGLConfig?) program = createProgram(vertexShader, fragmentShader) textureId = generateTexture() surfaceTexture = SurfaceTexture(textureId)

The renderer’s SurfaceTexture feeds frames to the shader. Add a setting in UI:

| Format | Sampling logic in shader | |------------------|-------------------------------------------------| | Side‑by‑side | leftCoord.x = vTexCoord.x / 2 | | Over‑under | leftCoord.y = vTexCoord.y / 2 | | Full‑frame left/right | Use separate textures if available |


anaglyph 3d video player for android