Creating a gl texture outside of GLSurfaceView.Renderer?

和自甴很熟 提交于 2019-12-11 02:23:57

问题


Is there a way to create gl textures outside of my implementation of GLSurfaceView.Renderer? I've only been able to create textures in the onSurfaceCreated method, since that's where I have access of the GL10 gl variable. It's limiting me because I can't create open gl textures on demand in my code and have to create everything in that method.

Alternatively, is there a way to get at the GL10 gl variable outside of the GLSurfaceView.Renderer? Or is there even another way to create gl textures?


回答1:


I found something that works, getting the EGLContext.

import javax.microedition.khronos.egl.EGLContext;
import javax.microedition.khronos.egl.EGL10;
import javax.microedition.khronos.opengles.GL10;

// in code.

EGL10 egl = (EGL10)EGLContext.getEGL(); 
GL10 gl = (GL10)egl.eglGetCurrentContext().getGL();



回答2:


you should keep your code separated. GL stuff should be done in gl related classes. logic should be done in logic related classes, having no idea about gl stuff...

so, no, you cant created gl textures if you dont have access to the GL10 variable. also, i think that onSurfaceCreated is the right method to do that stuff.



来源:https://stackoverflow.com/questions/5979069/creating-a-gl-texture-outside-of-glsurfaceview-renderer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!