Desire HD 和 A500 Tab 上的混合效果不一样
我正在使用 libgdx 和 gdxlw 制作动态壁纸,gdxlw 是 libgdx 之上的一个小框架,可以更轻松地使用 OpenGL 制作动态壁纸。
首先,我确保我没有使用 GL20。我希望尽可能保持GL10/GL11。我正在使用一个简单的正交相机。
我每次渲染调用的操作:
1... 使用
gl11.glClearColor(1, 1, 1, 1);
gl11.glClear(GL11.GL_COLOR_BUFFER_BIT) ;
我用白色填充屏幕。
2... 我使用 SpriteBatch 和 batch.setBlendFunction(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); 在顶部绘制一个黑色方块
;
3. .. 在此之上,我使用 SpriteBatch 绘制了一个大的(通常是缩放的)图像,
batch.setBlendFunction(GL11.GL_DST_COLOR, GL11.GL_ONE_MINUS_DST_COLOR);
然后,它只会在已经是黑色的地方绘制大图像,而不是在白色的地方绘制。它按照我的预期工作,非常适合我的项目。
这在我的 HTC Desire HD (Android 2.3.5) 上完美运行。但是,当我在 Acer Iconia A500 平板电脑(Android 3.2.1)上运行相同的应用程序时,大图像会绘制在黑白背景上,而不会混合。
无论我在绘制大图像时尝试将混合更改为什么,结果总是相同的。黑色方块不可见,但它应该是可见的。大图像正好压在它上面。
我可能做错了什么? 我可能遗漏了一些东西吗?
值得注意的是,我尝试在使用各种混合绘制大图像之后(之后)在大图像之上绘制一些随机精灵,这证明不同类型的混合实际上似乎确实有效。换句话说,混合并没有完全禁用。
混合时大图像的表现与小图像不同吗?
另一个值得注意的有趣的事情是,当我对大图像使用线性过滤时,您实际上可以非常微弱地辨认出黑色方块。但是,使用最近过滤时,它是不可见的。
请原谅我的困惑问题;我现在脑子里唯一想的就是“为什么会发生这种事?”我一整天都在拉头发,尝试了很多方法但没有成功。
libgdx 与平板电脑或 Android 3+ 不兼容吗?我找不到任何相关参考。
gdxlw 是罪魁祸首吗?
编辑:我做了一些测试,发现如果我将应用程序更改为使用 GL20 而不是 GL11,我在 Desire HD 上得到的结果与我的 Acer Iconia A500 相同。也就是说,我看到我的大图像,并且非常(!)模糊地看到它后面的黑色。
另外,我正在查看在 Acer Iconia A500 平板电脑上运行 GL11 版本的 logcat。它指出...
02-10 10:58:19.010: D/libEGL(9907): loaded /system/lib/egl/libGLES_android.so
02-10 10:58:19.020: D/libEGL(9907): loaded /system/lib/egl/libEGL_tegra.so
02-10 10:58:19.040: I/DEBUG(81): tid 9915 does not exist in pid 9893. ignoring debug request
02-10 10:58:19.040: D/libEGL(9907): loaded /system/lib/egl/libGLESv1_CM_tegra.so
02-10 10:58:19.040: D/libEGL(9907): loaded /system/lib/egl/libGLESv2_tegra.so
02-10 10:58:19.050: D/QuickLog(9907): checkGL20 is: true
02-10 10:58:19.080: D/HAL(9907): [HAL] hw_get_module:share library path:/system/lib/hw/gralloc.tegra.so
02-10 10:58:19.290: D/HAL(9907): [HAL] hw_get_module:share library path:/system/lib/hw/gralloc.tegra.so
02-10 10:58:19.290: D/AndroidGraphics(9907): GL20: true
02-10 10:58:19.300: D/AndroidGraphics(9907): OGL renderer: NVIDIA AP
02-10 10:58:19.300: D/AndroidGraphics(9907): OGL vendor: NVIDIA Corporation
02-10 10:58:19.300: D/AndroidGraphics(9907): OGL version: OpenGL ES-CM 1.1
02-10 10:58:19.300: D/AndroidGraphics(9907): OGL extensions: GL_EXT_bgra GL_EXT_texture_compression_dxt1 GL_EXT_texture_compression_s3tc GL_EXT_texture_format_BGRA8888 GL_NV_texture_npot_2D_mipmap GL_OES_byte_coordinates GL_OES_compressed_ETC1_RGB8_texture GL_OES_compressed_paletted_texture GL_OES_draw_texture GL_OES_extended_matrix_palette GL_OES_EGL_image GL_OES_EGL_image_external GL_OES_EGL_sync GL_OES_fbo_render_mipmap GL_OES_fixed_point GL_OES_framebuffer_object GL_OES_matrix_get GL_OES_matrix_palette GL_OES_point_size_array GL_OES_point_sprite GL_OES_query_matrix GL_OES_read_format GL_OES_rgb8_rgba8 GL_OES_single_precision GL_OES_stencil8 GL_OES_texture_cube_map GL_OES_vertex_half_float
02-10 10:58:19.300: D/AndroidGraphics(9907): framebuffer: (5, 6, 5, 0)
02-10 10:58:19.300: D/AndroidGraphics(9907): depthbuffer: (16)
02-10 10:58:19.300: D/AndroidGraphics(9907): stencilbuffer: (0)
...对我来说,这听起来像是按预期使用 OpenGL ES 1.1。我找不到有关“CM”代表什么的信息。但是,从运行相同应用程序版本的 Desire HD 中查看我的 logcat:
02-10 11:04:16.515: D/AndroidGraphics(10851): GL20: true
02-10 11:04:16.525: D/AndroidGraphics(10851): OGL renderer: Adreno 205
02-10 11:04:16.525: D/AndroidGraphics(10851): OGL vendor: Qualcomm
02-10 11:04:16.525: D/AndroidGraphics(10851): OGL version: OpenGL ES-CM 1.1
02-10 11:04:16.525: D/AndroidGraphics(10851): OGL extensions: GL_AMD_compressed_3DC_texture GL_AMD_compressed_ATC_texture GL_AMD_performance_monitor GL_APPLE_texture_2D_limited_npot GL_EXT_texture_filter_anisotropic GL_EXT_texture_format_BGRA8888 GL_EXT_texture_type_2_10_10_10_REV GL_OES_blend_equation_separate GL_OES_blend_func_separate GL_OES_blend_subtract GL_OES_compressed_ETC1_RGB8_texture GL_OES_compressed_paletted_texture GL_OES_depth_texture GL_OES_draw_texture GL_OES_framebuffer_object GL_OES_matrix_palette GL_OES_packed_depth_stencil GL_OES_point_size_array GL_OES_point_sprite GL_OES_read_format GL_OES_rgb8_rgba8 GL_OES_stencil_wrap GL_OES_EGL_image GL_OES_texture_cube_map GL_OES_texture_env_crossbar GL_OES_texture_float GL_OES_texture_half_float GL_OES_texture_half_float_linear GL_OES_texture_npot GL_OES_texture_mirrored_repeat GL_QCOM_binning_control GL_QCOM_extended_get GL_QCOM_tiled_rendering
02-10 11:04:16.535: D/AndroidGraphics(10851): framebuffer: (5, 6, 5, 0)
02-10 11:04:16.535: D/AndroidGraphics(10851): depthbuffer: (16)
02-10 11:04:16.535: D/AndroidGraphics(10851): stencilbuffer: (0)
...它表明它使用与我的平板电脑相同的 OpenGL 版本。
如果版本相同,两个实现的工作方式不应该相同吗?
硬件(一个是 Nvidia Tegra,另一个是 Qualcomm)会产生影响吗?
OpenGL 1.1 是吗?在 Tegra 设备上以某种方式“模拟”,但并不完美?
我也看到“OGL 扩展”列表有所不同。例如,搜索任何包含“blend”的内容时,我在 Desire HD 上找到了 GL_OES_blend_equation_separate
、GL_OES_blend_func_separate
和 GL_OES_blend_subtract
,而在 A500 上却找不到我能告诉你什么。
如果问题出在这些扩展中,我如何(如果可能)解决这个问题?
编辑:好的,现在我让它按照我想要的方式工作,但我只使用 GL20。不过,如果可能的话,我仍然想使用 GL10 或 GL11 来解决问题,因为我希望更多设备能够运行该应用程序。
I'm making a live wallpaper using libgdx as well as gdxlw which is a little framework on top of libgdx for making it easier to make a live wallpaper using OpenGL.
First off, I make sure I'm not using GL20. I wish to try to keep to GL10/GL11 as much as possible. I'm using a simple OrthographicCamera.
What I do each render call:
1... Using
gl11.glClearColor(1, 1, 1, 1);
gl11.glClear(GL11.GL_COLOR_BUFFER_BIT);
I fill the screen with white.
2... I draw, say, a black square on top, using SpriteBatch and
batch.setBlendFunction(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
3... On top of this I draw a large (usually scaled) image using SpriteBatch and
batch.setBlendFunction(GL11.GL_DST_COLOR, GL11.GL_ONE_MINUS_DST_COLOR);
Which will then only draw that large image where it's already black and not where it's white. It works as I expected it to and is perfect for my project.
This works perfectly on my HTC Desire HD (Android 2.3.5). However, when I run the very same app on my Acer Iconia A500 tablet (Android 3.2.1) the large image is drawn over both the black and white background without blending.
Regardless of what I've tried to change the blending to when drawing the large image, the result is always the same. The black square is not visible, which it should be. The large image just bulldozes right over it.
What could I be doing wrong?
Could I be missing something?
An interesting thing to note is that I tried drawing some random sprites on top of (after) the large image was drawn with various blending which proved that different kinds of blending in fact did seem to work. In other words, blending wasn't completely disabled.
Do large images behave differently than smaller ones when blending?
Another interesting thing to note is that when I use Linear filtering on the large image, you can actually make out the black square very faintly. However, it's not visible with Nearest filtering.
Please forgive my confused questions; the only thing in my mind right now is "why does this happen?" and I've been pulling my hair over it all day and tried many approaches with no success.
Is libgdx not compatible with tablets or Android 3+? I can't find any reference to that.
Is gdxlw the culprit?
EDIT: I've done some tests and found out that if I change the app to use GL20 instead of GL11 I get the same result on my Desire HD as my Acer Iconia A500. That is, I see my large image and extremely (!) vaguely I can see the black behind it.
Also, I'm looking at my logcat from running a GL11 version on the Acer Iconia A500 tablet. It states that...
02-10 10:58:19.010: D/libEGL(9907): loaded /system/lib/egl/libGLES_android.so
02-10 10:58:19.020: D/libEGL(9907): loaded /system/lib/egl/libEGL_tegra.so
02-10 10:58:19.040: I/DEBUG(81): tid 9915 does not exist in pid 9893. ignoring debug request
02-10 10:58:19.040: D/libEGL(9907): loaded /system/lib/egl/libGLESv1_CM_tegra.so
02-10 10:58:19.040: D/libEGL(9907): loaded /system/lib/egl/libGLESv2_tegra.so
02-10 10:58:19.050: D/QuickLog(9907): checkGL20 is: true
02-10 10:58:19.080: D/HAL(9907): [HAL] hw_get_module:share library path:/system/lib/hw/gralloc.tegra.so
02-10 10:58:19.290: D/HAL(9907): [HAL] hw_get_module:share library path:/system/lib/hw/gralloc.tegra.so
02-10 10:58:19.290: D/AndroidGraphics(9907): GL20: true
02-10 10:58:19.300: D/AndroidGraphics(9907): OGL renderer: NVIDIA AP
02-10 10:58:19.300: D/AndroidGraphics(9907): OGL vendor: NVIDIA Corporation
02-10 10:58:19.300: D/AndroidGraphics(9907): OGL version: OpenGL ES-CM 1.1
02-10 10:58:19.300: D/AndroidGraphics(9907): OGL extensions: GL_EXT_bgra GL_EXT_texture_compression_dxt1 GL_EXT_texture_compression_s3tc GL_EXT_texture_format_BGRA8888 GL_NV_texture_npot_2D_mipmap GL_OES_byte_coordinates GL_OES_compressed_ETC1_RGB8_texture GL_OES_compressed_paletted_texture GL_OES_draw_texture GL_OES_extended_matrix_palette GL_OES_EGL_image GL_OES_EGL_image_external GL_OES_EGL_sync GL_OES_fbo_render_mipmap GL_OES_fixed_point GL_OES_framebuffer_object GL_OES_matrix_get GL_OES_matrix_palette GL_OES_point_size_array GL_OES_point_sprite GL_OES_query_matrix GL_OES_read_format GL_OES_rgb8_rgba8 GL_OES_single_precision GL_OES_stencil8 GL_OES_texture_cube_map GL_OES_vertex_half_float
02-10 10:58:19.300: D/AndroidGraphics(9907): framebuffer: (5, 6, 5, 0)
02-10 10:58:19.300: D/AndroidGraphics(9907): depthbuffer: (16)
02-10 10:58:19.300: D/AndroidGraphics(9907): stencilbuffer: (0)
...which to me sounds like it's using OpenGL ES 1.1 as intended. I can't find information about what "CM" stands for though. However, looking at my logcat from my Desire HD running the same app version:
02-10 11:04:16.515: D/AndroidGraphics(10851): GL20: true
02-10 11:04:16.525: D/AndroidGraphics(10851): OGL renderer: Adreno 205
02-10 11:04:16.525: D/AndroidGraphics(10851): OGL vendor: Qualcomm
02-10 11:04:16.525: D/AndroidGraphics(10851): OGL version: OpenGL ES-CM 1.1
02-10 11:04:16.525: D/AndroidGraphics(10851): OGL extensions: GL_AMD_compressed_3DC_texture GL_AMD_compressed_ATC_texture GL_AMD_performance_monitor GL_APPLE_texture_2D_limited_npot GL_EXT_texture_filter_anisotropic GL_EXT_texture_format_BGRA8888 GL_EXT_texture_type_2_10_10_10_REV GL_OES_blend_equation_separate GL_OES_blend_func_separate GL_OES_blend_subtract GL_OES_compressed_ETC1_RGB8_texture GL_OES_compressed_paletted_texture GL_OES_depth_texture GL_OES_draw_texture GL_OES_framebuffer_object GL_OES_matrix_palette GL_OES_packed_depth_stencil GL_OES_point_size_array GL_OES_point_sprite GL_OES_read_format GL_OES_rgb8_rgba8 GL_OES_stencil_wrap GL_OES_EGL_image GL_OES_texture_cube_map GL_OES_texture_env_crossbar GL_OES_texture_float GL_OES_texture_half_float GL_OES_texture_half_float_linear GL_OES_texture_npot GL_OES_texture_mirrored_repeat GL_QCOM_binning_control GL_QCOM_extended_get GL_QCOM_tiled_rendering
02-10 11:04:16.535: D/AndroidGraphics(10851): framebuffer: (5, 6, 5, 0)
02-10 11:04:16.535: D/AndroidGraphics(10851): depthbuffer: (16)
02-10 11:04:16.535: D/AndroidGraphics(10851): stencilbuffer: (0)
...it states that it uses the same OpenGL version as my tablet.
Shouldn't both implementations work identically if both are the same version?
Does hardware, one being Nvidia Tegra and the other Qualcomm, make a difference?
Is OpenGL 1.1 "emulated" somehow, and imperfectly so, on a Tegra device?
I do also see that the list of "OGL Extensions" differs some. For example, searching for anything containing "blend" I find GL_OES_blend_equation_separate
, GL_OES_blend_func_separate
and GL_OES_blend_subtract
on my Desire HD while on my A500 I find none from what I can tell.
If the problem lies in these extensions, how (if possible) can I solve this?
EDIT: Ok, so now I got it to work the way I wanted it to but I'm using only GL20. I would still like to solve the problem using GL10 or GL11 if possible, however, as I want more devices to be able to run the app.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论