forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

A strange problem with loading textures.

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
LarryTM



Joined: 04 Jul 2006
Posts: 30

PostPosted: Tue Oct 09, 2007 12:02 am    Post subject: A strange problem with loading textures. Reply with quote

Hi.

Im trying to load fonts using FreeType2 and PSPGL and I have a strange problem:

http://img441.imageshack.us/my.php?image=testsq9.jpg

The text should look like this: Test Text

My loading code (a part of) :
Code:


GLuint * tex_base;

 (...)

GLubyte* expanded_data = new GLubyte[ 2 * width * height];

(...)

 glBindTexture( GL_TEXTURE_2D, tex_base[(int)ch]);      
   glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
   glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
    glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0,  GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, expanded_data );
   gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, width, height,  GL_RGBA, GL_UNSIGNED_BYTE, expanded_data);

Without the last line (gluBuild2DMipMaps) my psp just hangs up when I try to use my font texture;

Display code :
Code:

string tekst;

(...)

/* FontData.textury=tex_base; */

glPushMatrix();
  glTranslatef((float)a*h/3.0f,litery[(int)tekst.at(a)].y,0.0f);
  glBindTexture(GL_TEXTURE_2D,FontData.textury[(int)tekst.at(a)]);
  glBegin(GL_TRIANGLE_FAN);      
    glTexCoord2f(0,0);
    glVertex2f(0,litery[(int)tekst.at(a)].vert_y);
    glTexCoord2f(0,(float)litery[(int)tekst.at(a)].tx_cord_y);
   glVertex2f(0,0);
glTexCoord2f((float)litery[(int)tekst.at(a)].tx_cord_x,(float)litery[(int)tekst.at(a)].tx_cord_y);    glVertex2f(litery[(int)tekst.at(a)].vert_x,0);
    glTexCoord2f((float)litery[(int)tekst.at(a)].tx_cord_x,0);
    glVertex2f(litery[(int)tekst.at(a)].vert_x,litery[(int)tekst.at(a)].vert_y);
  glEnd();   
glPopMatrix();


Anyone have any ideas how to fix it?

Thanx!
Back to top
View user's profile Send private message Visit poster's website
Jim



Joined: 02 Jul 2005
Posts: 487
Location: Sydney

PostPosted: Tue Oct 09, 2007 7:23 am    Post subject: Reply with quote

One problem is your array is only 2*w*h in size, but then you call gluBuild2DMipmaps which is expecting 4*w*h of data.
Can you post how you initialise tex_base?

Jim
_________________
http://www.dbfinteractive.com
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
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 vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group