Register
Site Login
Site Search
Forums
Advertisement
Welcome to PocketMatrix. PocketMatrix is dedicated to providing the best online community for mobile device developers and enthusiests. What's new?

Textures in OpenGL ES


Textures in OpenGL ES

Postby CountZero » Aug 22, 2007 @ 11:02pm

This is something of a follow-up to the thread on E2DSurfaces. I'm using OpenGL ES instead of Edgelib's internal renderer and I find that my texture loading code does not work correctly anymore.

For instance, the code below shades only some faces of the cube and even then, only partially.

Code: Select all









10 
11 
12 
13 
14 
15 
16 
17 
18 
19 
20 
21 
22 
23 
    E2DSURFACEINFO lockinfo;
    unsigned char *bufptr;
    bufptr = texture.Lock(&lockinfo);
    if (bufptr)
    {
        int x, y;
        bufptr += lockinfo.bufferoffset;
        for (= 0; y < height; y++)
        {
            for (= 0; x < width; x++)
            {
            if (lockinfo.pixelformat == EDSP_INDEXED8)
                *bufptr = 255;
            else if (lockinfo.pixelformat == EDSP_TRUE12 || lockinfo.pixelformat == EDSP_TRUE16)
                *((unsigned short *)(bufptr)) = 255;
            else if (lockinfo.pixelformat == EDSP_TRUE32)
                *((unsigned long *)(bufptr)) = 255;
                    bufptr += lockinfo.xpitch;
            }
            bufptr += lockinfo.ypitch - texture.GetWidth() * lockinfo.xpitch;
        }
        texture.Unlock();
    }
23 lines; 15 keywds; 5 nums; 100 ops; 0 strs; 0 coms    Syntactic Coloring v0.4 - Dan East  


However, when I use the code to directly load a texture from a file, the textures are mapped perfectly. I'm using an N95 and the Symbian OpenGL ES examples work perfectly. What could be the difference between the edge renderer texture format and that of OpenGL ES?

Another thing that I noticed was that while using the Edgelib renderer, I was able to lock the texture, change its contents and the cube would show those chanegs. When I switched to OpenGL ES however, I'm not able to change the texture after the 1st binding.

Any help would be greatly appreciated :)

Cheers!
CountZero
pm Member
 
Posts: 21
Joined: Aug 3, 2007 @ 11:02pm


Re: Textures in OpenGL ES

Postby kuroneko » Aug 23, 2007 @ 7:25am

CountZero wrote:Another thing that I noticed was that while using the Edgelib renderer, I was able to lock the texture, change its contents and the cube would show those chanegs. When I switched to OpenGL ES however, I'm not able to change the texture after the 1st binding.


IIRC, you'd have to rebind the texture after you changed it. Usually, when you use h/w for rendering, binding a texture means copying the data from the client buffer to some server location (i.e. graphics memory). Changing your buffer content doesn't affect the server side.

HTH
kuroneko
pm Member
 
Posts: 14
Joined: Mar 27, 2007 @ 5:38am


Postby edge » Aug 23, 2007 @ 8:40am

Hi Countzero,

Kuroneko is correct, you need to re-upload the texture after it is changed. Also, you need to set the cleardata parameter to false when using UploadTexture().

I'm afraid it will have a negative impact on performance, because the uploading takes some time. While uploading, the texture is converted to an optimized layout which is one of the reasons texture uploading is slow.
Last edited by edge on Aug 24, 2007 @ 12:05pm, edited 1 time in total.
EDGELIB: Cross-platform mobile development at your fingertips
http://www.edgelib.com
User avatar
edge
pm Member
 
Posts: 1180
Joined: Aug 22, 2005 @ 3:42pm
Location: The Netherlands


Postby CountZero » Aug 23, 2007 @ 9:04pm

Thanks, that fixed the problem but hit the framerates signficantly. What causes the overhead in the UploadTexure method? Is it just a wrapper for glTexImage2d() ?

Cheers!
CountZero
pm Member
 
Posts: 21
Joined: Aug 3, 2007 @ 11:02pm


Postby edge » Aug 24, 2007 @ 10:07am

Hi Countzero,

Yes, the overhead is caused by glTexImage2D, because it needs to re-arrange the pixel layout (for render optimization purposes).

The speed of texture uploading can also differ between OpenGL (ES) implementations.
EDGELIB: Cross-platform mobile development at your fingertips
http://www.edgelib.com
User avatar
edge
pm Member
 
Posts: 1180
Joined: Aug 22, 2005 @ 3:42pm
Location: The Netherlands


OpenGLES texture disappears

Postby fuzzychicken » Sep 14, 2007 @ 4:16am

Hi all,

I am also trying to use Opengles (glGenTextures & glTexImage2D) just to load and render my own texture on N95. It works fine just a first few seconds. After that, when the small Edgelib introduction window (at the bottom) disappears, my texture disappears at the same time, and there is nothing more on the screen.

Another problem is that the edgelib characters change to blocks on screen, with their texture updated to my own texture.

I don't know how to make Opengles work with Edgelib properly. What could be the problems?

Thank you in advance.
fuzzychicken
pm Member
 
Posts: 5
Joined: Sep 14, 2007 @ 3:56am


Postby edge » Sep 14, 2007 @ 7:47am

Hi,

Can you tell me if you're binding the texture before rendering?
EDGELIB: Cross-platform mobile development at your fingertips
http://www.edgelib.com
User avatar
edge
pm Member
 
Posts: 1180
Joined: Aug 22, 2005 @ 3:42pm
Location: The Netherlands


Postby fuzzychicken » Sep 14, 2007 @ 3:08pm

Thank you very much for the reply.

I've found the problem of disappearing already. It happens if I enable this code on OnDisplayInit():

Code: Select all




#if defined(EGL_USEGL)
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    glEnable(GL_BLEND);
#endif
4 lines; 3 keywds; 0 nums; 9 ops; 0 strs; 0 coms    Syntactic Coloring v0.4 - Dan East  


So I have to temporarily comment this code for now.

However, the font is still wrong.

Yes, I did bind the texture before rendering. That's how I can see my texture on the screen.
fuzzychicken
pm Member
 
Posts: 5
Joined: Sep 14, 2007 @ 3:56am


Postby edge » Sep 17, 2007 @ 2:46pm

Hi,

I think the initial problem is caused by the blending option. The OpenGL renderer sees your texture as 100% transparent and doesn't render it.

I recommend turning the blending option on before rendering the font, and turning it off when rendering your own models.
EDGELIB: Cross-platform mobile development at your fingertips
http://www.edgelib.com
User avatar
edge
pm Member
 
Posts: 1180
Joined: Aug 22, 2005 @ 3:42pm
Location: The Netherlands


Return to EDGELIB


Sort


Forum Description

Powerful and affordable C++ middleware solution covering true multi-platform 2D, 3D and network features for Apple iPhone, Windows Mobile, Symbian S60, UIQ, Linux and Windows desktop.

Moderator:

edge

Forum permissions

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

cron