×

Discussion Board

Results 1 to 8 of 8
  1. #1
    Regular Contributor
    Join Date
    Jan 2005
    Posts
    154

    Thumbs down Series 60 BMP Texture Mapping With OpenGL ES Problem

    Regards,

    i am trying to load a bmp texture to a plane (simple example). the plane is shown on screen. the problem i am facing is creating the loader for the bmp. i used Series60 built-in function CFbsBitmap:: Load(...) to load the bitmap file. then i applied it on a CFbSBitmap object to hold the bitmap data like the following:

    iBitMap = new (ELeave) CFbsBitmap();
    iBitMap->Create( TSize(256,256), EColor16M );
    User::LeaveIfError(iBitMap->Load(KDrawBitmapPath, EMbmBitmapDrawbitmap));

    then i created a pointer to point to the first memeory address of the bitmap data array like this:

    TUint8 *tex1 = (TUint8*)iBitMap->DataAddress();

    now, it is supposed to have all the data in hold and ready for mapping. but, when i apply the glTexImage2D to load the texture, the system crashes. Note that my BMP is 256X256.

    /* Enable vertex, normals and texture arrays. */
    glEnableClientState( GL_VERTEX_ARRAY );
    glEnableClientState( GL_TEXTURE_COORD_ARRAY );
    glEnableClientState( GL_NORMAL_ARRAY );

    glVertexPointer( 3, GL_BYTE, 0, v); // v array holding plane verts
    glTexCoordPointer( 2, GL_BYTE, 0, x); // x holding texture coord
    glNormalPointer( GL_BYTE, 0, n); // n hold norms

    /* binding the texture */
    glGenTextures( 1, iNokTexObjects );
    glBindTexture( GL_TEXTURE_2D, iNokTexObjects[0] );
    glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, 256, 256,
    0, GL_RGB, GL_UNSIGNED_BYTE, tex1);

    // t holds triangles data
    glDrawElements( GL_TRIANGLES, 2 * 3, GL_UNSIGNED_BYTE, t);


    does this way of loading bmp in Series60 works? i dont know, i just tried to work around the Texture application provided witht he SDK since it uses conversion, coding and decoding for JPeg images. and i dont need JPeg here.

    one more thing...
    all code for texture mapping requirements is included in AppInit().
    if i pass to glTexImage2D the iBitMap instead of tex1 pointer, i get coloured dots on the square, which proves that texturing is enabled but the problem is when i use tex1!!!

    any clue??

  2. #2
    Regular Contributor
    Join Date
    Apr 2005
    Posts
    89

    Re: Series 60 BMP Texture Mapping With OpenGL ES Problem

    Do you use DrawingBegin() and DrawingEnd() with DataAddress()?

  3. #3
    Regular Contributor
    Join Date
    Jan 2005
    Posts
    154

    Re: Series 60 BMP Texture Mapping With OpenGL ES Problem

    No!!!!
    whats DrawingBegin() and DrawingEnd() ??

  4. #4
    Regular Contributor
    Join Date
    Apr 2005
    Posts
    89

    Re: Series 60 BMP Texture Mapping With OpenGL ES Problem

    You can read about them in SDK docs: they fix and release address taken by DataAddress(), otherwise it makes little sense because bitmap data can be relocated any time.

    (I don't know nothing about OpenGL, probably what you are doing is still not correct.)

  5. #5
    Regular Contributor
    Join Date
    Jan 2005
    Posts
    154

    Re: Series 60 BMP Texture Mapping With OpenGL ES Problem

    i read about them in the SDK. but they are defines int eh CFbsBitmapDevice class, which is nto the one i am using (CFbsBitmap).

  6. #6
    Registered User
    Join Date
    Jul 2005
    Posts
    6

    Re: Series 60 BMP Texture Mapping With OpenGL ES Problem

    check path of picture in textureappui.cpp line 16-25. i think you don't creat folder picture in "z:drive" example "C:\Symbian\8.0a\S60_2nd_FP2_T\epoc32\release\wins\udeb\z\picture" and copy picture to this folder or modify code line 16-25 and fix new path of picture

  7. #7
    Regular Contributor
    Join Date
    Aug 2005
    Posts
    192

    Re: Series 60 BMP Texture Mapping With OpenGL ES Problem

    You need to call LockHeap before calling DataAddress and then call UnlockHeap when you're finished.
    The example that comes with the SDK forgets to use them as well.

  8. #8
    Nokia Developer Expert
    Join Date
    Mar 2003
    Posts
    68

    Re: Series 60 BMP Texture Mapping With OpenGL ES Problem

    Some things to check:

    1. you are trying to load a 24 bits / pixel texture (GL_RGB with GL_UNSIGNED_BYTE) of size 256x256. Is this the format of your bitmap also? If the type doesn't match, glTexImage2D() can crash due to a illegal pointer reference. E.g., if your bitmap is EColor64K, it takes memory: 16 * 256 * 256 / 8 = 131072 bytes. The OpenGL ES (in your code) is assuming 24 bits/pixel, thus: 24 * 256 * 256 / 8 = 196608. All memory accesses done by OpenGL ES driver between offsets [131072, 196608] (during the texture copy) are out of bounds accesses and can cause an application crash due to this.

    2. make sure that the bitmap/heap is locked (as already mentioned here) when you call the DataAddress( ) and glTexImage2D( ). After glTexImage2D() the texture data has been copied from the client address space to OpenGL ES memory space and the pointer is no longer referenced by OpenGL ES

    3. if you get the crash solved, then there may be an issue with the formats that the Symbian bitmaps have and OpenGL ES has. 16-bit formats should match directly, but at least the 32bpp format does not match (you have to swap bytes in order to get color components in the right place before you call glTexImage2D() )

    Jani Vaarala
    Graphics Architect
    Nokia

Similar Threads

  1. Another OpenGL ES problem
    By rvhaasen in forum Symbian Tools & SDKs
    Replies: 3
    Last Post: 2006-08-16, 22:48
  2. Replies: 1
    Last Post: 2004-12-31, 13:08
  3. Series 90 WINS Emulator networking problem
    By redglove in forum Symbian Networking & Messaging (Closed)
    Replies: 1
    Last Post: 2004-11-01, 07:34
  4. Replies: 3
    Last Post: 2004-04-20, 07:40

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •