Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (526)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (593)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Volatile or not ?  (Read 3158 times)
0 Members and 1 Guest are viewing this topic.
Offline ranabp

Senior Newbie




Blit Me :)


« Posted 2003-08-04 04:21:44 »

Hello ppl,
I am using this method and hoping i am getting Accelerated Images. Before using this method my images were automatic. I went from 30-40 Fps to 30-40Fps !!
Yes, no change ! So i was wondering if my images are accelerated and if i am really supposed to see noticible difference in performance.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
    public static BufferedImage getAcceleratedImage(Image source)
    {
        // To ensure that the image has loaded into memory
        MediaTracker md = new MediaTracker(new Frame());
        md.addImage(source,0);
        try
        {
            md.waitForID(0);
        }
        catch(InterruptedException iex)
        {
            iex.printStackTrace();
        }
        int height = source.getHeight(null);
        int width = source.getWidth(null);
        // Create a BufferedImage compatible with Graphics Configuration
        // so that its accelerated; Get Graphics2D of the image and draw
        //onto it the source image.

        GraphicsDevice systemGfx = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
        GraphicsConfiguration gc = systemGfx.getDefaultConfiguration();
      BufferedImage acceleratedImage = gc.createCompatibleImage(width,height,Transparency.TRANSLUCENT);
        Graphics2D associatedGraphics = acceleratedImage.createGraphics();
        associatedGraphics.drawImage(source,0,0,null);
        return acceleratedImage;
    }


I have enabled System Properties for Aplha Acceleration and forcing vram (which i suppose is to force images to be stored in vid ram). And also using Buffered Strategy.

Offline Max Pesce

Junior Devvie




Nil tam arduum quod non ingenio vincas


« Reply #1 - Posted 2003-08-04 04:34:03 »

Hi

You should try something like this:

1  
2  
3  
4  
ImageCapabilities iCap=backBuffer.getCapabilities();

if(iCap.isTrueVolatile()) System.out.println("buffer is true Volatile!");
if(iCap.isAccelerated()) System.out.println("buffer is true Accelerated!");


Where backBuffer is your Volatile image.

I don't think you can get accelerated Alpha transparency... I know there's not a such acceleration on Java2d now.

Offline trembovetski

Senior Devvie




If only I knew what I'm talking about!


« Reply #2 - Posted 2003-08-04 04:41:33 »

Your code looks fine (other than creating a new frame for each image).

I assume you have at least DX7 installed - we need it for D3D-accelerated translucency.

Try running your app with graphics primitive tracing turned on and see if you have accelerated blits (that is, if there are any D3DBlitLoops::Blit primitives listed).

To turn tracing on:
 java -Dsun.java2d.trace=log App
or
 java -Dsun.java2d.trace=count App

use -Dsun.java2d.trace=help for more info.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Abuse

JGO Knight


Medals: 14


falling into the abyss of reality


« Reply #3 - Posted 2003-08-04 08:25:17 »

Make sure you are setting the alpha acceleration properties before any AWT/Swing components are initialised.
Otherwise, they will have no effect.

also, heres a far neater image loader.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
import java.awt.*;
import java.awt.image.*;
public class ImageLoader
{
   final GraphicsConfiguration gc;
   public ImageLoader(GraphicsConfiguration gc)
   {
      if(gc==null)
      {
         gc = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration();
      }
      this.gc = gc;
   }

   public BufferedImage loadImage(String resource)
   {
      try
      {
         BufferedImage src = javax.imageio.ImageIO.read(getClass().getResource(resource));
         BufferedImage dst = gc.createCompatibleImage(src.getWidth(),src.getHeight(),src.getColorModel().getTransparency());
         Graphics2D g2d = dst.createGraphics();
         g2d.setComposite(AlphaComposite.Src);
         g2d.drawImage(src,0,0,null);
         g2d.dispose();
         return dst;
      }
      catch(java.io.IOException e)
      {
         return null;
      }
   }
}

