Author Topic: overlay help needed  (Read 3083 times)

Offline dutch_delight

  • int
  • **
  • Posts: 58
    • View Profile
overlay help needed
« on: March 12, 2011, 01:13:40 am »
12 oclock on a friday night and I'm sitting behind my computer.  :'(

Anyway, I've been trying to work on a radar that is always visible on screen but I'm not fully understanding the overlay.

I've borrowed some code from the forum:

Overlay uiRadar = new Overlay(world, fb, "uiRadarT");
uiRadar.setVisibility(true);



It does slow things down quite badly so something is working but the overlay isn't showing. Texture shows fine when i do this (using texturepack):

fb.blit(uiRadarT, 0, 0, 0, 0, uiRadarT.getWidth(), uiRadarT.getHeight(), 128, 128, 100, false, null);



It says this in the java Docs:
"A scaled blit has to be applied by the application each frame. "

But I'm not getting it. how do I apply a scaled blit? What is a scaled blit?


Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: overlay help needed
« Reply #1 on: March 12, 2011, 08:45:51 pm »
That simply means that you have to call blit yourself each frame...just as you do right now. A scaled blit is a blit, where the resulting image has another size than the blitted textures->scaled! Apart from that, using an Overlay should not cause a slow down. You are not creating a new Overlay for each frame, are you?

Offline dutch_delight

  • int
  • **
  • Posts: 58
    • View Profile
Re: overlay help needed
« Reply #2 on: March 14, 2011, 10:16:58 pm »
Ah I see. And yes I am creating a new overlay every frame. Doh!

Code: [Select]
public void onDrawFrame(GL10 gl) {

fb.clear(back);
world.renderScene(fb);
world.draw(fb);

Overlay uiRadar = new Overlay(world, fb, "tapache");
uiRadar.setVisibility(true);

fb.display();

} catch (Exception e) {
Logger.log(e, Logger.MESSAGE);
}
}



I removed some of my (bad) code. But how should I be calling it then?
Declare it somewhere else first and then when it needs to be updated do:
uiRadar.setRotation(1.0f);
uiRadar.update(fb);
?


Really appreciate your help.




Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: overlay help needed
« Reply #3 on: March 14, 2011, 11:04:48 pm »
Actually, it shouldn't be needed to call update on it. Just create it and it should be there. If you want to rotate it, just do it. No need to update it afterwards.