Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
New Contributor
rus_phantom
Posts: 6
Registered: ‎12-23-2012
My Device: Playbook 2.0

show an RGBA image

   Hello. I tried to render on screen PNG image with alpha channel, using bbutil_load_texture function for load image and that code

 

glEnable(GL_TEXTURE_2D);

glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);

glVertexPointer(2, GL_FLOAT, 0, m_vertices);
glTexCoordPointer(2, GL_FLOAT, 0, m_tex_coord);
glBindTexture(GL_TEXTURE_2D, m_texture);

glColor4f(m_color.r, m_color.g, m_color.b, 1.0f);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);

glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDisableClientState(GL_VERTEX_ARRAY);
glDisable(GL_TEXTURE_2D);

to render it on my playbook. But its looks like that OpenGL doesn't look at alpha channel at all - my image rendering without transparency. That is image, with I want to render: ClickMe

That is a screenshot of what I got on the screen: ClickMe

 

Thanks

Developer
MikePembo951
Posts: 107
Registered: ‎02-15-2012
My Device: Blackberry Playbook 32GB

Re: show an RGBA image

[ Edited ]

correct me if im wrong but shouldnt you need GL blending turned on?

e.g.

glEnable(GL_BLEND);

glBlendFunct(__Source blending__, _Destination blending_);

//Draw stuff here

then once finished:

glDisable(GL_BLEND);

 

replace source and destination blending with the settings you want.

 

Look here:

http://www.khronos.org/opengles/sdk/docs/man/xhtml/glBlendFunc.xml

Developer
MikePembo951
Posts: 107
Registered: ‎02-15-2012
My Device: Blackberry Playbook 32GB

Re: show an RGBA image

try:

glBlendFunct(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

Developer
BGmot
Posts: 1,068
Registered: ‎11-24-2011
My Device: PlayBook

Re: show an RGBA image

How do you create native window on top of which you have your OpenGL? what format do you use?

Developer
MikePembo951
Posts: 107
Registered: ‎02-15-2012
My Device: Blackberry Playbook 32GB

Re: show an RGBA image

I'm confused,  BGmot could you rephrase the question?

Developer
BGmot
Posts: 1,068
Registered: ‎11-24-2011
My Device: PlayBook

Re: show an RGBA image

First you create native window

screen_create_window()

the set up transparency

int transparency = SCREEN_TRANSPARENCY_SOURCE_OVER;

screen_set_window_property_iv(screen_win_gles, SCREEN_PROPERTY_TRANSPARENCY, &transparency);

Then format I was talking above:

int format = SCREEN_FORMAT_RGBA8888;

screen_set_window_property_iv(screen_win_gles, SCREEN_PROPERTY_FORMAT, &format);

... some more settings here..

and finally 'attach' EGL surface to this window by calling eglCreateWindowSurface()

 

So what I meant was format and transparency settings are important if you want to acheive OpenGL window drawing transparency (at least if it placed on top of other native windows).