Make Elite IV:Dangerous happen! Pledge your backing at KICKSTARTER here! https://dl.dropbox.com/u/54785909/EliteIVsmaller.png
Offline ranabp

Senior Newbie




Blit Me :)


« Reply #4 - Posted 2003-08-04 11:02:06 »

Okae, my Images are Volatile and Accelerated !!!
And i do see

sun.awt.windows.D3DBlitLoops::Blit("Integer ARGB D3D with translucency", SrcOver, "Integer RGB
DirectDraw")

i was wondering that what effect does the Acceleration Threshold have on Rendering ??
And Thanks Abuse, for telling me that i have to set the properties before i init anything Graphical. No wonder my java -Dsun.java2d.trace=count wasnt working before.

If java2D uses DirectDraw under the hood, why is it still so slow ? I heard that i can see a lot of performance difference if i switch to Lwjgl / jogl etc etc. ?

Offline Kommi

Junior Devvie




All opinions will be lined up and shot!


« Reply #5 - Posted 2003-08-04 12:02:33 »

Hey Abuse does
1  
 g2d.setComposite(AlphaComposite.Src); 

give you translucent images? They are still not hardware accelerated right?

Trembovetsky,
Quote
I assume you have at least DX7 installed - we need it for D3D-accelerated translucency.


So are you saying we can have translucent accelerated images?

Kommi
Offline Abuse

JGO Knight


Medals: 14


falling into the abyss of reality


« Reply #6 - Posted 2003-08-04 13:40:19 »

Quote
Hey Abuse does
1  
 g2d.setComposite(AlphaComposite.Src); 

give you translucent images? They are still not hardware accelerated right?


no, that line insures the alpha values in the created image are the same as those in the source image.

The code would work fine without that line.... on Windows.
This is because blank images created under Windows default to 0x000000 i.e. a totally transparent black pixel.
However on Mac, they default to something different.
Which, without that line of code would result in you losing the alpha channel in the source image.

Make Elite IV:Dangerous happen! Pledge your backing at KICKSTARTER here! https://dl.dropbox.com/u/54785909/EliteIVsmaller.png
Offline trembovetski

Senior Devvie




If only I knew what I'm talking about!


« Reply #7 - Posted 2003-08-05 03:04:52 »

Kommi: yes, we have acceleration of translucent images on windows since 1.4.1_02, but it's turned off by default. Do a search for -Dsun.java2d.transaccel=true to find out more.

ranabp: acceleration threshold specifies how many times you need to copy from a yet unaccelerated managed image before we attempt to accelerate it. The default is 1. If you set it to 0, we'll try to accelerate the image on the first copy.

It's not clear why your app is running slow. Please run tracing with =count and post the output. Most likely you're performing one   of unaccelerated operations, causing the back-buffer to be punted to system memory.
Offline ranabp

Senior Newbie




Blit Me :)


« Reply #8 - Posted 2003-08-05 06:41:15 »

This is what i get sometimes when i try to enable trace=count
-----------------------------------
Welcome to AlienAttaX 0.7b
Init - System
Trying to enable Alpha Hardware Acceleration -  true
Forcing DirectDraw to Use VRAM -        true
DirectDraw surfaces constrained to use vram
New Acceleration Threshold: 1
Acceleration for translucent images is enabled.
Loading Errors ? false
Time constructing GM - 16
java.lang.InternalError: not implemented yet
       at sun.awt.windows.Win32OffScreenSurfaceData.getRaster(Win32OffScreenSurfaceData.java:338)
       at sun.java2d.loops.OpaqueCopyAnyToArgb.Blit(CustomComponent.java:73)
       at sun.java2d.loops.Blit$TraceBlit.Blit(Blit.java:301)
       at sun.java2d.loops.GraphicsPrimitive.convertFrom(GraphicsPrimitive.java:525)
       at sun.java2d.loops.MaskBlit$General.MaskBlit(MaskBlit.java:186)
       at sun.java2d.loops.MaskBlit$TraceMaskBlit.MaskBlit(MaskBlit.java:229)
       at sun.java2d.loops.MaskFill$General.MaskFill(MaskFill.java:155)
       at sun.java2d.loops.MaskFill$TraceMaskFill.MaskFill(MaskFill.java:185)
       at sun.java2d.loops.DrawGlyphList$General.DrawGlyphList(DrawGlyphList.java:109)
       at sun.java2d.loops.DrawGlyphList$TraceDrawGlyphList.DrawGlyphList(DrawGlyphList.java:139)
       at sun.java2d.pipe.SolidTextRenderer.drawGlyphList(SolidTextRenderer.java:38)
       at sun.java2d.pipe.GlyphListPipe.drawString(GlyphListPipe.java:47)
       at sun.java2d.pipe.ValidatePipe.drawString(ValidatePipe.java:123)
       at sun.java2d.SunGraphics2D.drawString(SunGraphics2D.java:2534)
       at GameManager.paint(GameManager.java:535)
       at AlienAttaX.render(AlienAttaX.java:69)
       at AlienAttaX.run(AlienAttaX.java:79)
       at java.lang.Thread.run(Thread.java:534)


