开发者

Creating a gl texture outside of GLSurfaceView.Renderer?

开发者 https://www.devze.com 2023-03-05 15:56 出处:网络
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 o

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 开发者_如何学Golimiting 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?


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();


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消