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
Developer
TobyKaos
Posts: 78
Registered: ‎12-12-2012
My Device: playbook
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
TobyKaos
Posts: 78
Registered: ‎12-12-2012
My Device: playbook

Re: OpenGL image with alpha are darker

premultiplied alpha ? Automatic?

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

Re: OpenGL image with alpha are darker

May be couple of screenshots?

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

Re: OpenGL image with alpha are darker

bug

 

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

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

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;
        }