Apart from that, when the trace works, i get :
RUNNING IN A WINDOW :: with bufferstrat

6639 calls to sun.java2d.loops.Blit::Blit(IntArgb, Xor, IntRgb)
8912 calls to sun.awt.windows.D3DBlitLoops::Blit("Integer ARGB D3D with translucency", SrcOver, "Int
eger RGB DirectDraw")
191 calls to sun.java2d.loops.Blit::Blit(ByteIndexedBm, SrcOverNoEa, IntArgb)
3264 calls to sun.java2d.loops.DrawGlyphList::DrawGlyphList(OpaqueColor, SrcNoEa, AnyInt)
506 calls to sun.java2d.loops.MaskFill::MaskFill(AnyColor, SrcOver, IntRgb)
1088 calls to sun.awt.windows.Win32BlitLoops::Blit("Integer RGB DirectDraw", SrcNoEa, "Integer RGB D
irectDraw")
15 calls to sun.java2d.loops.Blit::Blit(ByteIndexedBm, SrcOverNoEa, IntRgb)
5 calls to sun.java2d.loops.Blit::Blit(IntRgb, SrcNoEa, IntRgb)
54257 calls to GDIFillShape
107336 calls to sun.java2d.loops.Blit$GeneralMaskBlit::Blit(IntArgb, SrcOverNoEa, "Integer RGB Direc
tDraw")
5 calls to sun.awt.windows.Win32BlitLoops$DelegateBlitBgLoop::BlitBg(Any, SrcNoEa, "Integer RGB Dire
ctDraw with 1 bit transp")
639 calls to sun.awt.windows.Win32BlitLoops::Blit("Integer RGB DirectDraw with 1 bit transp", SrcOve
rNoEa, "Integer RGB DirectDraw")
888 calls to sun.java2d.loops.MaskFill::MaskFill(AnyColor, Src, IntRgb)
107336 calls to sun.java2d.loops.MaskBlit::MaskBlit(IntArgb, SrcOver, IntRgb)
5 calls to sun.java2d.loops.SetFillRectANY::FillRect(AnyColor, SrcNoEa, Any)
982 calls to DDFillRect
1093 calls to sun.java2d.loops.DrawGlyphList::DrawGlyphList(AnyColor, Xor, AnyInt)
1 call to sun.java2d.loops.ScaledBlit::ScaledBlit(ByteIndexedBm, SrcOverNoEa, IntRgb)
99 calls to sun.java2d.loops.Blit::Blit(IntArgb, SrcNoEa, IntArgb)
981 calls to GDIDrawShape
294251 total calls to 20 different primitives

Running in FullScreen also bufferstrat

5 calls to sun.awt.windows.Win32BlitLoops$DelegateBlitBgLoop::BlitBg(Any, SrcNoEa, "Integer RGB Dire
ctDraw with 1 bit transp")
36 calls to sun.java2d.loops.Blit::Blit(IntArgb, SrcNoEa, IntArgb)
5 calls to sun.java2d.loops.Blit::Blit(IntRgb, SrcNoEa, IntRgb)
993 calls to sun.java2d.loops.DrawGlyphList::DrawGlyphList(AnyColor, Xor, AnyInt)
150 calls to sun.java2d.loops.Blit::Blit(ByteIndexedBm, SrcOverNoEa, IntArgb)
5643 calls to sun.java2d.loops.Blit::Blit(IntArgb, Xor, IntRgb)
1680 calls to sun.java2d.loops.MaskFill::MaskFill(AnyColor, Src, IntRgb)
15 calls to sun.java2d.loops.Blit::Blit(ByteIndexedBm, SrcOverNoEa, IntRgb)
106415 calls to sun.java2d.loops.Blit$GeneralMaskBlit::Blit(IntArgb, SrcOverNoEa, "Integer RGB Direc
tDraw")
106415 calls to sun.java2d.loops.MaskBlit::MaskBlit(IntArgb, SrcOver, IntRgb)
5 calls to sun.java2d.loops.SetFillRectANY::FillRect(AnyColor, SrcNoEa, Any)
44375 calls to GDIFillShape
6172 calls to sun.awt.windows.D3DBlitLoops::Blit("Integer ARGB D3D with translucency", SrcOver, "Int
eger RGB DirectDraw")
2988 calls to sun.java2d.loops.DrawGlyphList::DrawGlyphList(OpaqueColor, SrcNoEa, AnyInt)
785 calls to DDFillRect
1 call to sun.java2d.loops.ScaledBlit::ScaledBlit(ByteIndexedBm, SrcOverNoEa, IntRgb)
784 calls to GDIDrawShape
675 calls to sun.awt.windows.Win32BlitLoops::Blit("Integer RGB DirectDraw with 1 bit transp", SrcOve
rNoEa, "Integer RGB DirectDraw")
277142 total calls to 18 different primitives


MeThinks that all the trouble is because of GDI - Which i think doesnt use using real directdraw acceleration !!! Since i am a "newless clubie" to the game scene, i dont know much.

Offline krypto

Junior Devvie




while(true) { self.caffeinate (); }


« Reply #9 - Posted 2003-08-05 08:40:54 »

Quote
Okae, my Images are Volatile and Accelerated !!!
And i do see

sun.awt.windows.D3DBlitLoops::Blit("Integer ARGB D3D with translucency", SrcOver, "Integer RGB
DirectDraw")



My apps trace log has no sign of the above mentioned D3DBlitLoops. Mine looks more like this:

Quote
sun.java2d.loops.MaskBlit::MaskBlit(IntArgb, SrcOver, Ushort565Rgb)
sun.java2d.loops.Blit$GeneralMaskBlit::Blit(IntArgb, SrcOverNoEa, "Short 565 RGB DirectDraw")
sun.java2d.loops.MaskBlit::MaskBlit(IntArgb, SrcOver, Ushort565Rgb)
sun.java2d.loops.Blit$GeneralMaskBlit::Blit(IntArgb, SrcOverNoEa, "Short 565 RGB DirectDraw")
sun.java2d.loops.MaskBlit::MaskBlit(IntArgb, SrcOver, Ushort565Rgb)
sun.awt.windows.Win32BlitLoops::Blit("Short 565 RGB DirectDraw", SrcNoEa, "Short 565 RGB DirectDraw")
sun.java2d.loops.Blit$GeneralMaskBlit::Blit(IntArgb, SrcOverNoEa, "Short 565 RGB DirectDraw")
sun.java2d.loops.MaskBlit::MaskBlit(IntArgb, SrcOver, Ushort565Rgb)
sun.java2d.loops.MaskFill::MaskFill(AnyColor, Src, Ushort565Rgb)
sun.awt.windows.Win32BlitLoops::Blit("Short 565 RGB DirectDraw with 1 bit transp", SrcOverNoEa, "Short 565 RGB DirectDraw")


Does this mean I don't have hardware acceleration? Cry

JRPG Users -  General Users Site
JRPG Developers -  The JRPG Project's Home
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Max Pesce

Junior Devvie




Nil tam arduum quod non ingenio vincas


« Reply #10 - Posted 2003-08-05 09:28:47 »

Yes.
It seems that Java is using the portable version (java2d)of graphics function for some reason.

Maybe you are not using VolatileImage when you have to.

Anyway I don't think that a feature (alpha acceleration) can be useful if to activate it I have to use a command line parameter!

Also if it is present only on windows why we should sacrify portability?

If I want to make a game with alpha transparence for windows I can choose the combo C++/DX, which is faster than NOT ACCELERATED Java version.


Offline krypto

Junior Devvie




while(true) { self.caffeinate (); }


« Reply #11 - Posted 2003-08-05 09:58:11 »

Quote
Yes.
It seems that Java is using the portable version (java2d)of graphics function for some reason.
Maybe you are not using VolatileImage when you have to.



I am using managed Images. What else could be wrong?

JRPG Users -  General Users Site
JRPG Developers -  The JRPG Project's Home
Offline Abuse

JGO Knight


Medals: 14


falling into the abyss of reality


« Reply #12 - Posted 2003-08-05 10:35:38 »

are you modifying the managed images ever?

Make Elite IV:Dangerous happen! Pledge your backing at KICKSTARTER here! https://dl.dropbox.com/u/54785909/EliteIVsmaller.png
Offline krypto

Junior Devvie




while(true) { self.caffeinate (); }


« Reply #13 - Posted 2003-08-05 10:48:26 »

Quote
are you modifying the managed images ever?


what do you mean by modify. All I am doing is rendering them to the screen. I really need to fix this and don't know where to start.

JRPG Users -  General Users Site
JRPG Developers -  The JRPG Project's Home
Offline Kommi

Junior Devvie




All opinions will be lined up and shot!


« Reply #14 - Posted 2003-08-05 10:57:04 »

Quote
Yes.

Anyway I don't think that a feature (alpha acceleration) can be useful if to activate it I have to use a command line parameter!


Maybe not now but I am sure it will be a standard in future versions, so learning it now makes sence.

Kommi
Offline Max Pesce

Junior Devvie




Nil tam arduum quod non ingenio vincas


« Reply #15 - Posted 2003-08-05 11:48:54 »

Quote

Maybe not now but I am sure it will be a standard in future versions, so learning it now makes sence.


I undersand what you say, but I have already a sprite library which can do rotations, scaling e transparency, and for now I don't use any of them.

I agree with you about learning it, but I'll not use till it will become standard.

I hope it will happen soon...

Offline ranabp

Senior Newbie




Blit Me :)


« Reply #16 - Posted 2003-08-05 15:56:12 »

Yeah max, but aplha acceleration is helpful when u are showing off ur snazzy (or even shabby) game effects.
And u can set the aplha enabler in system properties anywayz !!  Smiley

Offline trembovetski

Senior Devvie




If only I knew what I'm talking about!


« Reply #17 - Posted 2003-08-06 01:45:14 »

106415 calls to sun.java2d.loops.Blit$GeneralMaskBlit::Blit(IntArgb, SrcOverNoEa, "Integer RGB DirectDraw")
106415 calls to sun.java2d.loops.MaskBlit::MaskBlit(IntArgb, SrcOver, IntRgb)

These are the things that kill your performance. This is a software blit of a translucent buffered image to an accelerated image (backbuffer).

I see a couple of possibilites:
- you have some sprites as bufferedImages for some reason (so they are not being accelerated)
- you create more sprites that can fit in vram, some of them get accelerated, but most - don't
- you render to your sprites more often than you copy from them
Offline trembovetski

Senior Devvie




If only I knew what I'm talking about!


« Reply #18 - Posted 2003-08-06 01:48:46 »

hw accelerated translucecy was not enabled by default because we didn't have enough time to properly test it. Also, it's very limited, as you can see: only for certain types of images, one particular compositing rule (SrcOver).

In the next release we're hoping to have it on by default, and for all images.
Offline trembovetski

Senior Devvie




If only I knew what I'm talking about!


« Reply #19 - Posted 2003-08-06 01:56:49 »

krypto, it looks like you have our D3D functionality disabled for some reason: I can see that DDraw works fine (opaque and 1-bit transparent images are accelerated).

I'm assuming you do create translucent images with createCompatibleImage(w,h,Transparency.TRANSLUCENT), and have acceleration enabled with -Dsun.java2d.translaccel=true, right?

If so, check that you don't disable d3d via command line option or environment variable - a lot of people did that to avoid problems with D3D on Radeon boards with earlier jdk releases.

Another possibility is that your hardware doesn't support the functionality we need in hardware.
Offline ranabp

Senior Newbie




Blit Me :)


« Reply #20 - Posted 2003-08-06 02:47:31 »

Quote
106415 calls to sun.java2d.loops.Blit$GeneralMaskBlit::Blit(IntArgb, SrcOverNoEa, "Integer RGB DirectDraw")
106415 calls to sun.java2d.loops.MaskBlit::MaskBlit(IntArgb, SrcOver, IntRgb)

These are the things that kill your performance. This is a software blit of a translucent buffered image to an accelerated image (backbuffer).

I see a couple of possibilites:
- you have some sprites as bufferedImages for some reason (so they are not being accelerated)
- you create more sprites that can fit in vram, some of them get accelerated, but most - don't
- you render to your sprites more often than you copy from them


Hey,
     i think the first possibility can be ruled out. Because on my every Image creation i am checking out whether they are accelerated after creation or not, and they all are.
     The second one might be true, since i am creating about 20 images to start with and create others on the fly (exlosions only).
     But apart from image i am creating other geometrical stuff all the time, about 100 geometrical things. Lets say i am creating about MAX 250 sprites. I dont think that is too much !! I have 32 Meg gfx card.
   One thing i think might be a problem is ur third possibility. I have put up a simple time bench on my updateEverything method and rendering method. This is what my console shows :
Time Paint() - 15
Time Paint() - 15
Time Paint() - 31
Time Paint() - 15
Time Paint() - 16
Time Paint() - 16
Time Paint() - 16
Time Paint() - 15
Time Paint() - 15
Time Paint() - 16
Time Paint() - 15
Time Paint() - 16
Time Paint() - 16
Time Paint() - 15
Time Paint() - 16
Time Update() - 16
Time Paint() - 16
Time Paint() - 16
Time Update() - 16
Time Paint() - 16
Time Update() - 15
Time Paint() - 15
Time Paint() - 16
Time Update() - 16
Time Paint() - 16
Time Paint() - 16
Time Paint() - 15
Time Update() - 16
Time Paint() - 16
Time Paint() - 15
Time Paint() - 15
Time Paint() - 15
Time Paint() - 16
Time Paint() - 16
Time Update() - 15
Time Paint() - 16
Time Update() - 15
Time Paint() - 16
Time Paint() - 15
Time Paint() - 16
Time Paint() - 15
Time Paint() - 16
Time Paint() - 16
Time Paint() - 15
Time Paint() - 15
Time Paint() - 16
Time Paint() - 15
Time Paint() - 16
Time Paint() - 16
Time Paint() - 15
Time Paint() - 16
Time Paint() - 16
Time Paint() - 16
Time Paint() - 15
Time Paint() - 15
Time Paint() - 16
Time Paint() - 16
Time Paint() - 15
Time Paint() - 16
Time Paint() - 15
Time Paint() - 15
Time Paint() - 16
Time Paint() - 15
Time Update() - 16
Time Paint() - 16
Time Paint() - 15
Time Paint() - 15
Time Paint() - 16
Time Paint() - 16
Time Paint() - 15
Time Paint() - 16
Time Paint() - 15
Time Paint() - 16
Time Paint() - 15
Time Paint() - 16
Time Paint() - 15
Time Paint() - 16
Time Paint() - 15
Time Paint() - 15
Time Paint() - 16
Time Paint() - 16
Time Paint() - 15
Time Paint() - 15
Time Paint() - 16
Time Paint() - 16
Time Paint() - 15
Time Paint() - 16
Time Paint() - 15
Time Paint() - 16
Time Paint() - 15
Time Paint() - 16
Time Paint() - 15
Time Paint() - 16
Time Paint() - 16
Time Paint() - 16
Time Paint() - 16
Time Paint() - 15
Time Paint() - 16
Time Paint() - 16
Time Paint() - 16
Time Paint() - 16
Time Paint() - 16
Time Paint() - 16
Time Paint() - 15
Time Paint() - 16
Time Paint() - 16
Time Paint() - 16
Time Paint() - 16
Time Paint() - 15
Time Paint() - 16
Time Paint() - 16
Time Paint() - 16
Time Paint() - 16
Time Paint() - 15
Time Paint() - 16
Time Paint() - 15
Time Paint() - 16
Time Paint() - 16
Time Paint() - 15
Time Paint() - 16
Time Paint() - 15
Time Paint() - 16
Time Paint() - 16
Time Paint() - 15
Time Paint() - 15
Time Paint() - 16
Time Update() - 16
Time Paint() - 15
Time Paint() - 16
Time Paint() - 15
Time Paint() - 16
Time Paint() - 16
Time Paint() - 16
Time Paint() - 16
Time Paint() - 15
Time Paint() - 16
Time Paint() - 16
Time Paint() - 16
Time Paint() - 15
Time Paint() - 15
Time Paint() - 16
Time Paint() - 16
Time Paint() - 16
Time Paint() - 16
Time Paint() - 16
Time Paint() - 16
Time Paint() - 15
Time Paint() - 16
Time Paint() - 16
Time Paint() - 16
Time Paint() - 16
Time Paint() - 15
Time Paint() - 16
Time Paint() - 16
Time Paint() - 15
Time Paint() - 16
Time Paint() - 15
Time Paint() - 16
Time Paint() - 16
Time Paint() - 16
Time Paint() - 15
Time Paint() - 16
Time Paint() - 15
Time Paint() - 16
Time Paint() - 16
Time Paint() - 16
Time Paint() - 15
Time Paint() - 16
Time Paint() - 16
Time Paint() - 16
Time Paint() - 15
Time Paint() - 16
Time Paint() - 16
Time Update() - 15
Time Paint() - 16
Time Paint() - 15
Time Paint() - 15
Time Paint() - 16
Time Paint() - 15
Time Paint() - 16
Time Paint() - 16
Time Paint() - 16
Time Paint() - 16
Time Paint() - 15
Time Paint() - 15
Time Paint() - 16
Time Paint() - 15
Time Paint() - 16
Time Paint() - 15
Time Paint() - 16
Time Paint() - 16
Time Paint() - 16
Time Paint() - 15
Time Paint() - 16
Time Paint() - 16
Time Paint() - 15
Time Paint() - 16
Time Paint() - 15
Time Paint() - 16
Time Paint() - 16
Time Paint() - 15
Time Paint() - 16
Time Paint() - 16
Time Paint() - 16
Time Paint() - 15
Time Paint() - 15
Time Paint() - 16
Time Paint() - 16
Time Paint() - 15
Time Paint() - 15
Time Paint() - 16
Time Paint() - 16
Time Paint() - 15
Time Paint() - 16
Time Paint() - 15
Time Paint() - 16
Time Paint() - 16
Time Paint() - 16
Time Paint() - 15
Time Paint() - 15
Time Paint() - 16
Time Paint() - 16
Time Paint() - 15
Time Paint() - 16
Time Paint() - 15
Time Paint() - 16
Time Paint() - 15
Time Paint() - 15
Time Paint() - 16
Time Paint() - 15
Time Paint() - 16
Time Paint() - 15
Time Paint() - 16
Time Paint() - 15
Time Paint() - 16
Time Paint() - 16
Time Paint() - 16
Time Paint() - 15
Time Paint() - 15
Time Paint() - 16
Time Paint() - 16
Time Paint() - 15
Time Paint() - 16
Time Paint() - 15
Time Paint() - 16
Time Paint() - 15
Time Paint() - 16
Time Paint() - 16
Time Paint() - 16
Time Paint() - 15
Time Paint() - 16
Time Paint() - 15
Time Paint() - 15
Time Paint() - 16
Time Paint() - 16
Time Paint() - 16
Time Paint() - 16
Time Paint() - 15
Time Paint() - 15
Time Paint() - 16
Time Paint() - 15
Time Paint() - 16
Time Paint() - 15
Time Paint() - 16
Time Paint() - 16
Time Paint() - 16
Time Paint() - 15
Time Paint() - 16
Time Paint() - 16
Time Paint() - 16
Time Paint() - 16
Time Paint() - 15
Time Paint() - 16
Time Paint() - 15
Time Update() - 16
Time Paint() - 16
Time Paint() - 16
Time Paint() - 15
Time Paint() - 16
Time Paint() - 16
Time Paint() - 16
Time Paint() - 15
Time Paint() - 15

And my threaded loop is like :                  gameManager.update();                  gameManager.paint(bufferedGraphics);                  bufferedGraphics.show();
Thread.currentThread().yield();                  
ual.sleep(gameManager.REFRESH_RATE);


What i am trying to show here is in my code i am trying to call my update() and paint() ONCE every refresh. But from my console i gather that my update method doesnt get called as often as my render().  Maybe because my sleep time is too short - like 10 millisecond.
Shocked

PS - Sorry for the long stupid looking post  Grin

Offline Max Pesce

Junior Devvie




Nil tam arduum quod non ingenio vincas


« Reply #21 - Posted 2003-08-06 05:27:00 »

I hope you aren't using System.currentMillis() for your bench. It's slow and has a very low resolution.

So it cannot describe you the exact behavior of your program...  Sad

Offline ranabp

Senior Newbie




Blit Me :)


« Reply #22 - Posted 2003-08-06 08:58:35 »

Quote
I hope you aren't using System.currentMillis() for your bench. It's slow and has a very low resolution.

So it cannot describe you the exact behavior of your program...  Sad


Yes, i am afraid i am. I will change it to Gage or other high rez timer and post the results.

Offline swpalmer

JGO Coder


Exp: 12 years


Where's the Kaboom?


« Reply #23 - Posted 2003-08-06 11:10:37 »

Quote
I hope you aren't using System.currentMillis() for your bench. It's slow and has a very low resolution.

So it cannot describe you the exact behavior of your program...  Sad

I know of the resolution issues on various OS'.  But this is the first time I've heard someone say that it is slow.  Can you give more details about that?

Offline abies

Senior Devvie





« Reply #24 - Posted 2003-08-06 14:16:21 »

As far as time is concerned, on my 1300 Ghz processor, System.currentTimeMillis take up around 0.12us per call. This means around 150-160 processor cycles per call. If you consider that there is native call somewhere below, I think it is quite fast - in fact I doubt if you can get any of other timing routines to perform considerably faster.

For me 8.000.0000 calls per second is enough to not worry about performance implications. Resolution is terrible, but not the performance.

Artur Biesiadowski
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

toopeicgaming1999 (72 views)
2014-11-26 15:22:04

toopeicgaming1999 (62 views)
2014-11-26 15:20:36

toopeicgaming1999 (15 views)
2014-11-26 15:20:08

SHC (29 views)
2014-11-25 12:00:59

SHC (27 views)
2014-11-25 11:53:45

Norakomi (32 views)
2014-11-25 11:26:43

Gibbo3771 (27 views)
2014-11-24 19:59:16

trollwarrior1 (40 views)
2014-11-22 12:13:56

xFryIx (78 views)
2014-11-13 12:34:49

digdugdiggy (56 views)
2014-11-12 21:11:50
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!