如何获得一个EGL显示/上下文特定GLSurfaceView [英] How to get an EGL display/context to a specific GLSurfaceView

查看:511
本文介绍了如何获得一个EGL显示/上下文特定GLSurfaceView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个跟进我原来的问题,这可能是过于宽泛(而这一次可能是太具体,但也许我可以申请牛顿法)。

我的具体情况是:OpenGL ES 2.0的,在Android上,仅使用Java(没有JNI /本地code)

我想了解如何EGL和Android的GLES执行力度一起工作(或没有)。我有麻烦,因为EGL接口(API),似乎并不适合到Android的Java为中心的,基于活动的操作系统。

作为一个具体的例子:我有子类GLSurfaceView,并使用一个XML布局的实例,然后使用 findViewById()来检索参考。使用这种方法,我有<一个href="http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/graphics/GLES20TriangleRenderer.html"相对=nofollow>质感的三角形例如
的工作(在Android 2.2 GLES 2.0 API 8级)。这个例子没有使用EGL。作为一个学习的过程,我想重新写它使用EGL。

所有的例子我能找到使用 eglGetDisplay() eglInitialize(),开创油腻的黑色粉扑上下文抽烟。无我已经找到了例子,参考文献和问题的专门适用于ES2.0 / EGL /安卓/ Java的。难道我完全失去了一些东西? <一href="http://stackoverflow.com/questions/6365366/how-to-properly-initialize-and-terminate-egl-on-android">This问题是有关(我认为),但并没有在的ES 2.0编程指南是一个独立的C实现。

This is a follow up to my original Question, which was probably too broad (whereas this one is probably too specific but maybe I can apply Newton's Method).

My specific situation is: OpenGL ES 2.0, on Android, using only Java (no JNI/Native code).

I am trying to understand how EGL and Android's GLES implimentation work together (or don't). I am having trouble because the EGL interface(API) does not seem well suited to Android's Java centric, Activity based OS.

As a specific example: I have subclassed GLSurfaceView and create an instance using an XML layout and then use findViewById() to retrieve a reference. Using this approach I have the textured triangle example working (GLES 2.0 on Android 2.2, API level 8). This example does not use EGL. As a learning exercise I wanted to re-write it using EGL.

All the examples I can find use eglGetDisplay() and eglInitialize(), and create a context in puff of greasy black smoke. None of the examples, references and questions I have found apply specifically to ES2.0/EGL/Android/Java. Am I completely missing something? This question is related (I think) but does not have any responses and the example used in the ES 2.0 Programming Guide is a stand alone C implementation.

推荐答案

没有什么特定的Andr​​oid到EGL真的。当你创建一个EGL窗口表面(eglCreateWindowSurface),你给它一个表面或SurfaceHolder(其中一个SurfaceView会给你)。这意味着你可以pretty的多复制/粘贴EGL例如,从C,C ++或任何其他语言并将它在几分钟内对Android的工作。这就是我要做的事; - )

There is nothing Android specific to EGL really. When you create an EGL window surface (eglCreateWindowSurface) you give it a Surface or a SurfaceHolder (which a SurfaceView will give you.) This means you can pretty much copy/paste an EGL example from C, C++ or any other language and have it work on Android in minutes. That's how I do it ;-)

更新:我刚刚看了你的其他信息。您需要EGL初始化GLES环境。

Update: I just read your other message. You need EGL to initialize a GLES context.

这篇关于如何获得一个EGL显示/上下文特定GLSurfaceView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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