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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Developer
Posts: 78
Registered: ‎12-12-2012
My Device: playbook
My Carrier: free
Accepted Solution

OpenGL image with alpha are darker

Hello,

 

I run my game on BB10 (porting from Android, PC). On PC Android my game images with an alpha are ok but on the playbook all alpha are darker. Something I am missing?

 

Code to load texture:

 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, image.getWidth(), image.getHeight(), 0, GL_RGBA, GL_UNSIGNED_BYTE, image.getDatas());

 

 

 

Code to render a texture:

glClearColor((GLfloat)(gBackColor.r), (GLfloat)(gBackColor.g), (GLfloat)(gBackColor.b), (GLfloat)(gBackColor.a));

  // Efface l'ecran et le tampon de profondeur : note: pas besoin pour le color buffer car on affcihe tout l ecran
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);  
 
  glLoadIdentity();
  glPushMatrix();
 
  glEnableClientState(GL_VERTEX_ARRAY);
  glEnableClientState(GL_TEXTURE_COORD_ARRAY);
  glEnable(GL_TEXTURE_2D);
  glEnable(GL_BLEND);
  glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);   

 

   M_Color lightDiffuse = disp_GetGlobalDiffuse();

    // affect lightDiffuse
    lightDiffuse *= this->mDiffuseColor;
 
    glColor4f((GLfloat)(lightDiffuse.r), (GLfloat)(lightDiffuse.g), (GLfloat)(lightDiffuse.b), (GLfloat)lightDiffuse.a);

 

And finally I use glDrawArrays(....)

 

 

On PC and Android I have no problem.

 

Thank you

Developer
Posts: 78
Registered: ‎12-12-2012
My Device: playbook
My Carrier: free

Re: OpenGL image with alpha are darker

premultiplied alpha ? Automatic?

Highlighted
Developer
Posts: 1,068
Registered: ‎11-24-2011
My Device: PlayBook
My Carrier: x

Re: OpenGL image with alpha are darker

May be couple of screenshots?

Developer
Posts: 78
Registered: ‎12-12-2012
My Device: playbook
My Carrier: free

Re: OpenGL image with alpha are darker

bug

 

As you can see cloud are dark. Halo arround the fuel are dark to.

Developer
Posts: 78
Registered: ‎12-12-2012
My Device: playbook
My Carrier: free

Re: OpenGL image with alpha are darker

[ Edited ]

Found in other thread post:

 

int transparency = SCREEN_TRANSPARENCY_SOURCE_OVER;

screen_set_window_property_iv(screen_win_gles, SCREEN_PROPERTY_TRANSPARENCY, &transparency);

 

if you do not do it, then transparency is randomly set.

 

And add

 

int alphamode = SCREEN_PRE_MULTIPLIED_ALPHA;

    rc = screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_ALPHA_MODE, &alphamode);
    if (rc) {
            perror("screen_set_window_property_iv(SCREEN_PROPERTY_ALPHA_MODE)");
            bbutil_terminate();
            return EXIT_FAILURE;
        }