Creating a hole in the quadrilateral OpenGL ES 2.0

Tutorials concerning the OpenGL® ES cross-platform API for full-function 2D and 3D graphics on the Google-Android platform.

Creating a hole in the quadrilateral OpenGL ES 2.0

Postby devivan80 » Mon Apr 02, 2012 10:02 am

Hello!

At the stage of implementation should be done in the quadrangle round holes (in advance where they will be - is unknown.)
Using the OpenGL ES 2.0, Android 2.2 phones HTC Disaer S and HTC Disaer.

Probyval several ways:
One way) Using glBlendFunc.
In Photoshop create a mask: a rectangle with round neckline. Color of the rectangle - black (opaque), the cut-out of alpha = 0%.
The texture of the quadrangle (which cut out the hole) is opaque.

Here's the code:
Code: Select all
GLES20.glColorMask (false, false, false, true); / / draw a mask only for alpha

... I draw a mask ...

GLES20.glColorMask (true, true, true, true);


GLES20.glEnable (GLES20.GL_BLEND);
GLES20.glBlendFunc (GLES20.GL_DST_ALPHA, GLES20.GL_ONE_MINUS_DST_ALPHA);

... draw a rectangle (where the holes should appear)

GLES20.glDisable (GLES20.GL_BLEND);


As a result, the rectangle formed is not round and square holes ...
The hole and the quadrilateral are flat on one level. It seems that the hole is drawn "over" the quadrangle. At the same time in those places (at the landfill hole), where the rectangle should be visible - black (background color).

Method 2) Using the function glBlendFuncSeparate (). But when referring to it the application crashes.

3 method) Cut a hole through a shader. This is the only way that worked. But! In the shader, use the function "discard", which strongly inhibits (FPS drops from 60 to 20) on some devices (for example on the HTC Disaer).

Finally my list of extensions:
Code: Select all
GL_AMD_compressed_3DC_texture
GL_AMD_compressed_ATC_texture
GL_AMD_performance_monitor
GL_AMD_program_binary_Z400
GL_EXT_texture_filter_anisotropic
GL_EXT_texture_format_BGRA8888
GL_EXT_texture_type_2_10_10_10_REV
GL_NV_fence
GL_OES_compressed_ETC1_RGB8_texture
GL_OES_depth_texture
GL_OES_depth24
GL_OES_EGL_image
GL_OES_element_index_uint
GL_OES_fbo_render_mipmap
GL_OES_fragment_precision_high
GL_OES_get_program_binary
GL_OES_packed_depth_stencil
GL_OES_rgb8_rgba8
GL_OES_standard_derivatives
GL_OES_texture_3D
GL_OES_texture_float
GL_OES_texture_half_float
GL_OES_texture_half_float_linear
GL_OES_texture_npot
GL_OES_vertex_half_float
GL_OES_vertex_type_10_10_10_2
GL_QCOM_binning_control
GL_QCOM_driver_control
GL_QCOM_perfmon_global_mode
GL_QCOM_extended_get
GL_QCOM_extended_get2
GL_QCOM_tiled_rendering
GL_QCOM_writeonly_rendering
GL_QCOM_memory_monitor


I bet on the problem for a long time. I would be glad of any idea, because they ended at the very :( ...

Sorry for my english...
devivan80
Once Poster
Once Poster
 
Posts: 1
Joined: Mon Apr 02, 2012 9:54 am

Top

Return to Android 2D/3D Graphics - OpenGL Tutorials

Who is online

Users browsing this forum: No registered users and 2 guests