4

I recently worked on a live wallpaper application. In that i found out my Android live wallpaper has an odd issue. I use my HTC Wildfire S, Samsung Galaxy tab, Motorola Droid Millstone, Samsung galaxy pop to test my wallpaper along with the emulator and all is working fine, but on Samsung handsets (Samsung Galaxy S II and Samsung Galaxy Player have the symptom) the screen just stays Black for initial launch. But once we move to settings screen and return to preview its working fine.After a little debugging with those handsets I was able to find out that the wallpaper loads correctly, but the textures aren't just showing up. I tried searching about the problem, but didn't found anything helpful.

I bind a texture form the native code. In that am using the OPEN GL library to bind wallpaper . My opengl library intiation is like following

 glEnable(GL_TEXTURE_2D);
  glGenTextures(1, &textureConverted);
  glBindTexture(GL_TEXTURE_2D,textureConverted);
  //...and bind it to our array
  __android_log_print(ANDROID_LOG_DEBUG,
              "NDK initOpenGL()",
              "binded texture"
              );
  glTexParameterf(GL_TEXTURE_2D, 
          GL_TEXTURE_MIN_FILTER, 
          GL_NEAREST);
  glTexParameterf(GL_TEXTURE_2D, 
          GL_TEXTURE_MAG_FILTER, 
          GL_NEAREST);
  //Different possible texture parameters, e.g. GL10.GL_CLAMP_TO_EDGE
  glTexParameterf(GL_TEXTURE_2D, 
          GL_TEXTURE_WRAP_S, 
          GL_CLAMP_TO_EDGE);
  //GL_REPEAT);
  glTexParameterf(GL_TEXTURE_2D, 
          GL_TEXTURE_WRAP_T, 
          GL_CLAMP_TO_EDGE);
  //GL_REPEAT);
  glTexImage2D(GL_TEXTURE_2D,       /* target */
           0,           /* level */
           GL_RGBA,         /* internal format */
           textureWidth,        /* width */
           textureHeight,       /* height */
           0,           /* border */
           GL_RGBA,         /* format */
           GL_UNSIGNED_BYTE,/* type */
           NULL);
  //setup simple shading
  glShadeModel(GL_FLAT);
  //check_gl_error("glShademo_comdel");
  glColor4x(0x10000, 0x10000, 0x10000, 0x10000);

and in my drawFunction

 glClear(GL_COLOR_BUFFER_BIT);
  int max;
  glGetIntegerv(GL_MAX_TEXTURE_SIZE, &max);
    __android_log_print(ANDROID_LOG_DEBUG,
              "NDK drawFrame()",
              "GL_MAX_TEXTURE_SIZE: %d",
        max);
  glBindTexture(GL_TEXTURE_2D,textureConverted);
  int rect[4] = {0, textureHeight, textureWidth, nTextureHeight};
  glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, rect);

  glTexSubImage2D(GL_TEXTURE_2D, /* target */
          0,        /* level */
          0,    /* xoffset */
          0,    /* yoffset */
          textureWidth,
          textureHeight,
          GL_RGBA,  /* format */
          GL_UNSIGNED_BYTE, /* type */
          pFrameConverted->data[0]);
  glDrawTexiOES(0, 0, 0, drawWidth, drawHeight); //drawWidth is th screenwidth and drawheight is the screenheight

Why doesn't this work on Samsung phones?

Satheeshkumar
  • 452
  • 4
  • 13
  • Put glGetError in the code and see if it hits anything. It's possible you could be exceeding the GL_MAX_TEXTURE_SIZE, but can't say for sure. – Tim Apr 25 '12 at 06:40
  • I tried with the glGetError() function in my code. It always returns 0. So i think no problem on there. – Satheeshkumar Apr 25 '12 at 11:56
  • you need to give us more details: what are the values of textureWidth and textureHeight. Show us the code where you load the textures bitmaps and the code where you use glTexSubmage.. – Renard May 02 '12 at 12:25
  • @Renard Now you can get the details of glTexSubmage used in my code. the values of textureWidth and textureHeight are like as 256*256, 512*512.. – Satheeshkumar May 02 '12 at 13:16
  • You code looks fine at first glance. Have you tried to use GLSurfaceView.setDebugFlags(GLSurfaceView.DEBUG_CHECK_GL_ERROR);? – Renard May 02 '12 at 13:31
  • i check with this line of code GLSurfaceView.DEBUG_CHECK_GL_ERROR in my code. It always returns 0. – Satheeshkumar May 03 '12 at 04:24

2 Answers2

0

i fix this issue. It is all in the initiation of the opengl library. when i add glViewport(0, 0, screenWidth, screenHeight); this line of code, the bug was fixed. Now my opengl application renders all the devices. thank you guys.

Satheeshkumar
  • 452
  • 4
  • 13
  • Was glViewport being called at all previously? It seems odd that it would have worked on some devices, and also that it fixed itself on refresh on the SII. It would seem that glViewport is being called behind the scenes on some devices in certain situations. – Danny Parker May 06 '12 at 18:31
-2

some devices which doesn't have OpenGL ES Accelerator, can't run apps that use OpenGL library....Better you filter the devices in the Manifest file to prevent installing apps in those devices...

Manjunath
  • 2,063
  • 2
  • 29
  • 60
  • 1
    This is wrong Every Android device needs to support OpenGL if it wants to pass the the [Android compatibility program](http://static.googleusercontent.com/external_content/untrusted_dlcp/source.android.com/en//compatibility/4.0/android-4.0-cdd.pdf). See chapter 7.1.4 – Renard May 02 '12 at 12:24
  • Buddy, I have tested an OpenGL app on HTC wildfire S, which didn't work and even some more devices... How come I could comment without knowing it properly.... – Manjunath May 02 '12 at 12:26
  • The wildfire is one of the few devices that emulates OpenGL with software. So while this may break your OpenGL app it is still possible to use OpenGL. Also the OP has problems on the Galaxy S2 which definitely has a GPU. – Renard May 02 '12 at 12:29
  • As far as my knowledge, I have successful run OpenGL apps in Galaxy S2. Your argument is right. My answer is not a wrong one but just it's true in few cases. And, it's clearly wrong that, "Every Android device needs to support OpenGL". – Manjunath May 02 '12 at 12:37
  • 2
    I defer to the offical spec which states: Device implementations MUST support both OpenGL ES 1.0 and 2.0, as embodied and detailed in the Android SDK documentations. Additionally your answer is wrong because it ignores the fact that the problem occurs on Samsung Devices wich all have GPUs. – Renard May 02 '12 at 12:43