Results 1 to 1 of 1

Thread: Texture issues...

                  
   
  1. #1

    Default Texture issues...

    Lately, I've been trying to port one of my C++ engines to the DS. Everything is working great, however, I'm having some issues with textures - mostly from glTexImage2D().

    You see, all my textures are in a char* with rgb data. However, the last perimeter of glTexImage2D asks for a uint8*. I've tried converting my char* into a uint8*. It compiles, but all the pixels on the textures are the wrong color and it looks like they have been sorted at random.

    I'm "guessing" that the last perimeter of glTexImage2D does not want rgb data, or at least, not the way I have it formatted. Could someone tell me where I went wrong? Here is some source code if it helps:

    Code:
    int loadTexture(AU_Texture image) {
    int texId; glGenTextures(1, &texId); glBindTexture(GL_TEXTURE_2D, texId); glTexImage2D(
    GL_TEXTURE_2D, 0, GL_RGB, TEXTURE_SIZE_128, TEXTURE_SIZE_128, 0, TEXGEN_TEXCOORD, charToUint8(image.pixels,image.width,image.height));
    return texId;
    }
    "image.pixel" is a character pointer (char*). As you can see, I tried to make a function called "charToUint8" that tries to convert the data. Here is the "charToUint8" function:

    uint8* charToUint8(char* charPList,int w,int h){
    int i = 0, ii = 0, r = 0, g = 0, b = 0;
    uint8* outUL = new uint8[int(w*h*2)];
    while(i < int(w*h*3)){
    r = int(charPList[i]);
    g = int(charPList[i+1]);
    b = int(charPList[i+2]);

    //here is the problem
    outUL[ii] = r;
    outUL[ii+1] = b;

    i += 3;
    ii += 1;
    }
    return outUL;
    }

    Edit: After some experimentation, I noticed that the native DS format asks for a 2 byte color value. This means that it would need to convert the 3 byte rgb value to a 2 byte DS color value.

    I would be grateful if someone could point me in the right direction.
    Last edited by DeltaSpeeds; March 29th, 2009 at 23:53.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. V3N0M's PSP Custom Firmware Reference
    By V3N0M in forum DCEmu Gaming & General Discussion Forum
    Replies: 51
    Last Post: January 27th, 2008, 04:38
  2. New GlideHQ - Now with hi-resolution texture pack support!
    By wraggster in forum Nintendo News Forum
    Replies: 0
    Last Post: October 11th, 2007, 23:23
  3. New GlideHQ - Now with hi-resolution texture pack support!
    By wraggster in forum Nintendo News Forum
    Replies: 3
    Last Post: October 2nd, 2007, 05:54
  4. NJ Arcade Emulators Source Translations
    By b8a in forum DCEmu Homebrew, Emulation, Hacking and Development Forum
    Replies: 9
    Last Post: November 6th, 2006, 22:59
  5. mame compatibility list 097
    By plungmonies in forum DCEmu Gaming & General Discussion Forum
    Replies: 22
    Last Post: February 25th, 2006, 16:37

Tags for this Thread

Bookmarks

Posting Permissions

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