修改Grafika Texture2dProgram画画中画(或纹理纹理) [英] Modify Grafika Texture2dProgram to draw picture in picture (or texture in texture)

查看:1199
本文介绍了修改Grafika Texture2dProgram画画中画(或纹理纹理)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来的openGL所以有一些问题弄清楚如何修改grafika texture2dProgram,这样我可以得到画面效果(纹理或纹理)的画面。这是我的理解所有到目前为止的例子:

I am new to openGL so having some issues figure out how to modify grafika texture2dProgram so that I can get a picture in picture effect (or texture in texture). Here is my understanding so far from all the examples:

(后表面就绪)


  1. 安装视窗

  1. Setup Viewport

GLES20.glViewport(0, 0, width, height);


  • 设置Drawable2d具有纹理和顶点坐标

  • Setup Drawable2d which has texture and vertices coordinates

    new Drawable2d(RECTANGLE)
    


  • 在新的框架,使用Texture2dProgram绘制到视口中具有质感

  • On new frame, use the Texture2dProgram to draw into the viewport with the texture

    我要带我的理解和修改,使我得到了在屏幕上的画面输出的画面。我该如何实现这一目标?

    I want to take my understanding and modify so that I get a picture in picture output on the screen. How do I achieve this?

    我的理解是,我应该做到以下几点:创建两个Texture2dPrograms并分配不同质地的ID等一个texture2dprogram绘制只有一小部分传递不同的投影矩阵。是正确的还是我失去了一些东西?

    My understanding is that I should do the following: create two Texture2dPrograms and assign different texture id and pass different the projection matrix so that one texture2dprogram draws only on a smaller portion. Is that correct or am I missing something?

    推荐答案

    的<一个href=\"https://github.com/google/grafika/blob/master/src/com/android/grafika/gles/Texture2dProgram.java\"相对=nofollow> Texture2dProgram类只是抽象的GLES程序,封装顶点着色器和像素着色器。你只需要比他们多了一个,如果你需要不同的着色器,例如要使用正常和外部的纹理。

    The Texture2dProgram class just abstracts the GLES program, encapsulating a vertex shader and a pixel shader. You only need more than one of them if you need different shaders, e.g. you want to use both "normal" and "external" textures.

    如果你看一下<一个href=\"https://github.com/google/grafika/blob/master/src/com/android/grafika/HardwareScalerActivity.java\"相对=nofollow> HardwareScalerActivity ,你可以看到它使用相同的程序都绘制形状。你想要做类似的事情。 (它还创建一个 FlatShadedProgram ,因为它可以让你在UI它们之间翻转。)

    If you look at HardwareScalerActivity, you can see it drawing both of shapes with the same program. You want to do something similar. (It also creates a FlatShadedProgram because it allows you to flip between them in the UI.)

    Drawable2d 定义形状,程序定义它的呈现方式,以及的 Sprite2d 的限定的位置,大小,和外观。您可以设置 Sprite2d 对象上的纹理ID(请参阅 surfaceChanged() HardwareScalerActivity )。

    The Drawable2d defines the shape, the Program defines how it's rendered, and Sprite2d defines position, size, and appearance. You set the texture ID on the Sprite2d object (see surfaceChanged() in HardwareScalerActivity).

    这可能分解起初看起来有点怪,但它的方式OpenGL ES的工作非常适合。

    This decomposition may seem a little strange at first, but it fits well with the way OpenGL ES works.

    至于对另一件事顶部渲染一件事推移,在Grafika的GLES code是有限的pretty - 在平行于显示器的单一平面的2D只是渲染。无论你先画将由您绘制后的事情被覆盖。执行 Sprite2d 对象上不惹视,只需设置位置和大小。

    As far as rendering one thing on top of another thing goes, the GLES code in Grafika is pretty limited -- just 2D rendering in a single plane parallel to the display. Whatever you draw first will be overwritten by the things you draw after. Don't mess with the viewport, just set position and size on the Sprite2d object.

    这篇关于修改Grafika Texture2dProgram画画中画(或纹理纹理)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