-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Uniform method names for GlRect and GlRoundRect * Split GlTextureProgram and GlSimpleTextureProgram * Refactor texture programs * Create GlTexture class * Make texture variable * Refactoring and new features * Fix GlTexture constructors * Create GlDrawable.vertexArrayVersion for optimizations * Create Gl2dMesh * Improve texture program * Create geometry package * Small changes
- Loading branch information
Showing
24 changed files
with
757 additions
and
216 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
--- | ||
layout: page | ||
title: "Textures" | ||
description: "APIs for textures and framebuffer objects" | ||
order: 4 | ||
disqus: 1 | ||
--- | ||
|
||
### The GlTexture object | ||
|
||
The `GlTexture` object will generate and allocate an OpenGL texture. The texture can then be used to | ||
read from it, render into it, attach to a framebuffer object and much more. | ||
|
||
By default, the `GlTexture` is created with the `GLES11Ext.GL_TEXTURE_EXTERNAL_OES` texture target. | ||
This means that it is suitable for using it as the output of a `SurfaceTexture`: | ||
|
||
```kotlin | ||
val texture = GlTexture() | ||
val surfaceTexture = SurfaceTexture(texture.id) | ||
// Anytime the surface texture is passed new data, its contents are put into our GlTexture | ||
// For example, we can receive the stream of video frames: | ||
videoPlayer.setOutputSurface(surfaceTexture) | ||
videoPlayer.play() | ||
``` | ||
|
||
However, different targets can be specified within the texture constructor. When using `GLES20.GL_TEXTURE_2D`, | ||
you will probably want to use the constructor that accepts a `width` and `height` so that the buffer | ||
is actually allocated. | ||
|
||
> To render texture contents, just use a `GlTextureProgram` and pass the texture to it. | ||
See the [programs](programs#texture-program) page for details. | ||
|
||
### The GlFramebuffer object | ||
|
||
The `GlFramebuffer` object will generate an OpenGL framebuffer object. | ||
You can attach textures to it by using `GlFramebuffer.attach()`, like so: | ||
|
||
```kotlin | ||
val texture = GlTexture() | ||
val fbo = GlFramebuffer() | ||
fbo.attach(texture, GLES20.GL_COLOR_ATTACHMENT0) | ||
``` | ||
|
||
The attached textures will now receive the framebuffer contents. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
library/src/main/java/com/otaliastudios/opengl/core/GlBindable.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.otaliastudios.opengl.core | ||
|
||
interface GlBindable { | ||
fun bind() | ||
fun unbind() | ||
} | ||
|
||
fun GlBindable.use(block: () -> Unit) { | ||
bind() | ||
block() | ||
unbind() | ||
} |
2 changes: 1 addition & 1 deletion
2
...tudios/opengl/viewport/GlViewportAware.kt → ...liastudios/opengl/core/GlViewportAware.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package com.otaliastudios.opengl.viewport | ||
package com.otaliastudios.opengl.core | ||
|
||
import android.opengl.GLES20 | ||
|
||
|
Oops, something went wrong.