简体   繁体   English

在Android上执行较长的cpu进程时呈现opengl es

[英]Rendering opengl es while performing a long cpu process on Android

I am in the works of making a game (and game engine) on the Android platform using opengl es 1.x. 我正在使用opengl es 1.x在Android平台上制作游戏(和游戏引擎)。 While loading a level's data and building it, I want to render another scene so the player can have something to look at while the level loading code does it's work. 在加载和构建关卡的数据时,我想渲染另一个场景,以便玩家在关卡加载代码起作用时可以查看一些内容。 I thought of using a hook system where the level loading code would from time to time call a callback function that could so some rendering. 我想到了使用钩子系统,在该钩子系统中,关卡加载代码会不时调用一个回调函数,该回调函数可能会产生一些渲染。

The problem is how can I manually get OpenGL ES to display the contents of the backbuffer since the level loading code is performing its work on the opengl thread, since it too uses opengl es calls to perform it's work? 问题是,由于级别加载代码正在opengl线程上执行其工作,因为它也使用opengl es调用来执行其工作,因此我如何才能手动获取OpenGL ES以显示后缓冲区的内容?

Any advice is greatly appreciated, Thanks 任何建议,不胜感激,谢谢

You could try to do the opposite of having your loading code call the rendering code (let the rendering code call the loading code when there is some time in-between fames). 您可以尝试执行与使加载代码调用渲染代码相反的操作(当帧之间有一段时间时,让渲染代码调用加载代码)。 Divide (and conquer) your loading up into as small fractions as possible, (only read 100 bytes of a image buffer and so on) and call a general load() method that will do the smallest amount of work possible before returning, and then if you have time to call again before rendering the next frame, call it again and just iterate until your running low on time (to keep some target fps). 将您的加载分成(并征服)尽可能小的部分((仅读取图像缓冲区的100个字节,依此类推),并调用一般的load()方法,该方法将在返回之前进行尽可能少的工作,然后如果您有时间在渲染下一帧之前再次调用,请再次调用它并进行迭代,直到运行时间不足(以保持某些目标fps)为止。 This will only work well if you can divide pretty much all your loading into small chunks and create a queue for the loading "tasks". 仅当您可以将几乎所有的加载都分成小块并为加载的“任务”创建队列时,这才行得通。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM