Jump to content
  • Advertisement
Sign in to follow this  
Giacomo83

problem in displaying fonts with texture

This topic is 4844 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi! I've add a frame counter to my app using texured fonts...but the counter display always zero:(....here the code:

void CTexture::AppInit( TUint8 *tex1, TUint8 *tex2, TUint8 *tex3, TUint8 *tex4, TUint8 *tex5, TUint8 *tex6, TUint8 *tex7, TUint8 *tex8 )
{
   fps = 0;
   counter = 0;
   startTime.HomeTime();
   oneSecond = 1;

In the appInit I set the init value of fps(incresed every time that draw is called), counter(it counts the seconds) and oneSecond(the time I update the total frame counter). In the code below, I check if oneSecond is passed; if it is therefore I update the number of total frame, than I calculate the avarage frames per second: this value is used to have the coordinates of the texture for mapping the right font:

void CTexture::AppCycle( TInt aFrame,TInt dirx,TInt diry,TInt dirz)
{

   TTimeIntervalSeconds durationInSeconds;
   currentTime.HomeTime();
   currentTime.SecondsFrom(startTime, durationInSeconds);
   if(durationInSeconds >= oneSecond)
   {
      counter++;
      totalFps += fps;
      fps = 0;
      startTime.HomeTime();
      (TInt)averageFps = totalFps/counter;
      lmargin = averageFps*0.0625;
      //else if(averageFps>9 && averageFps<=19)
         
   }

Always in the appCycle, I call the function ShowFps, that draw the quad with the texture of the font, the textureCoord are:

  
   static const GLfloat nokTexCoords_quad1[4 * 2] =
   {
   lmargin,0.1875,
   lmargin+0.0625,0.1875,
   lmargin+0.0625,0.25,
   lmargin,0.25
   };

The value displayed is always zero! Can you help me?!

Share this post


Link to post
Share on other sites
Advertisement
I resolve in part the error!
But now I have this situation:
on the emulator run, but when I build for the target device, I have an error caused from the variables in the nokTexCoords_quad1 this function:

Code:


void CTexture::ShowFps2()
{
static const GLfloat nokTexCoords_quad2[4 * 2] =
{
lmargin,0.1875,
nmargin,0.1875,
nmargin,0.25,
lmargin,0.25
};

glLoadIdentity();
glTranslatef(-20,27,-100);
glScalex( 20 << 13, 20 << 13, 20 << 13 );
glEnable(GL_TEXTURE_2D);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glBindTexture( GL_TEXTURE_2D, iNokTexObjects[7] );
glVertexPointer( 3, GL_FLOAT, 0, vertices_quad1);
glTexCoordPointer( 2, GL_FLOAT , 0, nokTexCoords_quad2);
glNormalPointer( GL_BYTE, 0, normals_quad1);
glDrawElements(GL_TRIANGLES,2*3,GL_UNSIGNED_BYTE,indices_quad1);
glDisable(GL_TEXTURE_2D);
}

the value of lmargin and nmargin, depends from appCycle:
Code:

void CTexture::AppCycle( TInt aFrame,TInt dirx,TInt diry,TInt dirz)
{
fps++;
TTimeIntervalSeconds durationInSeconds;
currentTime.HomeTime();
currentTime.SecondsFrom(startTime, durationInSeconds);
if(durationInSeconds >= oneSecond)
{
counter++;
totalFps += fps;
fps = 0;
startTime.HomeTime();
(TInt)averageFps = totalFps/counter;
lmargin = averageFps*0.0625;
nmargin = lmargin + 0.0625;


How can I make the texture mapping for the font?!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!