Languages

Menu
Sites
Language
OpenGL ES 2.0 (texture) problems with GlPlayer

Hi, I'm porting my OpenGL ES 2.0 app to Tizen and ran into some problems; everything (textures from images & shader programs) loads OK, no errors from Tizen APIs and glGetError() returns 0 - but everything textured renders as total black (or not at all). I verified that things beyond that work OK by rendering with GL_LINES; this way the polygons (outlines) render correctly, therefore all the setup is correct otherwise. Also the app has been at a stable phase for almost a year, and is running 100% on several other platforms. I used GlPlayer because I did not want to include all the fugly EGL setup code; my question is, does GlPlayer actually set things up properly for OGL ES 2.0 or is it just for OGL ES 1.x? It does, anyway, have a construction flag for OGL ES 2.0..

Oh yes, and I'm running this on the emulator as I do not have the reference device for testing. The emulator has GPU support enabled. My development system is a Ubuntu 12.04 LTS 64 bit, with Nvidia drivers version 304 (the one from apt), OpenGL version 4.20.

This is how I'm setting things up (pretty much the code that gets generated for an opengl template app):

 

bool
MMark13App::OnAppInitialized(void)
{
        // TODO:

        // Add code to do after initialization here. 

        // Create a Frame
        MMark13Frame* pMMark13Frame = new MMark13Frame();
        pMMark13Frame->Construct();
        pMMark13Frame->SetName(L"MMark13");
        AddFrame(*pMMark13Frame);
        {
                __player = new Tizen::Graphics::Opengl::GlPlayer;
                __player->Construct(Tizen::Graphics::Opengl::EGL_CONTEXT_CLIENT_VERSION_2_X, pMMark13Frame);
                __player->SetFps(60);

                //__player->SetEglAttributePreset(Tizen::Graphics::Opengl::EGL_ATTRIBUTES_PRESET_RGB565);
                __player->SetEglAttributePreset(Tizen::Graphics::Opengl::EGL_ATTRIBUTES_PRESET_ARGB8888);
                __player->Start();
        }

        __renderer = new MMarkTizenController(); //new GlRendererTemplate();
        __player->SetIGlRenderer(__renderer);

        return true;
}

After this, its just portable C++ / OpenGL code starting from InitializeGl() and Draw(). I assume GlPlayer calls some kind of swapBuffers() method and I do not need to do that in the end of Draw()?

Maybe I'll try going through the EGL jungle today as per the GlesShader example and see if it works any better.

Oh, and another (simpler) question: is there a way to force an app to be landscape orientation only? Couldnt find this in the documentation and there isnt a lot about Tizen yet on google.

 

thanks, 

 

Matti

Responses

5 Replies
Chintan Gandhi

Hi Matti,

AFASIK GlPlayer do set things properly for OGL ES 2.0 aswel. Also for your simpler question you can set form layout to either Portrait or Landscape view. In case you are using UI builder then you can directly edit your IDF_FORM.xml and set the required layout.

https://developer.tizen.org/help/index.jsp?topic=%2Forg.tizen.native.apireference%2FclassTizen_1_1Ui_1_1Controls_1_1Form.html

void Tizen::Ui::Controls::Form::SetOrientation ( Orientation  orientation )  

Hope this helps.

thanks.

Matti Dahlbom

And this OGL ES 2.0 stuff should all work just fine on the emulator? The emulator is really, really sluggish.

Matti Dahlbom

Was wondering if there is something wrong in the way im loading the textures since things work with GL_LINES; does this look incorrect:

bool Create2DTexture(int width, int height, void* data,
                     GLuint* texture, bool clamp, bool useMipmaps)
{
    glActiveTexture(GL_TEXTURE0);
    glGenTextures(1, texture);
    glBindTexture(GL_TEXTURE_2D, *texture);
    if ( data != NULL )
    {
        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0,
                     GL_RGBA, GL_UNSIGNED_BYTE, data);
    }

    if ( useMipmaps )
    {
        glGenerateMipmap(GL_TEXTURE_2D);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
                        GL_LINEAR_MIPMAP_NEAREST);
    }
    else
    {
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    }
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

    if ( clamp )
    { 
        // Clamp to texture edges
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
    }
    else
    {
        // Repeat the texture in both directions
        glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
        glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
    }

    int glError = glGetError();
    if ( glError != GL_NO_ERROR )
    {
        LOG_DEBUG("Create2DTexture(): GL error: 0x%x", glError);
        return false;
    }

    return true;
}

Bitmap* ReadImageFromBundle(String fileName)
{
    String filepath = App::GetInstance()->GetAppResourcePath() + fileName;
    AppLogDebug("Loading image from path: %ls", filepath.GetPointer());

    Image image;
    image.Construct();
    return image.DecodeN(filepath, BITMAP_PIXEL_FORMAT_R8G8B8A8);
}

bool Load2DTextureFromBundle(const char* imageName, GLuint* texture,
    			 bool clamp, bool useMipmaps)
{
    std::unique_ptr<Bitmap> bitmap(ReadImageFromBundle(imageName));
    BufferInfo bufferInfo;
    if ( IsFailed(bitmap->Lock(bufferInfo)) )
    {
	LOG_DEBUG("Failed to lock the bitmap!");
	return false;
    }

    LOG_DEBUG("Read bitmap with dimensions: %d x %d",
              bufferInfo.width, bufferInfo.height);

    // Upload the texture to OpenGL and create the texture object
    Create2DTexture(bufferInfo.width, bufferInfo.height, bufferInfo.pPixels,
                    texture, clamp, useMipmaps);

    LOG_GL_ERROR();

    bitmap->Unlock();

    return true;
}

In above, Create2DTexture() is platform independent code and works perfectly, tested on various platforms. The two other functions are Tizen specific and might contain a bug? 

 

- Matti

Matti Dahlbom

It would appear that nothing I draw without a vertex buffer (ie. glBindBuffer(GL_ARRAY_BUFFER, 0);) , gets drawn on the emulator. Is this not supported..? At least all the other OGL ES 2.0 implementations on other platforms (Meego, iOS, Android) I've tried render no problem with no GL_ARRAY_BUFFER.

I have a kind of an special case where I "need" to do this. Wish I had a reference device to try on, since the emulator is crazy slow too :p

 

- Matti

muditha murthy

Go thorugh the sample of GlesShader which illustrates the buffer object management.