Android:OpenGL 重新加载纹理
我正在尝试在我的应用程序中添加一个加载屏幕,因为加载纹理需要一些时间。这就是我之前所做的...
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
super.onSurfaceCreated(gl, config);
if(firstTimeCreate) {
load(); //load settings
Assets.LoadTextures(this);
firstTimeCreate = false;}
else {
//When screen is resumed....
Assets.reloadTextures();}
这样,在应用程序恢复后,else 语句将生效并重新加载所有内容...我尝试将其适应于此
else {
//When screen is resumed....
Thread aThread = new Thread()
{
public void run(){
boolean once = true;
while(once)
{
Assets.reloadTexutres();
once = false;
}
}
};
aThread.start();
}
但是现在看来 OpenGL 无法将纹理绑定为屏幕是白色的。向这个方法添加线程会出现什么问题?在让 OpenGL 开始尝试渲染之前,我是否需要等待所有纹理加载完毕,如果是这样,我如何加载一个纹理,然后呈现一个加载屏幕,直到其余部分完成?
谢谢
I am trying to add a loading screen into my app as it takes some time to load off of the textures. This is what I was doing before...
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
super.onSurfaceCreated(gl, config);
if(firstTimeCreate) {
load(); //load settings
Assets.LoadTextures(this);
firstTimeCreate = false;}
else {
//When screen is resumed....
Assets.reloadTextures();}
This way after the app was resumed the else statement would take effect and reload everything...I tried to adapt it to this
else {
//When screen is resumed....
Thread aThread = new Thread()
{
public void run(){
boolean once = true;
while(once)
{
Assets.reloadTexutres();
once = false;
}
}
};
aThread.start();
}
However it just seems now that OpenGL cant bind the textures as the screen is white. What is going wrong by adding a thread to this method? Do I need to wait for all the textures to load before I let OpenGL start to try and render, if so how can I load one and then present a loading screen until the rest are done?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
OpenGL ES 上下文被分配给一个线程。因此,如果您想在一个线程中创建上下文并在另一个线程中使用它,您应该调用
eglMakeCurrent(...)
函数。OpenGL ES context is assigned to a thread. So, if you want to create context in one thread and use it in another thread, you should call
eglMakeCurrent(...)
function.