Forum: General Jailbreak Discussion - The General Jailbreak Discussion forum is your place to discuss everything related to the PS3 jailbreak. You can discuss QA Flags, CFW, kmeaw or find information about many general jailbreak methods.


The above video goes away if you are a member and logged in, so log in now!




 
Would you like to get all the new info from
PSX-Scene in your email each day?




Want to learn more about the team keeping you up to date with the latest scene news?

Read about them now!

Check out our Developer bios, too!

 


User Tag List

Thread: Loading TGA files in C++ for use with OpenGL (SOLVED)
  

Results 1 to 3 of 3
  1. #1 Loading TGA files in C++ for use with OpenGL (SOLVED) 
    Join Date
    Aug 2010
    Location
    Under your bed
    Posts
    515
    Downloads
    0
    Uploads
    0
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Likes Given
    1
    Likes Received
    0
    ThatOtherPerson has just posted about a problem he's been having for the past couple of days and has requested help from anyone that would like to lend a hand.

    ThatOtherPerson:
    Among the many samples and examples in the leaked PS3 SDK there is a function for recording screenshots in tga format. After finding it I decided to simply rewrite it to essentially work in reverse so that I could load TGA files and use them as textures for PSGL games. It was simple to do and works beautifully on PC. But for some reason it fails to correctly read the width and height of the images when I run it on PS3. It seems to work fine if I hard code in what width and height to use but it refuses to correctly read that from the tga files despite it doing so on Windows. I’ve wasted away the last two days trying to get it to work and have failed to do so. Can anyone see anything wrong with the bellow source code that could explain the failure? More then getting it to work I just really want to know WHY it isn’t working already.
    Code:
    GLuint loadtga(char* filename,bool mipmap){
    
    unsigned char header[12] = { 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
    unsigned char bpp = 32;
    unsigned char id = 8;
    unsigned short width;
    unsigned short height;
    unsigned char *pPixels = NULL;
    FILE *fp = NULL;
    
    fp = fopen(filename,"r");
    
    fread(header,sizeof(unsigned char),12,fp);
    fread(&width,sizeof(unsigned short),1,fp);
    fread(&height,sizeof(unsigned short),1,fp);
    fread(&bpp,sizeof(unsigned char),1,fp);
    fread(&id,sizeof(unsigned char),1,fp);
    
    pPixels = new unsigned char[width * height * 4];
    fread(pPixels, 4, width * height, fp);
    fclose(fp);
    
    GLuint texName;
    glPixelStorei(GL_UNPACK_ALIGNMENT,1);
    glGenTextures(1,&texName);
    glBindTexture(GL_TEXTURE_2D,texName);
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT);
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT);
    if(mipmap==0){
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
    }
    if(mipmap==1){
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_LINEAR);
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR_MIPMAP_LINEAR);
    gluBuild2DMipmaps(GL_TEXTURE_2D,GL_RGBA,width,height,
    GL_BGRA,GL_UNSIGNED_BYTE,pPixels);
    }
    glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA,width,height,
    0,GL_BGRA,GL_UNSIGNED_BYTE,pPixels);
    
    delete pPixels;
    
    return texName;
    
    }
    I posted his question here in an attempt to get it some more exposure and possibly a solution. If you think you know what the problem might be, feel free to hit him up at:

    Source: thatotherdev.wordpress.com
    Last edited by PuppetMaster; 11-07-2010 at 02:56 PM.

    Visit store.brewology.com often for up to date HomeBrew downloads.
    Reply With Quote  

  2. #2  
    Themaister is offline Registered User
    Join Date
    Oct 2010
    Posts
    12
    Downloads
    0
    Uploads
    0
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Likes Given
    0
    Likes Received
    1
    Classic endianness issue.
    Reply With Quote  

  3. #3  
    Join Date
    Aug 2010
    Location
    Under your bed
    Posts
    515
    Downloads
    0
    Uploads
    0
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Likes Given
    1
    Likes Received
    0
    Quote Originally Posted by Themaister View Post
    Classic endianness issue.
    I see you have helped solve the issue. I tip my hat to you good sir. Very nice.

    Visit store.brewology.com often for up to date HomeBrew downloads.
    Reply With Quote  

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