簡體   English   中英

在某些三星設備上的黑屏上顯示的Android OpenGL ES紋理

[英]Android OpenGL ES Textures Showing On Black screen on Some Samsung devices

我最近研究了動態壁紙應用程序。 我發現我的Android動態壁紙有一個奇怪的問題。 我使用HTC Wildfire S,三星Galaxy標簽,摩托羅拉Droid Millstone,三星銀河流行音樂與模擬器一起測試了我的壁紙,並且一切正常,但是在三星手機上(三星Galaxy S II和三星Galaxy Player都有症狀)屏幕僅停留在黑色以進行初始啟動。 但是一旦進入設置屏幕並預覽其工作正常,在使用這些手機進行了一些調試之后,我發現牆紙可以正確加載,但紋理並不僅僅是顯示出來的。 我嘗試搜索該問題,但沒有發現任何幫助。

我綁定了本機代碼的紋理。 在那使用OPEN GL庫來綁定牆紙。 我的opengl庫啟動如下

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

在我的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

為什么這在三星手機上不起作用?

我解決了這個問題。 一切都在opengl庫的啟動中。 當我添加glViewport(0, 0, screenWidth, screenHeight); 這行代碼,該錯誤已修復。 現在,我的opengl應用程序呈現了所有設備。 感謝大伙們。

某些沒有OpenGL ES Accelerator的設備無法運行使用OpenGL庫的應用程序。...最好過濾清單文件中的設備,以防止在這些設備中安裝應用程序...

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM